Child pages
  • Tinybundles
Skip to end of metadata
Go to start of metadata

Since July 2011, Tinybundles is available as a single, independent library as Pax Tinybundles.
Its not part of Swissbox anymore.

Java APIs to create OSGi related artifacts

This is all about creating OSGi related artifacts like Bundles, Fragments and Deployment Packages with Java Api. It is very convinient to create such artifacts on-the-fly inside Tests (like in Pax Exam).
On the other hand, this library can be a foundation of real end user tools that need to create those artifacts.


Add this to your pom:


All artifacts are available on Maven Central for general use.


Sources are on Github at

Create Bundles

To get full benefit of the fluent api, you should include

import static org.ops4j.pax.tinybundles.core.TinyBundles.*;

in your import section.

With this small library you can create small bundles like so:

InputStream inp = bundle()
            .add( MyFirstActivator.class )
            .add( HelloWorld.class )
            .add( HelloWorldImpl.class )
            .set( Constants.BUNDLE_SYMBOLICNAME, caption )
            .set( Constants.EXPORT_PACKAGE, "demo" )
            .set( Constants.IMPORT_PACKAGE, "demo" )
            .set( Constants.BUNDLE_ACTIVATOR, MyFirstActivator.class.getName() )
            .build( getStrategy() );

Have a look at to see a complete list of use case examples.

We found this quite useful when for example testing extender-bundles like PaxWeb or SpringDM.
As you see, resources are pulled from "current classpath" which means that you can easily construct stuff like you do in ordinary java apps and pull them together using a fluent api like the above.
It is also trivial to create thounsands of (different) bundles to test high load for example.

Create Fragments

Basically same as Bundles with just the "Bundle-Host" Header added in "set" section.

1 Comment

  1. Anonymous

    For some reason, adding tinybundles dependency to pom.xml is not working. Am having to manually download bundle from maven repository and include it. Any reason why ? BTW pax exam just rocks. But there are lots of dead links when it comes to documentation.