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,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,ResequenceReifier,ResumableReifier,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
FieldsFields inherited from class org.apache.camel.reifier.AbstractReifier
camelContext, route -
Constructor Summary
ConstructorsConstructorDescriptionProcessorReifier(org.apache.camel.CamelContext camelContext, T definition) ProcessorReifier(org.apache.camel.Route route, T definition) -
Method Summary
Modifier and TypeMethodDescriptionvoidstatic voidvoidconfigureChild(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.ProcessorcreateChildProcessor(boolean mandatory) Creates the child processor (outputs) from the current definitionprotected org.apache.camel.ProcessorcreateCompositeProcessor(List<org.apache.camel.Processor> list) Creates a new instance of some kind of composite processor which defaults to using aPipelinebut derived classes could change the behaviourprotected org.apache.camel.ProcessorPrefer to use {#link #createChildProcessor}.protected org.apache.camel.ProcessorcreateOutputsProcessor(Collection<org.apache.camel.model.ProcessorDefinition<?>> outputs) abstract org.apache.camel.ProcessorOverride this in definition class and implement logic to create the processor based on the definition model.protected org.apache.camel.ProcessorcreateProcessor(org.apache.camel.model.ProcessorDefinition<?> output) org.apache.camel.AggregationStrategygetConfiguredAggregationStrategy(org.apache.camel.model.AggregationStrategyAwareDefinition<?> definition) Will lookup and get the configuredAggregationStrategyfrom the given definition.getConfiguredExecutorService(String name, org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault) Will look up and get the configuredExecutorServicefrom the given definition.getConfiguredScheduledExecutorService(String name, org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault) Will look up and get the configuredScheduledExecutorServicefrom the given definition.protected StringgetId(org.apache.camel.model.OptionalIdentifiedDefinition<?> def) booleanhasOutputs(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 inRegistryfor aExecutorServiceregistered with the given executorServiceRef name.lookupScheduledExecutorServiceRef(String name, Object source, String executorServiceRef) Will lookup inRegistryfor aScheduledExecutorServiceregistered with the given executorServiceRef name.protected org.apache.camel.ChannelCreates the processor and wraps it in any necessary interceptors and error handlersprotected voidStrategy to execute any custom logic before theProcessoris created.static voidregisterReifier(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) booleanwillCreateNewThreadPool(org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault) Determines whether a new thread pool will be created or not.protected org.apache.camel.ChannelwrapChannel(org.apache.camel.Processor processor, org.apache.camel.model.ProcessorDefinition<?> child) protected org.apache.camel.ChannelwrapChannel(org.apache.camel.Processor processor, org.apache.camel.model.ProcessorDefinition<?> child, Boolean inheritErrorHandler) protected org.apache.camel.ProcessorwrapInErrorHandler(org.apache.camel.Processor output) Wraps the given output in an error handlerorg.apache.camel.ChannelwrapProcessor(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, unwrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.spi.BeanRepository
findSingleByType
-
Field Details
-
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 configuredExecutorServicefrom 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
Registryif found - from the known list of
ThreadPoolProfile(s). - if none found, then null is returned.
ExecutorServiceAwareDefinitionshould 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 theExecutorServiceis 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 inRegistrywas not found
-
getConfiguredScheduledExecutorService
public ScheduledExecutorService getConfiguredScheduledExecutorService(String name, org.apache.camel.model.ExecutorServiceAwareDefinition<?> definition, boolean useDefault) throws IllegalArgumentException Will look up and get the configuredScheduledExecutorServicefrom 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
Registryif found - from the known list of
ThreadPoolProfile(s). - if none found, then null is returned.
ExecutorServiceAwareDefinitionshould 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 theExecutorServiceis 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 inRegistrywas not found
-
lookupScheduledExecutorServiceRef
public ScheduledExecutorService lookupScheduledExecutorServiceRef(String name, Object source, String executorServiceRef) Will lookup inRegistryfor aScheduledExecutorServiceregistered with the given executorServiceRef name. This method will lookup for configured thread pool in the following order- from the
Registryif 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 theExecutorServiceis 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 inRegistryfor aExecutorServiceregistered with the given executorServiceRef name. This method will lookup for configured thread pool in the following order- from the
Registryif 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 theExecutorServiceis 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 aPipelinebut 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 theProcessoris 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 configuredAggregationStrategyfrom 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
Registryif found - if none found, then null is returned.
AggregationStrategyAwareDefinitionshould 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 inRegistrywas not found
-