Package org.apache.camel.model
Class RouteDefinitionHelper
- java.lang.Object
-
- org.apache.camel.model.RouteDefinitionHelper
-
public final class RouteDefinitionHelper extends Object
Helper forRouteDefinition
Utility methods to help preparingRouteDefinition
before they are added toCamelContext
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
forceAssignIds(org.apache.camel.CamelContext context, List<RouteDefinition> routes)
Force assigning ids to the routesstatic void
forceAssignIds(org.apache.camel.CamelContext context, ProcessorDefinition processor)
Force assigning ids to the give node and all its children (recursively).static Set<String>
gatherAllEndpointUris(org.apache.camel.CamelContext camelContext, RouteDefinition route, boolean includeInput, boolean includeOutputs, boolean includeDynamic)
Gather all the endpoint uri's the route is using from the EIPs that has a static or dynamic endpoint defined.static Set<String>
gatherAllStaticEndpointUris(org.apache.camel.CamelContext camelContext, RouteDefinition route, boolean includeInputs, boolean includeOutputs)
Gather all the endpoint uri's the route is using from the EIPs that has a static endpoint defined.static String
getRouteMessage(String route)
static void
initParent(ProcessorDefinition parent)
static void
prepareRoute(org.apache.camel.CamelContext context, RouteDefinition route)
Prepares the route.static void
prepareRoute(org.apache.camel.CamelContext context, RouteDefinition route, ErrorHandlerDefinition errorHandler, List<OnExceptionDefinition> onExceptions, List<InterceptDefinition> intercepts, List<InterceptFromDefinition> interceptFromDefinitions, List<InterceptSendToEndpointDefinition> interceptSendToEndpointDefinitions, List<OnCompletionDefinition> onCompletions)
Prepares the route which supports context scoped features such as onException, interceptors and onCompletionsstatic void
prepareRouteForInit(RouteDefinition route, List<ProcessorDefinition<?>> abstracts, List<ProcessorDefinition<?>> lower)
static void
sanityCheckRoute(RouteDefinition route)
Sanity check the route, that it has input(s) and outputs.static String
validateUniqueIds(RouteDefinition target, List<RouteDefinition> routes)
Validates that the target route has no duplicate id's from any of the existing routes.static String
validateUniqueIds(RouteDefinition target, List<RouteDefinition> routes, String prefixId)
Validates that the target route has no duplicate id's from any of the existing routes.
-
-
-
Method Detail
-
gatherAllStaticEndpointUris
public static Set<String> gatherAllStaticEndpointUris(org.apache.camel.CamelContext camelContext, RouteDefinition route, boolean includeInputs, boolean includeOutputs)
Gather all the endpoint uri's the route is using from the EIPs that has a static endpoint defined.- Parameters:
route
- the routeincludeInputs
- whether to include inputsincludeOutputs
- whether to include outputs- Returns:
- the endpoints uris
-
gatherAllEndpointUris
public static Set<String> gatherAllEndpointUris(org.apache.camel.CamelContext camelContext, RouteDefinition route, boolean includeInput, boolean includeOutputs, boolean includeDynamic)
Gather all the endpoint uri's the route is using from the EIPs that has a static or dynamic endpoint defined.- Parameters:
route
- the routeincludeInput
- whether to include inputsincludeOutputs
- whether to include outputsincludeDynamic
- whether to include dynamic outputs which has been in use during routing at runtime, gathered from theRuntimeEndpointRegistry
.- Returns:
- the endpoints uris
-
forceAssignIds
public static void forceAssignIds(org.apache.camel.CamelContext context, List<RouteDefinition> routes) throws Exception
Force assigning ids to the routes- Parameters:
context
- the camel contextroutes
- the routes- Throws:
Exception
- is thrown if error force assign ids to the routes
-
validateUniqueIds
public static String validateUniqueIds(RouteDefinition target, List<RouteDefinition> routes)
Validates that the target route has no duplicate id's from any of the existing routes.- Parameters:
target
- the target routeroutes
- the existing routes- Returns:
- null if no duplicate id's detected, otherwise the first found duplicate id is returned.
-
validateUniqueIds
public static String validateUniqueIds(RouteDefinition target, List<RouteDefinition> routes, String prefixId)
Validates that the target route has no duplicate id's from any of the existing routes.- Parameters:
target
- the target routeroutes
- the existing routesprefixId
- optional prefix to use in duplicate id detection- Returns:
- null if no duplicate id's detected, otherwise the first found duplicate id is returned.
-
initParent
public static void initParent(ProcessorDefinition parent)
-
prepareRouteForInit
public static void prepareRouteForInit(RouteDefinition route, List<ProcessorDefinition<?>> abstracts, List<ProcessorDefinition<?>> lower)
-
prepareRoute
public static void prepareRoute(org.apache.camel.CamelContext context, RouteDefinition route)
Prepares the route. This method does not mark the route as prepared afterwards.- Parameters:
context
- the camel contextroute
- the route
-
prepareRoute
public static void prepareRoute(org.apache.camel.CamelContext context, RouteDefinition route, ErrorHandlerDefinition errorHandler, List<OnExceptionDefinition> onExceptions, List<InterceptDefinition> intercepts, List<InterceptFromDefinition> interceptFromDefinitions, List<InterceptSendToEndpointDefinition> interceptSendToEndpointDefinitions, List<OnCompletionDefinition> onCompletions)
Prepares the route which supports context scoped features such as onException, interceptors and onCompletions This method does not mark the route as prepared afterwards.- Parameters:
context
- the camel contextroute
- the routeerrorHandler
- optional error handleronExceptions
- optional list of onExceptionsintercepts
- optional list of interceptorsinterceptFromDefinitions
- optional list of interceptFromsinterceptSendToEndpointDefinitions
- optional list of interceptSendToEndpointsonCompletions
- optional list onCompletions
-
sanityCheckRoute
public static void sanityCheckRoute(RouteDefinition route)
Sanity check the route, that it has input(s) and outputs.- Parameters:
route
- the route- Throws:
IllegalArgumentException
- is thrown if the route is invalid
-
forceAssignIds
public static void forceAssignIds(org.apache.camel.CamelContext context, ProcessorDefinition processor)
Force assigning ids to the give node and all its children (recursively). This is needed when doing tracing or the likes, where each node should have its id assigned so the tracing can pin point exactly.- Parameters:
context
- the camel contextprocessor
- the node
-
-