camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jyrki Ruuskanen (JIRA)" <>
Subject [jira] [Commented] (CAMEL-7875) Easier write access to Camel context registry
Date Wed, 01 Oct 2014 17:20:33 GMT


Jyrki Ruuskanen commented on CAMEL-7875:

I've been just thinking about the possible ways to make it easier to add objects into CamelContext's
registry from routebuilder's configure method. At the same time I'm trying to keep my routebuilders
portable so that they would run the same in org.apache.camel.main.Main and Karaf SCR bundle.

Your approach works fine in both as long as the CamelContext is created with a SimpleRegistry
and the routebuilder knows the registry key ("itself").

The change to SimpleRegistry up there in the original post is of course not possible because
it would make the registry non-empty when it's instanciated, and that would be odd to many
(including me). But the point was to guarantee that if routebuilder knows SimpleRegistry it
would also know its key.

The best solution would be to have a method for adding stuff in the Registry interface. Is
there a reason why Registry should be read-only?

> Easier write access to Camel context registry
> ---------------------------------------------
>                 Key: CAMEL-7875
>                 URL:
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Jyrki Ruuskanen
>            Priority: Minor
> 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)
> 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:
> {code}
> public static final String NAME;
> static {
>    NAME = java.util.UUID.randomUUID().tostring();
> }
> public SimpleRegistry() {
>    put.(NAME, this);
> }
> {code}

This message was sent by Atlassian JIRA

View raw message