Package org.apache.aries.blueprint.mutable

Examples of org.apache.aries.blueprint.mutable.MutableBeanMetadata



public class RsClientDefinitionParser extends AbstractBeanDefinitionParser {

    public Metadata parse(Element element, ParserContext context) {
        MutableBeanMetadata beanMetadata = createBeanMetadata(element, context, RsClientBlueprintBean.class);
        NamedNodeMap atts = element.getAttributes();

        String bus = null;
        for (int i = 0; i < atts.getLength(); i++) {
            Attr node = (Attr) atts.item(i);
            String val = node.getValue();
            String pre = node.getPrefix();
            String name = node.getLocalName();
            if ("bus".equals(name)) {
                bus = val;
            } else if (isAttribute(pre, name)) {
                if ("depends-on".equals(name)) {
                    beanMetadata.addDependsOn(val);
                } else if (!"name".equals(name)) {
                    beanMetadata.addProperty(name, AbstractBPBeanDefinitionParser.createValue(context, val));
                }
            }
        }

        Element elem = DOMUtils.getFirstElement(element);
        while (elem != null) {
            String name = elem.getLocalName();
            if ("properties".equals(name) || "headers".equals(name)) {
                Metadata map = parseMapData(context, beanMetadata, elem);
                beanMetadata.addProperty(name, map);
            } else if ("binding".equals(name)) {
                setFirstChildAsProperty(element, context, beanMetadata, "bindingConfig");
            } else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name)
                || "outFaultInterceptors".equals(name) || "features".equals(name) || "schemaLocations".equals(name) || "handlers".equals(name)) {
                Metadata list = parseListData(context, beanMetadata, elem);
                beanMetadata.addProperty(name, list);
            } else if ("features".equals(name) || "providers".equals(name)
                || "schemaLocations".equals(name) || "modelBeans".equals(name)
                || "serviceBeans".equals(name)) {
                Metadata list = parseListData(context, beanMetadata, elem);
                beanMetadata.addProperty(name, list);
            } else if ("model".equals(name)) {
                List<UserResource> resources = ResourceUtils.getResourcesFromElement(elem);
                MutablePassThroughMetadata value = context.createMetadata(MutablePassThroughMetadata.class);
                value.setObject(resources);
                beanMetadata.addProperty(name, value);
            } else {
                setFirstChildAsProperty(element, context, beanMetadata, name);
            }
        }
        if (StringUtils.isEmpty(bus)) {
            bus = "cxf";
        }
        //Will create a bus if needed...

        beanMetadata.addProperty("bus", getBusRef(context, bus));
        return beanMetadata;
    }
View Full Code Here


        }
        return id;
    }
   
    public MutableBeanMetadata createBeanMetadata(Element element, ParserContext context, Class runtimeClass) {
        MutableBeanMetadata answer = context.createMetadata(MutableBeanMetadata.class);
        answer.setRuntimeClass(runtimeClass);
        answer.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
        answer.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
        // set the Bean scope to be prototype, so we can get a new instance per looking up
        answer.setScope(MutableBeanMetadata.SCOPE_PROTOTYPE);
       
        if (!StringUtils.isEmpty(getIdOrName(element))) {
            answer.setId(getIdOrName(element));
        } else {
            // TODO we may need to throw exception for it
            answer.setId("camel.cxf.endpoint." + runtimeClass.getSimpleName() + "." + context.generateId());
        }
        return answer;
    }
View Full Code Here

import org.osgi.service.blueprint.reflect.Metadata;

public class RsServerDefinitionParser extends AbstractBeanDefinitionParser {
   
    public Metadata parse(Element element, ParserContext context) {
        MutableBeanMetadata beanMetadata = createBeanMetadata(element, context, RsServerBlueprintBean.class);
        NamedNodeMap atts = element.getAttributes();

        String bus = null;
        for (int i = 0; i < atts.getLength(); i++) {
            Attr node = (Attr) atts.item(i);
            String val = node.getValue();
            String pre = node.getPrefix();
            String name = node.getLocalName();
            if ("bus".equals(name)) {
                bus = val;
            } else if (isAttribute(pre, name)) {
                if ("depends-on".equals(name)) {
                    beanMetadata.addDependsOn(val);
                } else if (!"name".equals(name)) {
                    beanMetadata.addProperty(name, AbstractBPBeanDefinitionParser.createValue(context, val));
                }
            }
        }

        Element elem = DOMUtils.getFirstElement(element);
        while (elem != null) {
            String name = elem.getLocalName();
            if ("properties".equals(name)
                || "extensionMappings".equals(name)
                || "languageMappings".equals(name)) {
                Metadata map = parseMapData(context, beanMetadata, elem);
                beanMetadata.addProperty(name, map);
            } else if ("binding".equals(name)) {
                setFirstChildAsProperty(element, context, beanMetadata, "bindingConfig");
            } else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name)
                || "outFaultInterceptors".equals(name) || "features".equals(name) || "schemaLocations".equals(name) || "handlers".equals(name)) {
                Metadata list = parseListData(context, beanMetadata, elem);
                beanMetadata.addProperty(name, list);
            } else if ("features".equals(name) || "providers".equals(name)
                || "schemaLocations".equals(name) || "modelBeans".equals(name)) {
                Metadata list = parseListData(context, beanMetadata, elem);
                beanMetadata.addProperty(name, list);
            } else if ("model".equals(name)) {
                List<UserResource> resources = ResourceUtils.getResourcesFromElement(elem);
                MutablePassThroughMetadata value = context.createMetadata(MutablePassThroughMetadata.class);
                value.setObject(resources);
                beanMetadata.addProperty(name, value);
            } else {
                setFirstChildAsProperty(element, context, beanMetadata, name);
            }
        }
        if (StringUtils.isEmpty(bus)) {
            bus = "cxf";
        }
        //Will create a bus if needed...

        beanMetadata.addProperty("bus", getBusRef(context, bus));
        return beanMetadata;
    }
View Full Code Here

       
        MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
        factory.setId(".camelBlueprint.passThrough." + contextId);
        factory.setObject(new PassThroughCallable<Object>(value));

        MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
        factory2.setId(".camelBlueprint.factory." + contextId);
        factory2.setFactoryComponent(factory);
        factory2.setFactoryMethod("call");
        factory2.setInitMethod("afterPropertiesSet");
        factory2.setDestroyMethod("destroy");
        factory2.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
        factory2.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
        context.getComponentDefinitionRegistry().registerComponentDefinition(factory2);

        MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
        ctx.setId(contextId);
        ctx.setRuntimeClass(BlueprintCamelContext.class);
        ctx.setFactoryComponent(factory2);
        ctx.setFactoryMethod("getContext");
        ctx.setInitMethod("init");
        ctx.setDestroyMethod("destroy");

        // Register objects
        registerBeans(context, contextId, ccfb.getEndpoints());
        registerBeans(context, contextId, ccfb.getThreadPools());
        registerBeans(context, contextId, ccfb.getBeans());

        // Register processors
        MutablePassThroughMetadata beanProcessorFactory = context.createMetadata(MutablePassThroughMetadata.class);
        beanProcessorFactory.setId(".camelBlueprint.processor.bean.passThrough." + contextId);
        beanProcessorFactory.setObject(new PassThroughCallable<Object>(new CamelInjector(contextId)));

        MutableBeanMetadata beanProcessor = context.createMetadata(MutableBeanMetadata.class);
        beanProcessor.setId(".camelBlueprint.processor.bean." + contextId);
        beanProcessor.setRuntimeClass(CamelInjector.class);
        beanProcessor.setFactoryComponent(beanProcessorFactory);
        beanProcessor.setFactoryMethod("call");
        beanProcessor.setProcessor(true);
        beanProcessor.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
        context.getComponentDefinitionRegistry().registerComponentDefinition(beanProcessor);

        MutablePassThroughMetadata regProcessorFactory = context.createMetadata(MutablePassThroughMetadata.class);
        regProcessorFactory.setId(".camelBlueprint.processor.registry.passThrough." + contextId);
        regProcessorFactory.setObject(new PassThroughCallable<Object>(new CamelDependenciesFinder(contextId, context)));

        MutableBeanMetadata regProcessor = context.createMetadata(MutableBeanMetadata.class);
        regProcessor.setId(".camelBlueprint.processor.registry." + contextId);
        regProcessor.setRuntimeClass(CamelDependenciesFinder.class);
        regProcessor.setFactoryComponent(regProcessorFactory);
        regProcessor.setFactoryMethod("call");
        regProcessor.setProcessor(true);
        regProcessor.addDependsOn(".camelBlueprint.processor.bean." + contextId);
        regProcessor.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
        context.getComponentDefinitionRegistry().registerComponentDefinition(regProcessor);
        return ctx;
    }
View Full Code Here

        MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
        factory.setId(".camelBlueprint.passThrough." + id);
        factory.setObject(new PassThroughCallable<Object>(rcfb));

        MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
        factory2.setId(".camelBlueprint.factory." + id);
        factory2.setFactoryComponent(factory);
        factory2.setFactoryMethod("call");

        MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
        ctx.setId(id);
        ctx.setRuntimeClass(List.class);
        ctx.setFactoryComponent(factory2);
        ctx.setFactoryMethod("getRoutes");

        return ctx;
    }
View Full Code Here

        MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
        factory.setId(".camelBlueprint.passThrough." + id);
        factory.setObject(new PassThroughCallable<Object>(kspfb));

        MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
        factory2.setId(".camelBlueprint.factory." + id);
        factory2.setFactoryComponent(factory);
        factory2.setFactoryMethod("call");

        MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
        ctx.setId(id);
        ctx.setRuntimeClass(List.class);
        ctx.setFactoryComponent(factory2);
        ctx.setFactoryMethod("getObject");

        return ctx;
    }
View Full Code Here

        MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
        factory.setId(".camelBlueprint.passThrough." + id);
        factory.setObject(new PassThroughCallable<Object>(srfb));

        MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
        factory2.setId(".camelBlueprint.factory." + id);
        factory2.setFactoryComponent(factory);
        factory2.setFactoryMethod("call");

        MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
        ctx.setId(id);
        ctx.setRuntimeClass(List.class);
        ctx.setFactoryComponent(factory2);
        ctx.setFactoryMethod("getObject");

        return ctx;
    }
View Full Code Here

        MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
        factory.setId(".camelBlueprint.passThrough." + id);
        factory.setObject(new PassThroughCallable<Object>(scpfb));

        MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
        factory2.setId(".camelBlueprint.factory." + id);
        factory2.setFactoryComponent(factory);
        factory2.setFactoryMethod("call");

        MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
        ctx.setId(id);
        ctx.setRuntimeClass(List.class);
        ctx.setFactoryComponent(factory2);
        ctx.setFactoryMethod("getObject");

        return ctx;
    }
View Full Code Here

        MutablePassThroughMetadata eff = context.createMetadata(MutablePassThroughMetadata.class);
        eff.setId(".camelBlueprint.bean.passthrough." + id);
        eff.setObject(new PassThroughCallable<Object>(fact));

        MutableBeanMetadata ef = context.createMetadata(MutableBeanMetadata.class);
        ef.setId(".camelBlueprint.bean.factory." + id);
        ef.setFactoryComponent(eff);
        ef.setFactoryMethod("call");
        ef.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
        ef.setInitMethod("afterPropertiesSet");
        ef.setDestroyMethod("destroy");

        MutableBeanMetadata e = context.createMetadata(MutableBeanMetadata.class);
        e.setId(id);
        e.setRuntimeClass(fact.getObjectType());
        e.setFactoryComponent(ef);
        e.setFactoryMethod("getObject");
        e.addDependsOn(".camelBlueprint.processor.bean." + contextId);

        context.getComponentDefinitionRegistry().registerComponentDefinition(e);
    }
View Full Code Here

    public RMBPBeanDefinitionParser(Class<?> beanClass) {
        this.beanClass = beanClass;
    }
   
    protected Metadata parse(Element element, ParserContext context) {
        MutableBeanMetadata bean = context.createMetadata(MutableBeanMetadata.class);

        bean.setRuntimeClass(beanClass);

        String bus = element.getAttribute("bus");
        if (StringUtils.isEmpty(bus)) {
            bus = "cxf";
        }

        mapElementToJaxbProperty(context, bean, element,
                new QName(RM_NS, "deliveryAssurance"), "deliveryAssurance", DeliveryAssuranceType.class);
        mapElementToJaxbProperty(context, bean, element,
                new QName(RM_NS, "sourcePolicy"), "sourcePolicy", SourcePolicyType.class);
        mapElementToJaxbProperty(context, bean, element,
                new QName(RM_NS, "destinationPolicy"), "destinationPolicy", DestinationPolicyType.class);
        mapElementToJaxbProperty(context, bean, element,
                new QName("http://schemas.xmlsoap.org/ws/2005/02/rm/policy", "RMAssertion"),
                "RMAssertion",
                org.apache.cxf.ws.rmp.v200502.RMAssertion.class);
        mapElementToJaxbProperty(context, bean, element,
                new QName("http://docs.oasis-open.org/ws-rx/wsrmp/200702", "RMAssertion"),
                "RMAssertion",
                org.apache.cxf.ws.rmp.v200502.RMAssertion.class);

        parseAttributes(element, context, bean);
        parseChildElements(element, context, bean);

        bean.setId(beanClass.getName() + context.generateId());
       
        if (beanClass.equals(RMManager.class)) {
            bean.addProperty("bus", getBusRef(context, bus));
            bean.setDestroyMethod("shutdown");
        }

        return bean;
    }
View Full Code Here

TOP

Related Classes of org.apache.aries.blueprint.mutable.MutableBeanMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.