use of org.apache.camel.util.blueprint.SecureRandomParametersFactoryBean in project camel by apache.
the class CamelNamespaceHandler method parseSecureRandomParametersNode.
private Metadata parseSecureRandomParametersNode(Element element, ParserContext context) {
LOG.trace("Parsing SecureRandomParameters {}", 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 SecureRandomParametersFactoryBean)) {
throw new ComponentDefinitionException("Expected an instance of " + SecureRandomParametersFactoryBean.class);
}
SecureRandomParametersFactoryBean srfb = (SecureRandomParametersFactoryBean) value;
String id = srfb.getId();
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");
factory2.setInitMethod("afterPropertiesSet");
factory2.setDestroyMethod("destroy");
factory2.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
ctx.setId(id);
ctx.setRuntimeClass(SecureRandomParameters.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 SecureRandomParameters done, returning {}", ctx);
return ctx;
}
Aggregations