Chapter 2. Structure and features

Table of Contents

2.1. The Camel wrapper
2.2. The service

The Camel service relies on the OSGi bundles of Camel. It uses iPOJO to provides services on the OSGi gateway.

2.1. The Camel wrapper

The service implementation contains a wrapper of a Camel context, which is instantiated by the service when an application requires one. This wrapper contains :

  • A DefaultCamelContext object. This is the Camel context.
  • A String that contains the name of the Camel context. This name is used to identify the context in the applications that are using it.
  • A FileRegistryComponent object. This is a camel component automatically associated with each Camel context instantiated by the service. It provides a registry that allows bindings between a logical endpoint name and technical one. Instead of typing an entire endpoint definition to configure a route, it is just needed to give the logical entry in the registry.

    Example :

                                this.from("registry:cxfEndpoint")
                            

    will be a lot easier to write than

                                this.from("cxf://http://localhost:9000/SayHello?serviceClass=org.ow2.jonas.samples.camel.example.cxf.webservice.
                                    api.ISayHello&dataFormat=POJO")
                            

    These entries are set from an xml file, that matches the following XSD :

                    
    <schema targetNamespace="org.ow2.jonas.samples.camel.registry.impl.file:FileRegistry"
      elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema"
      xmlns:tns="org.ow2.jonas.samples.camel.registry.impl.file:FileRegistry">
      <element name="registry" type="tns:registry"></element>
    
      <complexType name="registry">
        <sequence maxOccurs="unbounded" minOccurs="0">
          <element name="entry" type="tns:entry"></element>
        </sequence>
      </complexType>
    
      <complexType name="entry">
        <sequence maxOccurs="1" minOccurs="1">
          <element name="logicalName" type="string"></element>
          <element name="technicalName" type="string"></element>
        </sequence>
      </complexType>
    </schema>
                    
                            

    Therefore, the file that allows the developer to use the previous example is :

                    
    <registry xmlns="org.ow2.jonas.samples.camel.registry.impl.file:FileRegistry"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="org.ow2.jonas.samples.camel.registry.impl.file:FileRegistry FileRegistry.xsd">
      <entry>
        <logicalName>cxfEndpoint</logicalName>
        <technicalName>
        <![CDATA[
            cxf://
            http://localhost:9000/SayHello?
            serviceClass=org.ow2.jonas.samples.camel.example.cxf.webservice.api.ISayHello&
            dataFormat=POJO
        ] ]>
        </technicalName>
      </entry>
    </registry>