Camel how to add something to registry - with java, in general

Here is one way of adding stuff to the registry in a RouteBuilder class. Below I am adding a TCPServerInitializerFactory which will be used later on. I always use the camel-blueprint archetype but create routes using java dsl. This works fine for me.

TCPServerInitializerFactory serverFactory = new TCPServerInitializerFactory(null);
final CamelContext camelContext = getContext();
        final org.apache.camel.impl.SimpleRegistry registry = new org.apache.camel.impl.SimpleRegistry();
        final org.apache.camel.impl.CompositeRegistry compositeRegistry = new org.apache.camel.impl.CompositeRegistry();
        compositeRegistry.addRegistry(camelContext.getRegistry());
        compositeRegistry.addRegistry(registry);
        ((org.apache.camel.impl.DefaultCamelContext) camelContext).setRegistry(compositeRegistry);
    registry.put("spf", serverFactory);

Tags:

Apache Camel