public abstract class DefaultComponent extends ServiceSupport implements Component
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Constructor and Description |
---|
DefaultComponent() |
DefaultComponent(CamelContext context) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterConfiguration(String uri,
String remaining,
Endpoint endpoint,
Map<String,Object> parameters)
Strategy to do post configuration logic.
|
ComponentConfiguration |
createComponentConfiguration()
Creates a configuration helper object for a component that lets you configure the various
URI and parameter values; then create the full URI for it, create a new Endpoint from it
or configure an existing Endpoint from the values.
|
EndpointConfiguration |
createConfiguration(String uri)
Attempt to create a configuration object from the given uri
|
Endpoint |
createEndpoint(String uri)
Attempt to resolve an endpoint for the given URI if the component is
capable of handling the URI.
|
protected abstract Endpoint |
createEndpoint(String uri,
String remaining,
Map<String,Object> parameters)
A factory method allowing derived components to create a new endpoint
from the given URI, remaining path and optional parameters
|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
<T> T |
getAndRemoveParameter(Map<String,Object> parameters,
String key,
Class<T> type)
Gets the parameter and remove it from the parameter map.
|
<T> T |
getAndRemoveParameter(Map<String,Object> parameters,
String key,
Class<T> type,
T defaultValue)
Gets the parameter and remove it from the parameter map.
|
CamelContext |
getCamelContext()
Get the
CamelContext |
protected String |
ifStartsWithReturnRemainder(String prefix,
String text)
Returns the reminder of the text if it starts with the prefix.
|
protected String |
preProcessUri(String uri)
Deprecated.
|
<T> List<T> |
resolveAndRemoveReferenceListParameter(Map<String,Object> parameters,
String key,
Class<T> elementType)
Resolves a reference list parameter in the registry and removes it from
the map.
|
<T> List<T> |
resolveAndRemoveReferenceListParameter(Map<String,Object> parameters,
String key,
Class<T> elementType,
List<T> defaultValue)
Resolves a reference list parameter in the registry and removes it from
the map.
|
<T> T |
resolveAndRemoveReferenceParameter(Map<String,Object> parameters,
String key,
Class<T> type)
Resolves a reference parameter in the registry and removes it from the map.
|
<T> T |
resolveAndRemoveReferenceParameter(Map<String,Object> parameters,
String key,
Class<T> type,
T defaultValue)
Resolves a reference parameter in the registry and removes it from the map.
|
void |
setCamelContext(CamelContext context)
Injects the
CamelContext |
protected void |
setProperties(Object bean,
Map<String,Object> parameters)
Sets the bean properties on the given bean
|
protected boolean |
useIntrospectionOnEndpoint()
Derived classes may wish to overload this to prevent the default introspection of URI parameters
on the created Endpoint instance
|
boolean |
useRawUri()
Whether to use raw or encoded uri, when creating endpoints.
|
protected void |
validateParameters(String uri,
Map<String,Object> parameters,
String optionPrefix)
Strategy for validation of parameters, that was not able to be resolved to any endpoint options.
|
protected void |
validateURI(String uri,
String path,
Map<String,Object> parameters)
Strategy for validation of the uri when creating the endpoint.
|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
public DefaultComponent()
public DefaultComponent(CamelContext context)
@Deprecated protected String preProcessUri(String uri)
public Endpoint createEndpoint(String uri) throws Exception
Component
Component.useRawUri()
for controlling whether the passed in uri
should be as-is (raw), or encoded (default).createEndpoint
in interface Component
uri
- the URI to create; either raw or encoded (default)Endpoint
or null if this component cannot create
Endpoint
instances using the given uriException
- is thrown if error creating the endpointComponent.useRawUri()
public ComponentConfiguration createComponentConfiguration()
Component
createComponentConfiguration
in interface Component
public EndpointConfiguration createConfiguration(String uri) throws Exception
Component
createConfiguration
in interface Component
uri
- the configuration URIEndpointConfiguration
Exception
- is thrown if the configuration URI is invalidpublic boolean useRawUri()
Component
protected void afterConfiguration(String uri, String remaining, Endpoint endpoint, Map<String,Object> parameters) throws Exception
uri
- the uriremaining
- the remaining part of the URI without the query parameters or component prefixendpoint
- the created endpointparameters
- the remaining parameters after the endpoint has been created and parsed the parametersException
- can be thrown to indicate error creating the endpointprotected void validateParameters(String uri, Map<String,Object> parameters, String optionPrefix)
uri
- the uriparameters
- the parameters, an empty map if no parameters givenoptionPrefix
- optional prefix to filter the parameters for validation. Use null for validate all.ResolveEndpointFailedException
- should be thrown if the URI validation failedprotected void validateURI(String uri, String path, Map<String,Object> parameters)
uri
- the uripath
- the path - part after the schemeparameters
- the parameters, an empty map if no parameters givenResolveEndpointFailedException
- should be thrown if the URI validation failedpublic CamelContext getCamelContext()
CamelContextAware
CamelContext
getCamelContext
in interface CamelContextAware
public void setCamelContext(CamelContext context)
CamelContextAware
CamelContext
setCamelContext
in interface CamelContextAware
context
- the Camel contextprotected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
protected abstract Endpoint createEndpoint(String uri, String remaining, Map<String,Object> parameters) throws Exception
uri
- the full URI of the endpointremaining
- the remaining part of the URI without the query
parameters or component prefixparameters
- the optional parameters passed inException
- is thrown if error creating the endpointprotected void setProperties(Object bean, Map<String,Object> parameters) throws Exception
bean
- the beanparameters
- properties to setException
protected boolean useIntrospectionOnEndpoint()
public <T> T getAndRemoveParameter(Map<String,Object> parameters, String key, Class<T> type)
parameters
- the parameterskey
- the keytype
- the requested type to convert the value from the parameterresolveAndRemoveReferenceParameter(Map, String, Class)
public <T> T getAndRemoveParameter(Map<String,Object> parameters, String key, Class<T> type, T defaultValue)
parameters
- the parameterskey
- the keytype
- the requested type to convert the value from the parameterdefaultValue
- use this default value if the parameter does not contain the keyresolveAndRemoveReferenceParameter(Map, String, Class, Object)
public <T> T resolveAndRemoveReferenceParameter(Map<String,Object> parameters, String key, Class<T> type)
T
- type of object to lookup in the registry.parameters
- parameter map.key
- parameter map key.type
- type of object to lookup in the registry.null
if the parameter map
doesn't contain the key.IllegalArgumentException
- if a non-null reference was not found in
registry.public <T> T resolveAndRemoveReferenceParameter(Map<String,Object> parameters, String key, Class<T> type, T defaultValue)
T
- type of object to lookup in the registry.parameters
- parameter map.key
- parameter map key.type
- type of object to lookup in the registry.defaultValue
- default value to use if the parameter map doesn't
contain the key.IllegalArgumentException
- if referenced object was not found in
registry.public <T> List<T> resolveAndRemoveReferenceListParameter(Map<String,Object> parameters, String key, Class<T> elementType)
parameters
- parameter map.key
- parameter map key.elementType
- result list element type.IllegalArgumentException
- if any of the referenced objects was
not found in registry.EndpointHelper.resolveReferenceListParameter(CamelContext, String, Class)
public <T> List<T> resolveAndRemoveReferenceListParameter(Map<String,Object> parameters, String key, Class<T> elementType, List<T> defaultValue)
parameters
- parameter map.key
- parameter map key.elementType
- result list element type.defaultValue
- default value to use if the parameter map doesn't
contain the key.IllegalArgumentException
- if any of the referenced objects was
not found in registry.EndpointHelper.resolveReferenceListParameter(CamelContext, String, Class)
protected String ifStartsWithReturnRemainder(String prefix, String text)
prefix
- the prefixtext
- the textApache Camel