Package org.apache.camel.impl
Class DefaultModel
- java.lang.Object
-
- org.apache.camel.impl.DefaultModel
-
- All Implemented Interfaces:
Model
public class DefaultModel extends Object implements Model
-
-
Constructor Summary
Constructors Constructor Description DefaultModel(org.apache.camel.CamelContext camelContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFaultToleranceConfiguration(String id, FaultToleranceConfigurationDefinition configuration)Adds the MicroProfile Fault Tolerance configurationvoidaddHystrixConfiguration(String id, HystrixConfigurationDefinition configuration)Adds the Hystrix configurationvoidaddResilience4jConfiguration(String id, Resilience4jConfigurationDefinition configuration)Adds the Resilience4j configurationvoidaddRestDefinitions(Collection<RestDefinition> restDefinitions, boolean addToRoutes)Adds a collection of rest definitions to the contextvoidaddRouteDefinition(RouteDefinition routeDefinition)Add a route definition to the contextvoidaddRouteDefinitions(Collection<RouteDefinition> routeDefinitions)Adds a collection of route definitions to the contextvoidaddServiceCallConfiguration(String serviceName, ServiceCallConfigurationDefinition configuration)Adds the service call configurationorg.apache.camel.CamelContextgetCamelContext()Map<String,DataFormatDefinition>getDataFormats()Gets the data formats that can be referenced in the routes.FaultToleranceConfigurationDefinitiongetFaultToleranceConfiguration(String id)Gets the MicroProfile Fault Tolerance configuration by the given name.HystrixConfigurationDefinitiongetHystrixConfiguration(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<T>>
TgetProcessorDefinition(String id, Class<T> type)Gets the processor definition from any of the routes which with the given idResilience4jConfigurationDefinitiongetResilience4jConfiguration(String id)Gets the Resilience4j configuration by the given name.List<RestDefinition>getRestDefinitions()Returns a list of the current REST definitionsRouteDefinitiongetRouteDefinition(String id)Gets the route definition with the given idList<RouteDefinition>getRouteDefinitions()Returns a list of the current route definitionsFunction<RouteDefinition,Boolean>getRouteFilter()Gets the current route filterServiceCallConfigurationDefinitiongetServiceCallConfiguration(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> Tlookup(org.apache.camel.CamelContext context, String ref, Class<T> type)voidremoveRouteDefinition(RouteDefinition routeDefinition)Removes a route definition from the context - stopping any previously running routes if any of them are actively runningvoidremoveRouteDefinitions(Collection<RouteDefinition> routeDefinitions)Removes a collection of route definitions from the context - stopping any previously running routes if any of them are actively runningDataFormatDefinitionresolveDataFormatDefinition(String name)Resolve a data format definition given its namevoidsetDataFormats(Map<String,DataFormatDefinition> dataFormats)Sets the data formats that can be referenced in the routes.voidsetFaultToleranceConfiguration(FaultToleranceConfigurationDefinition configuration)Sets the default MicroProfile Fault Tolerance configurationvoidsetFaultToleranceConfigurations(List<FaultToleranceConfigurationDefinition> configurations)Sets the MicroProfile Fault Tolerance configurationsvoidsetHystrixConfiguration(HystrixConfigurationDefinition configuration)Sets the default Hystrix configurationvoidsetHystrixConfigurations(List<HystrixConfigurationDefinition> configurations)Sets the Hystrix configurationsvoidsetResilience4jConfiguration(Resilience4jConfigurationDefinition configuration)Sets the default Resilience4j configurationvoidsetResilience4jConfigurations(List<Resilience4jConfigurationDefinition> configurations)Sets the Resilience4j configurationsvoidsetRouteFilter(Function<RouteDefinition,Boolean> routeFilter)Sets a custom route filter to use for filtering unwanted routes when routes are added.voidsetRouteFilterPattern(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 byPatternHelper.matchPattern(String, String).voidsetServiceCallConfiguration(ServiceCallConfigurationDefinition configuration)Sets the default service call configurationvoidsetServiceCallConfigurations(List<ServiceCallConfigurationDefinition> configurations)Sets the service call configurationsvoidsetTransformers(List<TransformerDefinition> transformers)Sets the transformers that can be referenced in the routes.voidsetValidators(List<ValidatorDefinition> validators)Sets the validators that can be referenced in the routes.protected booleanshouldStartRoutes()Should we start newly added routes?
-
-
-
Constructor Detail
-
DefaultModel
public DefaultModel(org.apache.camel.CamelContext camelContext)
-
-
Method Detail
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()
-
addRouteDefinitions
public void addRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception
Description copied from interface:ModelAdds a collection of route definitions to the context Important: Each route in the sameCamelContextmust have an unique route id. If you use the API fromCamelContextorModelto 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.- Specified by:
addRouteDefinitionsin interfaceModel- Parameters:
routeDefinitions- the route(s) definition to add- Throws:
Exception- if the route definitions could not be added for whatever reason
-
addRouteDefinition
public void addRouteDefinition(RouteDefinition routeDefinition) throws Exception
Description copied from interface:ModelAdd a route definition to the context Important: Each route in the sameCamelContextmust have an unique route id. If you use the API fromCamelContextorModelto 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.- Specified by:
addRouteDefinitionin interfaceModel- Parameters:
routeDefinition- the route definition to add- Throws:
Exception- if the route definition could not be added for whatever reason
-
removeRouteDefinitions
public void removeRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception
Description copied from interface:ModelRemoves a collection of route definitions from the context - stopping any previously running routes if any of them are actively running- Specified by:
removeRouteDefinitionsin interfaceModel- Parameters:
routeDefinitions- route(s) definitions to remove- Throws:
Exception- if the route definitions could not be removed for whatever reason
-
removeRouteDefinition
public void removeRouteDefinition(RouteDefinition routeDefinition) throws Exception
Description copied from interface:ModelRemoves a route definition from the context - stopping any previously running routes if any of them are actively running- Specified by:
removeRouteDefinitionin interfaceModel- Parameters:
routeDefinition- route definition to remove- Throws:
Exception- if the route definition could not be removed for whatever reason
-
getRouteDefinitions
public List<RouteDefinition> getRouteDefinitions()
Description copied from interface:ModelReturns a list of the current route definitions- Specified by:
getRouteDefinitionsin interfaceModel- Returns:
- list of the current route definitions
-
getRouteDefinition
public RouteDefinition getRouteDefinition(String id)
Description copied from interface:ModelGets the route definition with the given id- Specified by:
getRouteDefinitionin interfaceModel- Parameters:
id- id of the route- Returns:
- the route definition or null if not found
-
getRestDefinitions
public List<RestDefinition> getRestDefinitions()
Description copied from interface:ModelReturns a list of the current REST definitions- Specified by:
getRestDefinitionsin interfaceModel- Returns:
- list of the current REST definitions
-
addRestDefinitions
public void addRestDefinitions(Collection<RestDefinition> restDefinitions, boolean addToRoutes) throws Exception
Description copied from interface:ModelAdds a collection of rest definitions to the context- Specified by:
addRestDefinitionsin interfaceModel- Parameters:
restDefinitions- the rest(s) definition to addaddToRoutes- whether the rests should also automatically be added as routes- Throws:
Exception- if the rest definitions could not be created for whatever reason
-
getServiceCallConfiguration
public ServiceCallConfigurationDefinition getServiceCallConfiguration(String serviceName)
Description copied from interface:ModelGets the service call configuration by the given name. If no name is given the default configuration is returned, see setServiceCallConfiguration- Specified by:
getServiceCallConfigurationin interfaceModel- Parameters:
serviceName- name of service, or null to return the default configuration- Returns:
- the configuration, or null if no configuration has been registered
-
setServiceCallConfiguration
public void setServiceCallConfiguration(ServiceCallConfigurationDefinition configuration)
Description copied from interface:ModelSets the default service call configuration- Specified by:
setServiceCallConfigurationin interfaceModel- Parameters:
configuration- the configuration
-
setServiceCallConfigurations
public void setServiceCallConfigurations(List<ServiceCallConfigurationDefinition> configurations)
Description copied from interface:ModelSets the service call configurations- Specified by:
setServiceCallConfigurationsin interfaceModel- Parameters:
configurations- the configuration list
-
addServiceCallConfiguration
public void addServiceCallConfiguration(String serviceName, ServiceCallConfigurationDefinition configuration)
Description copied from interface:ModelAdds the service call configuration- Specified by:
addServiceCallConfigurationin interfaceModel- Parameters:
serviceName- name of the serviceconfiguration- the configuration
-
getHystrixConfiguration
public HystrixConfigurationDefinition getHystrixConfiguration(String id)
Description copied from interface:ModelGets the Hystrix configuration by the given name. If no name is given the default configuration is returned, see setHystrixConfiguration- Specified by:
getHystrixConfigurationin interfaceModel- Parameters:
id- id of the configuration, or null to return the default configuration- Returns:
- the configuration, or null if no configuration has been registered
-
setHystrixConfiguration
public void setHystrixConfiguration(HystrixConfigurationDefinition configuration)
Description copied from interface:ModelSets the default Hystrix configuration- Specified by:
setHystrixConfigurationin interfaceModel- Parameters:
configuration- the configuration
-
setHystrixConfigurations
public void setHystrixConfigurations(List<HystrixConfigurationDefinition> configurations)
Description copied from interface:ModelSets the Hystrix configurations- Specified by:
setHystrixConfigurationsin interfaceModel- Parameters:
configurations- the configuration list
-
addHystrixConfiguration
public void addHystrixConfiguration(String id, HystrixConfigurationDefinition configuration)
Description copied from interface:ModelAdds the Hystrix configuration- Specified by:
addHystrixConfigurationin interfaceModel- Parameters:
id- name of the configurationconfiguration- the configuration
-
getResilience4jConfiguration
public Resilience4jConfigurationDefinition getResilience4jConfiguration(String id)
Description copied from interface:ModelGets the Resilience4j configuration by the given name. If no name is given the default configuration is returned, see setResilience4jConfiguration- Specified by:
getResilience4jConfigurationin interfaceModel- Parameters:
id- id of the configuration, or null to return the default configuration- Returns:
- the configuration, or null if no configuration has been registered
-
setResilience4jConfiguration
public void setResilience4jConfiguration(Resilience4jConfigurationDefinition configuration)
Description copied from interface:ModelSets the default Resilience4j configuration- Specified by:
setResilience4jConfigurationin interfaceModel- Parameters:
configuration- the configuration
-
setResilience4jConfigurations
public void setResilience4jConfigurations(List<Resilience4jConfigurationDefinition> configurations)
Description copied from interface:ModelSets the Resilience4j configurations- Specified by:
setResilience4jConfigurationsin interfaceModel- Parameters:
configurations- the configuration list
-
addResilience4jConfiguration
public void addResilience4jConfiguration(String id, Resilience4jConfigurationDefinition configuration)
Description copied from interface:ModelAdds the Resilience4j configuration- Specified by:
addResilience4jConfigurationin interfaceModel- Parameters:
id- name of the configurationconfiguration- the configuration
-
getFaultToleranceConfiguration
public FaultToleranceConfigurationDefinition getFaultToleranceConfiguration(String id)
Description copied from interface:ModelGets the MicroProfile Fault Tolerance configuration by the given name. If no name is given the default configuration is returned, see setFaultToleranceConfigurationDefinition- Specified by:
getFaultToleranceConfigurationin interfaceModel- Parameters:
id- id of the configuration, or null to return the default configuration- Returns:
- the configuration, or null if no configuration has been registered
-
setFaultToleranceConfiguration
public void setFaultToleranceConfiguration(FaultToleranceConfigurationDefinition configuration)
Description copied from interface:ModelSets the default MicroProfile Fault Tolerance configuration- Specified by:
setFaultToleranceConfigurationin interfaceModel- Parameters:
configuration- the configuration
-
setFaultToleranceConfigurations
public void setFaultToleranceConfigurations(List<FaultToleranceConfigurationDefinition> configurations)
Description copied from interface:ModelSets the MicroProfile Fault Tolerance configurations- Specified by:
setFaultToleranceConfigurationsin interfaceModel- Parameters:
configurations- the configuration list
-
addFaultToleranceConfiguration
public void addFaultToleranceConfiguration(String id, FaultToleranceConfigurationDefinition configuration)
Description copied from interface:ModelAdds the MicroProfile Fault Tolerance configuration- Specified by:
addFaultToleranceConfigurationin interfaceModel- Parameters:
id- name of the configurationconfiguration- the configuration
-
resolveDataFormatDefinition
public DataFormatDefinition resolveDataFormatDefinition(String name)
Description copied from interface:ModelResolve a data format definition given its name- Specified by:
resolveDataFormatDefinitionin interfaceModel- Parameters:
name- the data format definition name or a reference to it in theRegistry- Returns:
- the resolved data format definition, or null if not found
-
getProcessorDefinition
public ProcessorDefinition<?> getProcessorDefinition(String id)
Description copied from interface:ModelGets the processor definition from any of the routes which with the given id- Specified by:
getProcessorDefinitionin interfaceModel- Parameters:
id- id of the processor definition- Returns:
- the processor definition or null if not found
-
getProcessorDefinition
public <T extends ProcessorDefinition<T>> T getProcessorDefinition(String id, Class<T> type)
Description copied from interface:ModelGets the processor definition from any of the routes which with the given id- Specified by:
getProcessorDefinitionin interfaceModel- Parameters:
id- id of the processor definitiontype- the processor definition type- Returns:
- the processor definition or null if not found
-
setDataFormats
public void setDataFormats(Map<String,DataFormatDefinition> dataFormats)
Description copied from interface:ModelSets the data formats that can be referenced in the routes.- Specified by:
setDataFormatsin interfaceModel- Parameters:
dataFormats- the data formats
-
getDataFormats
public Map<String,DataFormatDefinition> getDataFormats()
Description copied from interface:ModelGets the data formats that can be referenced in the routes.- Specified by:
getDataFormatsin interfaceModel- Returns:
- the data formats available
-
setTransformers
public void setTransformers(List<TransformerDefinition> transformers)
Description copied from interface:ModelSets the transformers that can be referenced in the routes.- Specified by:
setTransformersin interfaceModel- Parameters:
transformers- the transformers
-
getTransformers
public List<TransformerDefinition> getTransformers()
Description copied from interface:ModelGets the transformers that can be referenced in the routes.- Specified by:
getTransformersin interfaceModel- Returns:
- the transformers available
-
setValidators
public void setValidators(List<ValidatorDefinition> validators)
Description copied from interface:ModelSets the validators that can be referenced in the routes.- Specified by:
setValidatorsin interfaceModel- Parameters:
validators- the validators
-
getValidators
public List<ValidatorDefinition> getValidators()
Description copied from interface:ModelGets the validators that can be referenced in the routes.- Specified by:
getValidatorsin interfaceModel- Returns:
- the validators available
-
setRouteFilterPattern
public void setRouteFilterPattern(String include, String exclude)
Description copied from interface:ModelUsed 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 byPatternHelper.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.- Specified by:
setRouteFilterPatternin interfaceModel- Parameters:
include- the include patternexclude- the exclude pattern
-
getRouteFilter
public Function<RouteDefinition,Boolean> getRouteFilter()
Description copied from interface:ModelGets the current route filter- Specified by:
getRouteFilterin interfaceModel- Returns:
- the filter, or null if no custom filter has been configured.
-
setRouteFilter
public void setRouteFilter(Function<RouteDefinition,Boolean> routeFilter)
Description copied from interface:ModelSets a custom route filter to use for filtering unwanted routes when routes are added.- Specified by:
setRouteFilterin interfaceModel- Parameters:
routeFilter- the filter
-
shouldStartRoutes
protected boolean shouldStartRoutes()
Should we start newly added routes?
-
-