Search in sources :

Example 1 with SSLContextParametersFactoryBean

use of org.apache.camel.util.blueprint.SSLContextParametersFactoryBean in project camel by apache.

the class CamelNamespaceHandler method parseSSLContextParametersNode.

private Metadata parseSSLContextParametersNode(Element element, ParserContext context) {
    LOG.trace("Parsing SSLContextParameters {}", 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 SSLContextParametersFactoryBean)) {
        throw new ComponentDefinitionException("Expected an instance of " + SSLContextParametersFactoryBean.class);
    }
    SSLContextParametersFactoryBean scpfb = (SSLContextParametersFactoryBean) value;
    String id = scpfb.getId();
    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");
    factory2.setInitMethod("afterPropertiesSet");
    factory2.setDestroyMethod("destroy");
    factory2.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
    MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
    ctx.setId(id);
    ctx.setRuntimeClass(SSLContextParameters.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 SSLContextParameters 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) ExpressionNode(org.apache.camel.model.ExpressionNode) Node(org.w3c.dom.Node) JAXBException(javax.xml.bind.JAXBException) SSLContextParametersFactoryBean(org.apache.camel.util.blueprint.SSLContextParametersFactoryBean)

Aggregations

JAXBException (javax.xml.bind.JAXBException)1 MutableBeanMetadata (org.apache.aries.blueprint.mutable.MutableBeanMetadata)1 MutablePassThroughMetadata (org.apache.aries.blueprint.mutable.MutablePassThroughMetadata)1 ExpressionNode (org.apache.camel.model.ExpressionNode)1 SSLContextParametersFactoryBean (org.apache.camel.util.blueprint.SSLContextParametersFactoryBean)1 ComponentDefinitionException (org.osgi.service.blueprint.container.ComponentDefinitionException)1 Node (org.w3c.dom.Node)1