Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-7875

Easier write access to Camel context registry

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 3.0.0-M2, 3.0.0
    • camel-core
    • None
    • Unknown

    Description

      I haven't found a nice way to add beans to Camel context registry through Camel context reference in plain Java. Some beans are only needed by a certain endpoint and it would make sense to set the bean up with the endpoint in routebuilder configure method.

      If we added a reference to self in SimpleRegistry we could setup the Camel context by DefaultCamelContext(new SimpleRegistry()) or OsgiDefaultCamelContext(bundleContext, new SimpleRegistry()) and easily access the registry from the routebuilder with SimpleRegistry registry = (SimpleRegistry) getContext().lookupByName(SimpleRegistry.NAME);.

      Then we can set up beans in routebuilder configure and simply add them with registry.put. And the same routebuilder could be used in plain Java, in OSGi or elsewhere.

      All that is needed is this change in SimpleRegistry:

      public static final String NAME;
      static {
         NAME = java.util.UUID.randomUUID().tostring();
      }
      
      public SimpleRegistry() {
         put.(NAME, this);
      }
      

      Attachments

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              yuruki Jyrki Ruuskanen
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: