camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Registry/Repository support in CAMEL
Date Mon, 01 Dec 2008 15:35:45 GMT
2008/12/1 S. Ali Tokmen <savas-ali.tokmen@bull.net>:
> Hello
>
> I've been doing a lot of CAMEL-related architecture reading, code analysing
> and debugging these days and finally came up with a Registry which is kind
> of working. Here's how I proceed, any remarks are of course welcome:
>
>  1. The registry works this way:
>         * What I call "registry" is simply a mapping between keys and
>           values.
>         * Keys represent logical names, for example "loginWebService"
>         * Values represent technical names, for example
>           "http://security:9000/services/login/2.1/"
>         * The main method the registry has is "lookup", which returns
>           the technical name for the given logical name
>  2. The CAMEL component doing lookups on that registry is the
>     following class:
>
>     public class RegistryComponent implements Component<Exchange> {
>
>     [getters, setters, ...]
>
>         @SuppressWarnings("unchecked")
>         public Endpoint<Exchange> createEndpoint(String name) throws
>     Exception {
>             *// Name is registry:logicalName. Only keep the logicalName*
>             String logicalName = name.substring(0, name.indexOf(':') + 1);
>             *// Look up for the logicalName*
>             String technicalName = this.registry.lookup(logicalName);
>             *// technicalName is scheme:path*
>             *// For example jms:queue:myQueue has as scheme jms*
>             String scheme = technicalName.substring(0,
>     technicalName.indexOf(':'));
>             return context.getComponent(scheme).createEndpoint(name);
>         }
>     }
>  3. Let's now assume we have:
>         * A registry containing the following link: queue1 ->
>           jms:queue:myQueue
>         * The camel-context.xml file defining the following bean:
>           <bean id="registry" class="test.RegistryComponent"/>
>         * An endpoint with url: registry:queue1
>  4. When CAMEL looks for the endpoint registry:queue1
>        1. It automatically finds out that the registry protocol links
>           with the RegistryComponent class (thanks to the
>           configuration in camel-context.xml).
>        2. Since the RegistryComponent class is a Component, CAMEL will
>           always call its createEndpoint method:
>               * name is "registry:queue1"
>               * logicalName is "queue1"
>               * technicalName for the logicalName "queue1" is
>                 "jms:queue:myQueue"
>               * scheme is "jms"
>               * context.getComponent("jms") will return the JMS component
>               * createEndpoint will return the associated endpoint
>                 (JMS Queue instance)
>  5. When CAMEL looks for any endpoint that doesn't start with
>     registry, the RegistryComponent is not used.
>
> What do you think? Any comments?

Looks great! :)

BTW we've already got the Registry in CamelContext which wraps up
either JNDI or Spring. My first reaction was it might be worth looking
in that first before explicitly creating the endpoint; but I think the
default implementation of createEndpoint() will do that for you. e.g.
if you configured the endpoint "jms:someQueue" in Spring/Java/JNDI
then Camel should do the right thing I think so I don't think the
Registry component needs to worry about this.

Incidentally we have the ref component (RefComponent) which you could
maybe use to derive which could then use an alternative registry
implementation?

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Mime
View raw message