Class ExchangeHelper

java.lang.Object
org.apache.camel.support.ExchangeHelper

public final class ExchangeHelper extends Object
Some helper methods for working with Exchange objects
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    convertToMandatoryType(org.apache.camel.Exchange exchange, Class<T> type, Object value)
    Converts the value to the given expected type or throws an exception
    static <T> T
    convertToType(org.apache.camel.Exchange exchange, Class<T> type, Object value)
    Converts the value to the given expected type
    static org.apache.camel.Exchange
    copyExchangeAndSetCamelContext(org.apache.camel.Exchange exchange, org.apache.camel.CamelContext context)
    Copies the exchange but the copy will be tied to the given context
    static org.apache.camel.Exchange
    copyExchangeAndSetCamelContext(org.apache.camel.Exchange exchange, org.apache.camel.CamelContext context, boolean handover)
    Copies the exchange but the copy will be tied to the given context
    static void
    copyResults(org.apache.camel.Exchange target, org.apache.camel.Exchange source)
    Copies the results of a message exchange from the source exchange to the result exchange which will copy the message contents, exchange properties and the exception.
    static void
    copyResultsPreservePattern(org.apache.camel.Exchange target, org.apache.camel.Exchange source)
    Copies the source exchange to target exchange preserving the ExchangePattern of target.
    static org.apache.camel.Exchange
    createCopy(org.apache.camel.Exchange exchange, boolean preserveExchangeId)
    Creates a new instance and copies from the current message exchange so that it can be forwarded to another destination as a new instance.
    static org.apache.camel.Exchange
    createCorrelatedCopy(org.apache.camel.Exchange exchange, boolean handover)
    Creates a new instance and copies from the current message exchange so that it can be forwarded to another destination as a new instance.
    static org.apache.camel.Exchange
    createCorrelatedCopy(org.apache.camel.Exchange exchange, boolean handover, boolean useSameMessageId)
    Creates a new instance and copies from the current message exchange so that it can be forwarded to another destination as a new instance.
    static Map<String,Object>
    createVariableMap(org.apache.camel.Exchange exchange, boolean allowContextMapAll)
    Creates a Map of the variables which are made available to a script or template
    static <T> T
    extractFutureBody(org.apache.camel.CamelContext context, Future<?> future, long timeout, TimeUnit unit, Class<T> type)
    Extracts the body from the given future, that represents a handle to an asynchronous exchange.
    static <T> T
    extractFutureBody(org.apache.camel.CamelContext context, Future<?> future, Class<T> type)
    Extracts the body from the given future, that represents a handle to an asynchronous exchange.
    static Object
    extractResultBody(org.apache.camel.Exchange exchange, org.apache.camel.ExchangePattern pattern)
    Extracts the body from the given exchange.
    static String
    getAtRouteId(org.apache.camel.Exchange exchange)
     
    static <T> T
    getBinding(org.apache.camel.Exchange exchange, Class<T> type)
    Extracts the Exchange.BINDING of the given type or null if not present
    static Charset
    getCharset(org.apache.camel.Exchange exchange)
     
    static Charset
    getCharset(org.apache.camel.Exchange exchange, boolean useDefault)
    Gets the charset if set as header or property Exchange.CHARSET_NAME.
    static String
    getCharsetName(org.apache.camel.Exchange exchange)
     
    static String
    getCharsetName(org.apache.camel.Exchange exchange, boolean useDefault)
    Gets the charset name if set as header or property Exchange.CHARSET_NAME.
    static String
    getContentEncoding(org.apache.camel.Exchange exchange)
    Returns the MIME content encoding on the input message or null if one is not defined
    static String
    getContentType(org.apache.camel.Exchange exchange)
    Returns the MIME content type on the input message or null if one is not defined
    static <T> T
    getHeaderOrProperty(org.apache.camel.Exchange exchange, String name, Class<T> type)
    Gets an header or property of the correct type
    static <T> T
    getMandatoryHeader(org.apache.camel.Exchange exchange, String headerName, Class<T> type)
    Gets the mandatory inbound header of the correct type
    static <T> T
    getMandatoryHeader(org.apache.camel.Message message, String headerName, Class<T> type)
    Gets the mandatory inbound header of the correct type
    static <T> T
    getMandatoryProperty(org.apache.camel.Exchange exchange, String propertyName, Class<T> type)
    Gets the mandatory property of the exchange of the correct type
    static org.apache.camel.Message
    getOriginalInMessage(org.apache.camel.Exchange exchange)
    Gets the original IN Message this Unit of Work was started with.
    static org.apache.camel.Message
    getResultMessage(org.apache.camel.Exchange exchange)
    Returns the message where to write results in an exchange-pattern-sensitive way.
    static org.apache.camel.Route
    getRoute(org.apache.camel.Exchange exchange)
     
    static String
    getRouteId(org.apache.camel.Exchange exchange)
     
    static org.apache.camel.util.Scanner
    getScanner(org.apache.camel.Exchange exchange, Object value, String delimiter)
    Creates a Scanner for scanning the given value.
    static boolean
    isErrorHandlerBridge(org.apache.camel.Exchange exchange)
    Checks whether the exchange has been error handler bridged
    static boolean
    isFailureHandled(org.apache.camel.Exchange exchange)
    Checks whether the exchange has been failure handed
    static boolean
    isOutCapable(org.apache.camel.Exchange exchange)
    Returns true if the given exchange pattern (if defined) can support OUT messages
    static boolean
    isRedelivered(org.apache.camel.Exchange exchange)
    Checks whether the exchange UnitOfWork is redelivered
    static boolean
    isStreamCachingEnabled(org.apache.camel.Exchange exchange)
    Check whether or not stream caching is enabled for the given route or globally.
    static boolean
    isUnitOfWorkExhausted(org.apache.camel.Exchange exchange)
    Checks whether the exchange UnitOfWork is exhausted
    static String
    logIds(org.apache.camel.Exchange exchange)
    Gets both the messageId and exchangeId to be used for logging purposes.
    static Object
    lookupBean(org.apache.camel.Exchange exchange, String name)
    Performs a lookup in the registry of the bean name
    static <T> T
    lookupBean(org.apache.camel.Exchange exchange, String name, Class<T> type)
    Performs a lookup in the registry of the bean name and type
    static Object
    lookupMandatoryBean(org.apache.camel.Exchange exchange, String name)
    Performs a lookup in the registry of the mandatory bean name and throws an exception if it could not be found
    static <T> T
    lookupMandatoryBean(org.apache.camel.Exchange exchange, String name, Class<T> type)
    Performs a lookup in the registry of the mandatory bean name and throws an exception if it could not be found
    static <T> T
    newInstance(org.apache.camel.Exchange exchange, Class<T> type)
    Creates a new instance of the given type from the injector
    static void
    populateVariableMap(org.apache.camel.Exchange exchange, Map<String,Object> map, boolean allowContextMapAll)
    Populates the Map with the variables which are made available to a script or template
    static void
    prepareAggregation(org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)
    Prepares the exchanges for aggregation.
    static void
    prepareOutToIn(org.apache.camel.Exchange exchange)
    Strategy to prepare results before next iterator or when we are complete, which is done by copying OUT to IN, so there is only an IN as input for the next iteration.
    static void
    replaceMessage(org.apache.camel.Exchange exchange, org.apache.camel.Message newMessage, boolean outOnly)
    Replaces the existing message with the new message
    static org.apache.camel.Endpoint
    resolveEndpoint(org.apache.camel.CamelContext context, Object value)
    Attempts to resolve the endpoint for the given value
    static org.apache.camel.Endpoint
    resolveEndpoint(org.apache.camel.Exchange exchange, Object value)
    Attempts to resolve the endpoint for the given value
    static org.apache.camel.Endpoint
    resolvePrototypeEndpoint(org.apache.camel.CamelContext context, Object value)
    Attempts to resolve the endpoint (prototype scope) for the given value
    static org.apache.camel.Endpoint
    resolvePrototypeEndpoint(org.apache.camel.Exchange exchange, Object value)
    Attempts to resolve the endpoint (prototype scope) for the given value
    static String
    Resolve the component scheme (aka name) from the given endpoint uri
    static void
    setFailureHandled(org.apache.camel.Exchange exchange)
    Sets the exchange to be failure handled.
    static void
    setInOutBodyPatternAware(org.apache.camel.Exchange exchange, Object body)
    Sets the body in message in the exchange taking the exchange pattern into consideration.
    static void
    setOutBodyPatternAware(org.apache.camel.Exchange exchange, Object body)
    Sets the body in message in the exchange taking the exchange pattern into consideration.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getBinding

      public static <T> T getBinding(org.apache.camel.Exchange exchange, Class<T> type)
      Extracts the Exchange.BINDING of the given type or null if not present
      Parameters:
      exchange - the message exchange
      type - the expected binding type
      Returns:
      the binding object of the given type or null if it could not be found or converted
    • resolveEndpoint

      public static org.apache.camel.Endpoint resolveEndpoint(org.apache.camel.Exchange exchange, Object value) throws org.apache.camel.NoSuchEndpointException
      Attempts to resolve the endpoint for the given value
      Parameters:
      exchange - the message exchange being processed
      value - the value which can be an Endpoint or an object which provides a String representation of an endpoint via Object.toString()
      Returns:
      the endpoint
      Throws:
      org.apache.camel.NoSuchEndpointException - if the endpoint cannot be resolved
    • resolveEndpoint

      public static org.apache.camel.Endpoint resolveEndpoint(org.apache.camel.CamelContext context, Object value) throws org.apache.camel.NoSuchEndpointException
      Attempts to resolve the endpoint for the given value
      Parameters:
      context - the camel context
      value - the value which can be an Endpoint or an object which provides a String representation of an endpoint via Object.toString()
      Returns:
      the endpoint
      Throws:
      org.apache.camel.NoSuchEndpointException - if the endpoint cannot be resolved
    • resolvePrototypeEndpoint

      public static org.apache.camel.Endpoint resolvePrototypeEndpoint(org.apache.camel.Exchange exchange, Object value) throws org.apache.camel.NoSuchEndpointException
      Attempts to resolve the endpoint (prototype scope) for the given value
      Parameters:
      exchange - the message exchange being processed
      value - the value which can be an Endpoint or an object which provides a String representation of an endpoint via Object.toString()
      Returns:
      the endpoint
      Throws:
      org.apache.camel.NoSuchEndpointException - if the endpoint cannot be resolved
    • resolvePrototypeEndpoint

      public static org.apache.camel.Endpoint resolvePrototypeEndpoint(org.apache.camel.CamelContext context, Object value) throws org.apache.camel.NoSuchEndpointException
      Attempts to resolve the endpoint (prototype scope) for the given value
      Parameters:
      context - the camel context
      value - the value which can be an Endpoint or an object which provides a String representation of an endpoint via Object.toString()
      Returns:
      the endpoint
      Throws:
      org.apache.camel.NoSuchEndpointException - if the endpoint cannot be resolved
    • getMandatoryProperty

      public static <T> T getMandatoryProperty(org.apache.camel.Exchange exchange, String propertyName, Class<T> type) throws org.apache.camel.NoSuchPropertyException
      Gets the mandatory property of the exchange of the correct type
      Parameters:
      exchange - the exchange
      propertyName - the property name
      type - the type
      Returns:
      the property value
      Throws:
      org.apache.camel.TypeConversionException - is thrown if error during type conversion
      org.apache.camel.NoSuchPropertyException - is thrown if no property exists
    • getMandatoryHeader

      public static <T> T getMandatoryHeader(org.apache.camel.Exchange exchange, String headerName, Class<T> type) throws org.apache.camel.TypeConversionException, org.apache.camel.NoSuchHeaderException
      Gets the mandatory inbound header of the correct type
      Parameters:
      exchange - the exchange
      headerName - the header name
      type - the type
      Returns:
      the header value
      Throws:
      org.apache.camel.TypeConversionException - is thrown if error during type conversion
      org.apache.camel.NoSuchHeaderException - is thrown if no headers exists
    • getMandatoryHeader

      public static <T> T getMandatoryHeader(org.apache.camel.Message message, String headerName, Class<T> type) throws org.apache.camel.TypeConversionException, org.apache.camel.NoSuchHeaderException
      Gets the mandatory inbound header of the correct type
      Parameters:
      message - the message
      headerName - the header name
      type - the type
      Returns:
      the header value
      Throws:
      org.apache.camel.TypeConversionException - is thrown if error during type conversion
      org.apache.camel.NoSuchHeaderException - is thrown if no headers exists
    • getHeaderOrProperty

      public static <T> T getHeaderOrProperty(org.apache.camel.Exchange exchange, String name, Class<T> type) throws org.apache.camel.TypeConversionException
      Gets an header or property of the correct type
      Parameters:
      exchange - the exchange
      name - the name of the header or the property
      type - the type
      Returns:
      the header or property value
      Throws:
      org.apache.camel.TypeConversionException - is thrown if error during type conversion
      org.apache.camel.NoSuchHeaderException - is thrown if no headers exists
    • convertToMandatoryType

      public static <T> T convertToMandatoryType(org.apache.camel.Exchange exchange, Class<T> type, Object value) throws org.apache.camel.TypeConversionException, org.apache.camel.NoTypeConversionAvailableException
      Converts the value to the given expected type or throws an exception
      Returns:
      the converted value
      Throws:
      org.apache.camel.TypeConversionException - is thrown if error during type conversion
      org.apache.camel.NoTypeConversionAvailableException - } if no type converters exists to convert to the given type
    • convertToType

      public static <T> T convertToType(org.apache.camel.Exchange exchange, Class<T> type, Object value) throws org.apache.camel.TypeConversionException
      Converts the value to the given expected type
      Returns:
      the converted value
      Throws:
      org.apache.camel.TypeConversionException - is thrown if error during type conversion
    • createCorrelatedCopy

      public static org.apache.camel.Exchange createCorrelatedCopy(org.apache.camel.Exchange exchange, boolean handover)
      Creates a new instance and copies from the current message exchange so that it can be forwarded to another destination as a new instance. Unlike regular copy this operation will not share the same UnitOfWork so its should be used for async messaging, where the original and copied exchange are independent.
      Parameters:
      exchange - original copy of the exchange
      handover - whether the on completion callbacks should be handed over to the new copy.
    • createCorrelatedCopy

      public static org.apache.camel.Exchange createCorrelatedCopy(org.apache.camel.Exchange exchange, boolean handover, boolean useSameMessageId)
      Creates a new instance and copies from the current message exchange so that it can be forwarded to another destination as a new instance. Unlike regular copy this operation will not share the same UnitOfWork so its should be used for async messaging, where the original and copied exchange are independent.
      Parameters:
      exchange - original copy of the exchange
      handover - whether the on completion callbacks should be handed over to the new copy.
      useSameMessageId - whether to use same message id on the copy message.
    • createCopy

      public static org.apache.camel.Exchange createCopy(org.apache.camel.Exchange exchange, boolean preserveExchangeId)
      Creates a new instance and copies from the current message exchange so that it can be forwarded to another destination as a new instance.
      Parameters:
      exchange - original copy of the exchange
      preserveExchangeId - whether or not the exchange id should be preserved
      Returns:
      the copy
    • copyResults

      public static void copyResults(org.apache.camel.Exchange target, org.apache.camel.Exchange source)
      Copies the results of a message exchange from the source exchange to the result exchange which will copy the message contents, exchange properties and the exception. Notice the ExchangePattern is not copied/altered.
      Parameters:
      target - the target exchange which will have the output and error state added (result)
      source - the source exchange which is not modified
    • copyResultsPreservePattern

      public static void copyResultsPreservePattern(org.apache.camel.Exchange target, org.apache.camel.Exchange source)
      Copies the source exchange to target exchange preserving the ExchangePattern of target.
      Parameters:
      target - the target exchange which will have the output and error state added (result)
      source - source exchange.
    • getResultMessage

      public static org.apache.camel.Message getResultMessage(org.apache.camel.Exchange exchange)
      Returns the message where to write results in an exchange-pattern-sensitive way.
      Parameters:
      exchange - message exchange.
      Returns:
      result message.
    • isOutCapable

      public static boolean isOutCapable(org.apache.camel.Exchange exchange)
      Returns true if the given exchange pattern (if defined) can support OUT messages
      Parameters:
      exchange - the exchange to interrogate
      Returns:
      true if the exchange is defined as an ExchangePattern which supports OUT messages
    • newInstance

      public static <T> T newInstance(org.apache.camel.Exchange exchange, Class<T> type)
      Creates a new instance of the given type from the injector
      Parameters:
      exchange - the exchange
      type - the given type
      Returns:
      the created instance of the given type
    • createVariableMap

      public static Map<String,Object> createVariableMap(org.apache.camel.Exchange exchange, boolean allowContextMapAll)
      Creates a Map of the variables which are made available to a script or template
      Parameters:
      exchange - the exchange to make available
      allowContextMapAll - whether to allow access to all context map or not (prefer to use false due to security reasons preferred to only allow access to body/headers)
      Returns:
      a Map populated with the require variables
    • populateVariableMap

      public static void populateVariableMap(org.apache.camel.Exchange exchange, Map<String,Object> map, boolean allowContextMapAll)
      Populates the Map with the variables which are made available to a script or template
      Parameters:
      exchange - the exchange to make available
      map - the map to populate
      allowContextMapAll - whether to allow access to all context map or not (prefer to use false due to security reasons preferred to only allow access to body/headers)
    • getContentType

      public static String getContentType(org.apache.camel.Exchange exchange)
      Returns the MIME content type on the input message or null if one is not defined
      Parameters:
      exchange - the exchange
      Returns:
      the MIME content type
    • getContentEncoding

      public static String getContentEncoding(org.apache.camel.Exchange exchange)
      Returns the MIME content encoding on the input message or null if one is not defined
      Parameters:
      exchange - the exchange
      Returns:
      the MIME content encoding
    • lookupMandatoryBean

      public static Object lookupMandatoryBean(org.apache.camel.Exchange exchange, String name) throws org.apache.camel.NoSuchBeanException
      Performs a lookup in the registry of the mandatory bean name and throws an exception if it could not be found
      Parameters:
      exchange - the exchange
      name - the bean name
      Returns:
      the bean
      Throws:
      org.apache.camel.NoSuchBeanException - if no bean could be found in the registry
    • lookupMandatoryBean

      public static <T> T lookupMandatoryBean(org.apache.camel.Exchange exchange, String name, Class<T> type)
      Performs a lookup in the registry of the mandatory bean name and throws an exception if it could not be found
      Parameters:
      exchange - the exchange
      name - the bean name
      type - the expected bean type
      Returns:
      the bean
      Throws:
      org.apache.camel.NoSuchBeanException - if no bean could be found in the registry
    • lookupBean

      public static Object lookupBean(org.apache.camel.Exchange exchange, String name)
      Performs a lookup in the registry of the bean name
      Parameters:
      exchange - the exchange
      name - the bean name
      Returns:
      the bean, or null if no bean could be found
    • lookupBean

      public static <T> T lookupBean(org.apache.camel.Exchange exchange, String name, Class<T> type)
      Performs a lookup in the registry of the bean name and type
      Parameters:
      exchange - the exchange
      name - the bean name
      type - the expected bean type
      Returns:
      the bean, or null if no bean could be found
    • prepareAggregation

      public static void prepareAggregation(org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)
      Prepares the exchanges for aggregation.

      This implementation will copy the OUT body to the IN body so when you do aggregation the body is only in the IN body to avoid confusing end users.

      Parameters:
      oldExchange - the old exchange
      newExchange - the new exchange
    • isFailureHandled

      public static boolean isFailureHandled(org.apache.camel.Exchange exchange)
      Checks whether the exchange has been failure handed
      Parameters:
      exchange - the exchange
      Returns:
      true if failure handled, false otherwise
    • isErrorHandlerBridge

      public static boolean isErrorHandlerBridge(org.apache.camel.Exchange exchange)
      Checks whether the exchange has been error handler bridged
      Parameters:
      exchange - the exchange
      Returns:
      true if error handler bridged, false otherwise
    • isUnitOfWorkExhausted

      public static boolean isUnitOfWorkExhausted(org.apache.camel.Exchange exchange)
      Checks whether the exchange UnitOfWork is exhausted
      Parameters:
      exchange - the exchange
      Returns:
      true if exhausted, false otherwise
    • setFailureHandled

      public static void setFailureHandled(org.apache.camel.Exchange exchange)
      Sets the exchange to be failure handled.
      Parameters:
      exchange - the exchange
    • isRedelivered

      public static boolean isRedelivered(org.apache.camel.Exchange exchange)
      Checks whether the exchange UnitOfWork is redelivered
      Parameters:
      exchange - the exchange
      Returns:
      true if redelivered, false otherwise
    • isStreamCachingEnabled

      public static boolean isStreamCachingEnabled(org.apache.camel.Exchange exchange)
      Check whether or not stream caching is enabled for the given route or globally.
      Parameters:
      exchange - the exchange
      Returns:
      true if enabled, false otherwise
    • extractResultBody

      public static Object extractResultBody(org.apache.camel.Exchange exchange, org.apache.camel.ExchangePattern pattern)
      Extracts the body from the given exchange.

      If the exchange pattern is provided it will try to honor it and retrieve the body from either IN or OUT according to the pattern.

      Parameters:
      exchange - the exchange
      pattern - exchange pattern if given, can be null
      Returns:
      the result body, can be null.
      Throws:
      org.apache.camel.CamelExecutionException - is thrown if the processing of the exchange failed
    • extractFutureBody

      public static <T> T extractFutureBody(org.apache.camel.CamelContext context, Future<?> future, Class<T> type)
      Extracts the body from the given future, that represents a handle to an asynchronous exchange.

      Will wait until the future task is complete.

      Parameters:
      context - the camel context
      future - the future handle
      type - the expected body response type
      Returns:
      the result body, can be null.
      Throws:
      org.apache.camel.CamelExecutionException - is thrown if the processing of the exchange failed
    • extractFutureBody

      public static <T> T extractFutureBody(org.apache.camel.CamelContext context, Future<?> future, long timeout, TimeUnit unit, Class<T> type) throws TimeoutException
      Extracts the body from the given future, that represents a handle to an asynchronous exchange.

      Will wait for the future task to complete, but waiting at most the timeout value.

      Parameters:
      context - the camel context
      future - the future handle
      timeout - timeout value
      unit - timeout unit
      type - the expected body response type
      Returns:
      the result body, can be null.
      Throws:
      org.apache.camel.CamelExecutionException - is thrown if the processing of the exchange failed
      TimeoutException - is thrown if a timeout triggered
    • prepareOutToIn

      public static void prepareOutToIn(org.apache.camel.Exchange exchange)
      Strategy to prepare results before next iterator or when we are complete, which is done by copying OUT to IN, so there is only an IN as input for the next iteration.
      Parameters:
      exchange - the exchange to prepare
    • logIds

      public static String logIds(org.apache.camel.Exchange exchange)
      Gets both the messageId and exchangeId to be used for logging purposes.

      Logging both ids, can help to correlate exchanges which may be redelivered messages from for example a JMS broker.

      Parameters:
      exchange - the exchange
      Returns:
      a log message with both the messageId and exchangeId
    • copyExchangeAndSetCamelContext

      public static org.apache.camel.Exchange copyExchangeAndSetCamelContext(org.apache.camel.Exchange exchange, org.apache.camel.CamelContext context)
      Copies the exchange but the copy will be tied to the given context
      Parameters:
      exchange - the source exchange
      context - the camel context
      Returns:
      a copy with the given camel context
    • copyExchangeAndSetCamelContext

      public static org.apache.camel.Exchange copyExchangeAndSetCamelContext(org.apache.camel.Exchange exchange, org.apache.camel.CamelContext context, boolean handover)
      Copies the exchange but the copy will be tied to the given context
      Parameters:
      exchange - the source exchange
      context - the camel context
      handover - whether to handover on completions from the source to the copy
      Returns:
      a copy with the given camel context
    • replaceMessage

      public static void replaceMessage(org.apache.camel.Exchange exchange, org.apache.camel.Message newMessage, boolean outOnly)
      Replaces the existing message with the new message
      Parameters:
      exchange - the exchange
      newMessage - the new message
      outOnly - whether to replace the message as OUT message
    • getOriginalInMessage

      public static org.apache.camel.Message getOriginalInMessage(org.apache.camel.Exchange exchange)
      Gets the original IN Message this Unit of Work was started with.

      The original message is only returned if the option RuntimeConfiguration.isAllowUseOriginalMessage() is enabled. If it is disabled, then IllegalStateException is thrown.

      Returns:
      the original IN Message
    • resolveScheme

      public static String resolveScheme(String uri)
      Resolve the component scheme (aka name) from the given endpoint uri
      Parameters:
      uri - the endpoint uri
      Returns:
      the component scheme (name), or null if not possible to resolve
    • getCharsetName

      public static String getCharsetName(org.apache.camel.Exchange exchange)
      See Also:
    • getCharset

      public static Charset getCharset(org.apache.camel.Exchange exchange)
      See Also:
    • getCharsetName

      public static String getCharsetName(org.apache.camel.Exchange exchange, boolean useDefault)
      Gets the charset name if set as header or property Exchange.CHARSET_NAME. Notice: The lookup from the header has priority over the property.
      Parameters:
      exchange - the exchange
      useDefault - should we fallback and use JVM default charset if no property existed?
      Returns:
      the charset, or null if no found
    • getCharset

      public static Charset getCharset(org.apache.camel.Exchange exchange, boolean useDefault)
      Gets the charset if set as header or property Exchange.CHARSET_NAME. Notice: The lookup from the header has priority over the property.
      Parameters:
      exchange - the exchange
      useDefault - should we fallback and use JVM default charset if no property existed?
      Returns:
      the charset, or null if no found
    • getScanner

      public static org.apache.camel.util.Scanner getScanner(org.apache.camel.Exchange exchange, Object value, String delimiter)
      Creates a Scanner for scanning the given value.
      Parameters:
      exchange - the current exchange
      value - the value, typically the message IN body
      delimiter - the delimiter pattern to use
      Returns:
      the scanner, is newer null
    • getRouteId

      public static String getRouteId(org.apache.camel.Exchange exchange)
    • getAtRouteId

      public static String getAtRouteId(org.apache.camel.Exchange exchange)
    • getRoute

      public static org.apache.camel.Route getRoute(org.apache.camel.Exchange exchange)
    • setInOutBodyPatternAware

      public static void setInOutBodyPatternAware(org.apache.camel.Exchange exchange, Object body)
      Sets the body in message in the exchange taking the exchange pattern into consideration. If the pattern is out capable, then the body is set outbound message. Otherwise it is set on the inbound message.
      Parameters:
      exchange - the exchange containing the message to set the body
      body - the body to set
    • setOutBodyPatternAware

      public static void setOutBodyPatternAware(org.apache.camel.Exchange exchange, Object body)
      Sets the body in message in the exchange taking the exchange pattern into consideration. If the pattern is out capable, then the body is set outbound message. Otherwise nothing is done.
      Parameters:
      exchange - the exchange containing the message to set the body
      body - the body to set