Sunday, April 12, 2009

Easter Egg

Low volume these days.
Because (at least in germany) eastern is about finding gifts/easter eggs.
I want to give you an easteregg as well.
For early adopters there is a new project in my ops4j laboratory called TinyBundles.
Its a small library that allows definition+creation of (tiny) bundles on the fly right inside your java app / pax exam testcase.
With this small library you can create small bundles like so:


newBundle()
.set( Constants.BUNDLE_SYMBOLICNAME, "MyFirstTinyBundle" )
.set( Constants.EXPORT_PACKAGE, "org.ops4j.pax.tinybundles.demo" )
.set( Constants.IMPORT_PACKAGE, "org.ops4j.pax.tinybundles.demo,org.osgi.framework" )
.set( Constants.BUNDLE_ACTIVATOR, MyFirstActivator.class.getName() )
.addClass( MyFirstActivator.class )
.addClass( HelloWorld.class )
.addClass( HelloWorldImpl.class )
.build( asStream() )

I 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 contruct 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.

Will try to put that into a regular pax project so that it get more "official".
That being said, the library is usable right now when used like specified in the demo sub project:
Demos.

Just checkout the whole project here, run mvn clean install (probably with "-Dmaven.test.skip=true to skip long running tests that may change all the time (remeber, its still in my local incubator ;) ,open it in your favourite ide and play with the demos if you like to.

Wishing everyone a nice easter weekend!

3 comments:

Todor Boev said...

Great idea :)
I made a cruder version of this some time ago but it never ocured to me to polish it with a fluent API.

I wonder if it is prudent to somehow invoke BND in order to get the imports resolved for free.

This seems useful on one hand but not so much on the other - during testing you want tight control of the manifest.

Hmm. I think there is an on-the-fly bundelizer in PAX already.

Toni Menzel said...

yep, bnd is now integrated. I am also looking now into:
- Support Bundlor (just for people trying it out)
- other langues like groovy or scala to also write your Pax Exam tests in.

feel free to submit your ideas as well !

Automotive Parts said...

I just found your blog and bookmarked it in digg. You have great work in blog. Keep sharing more stuff.
Thanks
Tractor Supply