Search in sources :

Example 11 with Attribute

use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.

the class ManagedTypeTestCase method element.

private Element element(String type, String classname) {
    Element root = new Element(type, null);
    root.addAttribute(new Attribute("classname", classname));
    return root;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 12 with Attribute

use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.

the class ProvidedServiceHandlerTest method testServiceDetectionSuperSuperClass.

public void testServiceDetectionSuperSuperClass() throws ConfigurationException {
    String classname = "org.apache.felix.ipojo.handlers.providedservice.ComponentTestWithAnotherSuperClass";
    Element metadata = new Element("component", "");
    Element manipulation = new Element("manipulation", "");
    metadata.addAttribute(new Attribute("classname", classname));
    Element provides = new Element("provides", "");
    provides.addAttribute(new Attribute("specifications", "java.beans.FeatureDescriptor"));
    metadata.addElement(provides);
    metadata.addElement(manipulation);
    manipulation.addAttribute(new Attribute("classname", classname));
    manipulation.addAttribute(new Attribute("super", "java.beans.MethodDescriptor"));
    Mockito.when(factory.getPojoMetadata()).thenReturn(new PojoMetadata(metadata));
    Mockito.when(factory.getClassName()).thenReturn(classname);
    handler.initializeComponentFactory(desc, metadata);
    System.out.println(metadata);
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element) PojoMetadata(org.apache.felix.ipojo.parser.PojoMetadata)

Example 13 with Attribute

use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.

the class MethodMetadataTest method testComputationForArraysUsingPrimitiveFromElement.

public void testComputationForArraysUsingPrimitiveFromElement() {
    Element metadata1 = new Element("method", null);
    metadata1.addAttribute(new Attribute("name", "withOneArray"));
    metadata1.addAttribute(new Attribute("arguments", "{int[]}"));
    Element metadata2 = new Element("method", null);
    metadata2.addAttribute(new Attribute("name", "withOneArray"));
    metadata2.addAttribute(new Attribute("arguments", "{int[][]}"));
    Element metadata3 = new Element("method", null);
    metadata3.addAttribute(new Attribute("name", "withOneArray"));
    metadata3.addAttribute(new Attribute("arguments", "{int[][][]}"));
    MethodMetadata methodMetadata1 = new MethodMetadata(metadata1);
    Assert.assertEquals("withOneArray$int__", methodMetadata1.getMethodIdentifier());
    MethodMetadata methodMetadata2 = new MethodMetadata(metadata2);
    Assert.assertEquals("withOneArray$int____", methodMetadata2.getMethodIdentifier());
    MethodMetadata methodMetadata3 = new MethodMetadata(metadata3);
    Assert.assertEquals("withOneArray$int______", methodMetadata3.getMethodIdentifier());
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 14 with Attribute

use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.

the class MethodMetadataTest method testComputationForArraysUsingObjectsFromElement.

public void testComputationForArraysUsingObjectsFromElement() {
    Element metadata1 = new Element("method", null);
    metadata1.addAttribute(new Attribute("name", "withOneArray"));
    metadata1.addAttribute(new Attribute("arguments", "{java.lang.String[]}"));
    Element metadata2 = new Element("method", null);
    metadata2.addAttribute(new Attribute("name", "withOneArray"));
    metadata2.addAttribute(new Attribute("arguments", "{java.lang.String[][]}"));
    Element metadata3 = new Element("method", null);
    metadata3.addAttribute(new Attribute("name", "withOneArray"));
    metadata3.addAttribute(new Attribute("arguments", "{java.lang.String[][][]}"));
    MethodMetadata methodMetadata1 = new MethodMetadata(metadata1);
    Assert.assertEquals("withOneArray$java_lang_String__", methodMetadata1.getMethodIdentifier());
    MethodMetadata methodMetadata2 = new MethodMetadata(metadata2);
    Assert.assertEquals("withOneArray$java_lang_String____", methodMetadata2.getMethodIdentifier());
    MethodMetadata methodMetadata3 = new MethodMetadata(metadata3);
    Assert.assertEquals("withOneArray$java_lang_String______", methodMetadata3.getMethodIdentifier());
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 15 with Attribute

use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.

the class DependencyHandlerDescription method computeServiceReferenceDescription.

private void computeServiceReferenceDescription(ServiceReference ref, Element use) {
    use.addAttribute(new Attribute(Constants.SERVICE_ID, ref.getProperty(Constants.SERVICE_ID).toString()));
    String instance = (String) ref.getProperty(Factory.INSTANCE_NAME_PROPERTY);
    if (instance != null) {
        use.addAttribute(new Attribute(Factory.INSTANCE_NAME_PROPERTY, instance));
    }
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute)

Aggregations

Attribute (org.apache.felix.ipojo.metadata.Attribute)125 Element (org.apache.felix.ipojo.metadata.Element)109 Test (org.junit.Test)9 PojoMetadata (org.apache.felix.ipojo.parser.PojoMetadata)6 Iterator (java.util.Iterator)4 Enumeration (java.util.Enumeration)3 Map (java.util.Map)3 Set (java.util.Set)3 ServiceReference (org.osgi.framework.ServiceReference)3 List (java.util.List)2 Entry (java.util.Map.Entry)2 PropertyDescription (org.apache.felix.ipojo.architecture.PropertyDescription)2 FieldMetadata (org.apache.felix.ipojo.parser.FieldMetadata)2 MethodMetadata (org.apache.felix.ipojo.parser.MethodMetadata)2 Type (org.objectweb.asm.Type)2 Member (java.lang.reflect.Member)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1