Refine search
static Xnio doGetOsgiService() { Bundle bundle = FrameworkUtil.getBundle(Xnio.class); BundleContext context = bundle.getBundleContext(); if (context == null) { throw new IllegalStateException("Bundle not started"); } ServiceReference<Xnio> sr = context.getServiceReference(Xnio.class); if (sr == null) { return null; } return context.getService(sr); }
/** * Returns an {@code OsgiRegistry} instance. Call this method only if sure that the application is running in OSGi * environment, otherwise a call to this method can lead to an {@link ClassNotFoundException}. * * @return an {@code OsgiRegistry} instance. */ public static synchronized OsgiRegistry getInstance() { if (instance == null) { final ClassLoader classLoader = AccessController .doPrivileged(ReflectionHelper.getClassLoaderPA(ReflectionHelper.class)); if (classLoader instanceof BundleReference) { final BundleContext context = FrameworkUtil.getBundle(OsgiRegistry.class).getBundleContext(); if (context != null) { // context could be still null if the current bundle has not been started instance = new OsgiRegistry(context); } } } return instance; }
/** * Returns an {@code OsgiRegistry} instance. Call this method only if sure that the application is running in OSGi * environment, otherwise a call to this method can lead to an {@link ClassNotFoundException}. * * @return an {@code OsgiRegistry} instance. */ public static synchronized OsgiRegistry getInstance() { if (instance == null) { final ClassLoader classLoader = AccessController .doPrivileged(ReflectionHelper.getClassLoaderPA(ReflectionHelper.class)); if (classLoader instanceof BundleReference) { final BundleContext context = FrameworkUtil.getBundle(OsgiRegistry.class).getBundleContext(); if (context != null) { // context could be still null if the current bundle has not been started instance = new OsgiRegistry(context); } } } return instance; }
private SessionFactory getSessionFactory() { if ( sf == null ) { Bundle thisBundle = FrameworkUtil.getBundle( HibernateUtil.class ); BundleContext context = thisBundle.getBundleContext(); ServiceReference sr = context.getServiceReference( SessionFactory.class.getName() ); sf = ( SessionFactory ) context.getService( sr ); } return sf; } }
private EntityManagerFactory getEntityManagerFactory() { if ( emf == null ) { Bundle thisBundle = FrameworkUtil.getBundle( HibernateUtil.class ); BundleContext context = thisBundle.getBundleContext(); ServiceReference serviceReference = context.getServiceReference( PersistenceProvider.class.getName() ); PersistenceProvider persistenceProvider = ( PersistenceProvider ) context .getService( serviceReference ); emf = persistenceProvider.createEntityManagerFactory( "YourPersistenceUnitName", null ); } return emf; } }
/** * Log error to a logging service (if available), otherwise log to std error * * @param pMessage message to log * @param pThrowable an exception to log */ public static void logError(String pMessage, Throwable pThrowable) { final BundleContext bundleContext = FrameworkUtil .getBundle(ServiceAuthenticationHttpContext.class) .getBundleContext(); logError(bundleContext, pMessage, pThrowable); }
public static Bundle getBundle(long bundleId) { Bundle logBundle = FrameworkUtil.getBundle(Logs.class); BundleContext bundleContext = logBundle != null ? logBundle.getBundleContext() : null; Bundle bundle = bundleContext != null ? bundleContext.getBundle(bundleId) : null; return bundle; }
private String getProperty(String var, String def) { Bundle b = FrameworkUtil.getBundle(BgpManager.class); if (b == null) { return def; } BundleContext context = b.getBundleContext(); if (context == null) { return def; } String s = context.getProperty(var); return (s == null ? def : s); }
@Override public Framework getFramework(String felixCacheDir, boolean clean) { final Bundle bundle = FrameworkUtil.getBundle(Osgis.class); return (Framework) bundle.getBundleContext().getBundle(0); }
private Compat() { Bundle bundle = FrameworkUtil.getBundle(Compat.class); if (bundle != null) { BundleContext bundleContext = bundle.getBundleContext(); managementContextTracker = new ServiceTracker(bundleContext, ManagementContext.class, null); managementContextTracker.open(); } else { managementContextTracker = null; } }
public EventRegistryServiceImpl() { // Register this service with karaf BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); nicEventServiceRegistration = context.registerService(EventRegistryService.class, this, null); }
/** * Get all bundle list of APP-C * @return Array of Bundle */ Bundle[] getBundleList() { BundleContext myBundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); if (myBundleContext != null) { return myBundleContext.getBundles(); } return null; }
public FeaturesProcessingSerializer() { Bundle bundle = FrameworkUtil.getBundle(this.getClass()); this.bundleContext = bundle == null ? null : bundle.getBundleContext(); try { FEATURES_PROCESSING_CONTEXT = JAXBContext.newInstance(ObjectFactory.class); } catch (Exception e) { throw new RuntimeException(e); } }
public static IEclipseContextDebugger getDebugger() { Bundle bundle = FrameworkUtil.getBundle(ContextDebugHelper.class); BundleContext bundleContext = bundle == null ? null : bundle.getBundleContext(); ServiceReference<IEclipseContextDebugger> ref = bundleContext == null ? null : bundleContext.getServiceReference(IEclipseContextDebugger.class); if (ref == null) return null; IEclipseContextDebugger contextDebugger = bundleContext.getService(ref); bundleContext.ungetService(ref); // this is not the proper place but will do in a static environment return contextDebugger; } }
private void registerWithOSGIConsole() { BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()) .getBundleContext(); bundleContext.registerService(CommandProvider.class.getName(), this, null); }
private String getProperty(String property) { BundleContext bctx = null; try { bctx = FrameworkUtil.getBundle(getClass()).getBundleContext(); } catch (Exception e) { } String value = bctx != null ? bctx.getProperty(property) : null; return value != null ? value : System.getProperty(property); } }
public AaiService() { BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); ServiceReference sref = bctx.getServiceReference(AAIService.class); aaiClient = (AAIClient) bctx.getService(sref); }
private void registerWithOSGIConsole() { BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()) .getBundleContext(); bundleContext.registerService(CommandProvider.class.getName(), this, null); }
private void registerWithOSGIConsole() { BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()) .getBundleContext(); bundleContext.registerService(CommandProvider.class.getName(), this, null); }
private void registerWithOSGIConsole() { BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()) .getBundleContext(); bundleContext.registerService(CommandProvider.class.getName(), this, null); }