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); }
protected BundleContext getBundleContext() { if (context == null) { context = FrameworkUtil.getBundle(getClass()).getBundleContext(); } return context; }
@Override public Framework getFramework(String felixCacheDir, boolean clean) { final Bundle bundle = FrameworkUtil.getBundle(Osgis.class); return (Framework) bundle.getBundleContext().getBundle(0); }
public NetvirtProvider(final DataBroker dataBroker, final EntityOwnershipService eos, final boolean conntrackEnabled, final boolean intBridgeGenMac) { LOG.info("NetvirtProvider started"); this.dataBroker = dataBroker; NetvirtProvider.entityOwnershipService = eos; this.conntrackEnabled = conntrackEnabled; this.intBridgeGenMac = intBridgeGenMac; this.bundleContext = FrameworkUtil.getBundle(NetvirtProvider.class).getBundleContext(); }
public NeutronBgpvpnChangeListener(final DataBroker dataBroker, final NeutronvpnManager nVpnMgr, final IdManagerService idManager) { super(Bgpvpn.class); this.dataBroker = dataBroker; nvpnManager = nVpnMgr; this.idManager = idManager; BundleContext bundleContext=FrameworkUtil.getBundle(NeutronBgpvpnChangeListener.class).getBundleContext(); adminRDValue = bundleContext.getProperty(NeutronConstants.RD_PROPERTY_KEY); }
/** * @return the bundle context, if we run in an OSGi environment, null otherwise */ public BundleContext findBundleContext() { final Bundle bundle = FrameworkUtil.getBundle( getClass()); return bundle != null ? bundle.getBundleContext() : null; } }
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 static SendQueueManager getSendQueueManager() { BundleContext context = FrameworkUtil.getBundle(MailUtil.class).getBundleContext(); ServiceReference<SendQueueManager> ref = context.getServiceReference(SendQueueManager.class); if (ref == null) return null; return context.getService(ref); }
private static ServiceTracker<FrameworkLog, FrameworkLog> openLogTracker() { try { ServiceTracker<FrameworkLog, FrameworkLog> st = new ServiceTracker<>( FrameworkUtil.getBundle(LogHelper.class).getBundleContext(), FrameworkLog.class, null); st.open(); return st; } catch (Throwable t) { 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); } }
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); }
private void registerWithOSGIConsole() { BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()) .getBundleContext(); bundleContext.registerService(CommandProvider.class.getName(), this, null); }
@Override public String call() throws Exception { BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext(); Bundle sysBundle = context.getBundle(0); return sysBundle.getSymbolicName() + "-" + sysBundle.getVersion(); } };