use of org.apache.felix.ipojo.handlers.configuration.ConfigurationHandlerDescription in project felix by apache.
the class AdvancedTrackerAndRankerInterceptor method open.
@Override
public void open(DependencyModel dependency) {
super.open(dependency);
ConfigurationHandlerDescription handler = (ConfigurationHandlerDescription) dependency.getComponentInstance().getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
handler.addListener(this);
}
use of org.apache.felix.ipojo.handlers.configuration.ConfigurationHandlerDescription in project felix by apache.
the class TestArchitecture method testArchitectureForInstance1.
@Test
public void testArchitectureForInstance1() {
Architecture arch = osgiHelper.getServiceObject(Architecture.class, "(architecture.instance=instance)");
assertNotNull(arch);
// Test on String representation.
String desc = arch.getInstanceDescription().getDescription().toString();
assertTrue(desc.contains("managed.service.pid=\"FooProvider-3\""));
// Test on handler description
ConfigurationHandlerDescription hd = (ConfigurationHandlerDescription) arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
assertNotNull(hd);
assertEquals(2, hd.getProperties().length);
assertEquals("FooProvider-3", hd.getManagedServicePid());
// Check the getInstance() method
assertSame(arch.getInstanceDescription().getInstance(), instance1);
}
use of org.apache.felix.ipojo.handlers.configuration.ConfigurationHandlerDescription in project felix by apache.
the class AdvancedTrackerAndRankerInterceptor method close.
@Override
public void close(DependencyModel dependency) {
super.close(dependency);
ConfigurationHandlerDescription handler = (ConfigurationHandlerDescription) dependency.getComponentInstance().getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
handler.removeListener(this);
}
use of org.apache.felix.ipojo.handlers.configuration.ConfigurationHandlerDescription in project felix by apache.
the class TestPropagation method testPropagationFromConfigurationAdminWhenCreatingTheInstance.
@Test
public void testPropagationFromConfigurationAdminWhenCreatingTheInstance() throws IOException {
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("message", "message");
props.put("propagated", "propagated");
props.put(".private", "wow");
Configuration configuration = admin.createFactoryConfiguration(factoryName, "?");
configuration.update(props);
ServiceReference ref = osgiHelper.waitForService(FooService.class.getName(), "(instance.name=" + configuration.getPid() + ")", 1000);
// Check the propagation
assertEquals(ref.getProperty("propagated"), "propagated");
assertEquals(ref.getProperty("message"), "message");
assertNull(ref.getProperty(".private"));
assertNull(ref.getProperty("private"));
// Check the the .private property has the right value
ConfigurationHandlerDescription desc = (ConfigurationHandlerDescription) ipojoHelper.getArchitectureByName(configuration.getPid()).getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
PropertyDescription prop = desc.getPropertyByName(".private");
assertEquals(prop.getValue(), "wow");
// Update the property
props.put("message", "message2");
props.put("propagated", "propagated2");
props.put(".private", "wow2");
configuration.update(props);
grace();
ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), configuration.getPid());
// Check the propagation
assertEquals(ref.getProperty("propagated"), "propagated2");
assertEquals(ref.getProperty("message"), "message2");
desc = (ConfigurationHandlerDescription) ipojoHelper.getArchitectureByName(configuration.getPid()).getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
prop = desc.getPropertyByName(".private");
assertEquals(prop.getValue(), "wow2");
configuration.delete();
}
use of org.apache.felix.ipojo.handlers.configuration.ConfigurationHandlerDescription in project felix by apache.
the class TestArchitecture method testArchitectureForInstance2.
@Test
public void testArchitectureForInstance2() {
Architecture arch = osgiHelper.getServiceObject(Architecture.class, "(architecture.instance=instance-2)");
assertNotNull(arch);
// Test on String representation.
String desc = arch.getInstanceDescription().getDescription().toString();
assertTrue(desc.contains("managed.service.pid=\"instance\""));
// Test on handler description
ConfigurationHandlerDescription hd = (ConfigurationHandlerDescription) arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
assertNotNull(hd);
assertEquals(2, hd.getProperties().length);
assertEquals("instance", hd.getManagedServicePid());
// Check the getInstance() method
assertSame(arch.getInstanceDescription().getInstance(), instance2);
}
Aggregations