Object value = parseUsingJaxb(element, context, binder);
if (!(value instanceof CamelContextFactoryBean)) {
throw new ComponentDefinitionException("Expected an instance of " + CamelContextFactoryBean.class);
}
CamelContextFactoryBean ccfb = (CamelContextFactoryBean) value;
ccfb.setImplicitId(implicitId);
// The properties component is always used / created by the CamelContextFactoryBean
// so we need to ensure that the resolver is ready to use
ComponentMetadata propertiesComponentResolver = getComponentResolverReference(context, "properties");
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"));
factory2.addDependsOn(propertiesComponentResolver.getId());
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 factory beans
registerBeans(context, contextId, ccfb.getThreadPools());
registerBeans(context, contextId, ccfb.getEndpoints());
registerBeans(context, contextId, ccfb.getRedeliveryPolicies());
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)));