Class ProcessorReifier<T extends org.apache.camel.model.ProcessorDefinition<?>>

    • Field Detail

      • definition

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

      • ProcessorReifier

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

        public ProcessorReifier​(org.apache.camel.CamelContext camelContext,
                                T 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 configured ExecutorService 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.
        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 lookup and get the configured ScheduledExecutorService 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.
        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
      • 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)