Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B464017271 for ; Sun, 28 Sep 2014 09:48:35 +0000 (UTC) Received: (qmail 2592 invoked by uid 500); 28 Sep 2014 09:48:34 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 2548 invoked by uid 500); 28 Sep 2014 09:48:34 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 2538 invoked by uid 99); 28 Sep 2014 09:48:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Sep 2014 09:48:34 +0000 Date: Sun, 28 Sep 2014 09:48:33 +0000 (UTC) From: "Jyrki Ruuskanen (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CAMEL-7875) Easier write access to Camel context registry MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-7875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14150985#comment-14150985 ] Jyrki Ruuskanen edited comment on CAMEL-7875 at 9/28/14 9:48 AM: ----------------------------------------------------------------- Ideally, from a user's perspective, I would expect CamelContext to allow a direct put into its registry. Something like: getContext().getRegistry().add("thisand", "that");. But given the number of different registry combinations that is probably not very easy to implement in a clean fashion. Of course there is the usual way of passing the registry reference to the routebuilders, but that is not very straightforward when working with org.apache.camel.main.Main. was (Author: yuruki): Ideally, from a user's perspective, I would expect CamelContext to allow a direct put into its registry. Something like: getContext().getRegistry().add("thisand", "that");. But given the number of different registry combinations that is probably not very easy to implement in a clean fashion. And of course there is the usual way of passing the (simple)registry reference to the extended routebuilders. In the above self-referencing method we have to do casting, which makes me feel unsure about it. > 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)