I have an OSGi bundle that can also run in plain Java process. I need to be able to tell if the bundle was loaded in an OSGi system or not. How can I do that? If there is no OSGi-standard way of doing this, I will settle for Eclipse/Equinox-specific approach.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Add Bundle-Activator to your MANIFEST.MF. If it gets instantiated, then your JAR is running in an OSGi container.
You can check whether "this.getClass().getClassLoader() instanceof org.osgi.framework.BundleReference", which should only be true if you are running in an R4.2 OSGi framework.
If you don't have an activator, you can also try asking for your bundle:
If it returns null, your class wasn't loaded by OSGi.