use of org.apache.felix.ipojo.extender.InstanceDeclaration in project felix by apache.
the class DefaultConfigurationBuilderTestCase method testClear.
public void testClear() throws Exception {
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(parent);
builder.property("a", "b");
builder.property("c", "d");
InstanceDeclaration declaration = (InstanceDeclaration) builder.build();
assertEquals(declaration.getConfiguration().get("a"), "b");
builder.clear();
InstanceDeclaration declaration2 = (InstanceDeclaration) builder.build();
assertTrue(declaration2.getConfiguration().isEmpty());
}
use of org.apache.felix.ipojo.extender.InstanceDeclaration in project felix by apache.
the class DefaultConfigurationBuilderTestCase method testPropertyAddition.
public void testPropertyAddition() throws Exception {
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(parent);
builder.property("a", "b");
InstanceDeclaration declaration = (InstanceDeclaration) builder.build();
assertEquals(declaration.getConfiguration().get("a"), "b");
}
use of org.apache.felix.ipojo.extender.InstanceDeclaration in project felix by apache.
the class DefaultInstanceBuilderTestCase method testNoConfiguration.
public void testNoConfiguration() throws Exception {
InstanceBuilder builder = new DefaultInstanceBuilder(m_bundleContext, "type");
DeclarationHandle handle = builder.build();
InstanceDeclaration did = (InstanceDeclaration) handle;
assertEquals("type", did.getComponentName());
assertEquals(InstanceDeclaration.UNNAMED_INSTANCE, did.getInstanceName());
assertNull(did.getComponentVersion());
Dictionary<String, Object> configuration = did.getConfiguration();
assertTrue(configuration.isEmpty());
}
use of org.apache.felix.ipojo.extender.InstanceDeclaration in project felix by apache.
the class Arch method instance.
/**
* Displays the architecture of a specific instance.
* @param instance the instance name
*/
@Descriptor("Display the architecture of a specific instance")
public void instance(@Descriptor("target instance name") String instance) {
StringBuilder sb = new StringBuilder();
for (Architecture m_arch : m_archs) {
InstanceDescription id = m_arch.getInstanceDescription();
if (id.getName().equalsIgnoreCase(instance)) {
sb.append(id.getDescription());
sb.append('\n');
}
}
for (InstanceDeclaration instanceDeclaration : m_instances) {
if (!instanceDeclaration.getStatus().isBound()) {
if (instance.equals(name(instanceDeclaration.getConfiguration()))) {
sb.append(format("InstanceDeclaration %s not bound to its factory%n", instance));
sb.append(format(" type: %s%n", instanceDeclaration.getComponentName()));
sb.append(format(" reason: %s%n", instanceDeclaration.getStatus().getMessage()));
Throwable throwable = instanceDeclaration.getStatus().getThrowable();
if (throwable != null) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
throwable.printStackTrace(new PrintStream(os));
sb.append(" throwable: ");
sb.append(os.toString());
}
}
}
}
if (sb.length() == 0) {
System.err.printf("Instance named '%s' not found", instance);
} else {
System.out.print(sb);
}
}
Aggregations