Search in sources :

Example 76 with MutableBeanMetadata

use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project aries by apache.

the class AuthorizationNsHandler method authBeanProcessor.

private MutableBeanMetadata authBeanProcessor(ParserContext pc, ComponentDefinitionRegistry cdr) {
    MutableBeanMetadata meta = pc.createMetadata(MutableBeanMetadata.class);
    meta.setId(AuthorizationBeanProcessor.AUTH_PROCESSOR_BEAN_NAME);
    meta.setRuntimeClass(AuthorizationBeanProcessor.class);
    meta.setProcessor(true);
    meta.addProperty("cdr", passThrough(pc, cdr));
    return meta;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata)

Example 77 with MutableBeanMetadata

use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project aries by apache.

the class NSHandlerSix method parse.

// process elements
public Metadata parse(Element element, ParserContext context) {
    Metadata retval = null;
    if (element.getLocalName().equals(ELT_NAME)) {
        final String id = element.getAttributeNS(NSURI, ATTRIB_ID);
        MutableBeanMetadata bm = context.createMetadata(MutableBeanMetadata.class);
        bm.setId(id);
        bm.setScope("PROTOTYPE");
        bm.setClassName(TestBean.class.getName());
        retval = bm;
    }
    return retval;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) Metadata(org.osgi.service.blueprint.reflect.Metadata) PassThroughMetadata(org.apache.aries.blueprint.PassThroughMetadata) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) RefMetadata(org.osgi.service.blueprint.reflect.RefMetadata) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) MutableRefMetadata(org.apache.aries.blueprint.mutable.MutableRefMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata)

Example 78 with MutableBeanMetadata

use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project aries by apache.

the class NSHandlerThree method decorate.

public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) {
    if (node.getLocalName().equals(ATTRIB_ONE)) {
        if (component instanceof BeanMetadata) {
            if (context.getComponentDefinitionRegistry().getComponentDefinition(NSURI + "/BeanProcessor") == null) {
                BeanMetadata bm = context.createMetadata(BeanMetadata.class);
                MutableBeanMetadata mbm = (MutableBeanMetadata) bm;
                mbm.setProcessor(true);
                mbm.setRuntimeClass(BeanProcessorTest.class);
                mbm.setScope(BeanMetadata.SCOPE_SINGLETON);
                mbm.setId(NSURI + "/BeanProcessor");
                context.getComponentDefinitionRegistry().registerComponentDefinition(mbm);
            }
        }
    }
    return component;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata)

Example 79 with MutableBeanMetadata

use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project aries by apache.

the class IncorrectNamespaceHandler method parse.

@Override
public Metadata parse(Element element, ParserContext context) {
    MutableBeanMetadata metadata = context.createMetadata(MutableBeanMetadata.class);
    metadata.setProcessor(true);
    metadata.setId("aries-1503");
    metadata.setScope(BeanMetadata.SCOPE_SINGLETON);
    metadata.addArgument(new PassThroughMetadata() {

        @Override
        public Object getObject() {
            return "ARIES-1503";
        }

        @Override
        public String getId() {
            return "aries-1503-arg";
        }

        @Override
        public int getActivation() {
            return 0;
        }

        @Override
        public List<String> getDependsOn() {
            return null;
        }
    }, null, 0);
    metadata.setRuntimeClass(String.class);
    return metadata;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) PassThroughMetadata(org.apache.aries.blueprint.PassThroughMetadata) List(java.util.List)

Example 80 with MutableBeanMetadata

use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project aries by apache.

the class NSHandlerOne method decorate.

// process attributes
public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) {
    // and RefMetadata.
    if (component != null && component instanceof MutableBeanMetadata) {
        MutableBeanMetadata mbm = (MutableBeanMetadata) component;
        Attr a = (Attr) node;
        Element bean = a.getOwnerElement();
        String propname = bean.getAttributeNS(NSURI, ATTRIB_ONE);
        // if this were not a test, we might attempt to ensure this ref existed
        String passthruref = bean.getAttributeNS(NSURI, ATTRIB_TWO);
        MutableRefMetadata ref = (MutableRefMetadata) context.createMetadata(RefMetadata.class);
        ref.setComponentId(passthruref);
        mbm.addProperty(propname, ref);
    }
    return component;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) RefMetadata(org.osgi.service.blueprint.reflect.RefMetadata) MutableRefMetadata(org.apache.aries.blueprint.mutable.MutableRefMetadata) MutableRefMetadata(org.apache.aries.blueprint.mutable.MutableRefMetadata) Element(org.w3c.dom.Element) Attr(org.w3c.dom.Attr)

Aggregations

MutableBeanMetadata (org.apache.aries.blueprint.mutable.MutableBeanMetadata)96 Element (org.w3c.dom.Element)23 Node (org.w3c.dom.Node)20 MutablePassThroughMetadata (org.apache.aries.blueprint.mutable.MutablePassThroughMetadata)19 Metadata (org.osgi.service.blueprint.reflect.Metadata)19 MutableRefMetadata (org.apache.aries.blueprint.mutable.MutableRefMetadata)18 ComponentDefinitionException (org.osgi.service.blueprint.container.ComponentDefinitionException)18 MutableCollectionMetadata (org.apache.aries.blueprint.mutable.MutableCollectionMetadata)17 BeanMetadata (org.osgi.service.blueprint.reflect.BeanMetadata)16 ComponentMetadata (org.osgi.service.blueprint.reflect.ComponentMetadata)15 MutableValueMetadata (org.apache.aries.blueprint.mutable.MutableValueMetadata)13 RefMetadata (org.osgi.service.blueprint.reflect.RefMetadata)12 NodeList (org.w3c.dom.NodeList)11 MutableMapMetadata (org.apache.aries.blueprint.mutable.MutableMapMetadata)10 PassThroughMetadata (org.apache.aries.blueprint.PassThroughMetadata)9 JAXBException (javax.xml.bind.JAXBException)8 CollectionMetadata (org.osgi.service.blueprint.reflect.CollectionMetadata)8 ValueMetadata (org.osgi.service.blueprint.reflect.ValueMetadata)8 ExpressionNode (org.apache.camel.model.ExpressionNode)7 Attr (org.w3c.dom.Attr)7