private DomainProvider getDomainProvider(String domain) { Filter domainFilter = serviceUtils.makeFilter(DomainProvider.class, String.format("(%s=%s)", Constants.DOMAIN_KEY, domain)); DomainProvider domainProvider = serviceUtils.getOsgiServiceProxy(domainFilter, DomainProvider.class); return domainProvider; }
@Override public <T extends Domain> T getDomainEndpoint(Class<T> domainType, String location, String context) { Filter filter = utilsService.getFilterForLocation(domainType, location, context); return utilsService.getOsgiServiceProxy(filter, domainType); }
@Override public boolean isConnectorCurrentlyPresent(Class<? extends Domain> domainType) { Domain service; try { service = utilsService.getService(domainType, DEFAULT_TIMEOUT); } catch (OsgiServiceNotAvailableException e) { return false; } return service != null; }
/** * Sets the internal osgiServiceUtils class. This class does not have to be that one exported via * {@link #getServiceUtilsService()} since a user can export an implementation of this service with a higher * priority (for any reason). */ public static void setOsgiServiceUtils(OsgiUtilsService serviceUtils) throws OsgiServiceNotAvailableException { OpenEngSBCoreServices.serviceUtils = serviceUtils.getOsgiServiceProxy(OsgiUtilsService.class); }
@Override public boolean supports(final Class<? extends Object> authentication) { Iterator<AuthenticationProvider> serviceIterator = utilsService.getServiceIterator(providers, AuthenticationProvider.class); return Iterators.any(serviceIterator, new Predicate<AuthenticationProvider>() { @Override public boolean apply(AuthenticationProvider input) { return input.supports(authentication); } }); }
private OutgoingPort getPort(String portId) throws OsgiServiceNotAvailableException { return utilsService.getServiceWithId(OutgoingPort.class, portId); }
@SuppressWarnings("unchecked") private List<ServiceReference> getOsgiServices() { List<ServiceReference> references = utilsService.listServiceReferences(queryString); Collections.sort(references); return references; }
/** * Wiring is one of the core concepts in the OpenEngSB. The service retrieved by this method is used to get the * endpoints which can be reached within the OpenEngSB. */ public static WiringService getWiringService() throws OsgiServiceNotAvailableException { return serviceUtils.getOsgiServiceProxy(WiringService.class); }
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { Iterator<AuthenticationProvider> serviceIterator = utilsService.getServiceIterator(providers, AuthenticationProvider.class); AuthenticationException lastException = null; LOGGER.debug("iterating {} authenticationProviderServices", providers.size()); while (serviceIterator.hasNext()) { AuthenticationProvider provider = serviceIterator.next(); if (provider.supports(authentication.getClass())) { LOGGER.info("attempting authentication using provider {}", provider.getClass()); try { return provider.authenticate(authentication); } catch (AuthenticationException e) { lastException = e; } } } if (lastException == null) { lastException = new ProviderNotFoundException("No AuthenticationProvider found, that supports " + authentication.getClass()); } throw lastException; }
/** * OpenEngSB Core persistence service specialized to retrieve and store ConfigItem. Those are basically simple * persistence items which can be stored at various endpoints like file, the "regular" persistence service or * anywhere else. The type to request the config persistence service is stored directly at the Configuration objects * in a string constant such as RuleConfiguration#TYPE_ID or ContextConfiguration#TYPE_ID */ @Deprecated public static ConfigPersistenceService getConfigPersistenceService(String type) throws OsgiServiceNotAvailableException { Filter configPersistenceFilter; configPersistenceFilter = serviceUtils.makeFilter(ConfigPersistenceService.class, String.format("(%s=%s)", Constants.CONFIGURATION_ID, type)); return serviceUtils.getOsgiServiceProxy(configPersistenceFilter, ConfigPersistenceService.class); }
/** * Returns the {@link OsgiUtilsService} from the OSGi registry. This service helps to retrieve services from the * OSGi registry directly from the code. */ public static OsgiUtilsService getServiceUtilsService() throws OsgiServiceNotAvailableException { return serviceUtils.getOsgiServiceProxy(OsgiUtilsService.class); }
@Override public <T extends Domain> T getDomainEndpoint(Class<T> domainType, String location) { Filter filter = utilsService.getFilterForLocation(domainType, location); return utilsService.getOsgiServiceProxy(filter, domainType); }
@Override public Object invoke(List<ServiceReference> services, Method method, Object... args) throws Throwable { for (ServiceReference ref : services) { Object service = utilsService.getService(ref); try { method.invoke(service, args); } catch (InvocationTargetException e) { throw e.getCause(); } } return null; }
protected ConnectorInstanceFactory getConnectorFactory(ConnectorId id) { String connectorType = id.getConnectorType(); Filter connectorFilter = serviceUtils.makeFilter(ConnectorInstanceFactory.class, String.format("(&(%s=%s)(%s=%s))", Constants.DOMAIN_KEY, id.getDomainType(), Constants.CONNECTOR_KEY, connectorType)); ConnectorInstanceFactory service = serviceUtils.getOsgiServiceProxy(connectorFilter, ConnectorInstanceFactory.class); return service; }
public static OutgoingPortUtilService getOutgoingPortUtilService() throws OsgiServiceNotAvailableException { return serviceUtils.getOsgiServiceProxy(OutgoingPortUtilService.class); }
@Override public <T extends Domain> List<T> getDomainEndpoints(Class<T> domainType, String location, String context) { Filter filterForLocation = utilsService.getFilterForLocation(domainType, location); ServiceReference[] allServiceReferences; try { allServiceReferences = bundleContext.getAllServiceReferences(domainType.getName(), filterForLocation.toString()); } catch (InvalidSyntaxException e) { // this can never happen, because the filter has been compiled before throw new RuntimeException(e); } List<T> result = new ArrayList<T>(); if (allServiceReferences == null) { LOGGER.info("no references found for filter: {}", filterForLocation); return result; } LOGGER.debug("found {} references for {}", allServiceReferences.length, filterForLocation); for (ServiceReference ref : allServiceReferences) { Object serviceId = ref.getProperty(Constants.SERVICE_ID); String filterString = String.format("(%s=%s)", Constants.SERVICE_ID, serviceId); try { T osgiServiceProxy = utilsService.getOsgiServiceProxy(FrameworkUtil.createFilter(filterString), domainType); result.add(osgiServiceProxy); } catch (InvalidSyntaxException e) { throw new RuntimeException(e); } } return result; }
private Object retrieveOpenEngSBService(MethodCall call) { Map<String, String> metaData = call.getMetaData(); String serviceId = metaData.get("serviceId"); String filter = metaData.get("serviceFilter"); String filterString = createFilterString(filter, serviceId); return utilsService.getService(filterString); }
@Override protected void updateHandlerAttributes(CompositeConnector handler, Map<String, String> attributes) { String strategyFilter = createStrategyFilterString(attributes.get("compositeStrategy")); Filter filter = utilsService.makeFilter(CompositeConnectorStrategy.class, strategyFilter); CompositeConnectorStrategy strategy = utilsService.getOsgiServiceProxy(filter, CompositeConnectorStrategy.class); handler.setQueryString(attributes.get("queryString")); handler.setCompositeHandler(strategy); }
public static <T> T getResponseProxy(Event e, Class<T> targetClass) { String origin = e.getOrigin(); String filter = String.format("(%s=%s)", org.osgi.framework.Constants.SERVICE_PID, origin); return utilsService.getOsgiServiceProxy(filter, targetClass); }
public static <T> T getResponseProxy(Event e, Class<T> targetClass) { String origin = e.getOrigin(); String filter = String.format("(%s=%s)", Constants.ID_KEY, origin); return utilsService.getOsgiServiceProxy(filter, targetClass); }