Search in sources :

Example 31 with MutableBeanMetadata

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

the class ServerFactoryBeanDefinitionParser method parse.

@Override
public Metadata parse(Element element, ParserContext context) {
    MutableBeanMetadata bean = (MutableBeanMetadata) super.parse(element, context);
    bean.setInitMethod("init");
    bean.setDestroyMethod("destroy");
    // We don't really want to delay the registration of our Server
    bean.setActivation(ComponentMetadata.ACTIVATION_EAGER);
    return bean;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata)

Example 32 with MutableBeanMetadata

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

the class CamelNamespaceHandler method parseRestContextNode.

private Metadata parseRestContextNode(Element element, ParserContext context) {
    LOG.trace("Parsing RestContext {}", element);
    // now parse the rests with JAXB
    Binder<Node> binder;
    try {
        binder = getJaxbContext().createBinder();
    } catch (JAXBException e) {
        throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
    }
    Object value = parseUsingJaxb(element, context, binder);
    if (!(value instanceof CamelRestContextFactoryBean)) {
        throw new ComponentDefinitionException("Expected an instance of " + CamelRestContextFactoryBean.class);
    }
    CamelRestContextFactoryBean rcfb = (CamelRestContextFactoryBean) value;
    String id = rcfb.getId();
    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("getRests");
    // must be lazy as we want CamelContext to be activated first
    ctx.setActivation(ACTIVATION_LAZY);
    // lets inject the namespaces into any namespace aware POJOs
    injectNamespaces(element, binder);
    LOG.trace("Parsing RestContext done, returning {}", element, ctx);
    return ctx;
}
Also used : MutablePassThroughMetadata(org.apache.aries.blueprint.mutable.MutablePassThroughMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) ComponentDefinitionException(org.osgi.service.blueprint.container.ComponentDefinitionException) ExpressionNode(org.apache.camel.model.ExpressionNode) Node(org.w3c.dom.Node) JAXBException(javax.xml.bind.JAXBException) CamelRestContextFactoryBean(org.apache.camel.blueprint.CamelRestContextFactoryBean)

Example 33 with MutableBeanMetadata

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

the class CamelNamespaceHandler method parseKeyStoreParametersNode.

private Metadata parseKeyStoreParametersNode(Element element, ParserContext context) {
    LOG.trace("Parsing KeyStoreParameters {}", element);
    // now parse the key store parameters with JAXB
    Binder<Node> binder;
    try {
        binder = getJaxbContext().createBinder();
    } catch (JAXBException e) {
        throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
    }
    Object value = parseUsingJaxb(element, context, binder);
    if (!(value instanceof KeyStoreParametersFactoryBean)) {
        throw new ComponentDefinitionException("Expected an instance of " + KeyStoreParametersFactoryBean.class);
    }
    KeyStoreParametersFactoryBean kspfb = (KeyStoreParametersFactoryBean) value;
    String id = kspfb.getId();
    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");
    factory2.setInitMethod("afterPropertiesSet");
    factory2.setDestroyMethod("destroy");
    factory2.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
    MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
    ctx.setId(id);
    ctx.setRuntimeClass(KeyStoreParameters.class);
    ctx.setFactoryComponent(factory2);
    ctx.setFactoryMethod("getObject");
    // must be lazy as we want CamelContext to be activated first
    ctx.setActivation(ACTIVATION_LAZY);
    LOG.trace("Parsing KeyStoreParameters done, returning {}", ctx);
    return ctx;
}
Also used : MutablePassThroughMetadata(org.apache.aries.blueprint.mutable.MutablePassThroughMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) ComponentDefinitionException(org.osgi.service.blueprint.container.ComponentDefinitionException) KeyStoreParametersFactoryBean(org.apache.camel.util.blueprint.KeyStoreParametersFactoryBean) ExpressionNode(org.apache.camel.model.ExpressionNode) Node(org.w3c.dom.Node) JAXBException(javax.xml.bind.JAXBException)

Example 34 with MutableBeanMetadata

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

the class CamelNamespaceHandler method registerBean.

protected void registerBean(ParserContext context, String contextId, AbstractCamelFactoryBean<?> fact) {
    String id = fact.getId();
    fact.setCamelContextId(contextId);
    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);
}
Also used : MutablePassThroughMetadata(org.apache.aries.blueprint.mutable.MutablePassThroughMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata)

Example 35 with MutableBeanMetadata

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

the class CamelNamespaceHandler method parseRouteContextNode.

private Metadata parseRouteContextNode(Element element, ParserContext context) {
    LOG.trace("Parsing RouteContext {}", element);
    // now parse the routes with JAXB
    Binder<Node> binder;
    try {
        binder = getJaxbContext().createBinder();
    } catch (JAXBException e) {
        throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
    }
    Object value = parseUsingJaxb(element, context, binder);
    if (!(value instanceof CamelRouteContextFactoryBean)) {
        throw new ComponentDefinitionException("Expected an instance of " + CamelRouteContextFactoryBean.class);
    }
    CamelRouteContextFactoryBean rcfb = (CamelRouteContextFactoryBean) value;
    String id = rcfb.getId();
    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");
    // must be lazy as we want CamelContext to be activated first
    ctx.setActivation(ACTIVATION_LAZY);
    // lets inject the namespaces into any namespace aware POJOs
    injectNamespaces(element, binder);
    LOG.trace("Parsing RouteContext done, returning {}", element, ctx);
    return ctx;
}
Also used : MutablePassThroughMetadata(org.apache.aries.blueprint.mutable.MutablePassThroughMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) ComponentDefinitionException(org.osgi.service.blueprint.container.ComponentDefinitionException) CamelRouteContextFactoryBean(org.apache.camel.blueprint.CamelRouteContextFactoryBean) ExpressionNode(org.apache.camel.model.ExpressionNode) Node(org.w3c.dom.Node) JAXBException(javax.xml.bind.JAXBException)

Aggregations

MutableBeanMetadata (org.apache.aries.blueprint.mutable.MutableBeanMetadata)68 MutablePassThroughMetadata (org.apache.aries.blueprint.mutable.MutablePassThroughMetadata)17 Element (org.w3c.dom.Element)17 Node (org.w3c.dom.Node)14 ComponentDefinitionException (org.osgi.service.blueprint.container.ComponentDefinitionException)12 Metadata (org.osgi.service.blueprint.reflect.Metadata)11 ComponentMetadata (org.osgi.service.blueprint.reflect.ComponentMetadata)10 PassThroughMetadata (org.apache.aries.blueprint.PassThroughMetadata)9 BeanMetadata (org.osgi.service.blueprint.reflect.BeanMetadata)9 JAXBException (javax.xml.bind.JAXBException)8 MutableCollectionMetadata (org.apache.aries.blueprint.mutable.MutableCollectionMetadata)7 MutableRefMetadata (org.apache.aries.blueprint.mutable.MutableRefMetadata)7 ExpressionNode (org.apache.camel.model.ExpressionNode)7 RefMetadata (org.osgi.service.blueprint.reflect.RefMetadata)7 Attr (org.w3c.dom.Attr)7 NamedNodeMap (org.w3c.dom.NamedNodeMap)6 NodeList (org.w3c.dom.NodeList)6 List (java.util.List)5 QName (javax.xml.namespace.QName)5 ComponentDefinitionRegistry (org.apache.aries.blueprint.ComponentDefinitionRegistry)4