camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jyrki Ruuskanen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-7875) Easier write access to Camel context registry
Date Mon, 29 Sep 2014 07:45:33 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-7875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14151455#comment-14151455
] 

Jyrki Ruuskanen commented on CAMEL-7875:
----------------------------------------

Adding beans to registry seems to be hard also when unit testing with CamelTestSupport where
CamelContext creation is locked inside the longish doSetUp() method.

How about just biting the bullet and adding a bind(String name, Object bean) method to the
Registry interface and every implementation? Then the user wouldn't have to care which registry
flavor CamelContext is using behind the scenes.

> Easier write access to Camel context registry
> ---------------------------------------------
>
>                 Key: CAMEL-7875
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7875
>             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)
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:
> {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
(v6.3.4#6332)

Mime
View raw message