Launching a custom Java-class before starting the OSGi framework and during integration test

34 views
Skip to first unread message

Pratik Mehta

unread,
Aug 21, 2016, 4:42:54 PM8/21/16
to bndtools-users
Hi,

I am trying to find a way where I can do some task before starting the launching the framework from bndrun or before intergration test

For example: I need to start cassandra-daemon for my integration test and it is too complicated to do inside the osgi framework

Is there a way where I can provide an instruction in bnd.bnd or bndrun file to launch a java class which does the required tasks for me and then it starts the OSGi framework.

There is a similar feature in maven-pax plugin, it is possible to any tasks before launching the framework.

Thanks,
Pratik

Peter Kriens

unread,
Aug 22, 2016, 3:34:17 AM8/22/16
to bndtool...@googlegroups.com
You can put a JAR on the -runpath with an Embbded-Activator. This is a normal BundleActivator implementing class and the header ‘Embedded-Activator’ in the manifest point at that class. If you add 

public static boolean IMMEDIATE = true;

It gets started before any bundle. Otherwise it starts after the bundles have been started.

Kind regards,

Peter Kriens



--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pratik Mehta

unread,
Aug 22, 2016, 9:36:22 AM8/22/16
to bndtools-users
Hi Peter,

Thanks for the answer. 

But this will still expect the jar in runpath to be an osgi bundle. What I am trying to look is to have a way to invoke any script (may be start an karaf instance) or invoke any class in non osgi jar.

Thanks,
Pratik

Peter Kriens

unread,
Aug 22, 2016, 12:10:34 PM8/22/16
to bndtool...@googlegroups.com
Well you can do either of those choices in an activator?

However, starting a Karaf instance sounds more like a bash script that starts this JAR and the Karaf JAR?

Kind regards,

Peter Kriens

Pratik Mehta

unread,
Aug 22, 2016, 3:08:53 PM8/22/16
to bndtools-users
Hi Peter,

Thanks for the response. I will try with Embedded-Activator and see how that works for me.

Just to understand correctly, the jar that I add to -runpath need not be an OSGi bundle, right?

And about karaf: it would be bash script that starts the instance and I can achieve that using Embedded-Activator.

Thanks and Regards,
Pratik Mehta

Peter Kriens

unread,
Aug 23, 2016, 2:25:37 AM8/23/16
to bndtool...@googlegroups.com
The JAR does not have to be a bundle but it needs an Embedded-Activator header of course.

Kind regards,

Peter Kriens
Reply all
Reply to author
Forward
0 new messages