I have seen people keep references to OSGI BundleContext within DataHolders, IMHO this is a bad practice to keep OSGi internal state API within our own DataHolders, as I heard in some cases this is avoidable but IMHO we should discourage this usage and should use as the very last option only. Most of the cases it is possible to use one of the following approaches instead of above practice.
1.) Refactor the code to keep BundleContext as instance reference within the Component class itself instead of keeping inside a separate DataHolder. 2.) For outside the Component usages, use FrameworkUtil.getBundle(ClassFromBundle).getBundleContext() [1] [2] utility method to access BundleContext. [1] - https://osgi.org/javadoc/r4v43/core/org/osgi/framework/FrameworkUtil.html#getBundle(java.lang.Class) [2] - http://stackoverflow.com/questions/6527306/best-technique-for-getting-the-osgi-bundle-context Thanks ! -- Sagara Gunathunga Associate Director / Architect; WSO2, Inc.; http://wso2.com V.P Apache Web Services; http://ws.apache.org/ Linkedin; http://www.linkedin.com/in/ssagara Blog ; http://ssagara.blogspot.com
_______________________________________________ Architecture mailing list Architecture@wso2.org https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture