Example #1
0
 /**
  * Get the framework bundle.
  *
  * @return The framework bundle or null if there is no OSGi running.
  */
 public static Bundle getFrameWorkBundle() {
   final OSGiUtil osgiUtil = new OSGiUtil();
   for (Class<?> c : osgiUtil.getClassContext()) {
     final Bundle bundle = FrameworkUtil.getBundle(c);
     if (bundle != null
         && (bundle.getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.STOPPING)) > 0) {
       return bundle.getBundleContext().getBundles()[0];
     }
   }
   return null;
 }
Example #2
0
 /**
  * Get the bundle that called this function
  *
  * @return The bundle or null if there is no OSGi running
  */
 public static Bundle getCallingBundle() {
   final OSGiUtil osgiUtil = new OSGiUtil();
   for (Class<?> c : osgiUtil.getClassContext()) {
     final Bundle bundle = FrameworkUtil.getBundle(c);
     if (bundle != null
         && !bundle.getSymbolicName().equals("eu.monnetproject.core")
         && !bundle.getSymbolicName().equals("eu.monnetproject.framework.services")) {
       return bundle;
     }
   }
   return null;
 }