public abstract class AbstractApiProducer<E extends Enum<E> & ApiName,T> extends DefaultAsyncProducer implements PropertiesInterceptor, ResultInterceptor
Modifier and Type | Field and Description |
---|---|
protected AbstractApiEndpoint<E,T> |
endpoint |
protected ApiMethodHelper<?> |
methodHelper |
protected ApiMethodPropertiesHelper<T> |
propertiesHelper |
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Constructor and Description |
---|
AbstractApiProducer(AbstractApiEndpoint<E,T> endpoint,
ApiMethodPropertiesHelper<T> propertiesHelper) |
Modifier and Type | Method and Description |
---|---|
protected Object |
doInvokeMethod(ApiMethod method,
Map<String,Object> properties)
Invoke the API method.
|
protected ApiMethod |
findMethod(Exchange exchange,
Map<String,Object> properties) |
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.
|
process
createExchange, createExchange, createExchange, doStart, doStop, getEndpoint, isSingleton, toString
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
protected final ApiMethodPropertiesHelper<T> propertiesHelper
protected final ApiMethodHelper<?> methodHelper
public AbstractApiProducer(AbstractApiEndpoint<E,T> endpoint, ApiMethodPropertiesHelper<T> propertiesHelper)
public boolean process(Exchange exchange, AsyncCallback callback)
AsyncProcessor
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
.process
in interface AsyncProcessor
exchange
- the message exchangecallback
- 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.public void interceptProperties(Map<String,Object> properties)
PropertiesInterceptor
interceptProperties
in interface PropertiesInterceptor
properties
- method invocation arguments.protected Object doInvokeMethod(ApiMethod method, Map<String,Object> properties) throws RuntimeCamelException
method
- API method to invoke.properties
- method arguments from endpoint properties and exchange In headers.RuntimeCamelException
- on error. Exceptions thrown by API method are wrapped.public final Object splitResult(Object result)
ResultInterceptor
splitResult
in interface ResultInterceptor
result
- API method invocation resultpublic void interceptResult(Object methodResult, Exchange resultExchange)
ResultInterceptor
interceptResult
in interface ResultInterceptor
methodResult
- result of API method invocation.resultExchange
- result as a Camel exchange, may be a split result from Arrays or Collections.Apache Camel