public class DefaultModel extends Object implements Model
Constructor and Description |
---|
DefaultModel(org.apache.camel.CamelContext camelContext) |
Modifier and Type | Method and Description |
---|---|
void |
addHystrixConfiguration(String id,
HystrixConfigurationDefinition configuration)
Adds the Hystrix configuration
|
void |
addRestDefinitions(Collection<RestDefinition> restDefinitions,
boolean addToRoutes)
Adds a collection of rest definitions to the context
|
void |
addRestDefinitions(InputStream is,
boolean addToRoutes)
Adds a collection of rest definitions to the context
|
void |
addRouteDefinition(RouteDefinition routeDefinition)
Add a route definition to the context
Important: Each route in the same
CamelContext must have an unique route id. |
void |
addRouteDefinitions(Collection<RouteDefinition> routeDefinitions)
Adds a collection of route definitions to the context
Important: Each route in the same
CamelContext must have an unique route id. |
void |
addRouteDefinitions(InputStream is)
Adds a collection of route definitions to the context
Important: Each route in the same
CamelContext must have an unique route id. |
void |
addServiceCallConfiguration(String serviceName,
ServiceCallConfigurationDefinition configuration)
Adds the service call configuration
|
org.apache.camel.CamelContext |
getCamelContext() |
Map<String,DataFormatDefinition> |
getDataFormats()
Gets the data formats that can be referenced in the routes.
|
HystrixConfigurationDefinition |
getHystrixConfiguration(String id)
Gets the Hystrix configuration by the given name.
|
ProcessorDefinition |
getProcessorDefinition(String id)
Gets the processor definition from any of the routes which with the given id
|
<T extends ProcessorDefinition> |
getProcessorDefinition(String id,
Class<T> type)
Gets the processor definition from any of the routes which with the given id
|
List<RestDefinition> |
getRestDefinitions()
Returns a list of the current REST definitions
|
RouteDefinition |
getRouteDefinition(String id)
Gets the route definition with the given id
|
List<RouteDefinition> |
getRouteDefinitions()
Returns a list of the current route definitions
|
Function<RouteDefinition,Boolean> |
getRouteFilter()
Gets the current route filter
|
ServiceCallConfigurationDefinition |
getServiceCallConfiguration(String serviceName)
Gets the service call configuration by the given name.
|
List<TransformerDefinition> |
getTransformers()
Gets the transformers that can be referenced in the routes.
|
List<ValidatorDefinition> |
getValidators()
Gets the validators that can be referenced in the routes.
|
protected static <T> T |
lookup(org.apache.camel.CamelContext context,
String ref,
Class<T> type) |
protected void |
prepare(RouteDefinition routeDefinition) |
void |
removeRouteDefinition(RouteDefinition routeDefinition)
Removes a route definition from the context - stopping any previously running
routes if any of them are actively running
|
void |
removeRouteDefinitions(Collection<RouteDefinition> routeDefinitions)
Removes a collection of route definitions from the context - stopping any previously running
routes if any of them are actively running
|
DataFormatDefinition |
resolveDataFormatDefinition(String name)
Resolve a data format definition given its name
|
void |
setDataFormats(Map<String,DataFormatDefinition> dataFormats)
Sets the data formats that can be referenced in the routes.
|
void |
setHystrixConfiguration(HystrixConfigurationDefinition configuration)
Sets the default Hystrix configuration
|
void |
setHystrixConfigurations(List<HystrixConfigurationDefinition> configurations)
Sets the Hystrix configurations
|
void |
setRouteFilter(Function<RouteDefinition,Boolean> routeFilter)
Sets a custom route filter to use for filtering unwanted routes when routes are added.
|
void |
setRouteFilterPattern(String include,
String exclude)
Used for filtering routes routes matching the given pattern, which follows the following rules:
- Match by route id
- Match by route input endpoint uri
The matching is using exact match, by wildcard and regular expression as documented by
PatternHelper.matchPattern(String, String) . |
void |
setServiceCallConfiguration(ServiceCallConfigurationDefinition configuration)
Sets the default service call configuration
|
void |
setServiceCallConfigurations(List<ServiceCallConfigurationDefinition> configurations)
Sets the service call configurations
|
void |
setTransformers(List<TransformerDefinition> transformers)
Sets the transformers that can be referenced in the routes.
|
void |
setValidators(List<ValidatorDefinition> validators)
Sets the validators that can be referenced in the routes.
|
protected boolean |
shouldStartRoutes()
Should we start newly added routes?
|
protected void |
start(RouteDefinition routeDefinition) |
void |
startRoute(RouteDefinition routeDefinition) |
void |
startRouteDefinitions()
Start all routes from this model.
|
protected void |
startRouteDefinitions(Collection<RouteDefinition> list) |
public DefaultModel(org.apache.camel.CamelContext camelContext)
public org.apache.camel.CamelContext getCamelContext()
public void addRouteDefinitions(InputStream is) throws Exception
Model
CamelContext
must have an unique route id.
If you use the API from CamelContext
or Model
to add routes, then any
new routes which has a route id that matches an old route, then the old route is replaced by the new route.addRouteDefinitions
in interface Model
is
- input stream with the route(s) definition to addException
- if the route definitions could not be added for whatever reasonpublic void addRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception
Model
CamelContext
must have an unique route id.
If you use the API from CamelContext
or Model
to add routes, then any
new routes which has a route id that matches an old route, then the old route is replaced by the new route.addRouteDefinitions
in interface Model
routeDefinitions
- the route(s) definition to addException
- if the route definitions could not be added for whatever reasonpublic void addRouteDefinition(RouteDefinition routeDefinition) throws Exception
Model
CamelContext
must have an unique route id.
If you use the API from CamelContext
or Model
to add routes, then any
new routes which has a route id that matches an old route, then the old route is replaced by the new route.addRouteDefinition
in interface Model
routeDefinition
- the route definition to addException
- if the route definition could not be added for whatever reasonpublic void removeRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception
Model
removeRouteDefinitions
in interface Model
routeDefinitions
- route(s) definitions to removeException
- if the route definitions could not be removed for whatever reasonpublic void removeRouteDefinition(RouteDefinition routeDefinition) throws Exception
Model
removeRouteDefinition
in interface Model
routeDefinition
- route definition to removeException
- if the route definition could not be removed for whatever reasonpublic List<RouteDefinition> getRouteDefinitions()
Model
getRouteDefinitions
in interface Model
public RouteDefinition getRouteDefinition(String id)
Model
getRouteDefinition
in interface Model
id
- id of the routepublic List<RestDefinition> getRestDefinitions()
Model
getRestDefinitions
in interface Model
public void addRestDefinitions(InputStream is, boolean addToRoutes) throws Exception
Model
addRestDefinitions
in interface Model
is
- input stream with the rest(s) definition to addaddToRoutes
- whether the rests should also automatically be added as routesException
- if the rest definitions could not be created for whatever reasonpublic void addRestDefinitions(Collection<RestDefinition> restDefinitions, boolean addToRoutes) throws Exception
Model
addRestDefinitions
in interface Model
restDefinitions
- the rest(s) definition to addaddToRoutes
- whether the rests should also automatically be added as routesException
- if the rest definitions could not be created for whatever reasonpublic ServiceCallConfigurationDefinition getServiceCallConfiguration(String serviceName)
Model
getServiceCallConfiguration
in interface Model
serviceName
- name of service, or null to return the default configurationpublic void setServiceCallConfiguration(ServiceCallConfigurationDefinition configuration)
Model
setServiceCallConfiguration
in interface Model
configuration
- the configurationpublic void setServiceCallConfigurations(List<ServiceCallConfigurationDefinition> configurations)
Model
setServiceCallConfigurations
in interface Model
configurations
- the configuration listpublic void addServiceCallConfiguration(String serviceName, ServiceCallConfigurationDefinition configuration)
Model
addServiceCallConfiguration
in interface Model
serviceName
- name of the serviceconfiguration
- the configurationpublic HystrixConfigurationDefinition getHystrixConfiguration(String id)
Model
getHystrixConfiguration
in interface Model
id
- id of the configuration, or null to return the default configurationpublic void setHystrixConfiguration(HystrixConfigurationDefinition configuration)
Model
setHystrixConfiguration
in interface Model
configuration
- the configurationpublic void setHystrixConfigurations(List<HystrixConfigurationDefinition> configurations)
Model
setHystrixConfigurations
in interface Model
configurations
- the configuration listpublic void addHystrixConfiguration(String id, HystrixConfigurationDefinition configuration)
Model
addHystrixConfiguration
in interface Model
id
- name of the configurationconfiguration
- the configurationpublic DataFormatDefinition resolveDataFormatDefinition(String name)
Model
resolveDataFormatDefinition
in interface Model
name
- the data format definition name or a reference to it in the Registry
public ProcessorDefinition getProcessorDefinition(String id)
Model
getProcessorDefinition
in interface Model
id
- id of the processor definitionpublic <T extends ProcessorDefinition> T getProcessorDefinition(String id, Class<T> type)
Model
getProcessorDefinition
in interface Model
id
- id of the processor definitiontype
- the processor definition typepublic void setDataFormats(Map<String,DataFormatDefinition> dataFormats)
Model
setDataFormats
in interface Model
dataFormats
- the data formatspublic Map<String,DataFormatDefinition> getDataFormats()
Model
getDataFormats
in interface Model
public void setTransformers(List<TransformerDefinition> transformers)
Model
setTransformers
in interface Model
transformers
- the transformerspublic List<TransformerDefinition> getTransformers()
Model
getTransformers
in interface Model
public void setValidators(List<ValidatorDefinition> validators)
Model
setValidators
in interface Model
validators
- the validatorspublic List<ValidatorDefinition> getValidators()
Model
getValidators
in interface Model
public void startRouteDefinitions() throws Exception
Model
startRouteDefinitions
in interface Model
Exception
public void setRouteFilterPattern(String include, String exclude)
Model
PatternHelper.matchPattern(String, String)
.
For example to only include routes which starts with foo in their route id's, use: include=foo*
And to exclude routes which starts from JMS endpoints, use: exclude=jms:*
Exclude takes precedence over include.setRouteFilterPattern
in interface Model
include
- the include patternexclude
- the exclude patternpublic Function<RouteDefinition,Boolean> getRouteFilter()
Model
getRouteFilter
in interface Model
public void setRouteFilter(Function<RouteDefinition,Boolean> routeFilter)
Model
setRouteFilter
in interface Model
routeFilter
- the filterprotected void startRouteDefinitions(Collection<RouteDefinition> list) throws Exception
Exception
public void startRoute(RouteDefinition routeDefinition) throws Exception
Exception
protected void prepare(RouteDefinition routeDefinition) throws Exception
Exception
protected void start(RouteDefinition routeDefinition) throws Exception
Exception
protected boolean shouldStartRoutes()
Apache Camel