@Override public <S> ServiceObjects<S> getServiceObjects(ServiceReference<S> reference) { return bundleContext.getServiceObjects(reference); } }
@Override public <S> ServiceObjects<S> getServiceObjects(ServiceReference<S> reference) { return m_context.getServiceObjects(reference); }
public B swap(InstanceCbServiceObjectsServiceObjects<S> swap) { m_dereferenceServiceInternally = false; return setInstanceSwapCallbackRef((inst, component, oref, oserv, nref, nserv) -> swap.accept(oref.getBundle().getBundleContext().getServiceObjects(oref), nref.getBundle().getBundleContext().getServiceObjects(nref))); }
public <T> B swap(CbServiceObjectsServiceObjects<T, S> swap) { Class<T> type = Helpers.getLambdaArgType(swap, 0); m_dereferenceServiceInternally = false; return setComponentSwapCallbackRef(type, (inst, component, oref, oserv, nref, nserv) -> swap.accept((T) inst, oref.getBundle().getBundleContext().getServiceObjects(oref), nref.getBundle().getBundleContext().getServiceObjects(nref))); }
public ComponentServiceObjects getServiceObjects(final ServiceReference<?> ref) { ComponentServiceObjectsImpl cso = this.services.get(ref); if ( cso == null ) { final ServiceObjects serviceObjects = this.bundleContext.getServiceObjects(ref); if ( serviceObjects != null ) { cso = new ComponentServiceObjectsImpl(serviceObjects); final ComponentServiceObjectsImpl oldCSO = this.services.putIfAbsent(ref, cso); if ( oldCSO != null ) { cso = oldCSO; } } } return cso; }
public ComponentServiceObjects getServiceObjects(final ServiceReference<?> ref) { ComponentServiceObjectsImpl cso = this.services.get(ref); if ( cso == null ) { final ServiceObjects serviceObjects = this.bundleContext.getServiceObjects(ref); if ( serviceObjects != null ) { cso = new ComponentServiceObjectsImpl(serviceObjects); final ComponentServiceObjectsImpl oldCSO = this.services.putIfAbsent(ref, cso); if ( oldCSO != null ) { cso = oldCSO; } } } return cso; }
public B callbacks(InstanceCbServiceObjects<S> add, InstanceCbServiceObjects<S> change, InstanceCbServiceObjects<S> remove) { if (add != null) setInstanceCallbackRef(Cb.ADD, (inst, comp, ref, srv) -> add.accept(ref.getBundle().getBundleContext().getServiceObjects(ref))); if (change != null) setInstanceCallbackRef(Cb.CHG, (inst, comp, ref, srv) -> change.accept(ref.getBundle().getBundleContext().getServiceObjects(ref))); if (remove != null) setInstanceCallbackRef(Cb.REM, (inst, comp, ref, srv) -> remove.accept(ref.getBundle().getBundleContext().getServiceObjects(ref))); m_dereferenceServiceInternally = false; return (B) this; }
private <T> B callbacks(CbServiceObjects<T, S> add, CbServiceObjects<T, S> change, CbServiceObjects<T, S> remove) { if (add != null) setComponentCallbackRef(Cb.ADD, Helpers.getLambdaArgType(add, 0), (inst, comp, ref, srv) -> add.accept((T) inst, ref.getBundle().getBundleContext().getServiceObjects(ref))); if (change != null) setComponentCallbackRef(Cb.CHG, Helpers.getLambdaArgType(change, 0), (inst, comp, ref, srv) -> change.accept((T) inst, ref.getBundle().getBundleContext().getServiceObjects(ref))); if (remove != null) setComponentCallbackRef(Cb.REM, Helpers.getLambdaArgType(remove, 0), (inst, comp, ref, srv) -> remove.accept((T) inst, ref.getBundle().getBundleContext().getServiceObjects(ref))); m_dereferenceServiceInternally = false; return (B) this; }
public static List<CarbonCallbackHandler> getCallbackHandlers(String supportedLoginModule) { List<CarbonCallbackHandler> callbackHandlers = new ArrayList<>(); BundleContext bundleContext = CarbonSecurityDataHolder.getInstance().getBundleContext(); try { Collection<ServiceReference<CarbonCallbackHandler>> serviceReferences = bundleContext.getServiceReferences (CarbonCallbackHandler.class, "(&(" + CarbonCallbackHandler.SUPPORTED_LOGIN_MODULE + "=" + supportedLoginModule + ")(service.scope=prototype))"); if (serviceReferences != null) { serviceReferences.forEach( serviceReference -> callbackHandlers.add(bundleContext.getServiceObjects(serviceReference) .getService()) ); } } catch (InvalidSyntaxException e) { throw new IllegalStateException("Invalid syntax found while searching Callback handler " + supportedLoginModule); } return callbackHandlers; }
private S addToUsedServiceReferences(final ServiceReference<S> serviceReference) { ServiceObjectsWithCounter<S> serviceObjectsWithCounter = serviceObjectsByReferences .get(serviceReference); if (serviceObjectsWithCounter == null) { serviceObjectsWithCounter = new ServiceObjectsWithCounter<>(); serviceObjectsWithCounter.serviceObjects = getComponentContext().getBundleContext() .getServiceObjects(serviceReference); serviceObjectsByReferences.put(serviceReference, serviceObjectsWithCounter); } S service = serviceObjectsWithCounter.serviceObjects.getService(); serviceObjectsWithCounter.counter++; return service; }
public ServiceEventImpl(ComponentContext ctx, ServiceReference<?> reference, Object service) { super(service); m_service = service; m_bundle = ctx.getBundle(); m_bundleContext = ctx.getBundleContext(); m_serviceObjects = (m_bundleContext != null) ? m_bundleContext.getServiceObjects(reference) : null; m_reference = reference; m_logger = ctx.getLogger(); }
public ListenerRegistration addListenerRegistration(ServiceReference<EventListener> listenerRef) throws ServletException { checkShutdown(); ServiceHolder<EventListener> listenerHolder = new ServiceHolder<EventListener>(consumingContext.getServiceObjects(listenerRef)); EventListener listener = listenerHolder.get(); ListenerRegistration registration = null; try { if (listener == null) { throw new IllegalArgumentException("EventListener cannot be null"); } registration = doAddListenerRegistration(listenerHolder, listenerRef); } finally { if (registration == null) { listenerHolder.release(); } } return registration; }
@Override public boolean destroy() { final Filter s = this.getFilter(); if ( s != null ) { if ( super.destroy() ) { final ServiceObjects<Filter> so = this.bundleContext.getServiceObjects(getFilterInfo().getServiceReference()); if (so != null) { so.ungetService(s); } return true; } } return false; } }
@Override public boolean destroy() { final Filter s = this.getFilter(); if ( s != null ) { if ( super.destroy() ) { final ServiceObjects<Filter> so = this.bundleContext.getServiceObjects(getFilterInfo().getServiceReference()); if (so != null) { so.ungetService(s); } return true; } } return false; } }
@Override public boolean destroy() { final EventListener s = this.getListener(); if ( s != null ) { if ( super.destroy() ) { final ServiceObjects<EventListener> so = this.bundleContext.getServiceObjects(getListenerInfo().getServiceReference()); if (so != null) { so.ungetService(s); } return true; } } return false; } }
@Override public boolean destroy() { final EventListener s = this.getListener(); if ( s != null ) { if ( super.destroy() ) { final ServiceObjects<EventListener> so = this.bundleContext.getServiceObjects(getListenerInfo().getServiceReference()); if (so != null) { so.ungetService(s); } return true; } } return false; } }
@Override public boolean destroy() { final Servlet s = this.getServlet(); if ( s != null ) { if ( super.destroy() ) { final ServiceObjects<Servlet> so = this.bundleContext.getServiceObjects(getServletInfo().getServiceReference()); if (so != null) { so.ungetService(s); } return true; } } return false; }
@Override public boolean destroy() { final Servlet s = this.getServlet(); if ( s != null ) { if ( super.destroy() ) { final ServiceObjects<Servlet> so = this.bundleContext.getServiceObjects(getServletInfo().getServiceReference()); if (so != null) { so.ungetService(s); } return true; } } return false; }
@Override public int init() { if ( this.useCount > 0 ) { this.useCount++; return -1; } final ServiceReference<Filter> serviceReference = getFilterInfo().getServiceReference(); final ServiceObjects<Filter> so = this.bundleContext.getServiceObjects(serviceReference); this.setFilter((so == null ? null : so.getService())); final int reason = super.init(); if ( reason != -1 ) { if ( so != null ) { so.ungetService(this.getFilter()); } this.setFilter(null); } return reason; }
@Override public int init() { if ( this.useCount > 0 ) { this.useCount++; return -1; } final ServiceReference<EventListener> serviceReference = getListenerInfo().getServiceReference(); final ServiceObjects<EventListener> so = this.bundleContext.getServiceObjects(serviceReference); this.setListener((so == null ? null : so.getService())); final int reason = super.init(); if ( reason != -1 ) { if ( so != null ) { so.ungetService(this.getListener()); } this.setListener(null); } return reason; }