コード例 #1
0
ファイル: OSGiUtil.java プロジェクト: monnetproject/services
 /**
  * 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;
 }
コード例 #2
0
ファイル: OSGiUtil.java プロジェクト: monnetproject/services
 /**
  * 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;
 }