synchronized (t) { try { context.addServiceListener(t, listenerFilter); ServiceReference<S>[] references = null; if (trackClass != null) {
/** * Starts this {@code Activator}. * * @param bundleContext the {@code BundleContext} in which this * {@code Activator} is starting * @throws Exception error starting this activator */ @Override public void start(BundleContext bundleContext) throws Exception { this.bundleContext = bundleContext; bundleContext.addServiceListener(this); }
context.addServiceListener(new ServiceListener() { public void serviceChanged(final ServiceEvent event) { final ServiceReference sr = event.getServiceReference();
/** * {@inheritDoc} * * Initializes this <tt>StatsTransport</tt> if it has not been initialized * yet. */ @Override protected void bundleContextChanged( BundleContext oldValue, BundleContext newValue) { super.bundleContextChanged(oldValue, newValue); if (oldValue != null) oldValue.removeServiceListener(serviceListener); if (newValue != null) newValue.addServiceListener(serviceListener); initOrDispose(null); }
synchronized (t) { try { context.addServiceListener(t, listenerFilter); ServiceReference[] references = null; if (trackClass != null) {
@Override public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException { m_context.addServiceListener(listener, filter); }
@Override public void addServiceListener(ServiceListener listener) { m_context.addServiceListener(listener); }
/** * Initializes this {@code StatsTransport} so that * {@link #publishStatistics(Statistics)} may executed successfully. * Initializes {@link #statsService} i.e. the jitsi-stats library. * * @param bundleContext the {@code BundleContext} in which this * {@code StatsTransport} is to be initialized * @param cfg the {@code ConfigurationService} registered in * {@code bundleContext} if any */ private void init(BundleContext bundleContext, ConfigurationService cfg) { int appId = ConfigUtils.getInt(cfg, PNAME_CALLSTATS_IO_APP_ID, 0); String appSecret = ConfigUtils.getString(cfg, PNAME_CALLSTATS_IO_APP_SECRET, null); String keyId = ConfigUtils.getString(cfg, PNAME_CALLSTATS_IO_KEY_ID, null); String keyPath = ConfigUtils.getString(cfg, PNAME_CALLSTATS_IO_KEY_PATH, null); String bridgeId = ConfigUtils.getString( cfg, PNAME_CALLSTATS_IO_BRIDGE_ID, DEFAULT_BRIDGE_ID); // as we create only one instance of StatsService we will expect // it to register in OSGi as service, if it doesn't it means it failed serviceListener = new StatsServiceListener(appId, bundleContext); bundleContext.addServiceListener(serviceListener); StatsServiceFactory.getInstance().createStatsService( bundleContext, appId, appSecret, keyId, keyPath, bridgeId); }
/** * Creates the EventDispatcher. * @param bc the bundle context used to register and unregister * {@link ServiceListener}. */ private EventDispatcher(BundleContext bc) { m_context = bc; m_listeners = new HashMap(); // Only one thread can call the start method. m_context.addServiceListener(this); }
/** * @param osgiServ */ public GeneralActionListener(ServiceReference sr, String serviceId) { try { Activator.bc.addServiceListener(this, "("+Constants.SERVICE_ID+"="+sr.getProperty(Constants.SERVICE_ID)+")"); } catch (InvalidSyntaxException ingnored) {} this.dev=sr; this.id=serviceId; this.open=true; }
public void init() throws Exception { LOG.trace("init {}", this); // add service listener so we can be notified when blueprint container is done // and we would be ready to start CamelContext bundleContext.addServiceListener(this); // add blueprint listener as service, as we need this for the blueprint container // to support change events when it changes states registration = bundleContext.registerService(BlueprintListener.class, this, null); }
public CommandTracker() throws Exception { BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext(); if (context == null) { throw new IllegalStateException("Bundle is stopped"); } ServiceListener listener = event -> commands.clear(); context.addServiceListener(listener, String.format("(&(%s=*)(%s=*))", CommandProcessor.COMMAND_SCOPE, CommandProcessor.COMMAND_FUNCTION)); } }
private void setSessionId(String sessionId) { try { m_bundleContext.removeServiceListener(this); m_bundleContext.addServiceListener(this, String.format("(&(objectClass=%s)(sessionId=%s))", "org.opennms.features.topology.api.topo.Criteria", sessionId)); } catch (InvalidSyntaxException e) { LoggerFactory.getLogger(getClass()).error("registerServiceListener() failed", e); } }
public void open() { if (open.compareAndSet(false, true)) { try { String filterString = '(' + Constants.OBJECTCLASS + '=' + clazz.getName() + ')'; ctx.addServiceListener(listener, filterString); findMatchingReference(null); } catch (InvalidSyntaxException e) { // this can never happen. (famous last words :) } } }
public void open() { if (open.compareAndSet(false, true)) { try { String filterString = '(' + Constants.OBJECTCLASS + '=' + className + ')'; if (filter != null) filterString = "(&" + filterString + filter + ')'; ctx.addServiceListener(this, filterString); findMatchingReference(null); } catch (InvalidSyntaxException e) { // this can never happen. (famous last words :) } } }
public void open() { if (open.compareAndSet(false, true)) { try { String filterString = '(' + Constants.OBJECTCLASS + '=' + clazz.getName() + ')'; ctx.addServiceListener(listener, filterString); findMatchingReference(null); } catch (InvalidSyntaxException e) { // this can never happen. (famous last words :) } } }
public void open() { if (open.compareAndSet(false, true)) { try { String filterString = '(' + Constants.OBJECTCLASS + '=' + className + ')'; if (filter != null) filterString = "(&" + filterString + filter + ')'; ctx.addServiceListener(this, filterString); findMatchingReference(null); } catch (InvalidSyntaxException e) { // this can never happen. (famous last words :) } } }
public void start(BundleContext context) { systemBundleLog.setBundle(context.getBundle()); context.addBundleListener(this); context.addServiceListener(this); context.addFrameworkListener(this); context.addBundleListener(logServiceFactory); logReaderServiceRegistration = context.registerService(LOGREADERSERVICE_CLASSES, logReaderServiceFactory, null); logServiceRegistration = context.registerService(LOGSERVICE_CLASSES, logServiceFactory, null); eventAdminAdapter = new EventAdminAdapter(context, logReaderServiceFactory); eventAdminAdapter.start(); }
public void start(BundleContext context) { systemBundleLog.setBundle(context.getBundle()); context.addBundleListener(this); context.addServiceListener(this); context.addFrameworkListener(this); context.addBundleListener(logServiceFactory); logReaderServiceRegistration = context.registerService(LOGREADERSERVICE_CLASSES, logReaderServiceFactory, null); logServiceRegistration = context.registerService(LOGSERVICE_CLASSES, logServiceFactory, null); eventAdminAdapter = new EventAdminAdapter(context, logReaderServiceFactory); eventAdminAdapter.start(); }
public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException { FilterIndex filterIndex = m_cache.hasFilterIndexFor(null, filter); if (filterIndex != null) { filterIndex.addServiceListener(listener, filter); } else { m_context.addServiceListener(listener, filter); } }