Refine search
private void sendAdminEvent() { ServiceReference eaRef = bc.getServiceReference(EventAdmin.class.getName()); if (eaRef != null) { EventAdmin ea = (EventAdmin) bc.getService(eaRef); ea.sendEvent(new Event("jersey/test/DEPLOYED", new HashMap<String, String>() { { put("context-path", "/"); } })); bc.ungetService(eaRef); } }
private IApplicationContext getApplicationContext() { Collection<ServiceReference<IApplicationContext>> references; try { references = context.getServiceReferences(IApplicationContext.class, "(eclipse.application.type=main.thread)"); //$NON-NLS-1$ } catch (InvalidSyntaxException e) { return null; } if (references == null || references.isEmpty()) return null; // assumes the application context is available as a service ServiceReference<IApplicationContext> firstRef = references.iterator().next(); IApplicationContext result = context.getService(firstRef); if (result != null) { context.ungetService(firstRef); return result; } return null; }
@Override public Object addingService(ServiceReference reference) { Object service = bundleContext.getService(reference); if(StanbolNamespacePrefixService.this.equals(service)){//we need not to track this instance bundleContext.ungetService(reference); return null; } __sortedProviderRef = null; return service; } });
@Override public void configAdminUpdate(String pid, Map<String, String> data) { ServiceReference sref = bundleContext.getServiceReference(ConfigurationAdmin.class.getName()); if (sref == null) { throw new IllegalStateException("The configuration admin service cannot be found."); } try { ConfigurationAdmin ca = (ConfigurationAdmin) bundleContext.getService(sref); if (ca == null) { throw new IllegalStateException("The configuration admin service cannot be found."); } Configuration config = ca.getConfiguration(pid, null); config.update(new Hashtable<String, String>(data)); } catch (IOException ioe) { throw new RuntimeException(ioe); } finally { bundleContext.ungetService(sref); } } }
@Override public Object addingService(ServiceReference reference) { Object service = bundleContext.getService(reference); if(StanbolNamespacePrefixService.this.equals(service)){//we need not to track this instance bundleContext.ungetService(reference); return null; } __sortedProviderRef = null; return service; } });
/** * Stops this bundle. */ @Override public void stop(BundleContext bundleContext) throws Exception { try { // Unregister this instance as an OSGi service. Collection<ServiceReference<ComponentImpl>> serviceReferences = bundleContext.getServiceReferences(ComponentImpl.class, null); if (serviceReferences != null) { for (ServiceReference<ComponentImpl> serviceReference : serviceReferences) { Object service = bundleContext.getService(serviceReference); if (service == this) bundleContext.ungetService(serviceReference); } } } finally { common.stop(bundleContext); } }
/** * Log error to a logging service (if available), otherwise log to std error * * @param pBundleContext bundle context to lookup LogService * @param pMessage message to log * @param pThrowable an exception to log */ public static void logError(BundleContext pBundleContext, String pMessage, Throwable pThrowable) { final ServiceReference lRef = pBundleContext.getServiceReference(LogService.class.getName()); if (lRef != null) { try { final LogService logService = (LogService) pBundleContext.getService(lRef); if (logService != null) { logService.log(LogService.LOG_ERROR, pMessage, pThrowable); return; } } finally { pBundleContext.ungetService(lRef); } } System.err.println("Jolokia-Error: " + pMessage + " : " + pThrowable.getMessage()); } }
private void addRef(ServiceReference<T> ref) { T service = ctx.getService(ref); synchronized (refs) { if (!refs.containsKey(ref)) { refs.put(ref, service); return; } } ctx.ungetService(ref); }
: serviceReferences) Object service = bundleContext.getService(serviceReference); bundleContext.ungetService(serviceReference);
static <T> T getService(Class<T> clazz) { ServiceReference<T> reference = context.getServiceReference(clazz); if (reference == null) return null; T result = context.getService(reference); context.ungetService(reference); return result; }
public JdbcConnector(final BundleContext bundleContext, final ServiceReference<?> reference) { this.datasource = (CommonDataSource)bundleContext.getService(reference); this.resources = new LinkedList<>(); this.resources.addFirst(() -> bundleContext.ungetService(reference)); }
Location configurationLocation = PlatformActivator.getContext().getService(serviceRef); if (configurationLocation == null) return true; File file = new File(configurationLocation.getURL().getPath() + "/org.eclipse.core.runtime"); //$NON-NLS-1$ PlatformActivator.getContext().ungetService(serviceRef); file = new File(file, F_KEYRING); keyringFile = file.getAbsolutePath();
static <T> T getService(Class<T> clazz) { ServiceReference<T> reference = context.getServiceReference(clazz); if (reference == null) return null; T result = context.getService(reference); context.ungetService(reference); return result; }
public JdbcConnector(final BundleContext bundleContext, final ServiceReference<?> reference) { this.datasource = (CommonDataSource)bundleContext.getService(reference); this.resources = new LinkedList<>(); this.resources.addFirst(() -> bundleContext.ungetService(reference)); }
public static PluginConverter acquirePluginConverter() { if (bundleContext == null) return null; ServiceReference reference = bundleContext.getServiceReference(PluginConverter.class.getName()); if (reference == null) return null; PluginConverter result = (PluginConverter) bundleContext.getService(reference); bundleContext.ungetService(reference); return result; }
@Override public Set<CommandProvider> addingService( ServiceReference<CommandProvider> reference) { if (reference.getProperty("osgi.command.function") != null) { // must be a gogo function already; don' track return null; } CommandProvider command = context.getService(reference); legacyCommandProviders.add(command); context.ungetService(reference); return legacyCommandProviders; }
protected void warn(String message, Throwable t) { ServiceReference<LogService> ref = bundleContext.getServiceReference(LogService.class); if (ref != null) { LogService svc = bundleContext.getService(ref); svc.log(LogService.LOG_WARNING, message, t); bundleContext.ungetService(ref); } }
public void run(){ try { UPnPEventListener listener = (UPnPEventListener) context.getService(sr); listener.notifyUPnPEvent(deviceId,serviceId,events); context.ungetService(sr); } catch (Exception ignored){ } } }
public static <T> T withMetaTypeService(BundleContext context, Function<MetaTypeService, T> callable) { ServiceReference<MetaTypeService> ref = context.getServiceReference(MetaTypeService.class); try { MetaTypeService metaService = context.getService(ref); return callable.apply(metaService); } finally { context.ungetService(ref); } }
public void bindManagementStrategy(ServiceReference reference) { ManagementStrategy ms = (ManagementStrategy) bundleContext.getService(reference); managementStrategy.updateRef(currentMs, ms); if (currentMsRef != null) { bundleContext.ungetService(currentMsRef); } currentMs = ms; currentMsRef = reference; }