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

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.impl.DefaultConsumer
          extended by org.apache.camel.impl.ScheduledPollConsumer
              extended by org.apache.camel.util.component.AbstractApiConsumer<E,T>
All Implemented Interfaces:
Runnable, Consumer, PollingConsumerPollingStrategy, RouteAware, Service, ShutdownableService, StatefulService, SuspendableService, PropertiesInterceptor, PropertyNamesInterceptor, ResultInterceptor

public abstract class AbstractApiConsumer<E extends Enum<E> & ApiName,T>
extends ScheduledPollConsumer
implements PropertyNamesInterceptor, PropertiesInterceptor, ResultInterceptor

Abstract base class for API Component Consumers.


Field Summary
protected  AbstractApiEndpoint<E,T> endpoint
           
protected  org.slf4j.Logger log
           
protected  ApiMethod method
           
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
AbstractApiConsumer(AbstractApiEndpoint<E,T> endpoint, Processor processor)
           
 
Method Summary
protected  Object doInvokeMethod(Map<String,Object> args)
          Invoke the API method.
 void interceptProperties(Map<String,Object> properties)
          Intercept method invocation arguments used to find and invoke API method.
 void interceptPropertyNames(Set<String> propertyNames)
          Intercept property names used to find API Method.
 void interceptResult(Object result, Exchange resultExchange)
          Do additional result exchange processing, for example, adding custom headers.
 boolean isGreedy()
           
 boolean isSplitResult()
           
protected  int poll()
          The polling method which is invoked periodically to poll this consumer
 void setSplitResult(boolean splitResult)
           
 Object splitResult(Object result)
          Split a complex result into result elements.
 
Methods inherited from class org.apache.camel.impl.ScheduledPollConsumer
afterPoll, beforePoll, doShutdown, doStart, doStop, doSuspend, getBackoffCounter, getBackoffErrorThreshold, getBackoffIdleThreshold, getBackoffMultiplier, getDelay, getInitialDelay, getPollStrategy, getRunLoggingLevel, getScheduledExecutorService, getScheduler, getSchedulerProperties, getTimeUnit, isPollAllowed, isPolling, isSchedulerStarted, isSendEmptyMessageWhenIdle, isStartScheduler, isUseFixedDelay, onInit, processEmptyMessage, run, setBackoffErrorThreshold, setBackoffIdleThreshold, setBackoffMultiplier, setDelay, setGreedy, setInitialDelay, setPollStrategy, setRunLoggingLevel, setScheduledExecutorService, setScheduler, setSchedulerProperties, setSendEmptyMessageWhenIdle, setStartScheduler, setTimeUnit, setUseFixedDelay, startScheduler
 
Methods inherited from class org.apache.camel.impl.DefaultConsumer
createUoW, doneUoW, getAsyncProcessor, getEndpoint, getExceptionHandler, getProcessor, getRoute, handleException, handleException, setExceptionHandler, setRoute, toString
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, 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.SuspendableService
isSuspended, resume, suspend
 
Methods inherited from interface org.apache.camel.Service
start, stop
 

Field Detail

log

protected final org.slf4j.Logger log

endpoint

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

method

protected final ApiMethod method
Constructor Detail

AbstractApiConsumer

public AbstractApiConsumer(AbstractApiEndpoint<E,T> endpoint,
                           Processor processor)
Method Detail

isGreedy

public boolean isGreedy()
Overrides:
isGreedy in class ScheduledPollConsumer

poll

protected int poll()
            throws Exception
Description copied from class: ScheduledPollConsumer
The polling method which is invoked periodically to poll this consumer

Specified by:
poll in class ScheduledPollConsumer
Returns:
number of messages polled, will be 0 if no message was polled at all.
Throws:
Exception - can be thrown if an exception occurred during polling

interceptPropertyNames

public void interceptPropertyNames(Set<String> propertyNames)
Description copied from interface: PropertyNamesInterceptor
Intercept property names used to find API Method. Used to add any custom/hidden method arguments, which MUST be provided in interceptProperties() override.

Specified by:
interceptPropertyNames in interface PropertyNamesInterceptor
Parameters:
propertyNames - argument names.

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(Map<String,Object> args)
Invoke the API method. This method can be overridden, for example to synchronize API calls for thread-unsafe proxies. Derived class MUST call super.doInvokeMethod() to invoke the API method.

Parameters:
args - method arguments from endpoint parameters.
Returns:
method invocation result.

splitResult

public 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 result,
                            Exchange resultExchange)
Description copied from interface: ResultInterceptor
Do additional result exchange processing, for example, adding custom headers.

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

isSplitResult

public final boolean isSplitResult()

setSplitResult

public final void setSplitResult(boolean splitResult)


Apache Camel