org.apache.camel.util.component
Class AbstractApiProducer<E extends Enum<E> & ApiName,T>

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.impl.DefaultProducer
          extended by org.apache.camel.impl.DefaultAsyncProducer
              extended by org.apache.camel.util.component.AbstractApiProducer<E,T>
All Implemented Interfaces:
AsyncProcessor, IsSingleton, Processor, Producer, Service, ShutdownableService, StatefulService, SuspendableService, PropertiesInterceptor, ResultInterceptor

public abstract class AbstractApiProducer<E extends Enum<E> & ApiName,T>
extends DefaultAsyncProducer
implements PropertiesInterceptor, ResultInterceptor

Base class for API based Producers


Field Summary
protected  AbstractApiEndpoint<E,T> endpoint
           
protected  ApiMethodHelper<?> methodHelper
           
protected  ApiMethodPropertiesHelper<T> propertiesHelper
           
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
AbstractApiProducer(AbstractApiEndpoint<E,T> endpoint, ApiMethodPropertiesHelper<T> propertiesHelper)
           
 
Method Summary
protected  Object doInvokeMethod(ApiMethod method, Map<String,Object> properties)
          Invoke the API method.
 void interceptProperties(Map<String,Object> properties)
          Intercept method invocation arguments used to find and invoke API method.
 void interceptResult(Object methodResult, Exchange resultExchange)
          Do additional result exchange processing, for example, adding custom headers.
 boolean process(Exchange exchange, AsyncCallback callback)
          Processes the message exchange.
 Object splitResult(Object result)
          Split a complex result into result elements.
 
Methods inherited from class org.apache.camel.impl.DefaultAsyncProducer
process
 
Methods inherited from class org.apache.camel.impl.DefaultProducer
createExchange, createExchange, createExchange, doStart, doStop, getEndpoint, isSingleton, toString
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.camel.Service
start, stop
 

Field Detail

endpoint

protected final AbstractApiEndpoint<E extends Enum<E> & ApiName,T> endpoint

propertiesHelper

protected final ApiMethodPropertiesHelper<T> propertiesHelper

methodHelper

protected final ApiMethodHelper<?> methodHelper
Constructor Detail

AbstractApiProducer

public AbstractApiProducer(AbstractApiEndpoint<E,T> endpoint,
                           ApiMethodPropertiesHelper<T> propertiesHelper)
Method Detail

process

public boolean process(Exchange exchange,
                       AsyncCallback callback)
Description copied from interface: AsyncProcessor
Processes the message exchange. Similar to Processor.process(org.apache.camel.Exchange), but the caller supports having the exchange asynchronously processed.

If there was a failure processing then the caused Exception would be set on the Exchange.

Specified by:
process in interface AsyncProcessor
Parameters:
exchange - the message exchange
callback - the AsyncCallback will be invoked when the processing of the exchange is completed. If the exchange is completed synchronously, then the callback is also invoked synchronously. The callback should therefore be careful of starting recursive loop.
Returns:
(doneSync) true to continue execute synchronously, false to continue being executed asynchronously

interceptProperties

public void interceptProperties(Map<String,Object> properties)
Description copied from interface: PropertiesInterceptor
Intercept method invocation arguments used to find and invoke API method. Can be overridden to add custom/hidden method arguments.

Specified by:
interceptProperties in interface PropertiesInterceptor
Parameters:
properties - method invocation arguments.

doInvokeMethod

protected Object doInvokeMethod(ApiMethod method,
                                Map<String,Object> properties)
                         throws RuntimeCamelException
Invoke the API method. Derived classes can override, but MUST call super.doInvokeMethod().

Parameters:
method - API method to invoke.
properties - method arguments from endpoint properties and exchange In headers.
Returns:
API method invocation result.
Throws:
RuntimeCamelException - on error. Exceptions thrown by API method are wrapped.

splitResult

public final Object splitResult(Object result)
Description copied from interface: ResultInterceptor
Split a complex result into result elements.

Specified by:
splitResult in interface ResultInterceptor
Parameters:
result - API method invocation result
Returns:
either the same result if it cannot be split, or an array object with split results

interceptResult

public void interceptResult(Object methodResult,
                            Exchange resultExchange)
Description copied from interface: ResultInterceptor
Do additional result exchange processing, for example, adding custom headers.

Specified by:
interceptResult in interface ResultInterceptor
Parameters:
methodResult - result of API method invocation.
resultExchange - result as a Camel exchange, may be a split result from Arrays or Collections.


Apache Camel