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
,ConvertHeaderReifier
,ConvertVariableReifier
,DelayReifier
,DisabledReifier
,DynamicRouterReifier
,EnrichReifier
,FilterReifier
,FinallyReifier
,IdempotentConsumerReifier
,InterceptReifier
,InterceptSendToEndpointReifier
,KameletReifier
,LoadBalanceReifier
,LogReifier
,LoopReifier
,MarshalReifier
,MulticastReifier
,OnCompletionReifier
,OnExceptionReifier
,OnFallbackReifier
,OtherwiseReifier
,PausableReifier
,PipelineReifier
,PollEnrichReifier
,ProcessReifier
,RecipientListReifier
,RemoveHeaderReifier
,RemoveHeadersReifier
,RemovePropertiesReifier
,RemovePropertyReifier
,RemoveVariableReifier
,ResequenceReifier
,ResumableReifier
,RollbackReifier
,RouteReifier
,RoutingSlipReifier
,SagaReifier
,SamplingReifier
,ScriptReifier
,SendReifier
,ServiceCallReifier
,SetBodyReifier
,SetExchangePatternReifier
,SetHeaderReifier
,SetHeadersReifier
,SetPropertyReifier
,SetVariableReifier
,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
Modifier and TypeFieldDescriptionprotected final T
static final String
Global option onCamelContext.getGlobalOptions()
that tooling can use to disable all route processors, which allows to startup Camel without wiring up and initializing all route EIPs that may use custom processors, beans, and other services that may not be available, or is unwanted to be in use; for example to have fast startup, and being able to introspect CamelContext and the route models.Fields inherited from class org.apache.camel.reifier.AbstractReifier
camelContext, route
-
Constructor Summary
ConstructorDescriptionProcessorReifier
(org.apache.camel.CamelContext camelContext, T definition) ProcessorReifier
(org.apache.camel.Route route, T definition) -
Method Summary
Modifier and TypeMethodDescriptionvoid
static void
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
Prefer to use {#link #createChildProcessor}.protected org.apache.camel.Processor
createOutputsProcessor
(Collection<org.apache.camel.model.ProcessorDefinition<?>> outputs) abstract org.apache.camel.Processor
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) org.apache.camel.AggregationStrategy
getConfiguredAggregationStrategy
(org.apache.camel.model.AggregationStrategyAwareDefinition<?> definition) Will lookup and get the configuredAggregationStrategy
from the given definition.getConfiguredExecutorService
(String name, org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault) Will look up and get the configuredExecutorService
from the given definition.getConfiguredScheduledExecutorService
(String name, org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault) Will look up 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.lookupExecutorServiceRef
(String name, Object source, String executorServiceRef) Will lookup inRegistry
for aExecutorService
registered with the given executorServiceRef name.lookupScheduledExecutorServiceRef
(String name, Object source, String executorServiceRef) Will lookup inRegistry
for aScheduledExecutorService
registered with the given executorServiceRef name.protected org.apache.camel.Channel
Creates the processor and wraps it in any necessary interceptors and error handlersprotected void
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 handlersMethods inherited from class org.apache.camel.reifier.AbstractReifier
asRef, createExpression, createExpression, createPredicate, createPredicate, findByType, findByTypeWithName, getCamelContext, getRegistry, lookupByName, lookupByNameAndType, mandatoryLookup, or, parse, parse, parseBoolean, parseBoolean, parseDuration, parseDuration, parseFloat, parseFloat, parseInt, parseInt, parseLong, parseLong, parseString, resolveEndpoint, unwrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.camel.spi.BeanRepository
findSingleByType, mandatoryFindSingleByType
-
Field Details
-
DISABLE_ALL_PROCESSORS
Global option onCamelContext.getGlobalOptions()
that tooling can use to disable all route processors, which allows to startup Camel without wiring up and initializing all route EIPs that may use custom processors, beans, and other services that may not be available, or is unwanted to be in use; for example to have fast startup, and being able to introspect CamelContext and the route models.- See Also:
-
definition
-
-
Constructor Details
-
ProcessorReifier
-
ProcessorReifier
-
-
Method Details
-
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
public ExecutorService getConfiguredExecutorService(String name, org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault) throws IllegalArgumentException Will look up and get the configuredExecutorService
from the given definition. This method will look up 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 look up and get the configuredScheduledExecutorService
from the given definition. This method will look up 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
Override this in definition class and implement logic to create the processor based on the definition model.- Throws:
Exception
-
createOutputsProcessor
Prefer to use {#link #createChildProcessor}.- Throws:
Exception
-
createChildProcessor
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
-
addRoutes
- Throws:
Exception
-
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
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
-
getConfiguredAggregationStrategy
public org.apache.camel.AggregationStrategy getConfiguredAggregationStrategy(org.apache.camel.model.AggregationStrategyAwareDefinition<?> definition) Will lookup and get the configuredAggregationStrategy
from the given definition. This method will lookup for configured aggregation strategy in the following order- from the definition if any explicit configured aggregation strategy.
- from the
Registry
if found - if none found, then null is returned.
AggregationStrategyAwareDefinition
should use this helper method to ensure they support configured executor services in the same coherent way.- Parameters:
definition
- the node definition which may leverage aggregation strategy- Throws:
IllegalArgumentException
- is thrown if lookup of aggregation strategy inRegistry
was not found
-