public final class EndpointHelper extends Object
Endpoint
instancesModifier and Type | Method and Description |
---|---|
static String |
browseRangeMessagesAsXml(BrowsableEndpoint endpoint,
Integer fromIndex,
Integer toIndex,
Boolean includeBody)
Browses the
BrowsableEndpoint within the given range, and returns the messages as a XML payload. |
static String |
createEndpointId()
A helper method for Endpoint implementations to create new Ids for Endpoints which also implement
HasId |
static Map<String,Object> |
endpointProperties(CamelContext camelContext,
String uri)
Parses the endpoint uri and builds a map of documentation information for each option which is extracted
from the component json documentation
|
static String |
getRouteIdFromEndpoint(Endpoint endpoint)
Gets the route id for the given endpoint in which there is a consumer listening.
|
static boolean |
isReferenceParameter(String parameter)
Is the given parameter a reference parameter (starting with a # char)
|
static String |
lookupEndpointRegistryId(Endpoint endpoint)
Lookup the id the given endpoint has been enlisted with in the
Registry . |
static boolean |
matchEndpoint(CamelContext context,
String uri,
String pattern)
Matches the endpoint with the given pattern.
|
static boolean |
matchEndpoint(String uri,
String pattern)
Deprecated.
|
static boolean |
matchPattern(String name,
String pattern)
Matches the name with the given pattern.
|
static void |
pollEndpoint(Endpoint endpoint,
Processor processor)
Creates a
PollingConsumer and polls all pending messages on the
endpoint and invokes the given Processor to process each
Exchange and then closes down the consumer and throws any
exceptions thrown. |
static void |
pollEndpoint(Endpoint endpoint,
Processor processor,
long timeout)
Creates a
PollingConsumer and polls all pending messages on the endpoint
and invokes the given Processor to process each Exchange and then closes
down the consumer and throws any exceptions thrown. |
static <T> T |
resloveStringParameter(CamelContext context,
String value,
Class<T> type)
Deprecated.
|
static ExchangePattern |
resolveExchangePatternFromUrl(String url)
Attempts to resolve if the url has an exchangePattern option configured
|
static <T> T |
resolveParameter(CamelContext context,
String value,
Class<T> type)
Resolves a parameter, by doing a reference lookup if the parameter is a reference, and converting
the parameter to the given type.
|
static <T> List<T> |
resolveReferenceListParameter(CamelContext context,
String value,
Class<T> elementType)
Resolves a reference list parameter by making lookups in the registry.
|
static <T> T |
resolveReferenceParameter(CamelContext context,
String value,
Class<T> type)
Resolves a reference parameter by making a lookup in the registry.
|
static <T> T |
resolveReferenceParameter(CamelContext context,
String value,
Class<T> type,
boolean mandatory)
Resolves a reference parameter by making a lookup in the registry.
|
static void |
setProperties(CamelContext context,
Object bean,
Map<String,Object> parameters)
Sets the regular properties on the given bean
|
static void |
setReferenceProperties(CamelContext context,
Object bean,
Map<String,Object> parameters)
Sets the reference properties on the given bean
This is convention over configuration, setting all reference parameters (using
isReferenceParameter(String)
by looking it up in registry and setting it on the bean if possible. |
public static void pollEndpoint(Endpoint endpoint, Processor processor, long timeout) throws Exception
PollingConsumer
and polls all pending messages on the endpoint
and invokes the given Processor
to process each Exchange
and then closes
down the consumer and throws any exceptions thrown.Exception
public static void pollEndpoint(Endpoint endpoint, Processor processor) throws Exception
PollingConsumer
and polls all pending messages on the
endpoint and invokes the given Processor
to process each
Exchange
and then closes down the consumer and throws any
exceptions thrown.Exception
public static boolean matchEndpoint(CamelContext context, String uri, String pattern)
CamelContext.resolvePropertyPlaceholders(String)
.
The match rules are applied in this order:
context
- the Camel context, if null then property placeholder resolution is skipped.uri
- the endpoint uripattern
- a pattern to match@Deprecated public static boolean matchEndpoint(String uri, String pattern)
matchEndpoint(org.apache.camel.CamelContext, String, String)
instead.public static boolean matchPattern(String name, String pattern)
name
- the namepattern
- a pattern to matchpublic static void setProperties(CamelContext context, Object bean, Map<String,Object> parameters) throws Exception
context
- the camel contextbean
- the beanparameters
- parametersException
- is thrown if setting property failspublic static void setReferenceProperties(CamelContext context, Object bean, Map<String,Object> parameters) throws Exception
isReferenceParameter(String)
by looking it up in registry and setting it on the bean if possible.context
- the camel contextbean
- the beanparameters
- parametersException
- is thrown if setting property failspublic static boolean isReferenceParameter(String parameter)
parameter
- the parameterpublic static <T> T resolveReferenceParameter(CamelContext context, String value, Class<T> type)
T
- type of object to lookup.context
- Camel context to use for lookup.value
- reference parameter value.type
- type of object to lookup.IllegalArgumentException
- if referenced object was not found in registry.public static <T> T resolveReferenceParameter(CamelContext context, String value, Class<T> type, boolean mandatory)
T
- type of object to lookup.context
- Camel context to use for lookup.value
- reference parameter value.type
- type of object to lookup.null
only if
mandatory
is false
).IllegalArgumentException
- if object was not found in registry and
mandatory
is true
.public static <T> List<T> resolveReferenceListParameter(CamelContext context, String value, Class<T> elementType)
context
- Camel context to use for lookup.value
- reference parameter value.elementType
- result list element type.IllegalArgumentException
- if any referenced object was not found in registry.public static <T> T resolveParameter(CamelContext context, String value, Class<T> type)
T
- type of object to convert the parameter value as.context
- Camel context to use for lookup.value
- parameter or reference parameter value.type
- type of object to lookup.IllegalArgumentException
- if referenced object was not found in registry.@Deprecated public static <T> T resloveStringParameter(CamelContext context, String value, Class<T> type)
resolveParameter(org.apache.camel.CamelContext, String, Class)
public static String getRouteIdFromEndpoint(Endpoint endpoint)
endpoint
- the endpointpublic static String createEndpointId()
HasId
public static String lookupEndpointRegistryId(Endpoint endpoint)
Registry
.endpoint
- the endpointpublic static String browseRangeMessagesAsXml(BrowsableEndpoint endpoint, Integer fromIndex, Integer toIndex, Boolean includeBody)
BrowsableEndpoint
within the given range, and returns the messages as a XML payload.endpoint
- the browsable endpointfromIndex
- from rangetoIndex
- to rangeincludeBody
- whether to include the message body in the XML payloadIllegalArgumentException
- if the from and to range is invalidMessageHelper.dumpAsXml(org.apache.camel.Message)
public static ExchangePattern resolveExchangePatternFromUrl(String url) throws URISyntaxException
url
- the urlURISyntaxException
- is thrown if uri is invalidpublic static Map<String,Object> endpointProperties(CamelContext camelContext, String uri) throws Exception
camelContext
- the Camel contexturi
- the endpoint uriException
- is thrown in case of errorApache Camel