/** * Does the service instance match with the given factory ? * @param fact : the factory to test. * @return true if the factory match, false otherwise. */ public boolean match(ServiceReference fact) { // Check if the factory can provide the specification ComponentTypeDescription desc = (ComponentTypeDescription) fact.getProperty("component.description"); if (desc == null) { return false; // No component type description. } String[] provides = desc.getprovidedServiceSpecification(); for (int i = 0; provides != null && i < provides.length; i++) { if (provides[i].equals(m_specification)) { // Check that the factory needs every properties contained in // the configuration PropertyDescription[] props = desc.getProperties(); Properties conf = new Properties(); Enumeration keys = m_configuration.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); if (!containsProperty(key, props)) { return false; } conf.put(key, m_configuration.get(key)); } Factory factory = (Factory) getService(fact); return factory.isAcceptable(conf); } } return false; }
/** * Does the service instance match with the given factory ? * @param fact : the factory to test. * @return true if the factory match, false otherwise. */ public boolean match(ServiceReference fact) { // Check if the factory can provide the specification ComponentTypeDescription desc = (ComponentTypeDescription) fact.getProperty("component.description"); if (desc == null) { return false; // No component type description. } String[] provides = desc.getprovidedServiceSpecification(); for (int i = 0; provides != null && i < provides.length; i++) { if (provides[i].equals(m_specification)) { // Check that the factory needs every properties contained in // the configuration PropertyDescription[] props = desc.getProperties(); Properties conf = new Properties(); Enumeration keys = m_configuration.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); if (!containsProperty(key, props)) { return false; } conf.put(key, m_configuration.get(key)); } Factory factory = (Factory) getService(fact); return factory.isAcceptable(conf); } } return false; }
if (factory.getComponentDescription().getprovidedServiceSpecification().length != 0) { pw.key("services"); pw.value(factory.getComponentDescription().getprovidedServiceSpecification());