Working with bundles if kind of frustrating if you have to play with couple of them. Each time you build them, they need to be deployed in the container, and doing it by hand can be a tendentious job.
Instead, a much better approach would be to change the build process to make this happen automatically. For this there are couple of approaches, from which I find as easiest to put in practice to use the container’s auto-deploy feature. Both Felix and GlassFish (these I’ve played with), but probably the others have this feature to monitor a folder for new jar files, and when they appear in the folder, they automatically deploy them. When bundles are removed from the folder, they are un-deployed from the container. If the jar file changes, it is either updated or redeployed.
GlassFish already supports this deployment process. The folder where is watching for new bundles is located at:
for .war applications and
for OSGI bundles.
In order to have this deployment active in Felix, you will need to install an additional OSGI module, called File Install. Can be downloaded from Felix’s web page. You just have to put it in
folder and will be deployed next time container starts.
The folder where Felix will watch for bundles can be configured using the felix.fileinstall.dir property from the file located at:
Having these said, all what remains to be done is to configure the latest step of build to copy all the bundles which need to be deployed in the target folder where it will be deployed by the OSGI container. This step depends on what IDE, build system,etc are you using.
For users with Maven, you can add for example an additional module called let’s say deploy, who’s job would be to deploy the application. You will have to add all artifacts and dependencies which need to be installed in this module’s POM file, then you can add a build step like in the file bellow in order to have these artifacts copied in the target folder:
<!-- usual POM stuff --> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-bundles</id> <phase>validate</phase> <goals> <goal>copy</goal> </goals> <configuration> <artifactItems> <!-- Our bundles which need to be deployed --> <artifactItem> <groupId>group id of your artifact</groupId> <artifactId>id of your artifact</artifactId> <version>version of your artifact</version> </artifactItem> <artifactItem> <groupId>group of your artifact</groupId> <artifactId>id of your artifact</artifactId> <version>version of your artifact</version> </artifactItem> ... </artifactItems> <outputDirectory>target folder where container looks for OSGI bundles</outputDirectory> <overWriteSnapshots>true</overWriteSnapshots> </configuration> </execution> </executions> </plugin> </plugins> </build>
Of course this can be made in many ways, this is one which worked for me. Feel free to add comments and suggestions over the process