2008/12/10 S. Ali Tokmen <[EMAIL PROTECTED]>:
> Hello
>
> I've been working on integrating a registry/repository support into CAMEL.
> The current implementation uses XML files, later it should also be linked
> with real-life repositories (Galaxy, OW2 Registry, ...). The implementation
> is now complete, and here's how I've done it:
>
> To use the registry, I use the Spring camel-context XML file and map the
> "registry:" protocol to the lookup class:
>
> <!-- The registry component, configured as a File Registry -->
> <bean id="registry" class="test.FileRegistryComponent">
>     <property name="file" value="registry.xml"/>
> </bean>
> The file-based registry/repository is an XML file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <registry xmlns="custom:FileRegistry"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>     xsi:schemaLocation="custom:FileRegistry FileRegistry.xsd">
>     <entry>
>         <logicalName>queue</logicalName>
>         <technicalName>
>             joram:queue:sampleQueue
>         </technicalName>
>     </entry>
>     <entry>
>         <logicalName>topic</logicalName>
>         <technicalName>
>             joram:topic:sampleTopic
>         </technicalName>
>     </entry>
>     <entry>
>         <logicalName>sampleWebService</logicalName>
>         <technicalName>
>         <![CDATA[
>             cxf://
>                 http://localhost:9000/CxfService_1/SayHello
>                 ?serviceClass=test.ISayHello
>                 &wsdlURL=http://localhost:9000/CxfService_1/SayHello?wsdl
>                 &serviceName={http://test/}SayHello
>                 &portName={http://test/}SayHelloPort
>                 &dataFormat=POJO
>         ]]>
>         </technicalName>
>     </entry>
> </registry>
>
> The XSD for the XML is attached.
> Finally, you simply prefix your endpoint with "registry:" to point it to a
> registry/repository entry. For example, in DSL:
>
> from("registry:queue").process(new Processor() {
>     public void process(Exchange e) {
>         // Convert JMS message content into WS request
>         final List<String> params = new ArrayList<String>();
>         e.getIn().setHeader(CxfConstants.OPERATION_NAME, "hello");
>         String body = e.getIn().getBody(String.class);
>         params.add(body);
>         e.getIn().setBody(params);
>     }
> }).to("registry:sampleWebService").to("registry:topic");
>
> I'm attaching the registry/repository's Java implementation. Any comments
> are welcome.

Great stuff! :)

BTW could you raise a JIRA and attach the code there please? Its
described in the 'contributing patches' section...
http://activemq.apache.org/camel/contributing.html

the main thing to do is to remember to tick the 'grant ASF license'
when you add your attachments. Then we've an audit trail that shows
the license of patches etc.


> PS: I know that based on the fact that I'm using an XSD schema I could have
> also used the JAXB APIs to match XML files to Java classes (tools
> automatically do it, so why bother!). If you think that's better, I could
> well switch to that as well.

Yeah we could refine the patch over time to do this if you prefer.
Either generating POJOs from the XSD or vice versa (we do the latter
in the camel-spring.xsd for example)


> PPS: When CAMEL 1.5.1 will be out, the parent class that's used for the
> registry will be RefComponent. The modification is minor, but neat.

Yeah, good point.

> Do you think this can be commited into the CAMEL examples?

Definitely!

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

Open Source Integration
http://fusesource.com/

Reply via email to