[
https://issues.apache.org/jira/browse/CAMEL-7875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14184074#comment-14184074
]
Claus Ibsen commented on CAMEL-7875:
------------------------------------
We have to be careful about this. As Camel does not hosts its own bean registry
but integrates with spring / jndi / cdi / osgi etc. And those have various
features to pre/post process the beans and whatnot.
A Camel registry will thus not offer that functionality, and make it
inconsistent behavior when a bean is found from Camel vs the others.
Also if a bean by type / name is in both which one to choose, and return? (eg
how to handle duplicates) etc.
If the use-case is to make it easier to register beans manually to override
existing beans for unit testing, then its better to improve camel-test. And
leave current as-is.
> 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
> Assignee: Willem Jiang
> 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)