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 Details

    • DISABLE_ALL_PROCESSORS

      public static final String DISABLE_ALL_PROCESSORS
      Global option on CamelContext.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

      protected final T extends org.apache.camel.model.ProcessorDefinition<?> definition
  • Constructor Details

    • ProcessorReifier

      public ProcessorReifier(org.apache.camel.Route route, T definition)
    • ProcessorReifier

      public ProcessorReifier(org.apache.camel.CamelContext camelContext, T definition)
  • 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 configured ExecutorService 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.
      The various 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 the ExecutorService is created based on a ThreadPoolProfile.
      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 in Registry 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 configured ScheduledExecutorService 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.
      The various 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 the ExecutorService is created based on a ThreadPoolProfile.
      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 in Registry was not found
    • lookupScheduledExecutorServiceRef

      public ScheduledExecutorService lookupScheduledExecutorServiceRef(String name, Object source, String executorServiceRef)
      Will lookup in Registry for a ScheduledExecutorService 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 the ExecutorService is created based on a ThreadPoolProfile.
      source - the source to use the thread pool
      executorServiceRef - reference name of the thread pool
      Returns:
      the executor service, or null if none was found.
    • lookupExecutorServiceRef

      public ExecutorService lookupExecutorServiceRef(String name, Object source, String executorServiceRef)
      Will lookup in Registry for a ExecutorService 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 the ExecutorService is created based on a ThreadPoolProfile.
      source - the source to use the thread pool
      executorServiceRef - reference name of the thread pool
      Returns:
      the executor service, or null if none was found.
    • 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 outputs
      excludeAbstract - 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
    • addRoutes

      public void addRoutes() throws Exception
      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 a Pipeline 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 the Processor 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)
    • getConfiguredAggregationStrategy

      public org.apache.camel.AggregationStrategy getConfiguredAggregationStrategy(org.apache.camel.model.AggregationStrategyAwareDefinition<?> definition)
      Will lookup and get the configured AggregationStrategy 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.
      The various 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 in Registry was not found