/** * 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); }
/** * 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); }
/** * 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); }
public static OutgoingPortUtilService getOutgoingPortUtilService() throws OsgiServiceNotAvailableException { return serviceUtils.getOsgiServiceProxy(OutgoingPortUtilService.class); }
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 <T extends Domain> T getDomainEndpoint(Class<T> domainType, String location) { Filter filter = utilsService.getFilterForLocation(domainType, location); return utilsService.getOsgiServiceProxy(filter, domainType); }
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); }
/** * 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); }
public static void sendRemoteEvent(String portId, String destination, RemoteEvent e, Map<String, String> metaData) throws PortNotAvailableException { MethodCall methodCall = new MethodCall("processRemoteEvent", new Object[]{ e }, metaData); OutgoingPortUtilService portUtilService = utilsService.getOsgiServiceProxy(OutgoingPortUtilService.class); portUtilService.sendMethodCall(portId, destination, methodCall); }
public static void sendRemoteEvent(String portId, String destination, RemoteEvent e, Map<String, String> metaData) throws PortNotAvailableException { MethodCall methodCall = new MethodCall("processRemoteEvent", new Object[]{ e }, metaData); OutgoingPortUtilService portUtilService = utilsService.getOsgiServiceProxy(OutgoingPortUtilService.class); portUtilService.sendMethodCall(portId, destination, methodCall); }
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; }
@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); }
@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; }