How to determine if an osgi container works

I have an OSGi package that can also work in a simple Java process. I need to find out if the package is downloaded to the OSGi system or not. How can i do this? If there is no standard OSGi method for this, I will agree to an Eclipse / Equinox based approach.

+4
source share
3 answers

If you do not have an activator, you can also ask for your kit:

Bundle b = org.osgi.framework.FrameworkUtil.getBundle(MyClass.this); 

If it returns null, your class has not been loaded by OSGi.

+6
source

Add the Bundle-Activator to your MANIFEST.MF. If it is created, your JAR runs in the OSGi container.

+10
source

You can check if this.getClass () is there. getClassLoader () instanceof org.osgi.framework.BundleReference ", which should be right only if you are running OS4i R4.2.

+1
source

All Articles