Package com.atlassian.confluence.util
Class OsgiUtils
java.lang.Object
com.atlassian.confluence.util.OsgiUtils
This util helps plugins to do shady things directly with OSGi.
- Since:
- 7.0.1
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfindApplicationContextInOsgiBundle
(com.atlassian.plugin.Plugin plugin) HACK Grab the bean with a name matching the jobKey from the target plugin's.
-
Constructor Details
-
OsgiUtils
public OsgiUtils()
-
-
Method Details
-
findApplicationContextInOsgiBundle
public static Optional<Object> findApplicationContextInOsgiBundle(com.atlassian.plugin.Plugin plugin) HACK Grab the bean with a name matching the jobKey from the target plugin's. Ideally, we'd be loading an OSGi ServiceReference by name, but that won't work for us here, due to spring-scanner not supporting adding custom properties, and OSGi not having named service instances by default. Sigh DO NOT DO WHAT I HAVE DONE :(The reason why this method returns
Optional<Object>
instead ofOptional<ApplicationContext>
is to avoid class casting errors between different classloaders, e.g.java.lang.ClassCastException: org.springframework.osgi.atlassian.NonValidatingOsgiBundleXmlApplicationContext cannot be cast to org.springframework.context.ApplicationContext
-