[switchyard-issues] [JBoss JIRA] Created: (SWITCHYARD-201) Camel Component: Implement reference binding support

Daniel Bevenius (JIRA) jira-events at lists.jboss.org
Tue Mar 29 07:07:56 EDT 2011


Camel Component: Implement reference binding support
----------------------------------------------------

                 Key: SWITCHYARD-201
                 URL: https://issues.jboss.org/browse/SWITCHYARD-201
             Project: SwitchYard
          Issue Type: Task
            Reporter: Daniel Bevenius
            Assignee: Daniel Bevenius
             Fix For: 0.1


This task is about adding the ability for Switchyard services to use Camel endpoints by specifying a reference element in the component configuration. Services can use other services and those services are declared using references. The idea is to add the ability for services to specify that they require functionality from a Camel endpoint. The service might consume from a Camel endpoint or they might produce to a Camel endpoint, or both.

So for example, say you require to call a service that is implemented in Camel. One way might be to use the @Reference annotation that exists for the Switchyard bean component: 
{code} 
public class InventoryServiceBean implements InventoryService {

    @Reference
    WarehouseService warehouseService;

    public ReservationResult reservItem(final long itemId) {
        if (warehouseService.hasItem(itemId)) {
            ...
        } else {
            return new ReservationResult(false, "Could not fullfill reservation request...");
        }
    }
}

{code} 

And the xml configuration for this component:
{code:xml}
<composite>

    <component name="Component">
        <service name="InventoryService">
            <interface.java interface="org.switchyard.examples.InventoryService"/>
            <implementation.bean class="org.switchyard.examples.InventoryServiceBean"/>
        </service>
        <reference name="WarehouseStatusService>
            <interface.java interface="org.switchyard.examples.WarehouseService"/>
            <binding.camel uri="invm://warehouseStatusService"/>
        </reference>
    </component>

<composite>

{code}


The proxy instance might then be create something like this:
{code}
CamelContext camelContext = new DefaultCamelContext();
Endpoint endpoint = camelContext.getEndpoint(uri);
Class[] interfaces = // create class using 
WarehousService warehouseService = ProxyHelper.createProxy(endpoint, "org.switchyard.example.WarehouseService");
warehouseService.hasItem(2);
{code}





--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the switchyard-issues mailing list