camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "S. Ali Tokmen" <savas-ali.tok...@bull.net>
Subject Registry/Repository support in CAMEL
Date Mon, 01 Dec 2008 15:25:03 GMT
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?

Cheers

-- 

S. Ali Tokmen
savas-ali.tokmen@bull.net

Office: +33 4 76 29 76 19
GSM:    +33 66 43 00 555

Bull, Architect of an Open World TM
http://www.bull.com


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message