Package org.apache.camel.reifier
Class ProcessorReifier<T extends org.apache.camel.model.ProcessorDefinition<?>>
- java.lang.Object
-
- org.apache.camel.reifier.AbstractReifier
-
- org.apache.camel.reifier.ProcessorReifier<T>
-
- All Implemented Interfaces:
org.apache.camel.spi.BeanRepository
- Direct Known Subclasses:
AbstractPolicyReifier
,AggregateReifier
,BeanReifier
,CatchReifier
,ChoiceReifier
,CircuitBreakerReifier
,ClaimCheckReifier
,ConvertBodyReifier
,DelayReifier
,DynamicRouterReifier
,EnrichReifier
,FilterReifier
,FinallyReifier
,IdempotentConsumerReifier
,InterceptReifier
,InterceptSendToEndpointReifier
,KameletReifier
,LoadBalanceReifier
,LogReifier
,LoopReifier
,MarshalReifier
,MulticastReifier
,OnCompletionReifier
,OnExceptionReifier
,OnFallbackReifier
,OtherwiseReifier
,PipelineReifier
,PollEnrichReifier
,ProcessReifier
,RecipientListReifier
,RemoveHeaderReifier
,RemoveHeadersReifier
,RemovePropertiesReifier
,RemovePropertyReifier
,ResequenceReifier
,RollbackReifier
,RouteReifier
,RoutingSlipReifier
,SagaReifier
,SamplingReifier
,ScriptReifier
,SendReifier
,ServiceCallReifier
,SetBodyReifier
,SetExchangePatternReifier
,SetHeaderReifier
,SetPropertyReifier
,SortReifier
,SplitReifier
,StepReifier
,StopReifier
,ThreadsReifier
,ThrottleReifier
,ThrowExceptionReifier
,ToDynamicReifier
,TransformReifier
,TryReifier
,UnmarshalReifier
,ValidateReifier
,WhenReifier
,WhenSkipSendToEndpointReifier
public abstract class ProcessorReifier<T extends org.apache.camel.model.ProcessorDefinition<?>> extends AbstractReifier
-
-
Field Summary
Fields Modifier and Type Field Description protected T
definition
-
Fields inherited from class org.apache.camel.reifier.AbstractReifier
camelContext, route
-
-
Constructor Summary
Constructors Constructor Description ProcessorReifier(org.apache.camel.CamelContext camelContext, T definition)
ProcessorReifier(org.apache.camel.Route route, T definition)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addRoutes()
static void
clearReifiers()
void
configureChild(org.apache.camel.model.ProcessorDefinition<?> output)
Strategy for children to do any custom configurationstatic ProcessorReifier<? extends org.apache.camel.model.ProcessorDefinition<?>>
coreReifier(org.apache.camel.Route route, org.apache.camel.model.ProcessorDefinition<?> definition)
protected org.apache.camel.Processor
createChildProcessor(boolean mandatory)
Creates the child processor (outputs) from the current definitionprotected org.apache.camel.Processor
createCompositeProcessor(List<org.apache.camel.Processor> list)
Creates a new instance of some kind of composite processor which defaults to using aPipeline
but derived classes could change the behaviourprotected org.apache.camel.Processor
createOutputsProcessor()
Prefer to use {#link #createChildProcessor}.protected org.apache.camel.Processor
createOutputsProcessor(Collection<org.apache.camel.model.ProcessorDefinition<?>> outputs)
abstract org.apache.camel.Processor
createProcessor()
Override this in definition class and implement logic to create the processor based on the definition model.protected org.apache.camel.Processor
createProcessor(org.apache.camel.model.ProcessorDefinition<?> output)
ExecutorService
getConfiguredExecutorService(String name, org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault)
Will lookup and get the configuredExecutorService
from the given definition.ScheduledExecutorService
getConfiguredScheduledExecutorService(String name, org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault)
Will lookup and get the configuredScheduledExecutorService
from the given definition.protected String
getId(org.apache.camel.model.OptionalIdentifiedDefinition<?> def)
boolean
hasOutputs(List<org.apache.camel.model.ProcessorDefinition<?>> outputs, boolean excludeAbstract)
Is there any outputs in the given list.ExecutorService
lookupExecutorServiceRef(String name, Object source, String executorServiceRef)
Will lookup inRegistry
for aExecutorService
registered with the given executorServiceRef name.ScheduledExecutorService
lookupScheduledExecutorServiceRef(String name, Object source, String executorServiceRef)
Will lookup inRegistry
for aScheduledExecutorService
registered with the given executorServiceRef name.protected org.apache.camel.Channel
makeProcessor()
Creates the processor and wraps it in any necessary interceptors and error handlersprotected void
preCreateProcessor()
Strategy to execute any custom logic before theProcessor
is created.static void
registerReifier(Class<?> processorClass, BiFunction<org.apache.camel.Route,org.apache.camel.model.ProcessorDefinition<?>,ProcessorReifier<? extends org.apache.camel.model.ProcessorDefinition<?>>> creator)
static ProcessorReifier<? extends org.apache.camel.model.ProcessorDefinition<?>>
reifier(org.apache.camel.Route route, org.apache.camel.model.ProcessorDefinition<?> definition)
boolean
willCreateNewThreadPool(org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault)
Determines whether a new thread pool will be created or not.protected org.apache.camel.Channel
wrapChannel(org.apache.camel.Processor processor, org.apache.camel.model.ProcessorDefinition<?> child)
protected org.apache.camel.Channel
wrapChannel(org.apache.camel.Processor processor, org.apache.camel.model.ProcessorDefinition<?> child, Boolean inheritErrorHandler)
protected org.apache.camel.Processor
wrapInErrorHandler(org.apache.camel.Processor output)
Wraps the given output in an error handlerorg.apache.camel.Channel
wrapProcessor(org.apache.camel.Processor processor)
Wraps the child processor in whatever necessary interceptors and error handlers-
Methods inherited from class org.apache.camel.reifier.AbstractReifier
asRef, createExpression, createExpression, createPredicate, createPredicate, findByType, findByTypeWithName, findSingleByType, getRegistry, lookup, lookupByName, lookupByNameAndType, mandatoryLookup, or, parse, parse, parseBoolean, parseBoolean, parseDuration, parseDuration, parseFloat, parseFloat, parseInt, parseInt, parseLong, parseLong, parseString, resolveEndpoint, unwrap
-
-
-
-
Field Detail
-
definition
protected final T extends org.apache.camel.model.ProcessorDefinition<?> definition
-
-
Method Detail
-
registerReifier
public static void registerReifier(Class<?> processorClass, BiFunction<org.apache.camel.Route,org.apache.camel.model.ProcessorDefinition<?>,ProcessorReifier<? extends org.apache.camel.model.ProcessorDefinition<?>>> creator)
-
clearReifiers
public static void clearReifiers()
-
reifier
public static ProcessorReifier<? extends org.apache.camel.model.ProcessorDefinition<?>> reifier(org.apache.camel.Route route, org.apache.camel.model.ProcessorDefinition<?> definition)
-
coreReifier
public static ProcessorReifier<? extends org.apache.camel.model.ProcessorDefinition<?>> coreReifier(org.apache.camel.Route route, org.apache.camel.model.ProcessorDefinition<?> definition)
-
willCreateNewThreadPool
public boolean willCreateNewThreadPool(org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault)
Determines whether a new thread pool will be created or not. This is used to know if a new thread pool will be created, and therefore is not shared by others, and therefore exclusive to the definition.- Parameters:
definition
- the node definition which may leverage executor service.useDefault
- whether to fallback and use a default thread pool, if no explicit configured- Returns:
- true if a new thread pool will be created, false if not
- See Also:
getConfiguredExecutorService(String, ExecutorServiceAwareDefinition, boolean)
-
getConfiguredExecutorService
public ExecutorService getConfiguredExecutorService(String name, org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault) throws IllegalArgumentException
Will lookup and get the configuredExecutorService
from the given definition. This method will lookup for configured thread pool in the following order- from the definition if any explicit configured executor service.
- from the
Registry
if found - from the known list of
ThreadPoolProfile(s)
. - if none found, then null is returned.
ExecutorServiceAwareDefinition
should use this helper method to ensure they support configured executor services in the same coherent way.- Parameters:
name
- name which is appended to the thread name, when theExecutorService
is created based on aThreadPoolProfile
.definition
- the node definition which may leverage executor service.useDefault
- whether to fallback and use a default thread pool, if no explicit configured- Returns:
- the configured executor service, or null if none was configured.
- Throws:
IllegalArgumentException
- is thrown if lookup of executor service inRegistry
was not found
-
getConfiguredScheduledExecutorService
public ScheduledExecutorService getConfiguredScheduledExecutorService(String name, org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault) throws IllegalArgumentException
Will lookup and get the configuredScheduledExecutorService
from the given definition. This method will lookup for configured thread pool in the following order- from the definition if any explicit configured executor service.
- from the
Registry
if found - from the known list of
ThreadPoolProfile(s)
. - if none found, then null is returned.
ExecutorServiceAwareDefinition
should use this helper method to ensure they support configured executor services in the same coherent way.- Parameters:
name
- name which is appended to the thread name, when theExecutorService
is created based on aThreadPoolProfile
.definition
- the node definition which may leverage executor service.useDefault
- whether to fallback and use a default thread pool, if no explicit configured- Returns:
- the configured executor service, or null if none was configured.
- Throws:
IllegalArgumentException
- is thrown if the found instance is not a ScheduledExecutorService type, or lookup of executor service inRegistry
was not found
-
lookupScheduledExecutorServiceRef
public ScheduledExecutorService lookupScheduledExecutorServiceRef(String name, Object source, String executorServiceRef)
Will lookup inRegistry
for aScheduledExecutorService
registered with the given executorServiceRef name. This method will lookup for configured thread pool in the following order- from the
Registry
if found - from the known list of
ThreadPoolProfile(s)
. - if none found, then null is returned.
- Parameters:
name
- name which is appended to the thread name, when theExecutorService
is created based on aThreadPoolProfile
.source
- the source to use the thread poolexecutorServiceRef
- reference name of the thread pool- Returns:
- the executor service, or null if none was found.
- from the
-
lookupExecutorServiceRef
public ExecutorService lookupExecutorServiceRef(String name, Object source, String executorServiceRef)
Will lookup inRegistry
for aExecutorService
registered with the given executorServiceRef name. This method will lookup for configured thread pool in the following order- from the
Registry
if found - from the known list of
ThreadPoolProfile(s)
. - if none found, then null is returned.
- Parameters:
name
- name which is appended to the thread name, when theExecutorService
is created based on aThreadPoolProfile
.source
- the source to use the thread poolexecutorServiceRef
- reference name of the thread pool- Returns:
- the executor service, or null if none was found.
- from the
-
hasOutputs
public boolean hasOutputs(List<org.apache.camel.model.ProcessorDefinition<?>> outputs, boolean excludeAbstract)
Is there any outputs in the given list. Is used for check if the route output has any real outputs (non abstracts)- Parameters:
outputs
- the outputsexcludeAbstract
- whether or not to exclude abstract outputs (e.g. skip onException etc.)- Returns:
- true if has outputs, otherwise false is returned
-
createProcessor
public abstract org.apache.camel.Processor createProcessor() throws Exception
Override this in definition class and implement logic to create the processor based on the definition model.- Throws:
Exception
-
createOutputsProcessor
protected org.apache.camel.Processor createOutputsProcessor() throws Exception
Prefer to use {#link #createChildProcessor}.- Throws:
Exception
-
createChildProcessor
protected org.apache.camel.Processor createChildProcessor(boolean mandatory) throws Exception
Creates the child processor (outputs) from the current definition- Parameters:
mandatory
- whether or not children is mandatory (ie the definition should have outputs)- Returns:
- the created children, or null if definition had no output
- Throws:
Exception
- is thrown if error creating the child or if it was mandatory and there was no output defined on definition
-
wrapProcessor
public org.apache.camel.Channel wrapProcessor(org.apache.camel.Processor processor) throws Exception
Wraps the child processor in whatever necessary interceptors and error handlers- Throws:
Exception
-
wrapChannel
protected org.apache.camel.Channel wrapChannel(org.apache.camel.Processor processor, org.apache.camel.model.ProcessorDefinition<?> child) throws Exception
- Throws:
Exception
-
wrapChannel
protected org.apache.camel.Channel wrapChannel(org.apache.camel.Processor processor, org.apache.camel.model.ProcessorDefinition<?> child, Boolean inheritErrorHandler) throws Exception
- Throws:
Exception
-
wrapInErrorHandler
protected org.apache.camel.Processor wrapInErrorHandler(org.apache.camel.Processor output) throws Exception
Wraps the given output in an error handler- Parameters:
output
- the output- Returns:
- the output wrapped with the error handler
- Throws:
Exception
- can be thrown if failed to create error handler builder
-
createCompositeProcessor
protected org.apache.camel.Processor createCompositeProcessor(List<org.apache.camel.Processor> list) throws Exception
Creates a new instance of some kind of composite processor which defaults to using aPipeline
but derived classes could change the behaviour- Throws:
Exception
-
createOutputsProcessor
protected org.apache.camel.Processor createOutputsProcessor(Collection<org.apache.camel.model.ProcessorDefinition<?>> outputs) throws Exception
- Throws:
Exception
-
createProcessor
protected org.apache.camel.Processor createProcessor(org.apache.camel.model.ProcessorDefinition<?> output) throws Exception
- Throws:
Exception
-
makeProcessor
protected org.apache.camel.Channel makeProcessor() throws Exception
Creates the processor and wraps it in any necessary interceptors and error handlers- Throws:
Exception
-
preCreateProcessor
protected void preCreateProcessor()
Strategy to execute any custom logic before theProcessor
is created.
-
configureChild
public void configureChild(org.apache.camel.model.ProcessorDefinition<?> output)
Strategy for children to do any custom configuration- Parameters:
output
- the child to be added as output to this
-
getId
protected String getId(org.apache.camel.model.OptionalIdentifiedDefinition<?> def)
-
-