Java Code Examples for org.osgi.framework.Constants#SERVICE_PID
The following examples show how to use
org.osgi.framework.Constants#SERVICE_PID .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigurableServiceResource.java From openhab-core with Eclipse Public License 2.0 | 6 votes |
private @Nullable String getConfigDescriptionByFactoryPid(String factoryPid) { String configDescriptionURI = null; String filter = "(" + Constants.SERVICE_PID + "=" + factoryPid + ")"; try { ServiceReference<?>[] refs = bundleContext.getServiceReferences((String) null, filter); if (refs != null && refs.length > 0) { configDescriptionURI = (String) refs[0] .getProperty(ConfigurableService.SERVICE_PROPERTY_DESCRIPTION_URI); } } catch (InvalidSyntaxException e) { logger.error("Cannot get service references because the syntax of the filter '{}' is invalid.", filter); } return configDescriptionURI; }
Example 2
Source File: ConfigurableServiceResource.java From smarthome with Eclipse Public License 2.0 | 6 votes |
private String getConfigDescriptionByFactoryPid(String factoryPid) { String configDescriptionURI = null; String filter = "(" + Constants.SERVICE_PID + "=" + factoryPid + ")"; try { ServiceReference<?>[] refs = RESTCoreActivator.getBundleContext().getServiceReferences((String) null, filter); if (refs != null && refs.length > 0) { configDescriptionURI = (String) refs[0] .getProperty(ConfigurableService.SERVICE_PROPERTY_DESCRIPTION_URI); } } catch (InvalidSyntaxException e) { logger.error("Cannot get service references because the syntax of the filter '{}' is invalid.", filter); } return configDescriptionURI; }
Example 3
Source File: ConfigurableServiceResource.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
private @Nullable ConfigurableServiceDTO getMultiConfigServiceById(String serviceId) { String filter = "(&(" + Constants.SERVICE_PID + "=" + serviceId + ")(" + ConfigurationAdmin.SERVICE_FACTORYPID + "=*))"; List<ConfigurableServiceDTO> services = getServicesByFilter(filter); if (services.size() == 1) { return services.get(0); } return null; }
Example 4
Source File: ConfigurationAdminFactory.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Fetch all service references of the given service type that has a PID * matching the given one. * * @param c * The service class. * @param pid * The PID to match for. * @return collection with all service references that matches. */ <C> Collection<ServiceReference<C>> getServiceReferencesWithPid(Class<C> c, String pid) { final String filter = "(" + Constants.SERVICE_PID + "=" + pid + ")"; try { return Activator.bc.getServiceReferences(c, filter); } catch (final InvalidSyntaxException e) { Activator.log.error("Faulty ldap filter " + filter + ": " + e.getMessage(), e); @SuppressWarnings("unchecked") final Collection<ServiceReference<C>> res = Collections.EMPTY_LIST; return res; } }
Example 5
Source File: OsgiConfigLoader.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Override public Map<String, String> load() { if (configAdmin == null) { LOG.warn("No OSGi configuration-admin available - cannot load {}.cfg", propertiesPath); return ImmutableMap.of(); } String filter = '(' + Constants.SERVICE_PID + '=' + propertiesPath + ')'; Configuration[] configs; try { configs = configAdmin.listConfigurations(filter); } catch (InvalidSyntaxException | IOException e) { LOG.info("Cannot list OSGi configurations"); throw Exceptions.propagate(e); } final MutableMap<String, String> map = MutableMap.of(); if (configs != null) { for (Configuration config : configs) { LOG.debug("Reading OSGi configuration from {}; bundleLocation={}", config.getPid(), config.getBundleLocation()); map.putAll(dictToMap(config.getProperties())); } } else { LOG.info("No OSGi configuration found for {}.cfg", propertiesPath); } return map; }
Example 6
Source File: OsgiLauncherImpl.java From brooklyn-server with Apache License 2.0 | 5 votes |
private Configuration getConfiguration(ConfigurationAdmin configAdmin, String brooklynConfigPid) { String filter = '(' + Constants.SERVICE_PID + '=' + brooklynConfigPid + ')'; Configuration[] configs; try { configs = configAdmin.listConfigurations(filter); } catch (InvalidSyntaxException | IOException e) { throw Exceptions.propagate(e); } if (configs != null && configs.length > 0) { return configs[0]; } else { return null; } }
Example 7
Source File: ConfigurableServiceResource.java From smarthome with Eclipse Public License 2.0 | 5 votes |
private ConfigurableServiceDTO getMultiConfigServiceById(String serviceId) { String filter = "(&(" + Constants.SERVICE_PID + "=" + serviceId + ")(" + ConfigurationAdmin.SERVICE_FACTORYPID + "=*))"; List<ConfigurableServiceDTO> services = getServicesByFilter(filter); if (services.size() == 1) { return services.get(0); } return null; }
Example 8
Source File: ServiceRegistrationsTrackerTest.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Before public void prepare() { tracker = new ServiceRegistrationsTracker(new ServiceIdentifier(Constants.SERVICE_PID, "foo")); }