public final class ProcessorDefinitionHelper extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
addPropertyPlaceholdersChangeRevertAction(Runnable action) |
static Runnable |
createPropertyPlaceholdersChangeReverter()
Creates a Runnable which when run will revert property placeholder
updates to the camel route definitions that were done after this method
is called.
|
static <T> Iterator<T> |
filterTypeInOutputs(List<ProcessorDefinition<?>> outputs,
Class<T> type)
Looks for the given type in the list of outputs and recurring all the
children as well.
|
static <T> Iterator<T> |
filterTypeInOutputs(List<ProcessorDefinition<?>> outputs,
Class<T> type,
int maxDeep)
Looks for the given type in the list of outputs and recurring all the
children as well.
|
static <T extends ProcessorDefinition> |
findFirstParentOfType(Class<T> parentType,
ProcessorDefinition<?> node,
boolean recursive)
Is the given node parent(s) of the given type
|
static <T> T |
findFirstTypeInOutputs(List<ProcessorDefinition<?>> outputs,
Class<T> type)
Looks for the given type in the list of outputs and recurring all the
children as well.
|
static Set<String> |
gatherAllNodeIds(ProcessorDefinition<?> node,
Set<String> set,
boolean onlyCustomId,
boolean includeAbstract)
Traverses the node, including its children (recursive), and gathers all
the node ids.
|
static ExecutorService |
getConfiguredExecutorService(org.apache.camel.spi.RouteContext routeContext,
String name,
ExecutorServiceAwareDefinition<?> definition,
boolean useDefault)
Will lookup and get the configured
ExecutorService from the given definition. |
static ScheduledExecutorService |
getConfiguredScheduledExecutorService(org.apache.camel.spi.RouteContext routeContext,
String name,
ExecutorServiceAwareDefinition<?> definition,
boolean useDefault)
Will lookup and get the configured
ScheduledExecutorService from the given
definition. |
static RouteDefinition |
getRoute(org.apache.camel.NamedNode node)
Gets the route definition the given node belongs to.
|
static String |
getRouteId(org.apache.camel.NamedNode node)
Gets the route id the given node belongs to.
|
static boolean |
hasOutputs(List<ProcessorDefinition<?>> outputs,
boolean excludeAbstract)
Is there any outputs in the given list.
|
static boolean |
isFirstChildOfType(Class<?> parentType,
ProcessorDefinition<?> node)
Is the given child the first in the outputs from the parent?
|
static boolean |
isParentOfType(Class<? extends ProcessorDefinition> parentType,
ProcessorDefinition<?> node,
boolean recursive)
Is the given node parent(s) of the given type
|
static ExecutorService |
lookupExecutorServiceRef(org.apache.camel.spi.RouteContext routeContext,
String name,
Object source,
String executorServiceRef)
Will lookup in
Registry for a
ExecutorService registered with the given
executorServiceRef name. |
static ScheduledExecutorService |
lookupScheduledExecutorServiceRef(org.apache.camel.spi.RouteContext routeContext,
String name,
Object source,
String executorServiceRef)
Will lookup in
Registry for a
ScheduledExecutorService registered with the given
executorServiceRef name. |
static void |
resolvePropertyPlaceholders(org.apache.camel.CamelContext camelContext,
Object definition)
Inspects the given definition and resolves any property placeholders from
its properties.
|
static boolean |
willCreateNewThreadPool(org.apache.camel.spi.RouteContext routeContext,
ExecutorServiceAwareDefinition<?> definition,
boolean useDefault)
Determines whether a new thread pool will be created or not.
|
public static <T> Iterator<T> filterTypeInOutputs(List<ProcessorDefinition<?>> outputs, Class<T> type)
outputs - list of outputs, can be null or empty.type - the type to look forpublic static <T> Iterator<T> filterTypeInOutputs(List<ProcessorDefinition<?>> outputs, Class<T> type, int maxDeep)
outputs - list of outputs, can be null or empty.type - the type to look formaxDeep - maximum levels deep to traversepublic static <T> T findFirstTypeInOutputs(List<ProcessorDefinition<?>> outputs, Class<T> type)
outputs - list of outputs, can be null or empty.type - the type to look forpublic static boolean isFirstChildOfType(Class<?> parentType, ProcessorDefinition<?> node)
parentType - the type the parent must benode - the nodepublic static boolean isParentOfType(Class<? extends ProcessorDefinition> parentType, ProcessorDefinition<?> node, boolean recursive)
parentType - the parent typenode - the current noderecursive - whether or not to check grand parent(s) as wellpublic static <T extends ProcessorDefinition> T findFirstParentOfType(Class<T> parentType, ProcessorDefinition<?> node, boolean recursive)
parentType - the parent typenode - the current noderecursive - whether or not to check grand parent(s) as wellpublic static RouteDefinition getRoute(org.apache.camel.NamedNode node)
node - the nodepublic static String getRouteId(org.apache.camel.NamedNode node)
node - the nodepublic static Set<String> gatherAllNodeIds(ProcessorDefinition<?> node, Set<String> set, boolean onlyCustomId, boolean includeAbstract)
node - the target nodeset - set to store ids, if null a new set will be createdonlyCustomId - whether to only store custom assigned ids (ie.
OptionalIdentifiedDefinition.hasCustomIdAssigned()includeAbstract - whether to include abstract nodes (ie.
ProcessorDefinition.isAbstract()public static boolean hasOutputs(List<ProcessorDefinition<?>> outputs, boolean excludeAbstract)
outputs - the outputsexcludeAbstract - whether or not to exclude abstract outputs (e.g.
skip onException etc.)public static boolean willCreateNewThreadPool(org.apache.camel.spi.RouteContext routeContext, ExecutorServiceAwareDefinition<?> definition, boolean useDefault)
routeContext - the route contextdefinition - the node definition which may leverage executor
service.useDefault - whether to fallback and use a default thread pool, if
no explicit configuredgetConfiguredExecutorService(org.apache.camel.spi.RouteContext,
String, ExecutorServiceAwareDefinition, boolean)public static ExecutorService lookupExecutorServiceRef(org.apache.camel.spi.RouteContext routeContext, String name, Object source, String executorServiceRef)
Registry for a
ExecutorService registered with the given
executorServiceRef name.
This method will lookup for configured thread pool in the following order
Registry if foundThreadPoolProfile(s).routeContext - the route contextname - name which is appended to the thread name, when the
ExecutorService is created based
on a ThreadPoolProfile.source - the source to use the thread poolexecutorServiceRef - reference name of the thread poolpublic static ExecutorService getConfiguredExecutorService(org.apache.camel.spi.RouteContext routeContext, String name, ExecutorServiceAwareDefinition<?> definition, boolean useDefault) throws IllegalArgumentException
ExecutorService from the given definition.
This method will lookup for configured thread pool in the following order
Registry if foundThreadPoolProfile(s).ExecutorServiceAwareDefinition should use this helper
method to ensure they support configured executor services in the same
coherent way.routeContext - the route contextname - 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 configuredIllegalArgumentException - is thrown if lookup of executor service
in Registry was not foundpublic static ScheduledExecutorService lookupScheduledExecutorServiceRef(org.apache.camel.spi.RouteContext routeContext, String name, Object source, String executorServiceRef)
Registry for a
ScheduledExecutorService registered with the given
executorServiceRef name.
This method will lookup for configured thread pool in the following order
Registry if foundThreadPoolProfile(s).routeContext - the route contextname - name which is appended to the thread name, when the
ExecutorService is created based
on a ThreadPoolProfile.source - the source to use the thread poolexecutorServiceRef - reference name of the thread poolpublic static ScheduledExecutorService getConfiguredScheduledExecutorService(org.apache.camel.spi.RouteContext routeContext, String name, ExecutorServiceAwareDefinition<?> definition, boolean useDefault) throws IllegalArgumentException
ScheduledExecutorService from the given
definition.
This method will lookup for configured thread pool in the following order
Registry if foundThreadPoolProfile(s).ExecutorServiceAwareDefinition should use this helper
method to ensure they support configured executor services in the same
coherent way.routeContext - the rout contextname - 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 configuredIllegalArgumentException - is thrown if the found instance is not a
ScheduledExecutorService type, or lookup of executor service
in Registry was not foundpublic static Runnable createPropertyPlaceholdersChangeReverter()
Runnable undo = ProcessorDefinitionHelper.createPropertyPlaceholdersChangeReverter();
try {
// All property resolutions in this block will be reverted.
} finally {
undo.run();
}
public static void addPropertyPlaceholdersChangeRevertAction(Runnable action)
public static void resolvePropertyPlaceholders(org.apache.camel.CamelContext camelContext, Object definition) throws Exception
OtherAttributesAware. Also known constant
fields on Exchange is replaced with their actual constant value,
eg Exchange.FILE_NAME is replaced with CamelFileName.camelContext - the Camel contextdefinition - the definition which should implement
OtherAttributesAwareException - is thrown if property placeholders was used and there
was an error resolving themCamelContext.resolvePropertyPlaceholders(String),
org.apache.camel.component.properties.PropertiesComponentApache Camel