java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultProducer
org.apache.camel.support.DefaultAsyncProducer
org.apache.camel.support.component.AbstractApiProducer<E,T>
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.AsyncProcessor,org.apache.camel.AsyncProducer,org.apache.camel.EndpointAware,org.apache.camel.IsSingleton,org.apache.camel.Processor,org.apache.camel.Producer,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.StatefulService,PropertiesInterceptor,ResultInterceptor,org.apache.camel.SuspendableService
public abstract class AbstractApiProducer<E extends Enum<E> & ApiName,T>
extends DefaultAsyncProducer
implements PropertiesInterceptor, ResultInterceptor
Base class for API based Producers
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AbstractApiEndpoint<E, T> protected final ApiMethodHelper<?> protected final ApiMethodPropertiesHelper<T> Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
ConstructorsConstructorDescriptionAbstractApiProducer(AbstractApiEndpoint<E, T> endpoint, ApiMethodPropertiesHelper<T> propertiesHelper) -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectdoInvokeMethod(ApiMethod method, Map<String, Object> properties) Invoke the API method.protected ApiMethodfindMethod(org.apache.camel.Exchange exchange, Map<String, Object> properties) voidinterceptProperties(Map<String, Object> properties) Intercept method invocation arguments used to find and invoke API method.voidinterceptResult(Object methodResult, org.apache.camel.Exchange resultExchange) Do additional result exchange processing, for example, adding custom headers.booleanprocess(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback) final ObjectsplitResult(Object result) Split a complex result into result elements.Methods inherited from class org.apache.camel.support.DefaultAsyncProducer
process, processAsyncMethods inherited from class org.apache.camel.support.DefaultProducer
createExchange, doStart, doStop, getEndpoint, isSingleton, toStringMethods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.camel.EndpointAware
getEndpointMethods inherited from interface org.apache.camel.IsSingleton
isSingletonMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Field Details
-
endpoint
-
propertiesHelper
-
methodHelper
-
-
Constructor Details
-
AbstractApiProducer
public AbstractApiProducer(AbstractApiEndpoint<E, T> endpoint, ApiMethodPropertiesHelper<T> propertiesHelper)
-
-
Method Details
-
process
public boolean process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback) - Specified by:
processin interfaceorg.apache.camel.AsyncProcessor
-
interceptProperties
Description copied from interface:PropertiesInterceptorIntercept method invocation arguments used to find and invoke API method. Can be overridden to add custom/hidden method arguments.- Specified by:
interceptPropertiesin interfacePropertiesInterceptor- Parameters:
properties- method invocation arguments.
-
doInvokeMethod
protected Object doInvokeMethod(ApiMethod method, Map<String, Object> properties) throws org.apache.camel.RuntimeCamelExceptionInvoke 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:
org.apache.camel.RuntimeCamelException- on error. Exceptions thrown by API method are wrapped.
-
splitResult
Description copied from interface:ResultInterceptorSplit a complex result into result elements.- Specified by:
splitResultin interfaceResultInterceptor- Parameters:
result- API method invocation result- Returns:
- either the same result if it cannot be split, an array or collection object with split results
-
interceptResult
Description copied from interface:ResultInterceptorDo additional result exchange processing, for example, adding custom headers.- Specified by:
interceptResultin interfaceResultInterceptor- Parameters:
methodResult- result of API method invocation.resultExchange- result as a Camel exchange, may be a split result from Arrays or Collections.
-
findMethod
-