org.apache.camel.util.component
Class AbstractApiEndpoint<E extends ApiName,T>

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.impl.DefaultEndpoint
          extended by org.apache.camel.util.component.AbstractApiEndpoint<E,T>
All Implemented Interfaces:
CamelContextAware, Endpoint, IsSingleton, Service, ShutdownableService, HasId, StatefulService, SuspendableService, PropertiesInterceptor, PropertyNamesInterceptor

public abstract class AbstractApiEndpoint<E extends ApiName,T>
extends DefaultEndpoint
implements PropertyNamesInterceptor, PropertiesInterceptor

Abstract base class for API Component Endpoints.


Field Summary
protected  E apiName
           
protected  T configuration
           
protected  String inBody
           
protected  org.slf4j.Logger log
           
protected  ApiMethodHelper<? extends ApiMethod> methodHelper
           
protected  String methodName
           
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
AbstractApiEndpoint(String endpointUri, Component component, E apiName, String methodName, ApiMethodHelper<? extends ApiMethod> methodHelper, T endpointConfiguration)
           
 
Method Summary
protected abstract  void afterConfigureProperties()
          Initialize proxies, create server connections, etc.
 void configureProperties(Map<String,Object> options)
          Configure properties on this endpoint.
 E getApiName()
          Returns API name.
abstract  Object getApiProxy(ApiMethod method, Map<String,Object> args)
          Returns an instance of an API Proxy based on apiName, method and args.
 List<ApiMethod> getCandidates()
          Returns candidate methods for this endpoint.
 T getConfiguration()
          Returns endpoint configuration object.
 Map<String,Object> getEndpointProperties()
           
 Set<String> getEndpointPropertyNames()
           
 ExecutorService getExecutorService()
           
 String getInBody()
          Returns name of parameter passed in the exchange In Body.
 ApiMethodHelper<? extends ApiMethod> getMethodHelper()
          Returns method helper.
 String getMethodName()
          Returns method name.
protected abstract  ApiMethodPropertiesHelper<T> getPropertiesHelper()
          Returns generated helper that extends ApiMethodPropertiesHelper to work with API properties.
protected abstract  String getThreadProfileName()
          Returns Thread profile name.
 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.
 boolean isSingleton()
          Whether this class supports being singleton or not.
 void setInBody(String inBody)
          Sets the name of a parameter to be passed in the exchange In Body.
 
Methods inherited from class org.apache.camel.impl.DefaultEndpoint
configureConsumer, configurePollingConsumer, createEndpointConfiguration, createEndpointUri, createExchange, createExchange, createExchange, createPollingConsumer, doStart, doStop, equals, getCamelContext, getComponent, getConsumerProperties, getEndpointConfiguration, getEndpointKey, getEndpointUri, getExchangePattern, getId, getPollingConsumerQueueSize, hashCode, isLenientProperties, isPollingConsumerBlockWhenFull, isSynchronous, setCamelContext, setConsumerProperties, setEndpointConfiguration, setEndpointUri, setEndpointUriIfNotSpecified, setExchangePattern, setPollingConsumerBlockWhenFull, setPollingConsumerQueueSize, setProperties, setSynchronous, 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, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.camel.Endpoint
createConsumer, createProducer
 
Methods inherited from interface org.apache.camel.Service
start, stop
 

Field Detail

log

protected final org.slf4j.Logger log

apiName

protected final E extends ApiName apiName

methodName

protected final String methodName

methodHelper

protected final ApiMethodHelper<? extends ApiMethod> methodHelper

configuration

@UriParam
protected final T configuration

inBody

@UriParam
protected String inBody
Constructor Detail

AbstractApiEndpoint

public AbstractApiEndpoint(String endpointUri,
                           Component component,
                           E apiName,
                           String methodName,
                           ApiMethodHelper<? extends ApiMethod> methodHelper,
                           T endpointConfiguration)
Method Detail

isSingleton

public boolean isSingleton()
Description copied from interface: IsSingleton
Whether this class supports being singleton or not.

Specified by:
isSingleton in interface IsSingleton
Returns:
true to be a single shared instance, false to create new instances.

getPropertiesHelper

protected abstract ApiMethodPropertiesHelper<T> getPropertiesHelper()
Returns generated helper that extends ApiMethodPropertiesHelper to work with API properties.

Returns:
properties helper.

configureProperties

public void configureProperties(Map<String,Object> options)
Description copied from interface: Endpoint
Configure properties on this endpoint.

Specified by:
configureProperties in interface Endpoint
Overrides:
configureProperties in class DefaultEndpoint
Parameters:
options - the options (properties)

afterConfigureProperties

protected abstract void afterConfigureProperties()
Initialize proxies, create server connections, etc. after endpoint properties have been configured.


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.

getConfiguration

public final T getConfiguration()
Returns endpoint configuration object. One of the generated *EndpointConfiguration classes that extends component configuration class.

Returns:
endpoint configuration object

getApiName

public final E getApiName()
Returns API name.

Returns:
apiName property.

getMethodName

public final String getMethodName()
Returns method name.

Returns:
methodName property.

getMethodHelper

public final ApiMethodHelper<? extends ApiMethod> getMethodHelper()
Returns method helper.

Returns:
methodHelper property.

getCandidates

public final List<ApiMethod> getCandidates()
Returns candidate methods for this endpoint.

Returns:
list of candidate methods.

getInBody

public final String getInBody()
Returns name of parameter passed in the exchange In Body.

Returns:
inBody property.

setInBody

public final void setInBody(String inBody)
                     throws IllegalArgumentException
Sets the name of a parameter to be passed in the exchange In Body.

Parameters:
inBody - parameter name
Throws:
IllegalArgumentException - for invalid parameter name.

getEndpointPropertyNames

public final Set<String> getEndpointPropertyNames()

getEndpointProperties

public final Map<String,Object> getEndpointProperties()

getApiProxy

public abstract Object getApiProxy(ApiMethod method,
                                   Map<String,Object> args)
Returns an instance of an API Proxy based on apiName, method and args. Called by AbstractApiConsumer or AbstractApiProducer.

Parameters:
method - method about to be invoked
args - method arguments
Returns:
a Java object that implements the method to be invoked.
See Also:
AbstractApiProducer, AbstractApiConsumer

getExecutorService

public final ExecutorService getExecutorService()

getThreadProfileName

protected abstract String getThreadProfileName()
Returns Thread profile name. Generated as a constant THREAD_PROFILE_NAME in *Constants.

Returns:
thread profile name to use.


Apache Camel