org.apache.camel.util
Class CamelContextHelper

java.lang.Object
  extended by org.apache.camel.util.CamelContextHelper

public final class CamelContextHelper
extends Object

A number of helper methods

Version:

Method Summary
static
<T> T
convertTo(CamelContext context, Class<T> type, Object value)
          Converts the given value to the requested type
static Endpoint getEndpointInjection(CamelContext camelContext, String uri, String ref, String injectionPointName, boolean mandatory)
          Evaluates the @EndpointInject annotation using the given context
static Endpoint getMandatoryEndpoint(CamelContext camelContext, String uri)
          Returns the mandatory endpoint for the given URI or the NoSuchEndpointException is thrown
static
<T extends Endpoint>
T
getMandatoryEndpoint(CamelContext camelContext, String uri, Class<T> type)
          Returns the mandatory endpoint for the given URI and type or the NoSuchEndpointException is thrown
static int getMaximumCachePoolSize(CamelContext camelContext)
          Gets the maximum cache pool size.
static int getMaximumEndpointCacheSize(CamelContext camelContext)
          Gets the maximum endpoint cache size.
static Object lookup(CamelContext context, String name)
          Look up the given named bean in the Registry on the CamelContext
static
<T> T
lookup(CamelContext context, String name, Class<T> beanType)
          Look up the given named bean of the given type in the Registry on the CamelContext
static
<T> T
mandatoryConvertTo(CamelContext context, Class<T> type, Object value)
          Converts the given value to the specified type throwing an IllegalArgumentException if the value could not be converted to a non null value
static Object mandatoryLookup(CamelContext context, String name)
          Look up the given named bean in the Registry on the CamelContext or throws NoSuchBeanException if not found.
static
<T> T
mandatoryLookup(CamelContext context, String name, Class<T> beanType)
          Look up the given named bean of the given type in the Registry on the CamelContext or throws NoSuchBeanException if not found.
static
<T> T
newInstance(CamelContext context, Class<T> beanType)
          Creates a new instance of the given type using the Injector on the given CamelContext
static Boolean parseBoolean(CamelContext camelContext, String text)
          Parses the given text and converts it to an Boolean and handling property placeholders as well
static Double parseDouble(CamelContext camelContext, String text)
          Parses the given text and converts it to a Double and handling property placeholders as well
static Integer parseInteger(CamelContext camelContext, String text)
          Parses the given text and converts it to an Integer and handling property placeholders as well
static Long parseLong(CamelContext camelContext, String text)
          Parses the given text and converts it to an Long and handling property placeholders as well
static String parseText(CamelContext camelContext, String text)
          Parses the given text and handling property placeholders as well
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getMandatoryEndpoint

public static Endpoint getMandatoryEndpoint(CamelContext camelContext,
                                            String uri)
                                     throws NoSuchEndpointException
Returns the mandatory endpoint for the given URI or the NoSuchEndpointException is thrown

Throws:
NoSuchEndpointException

getMandatoryEndpoint

public static <T extends Endpoint> T getMandatoryEndpoint(CamelContext camelContext,
                                                          String uri,
                                                          Class<T> type)
Returns the mandatory endpoint for the given URI and type or the NoSuchEndpointException is thrown


convertTo

public static <T> T convertTo(CamelContext context,
                              Class<T> type,
                              Object value)
Converts the given value to the requested type


mandatoryConvertTo

public static <T> T mandatoryConvertTo(CamelContext context,
                                       Class<T> type,
                                       Object value)
Converts the given value to the specified type throwing an IllegalArgumentException if the value could not be converted to a non null value


newInstance

public static <T> T newInstance(CamelContext context,
                                Class<T> beanType)
Creates a new instance of the given type using the Injector on the given CamelContext


lookup

public static Object lookup(CamelContext context,
                            String name)
Look up the given named bean in the Registry on the CamelContext


lookup

public static <T> T lookup(CamelContext context,
                           String name,
                           Class<T> beanType)
Look up the given named bean of the given type in the Registry on the CamelContext


mandatoryLookup

public static Object mandatoryLookup(CamelContext context,
                                     String name)
Look up the given named bean in the Registry on the CamelContext or throws NoSuchBeanException if not found.


mandatoryLookup

public static <T> T mandatoryLookup(CamelContext context,
                                    String name,
                                    Class<T> beanType)
Look up the given named bean of the given type in the Registry on the CamelContext or throws NoSuchBeanException if not found.


getEndpointInjection

public static Endpoint getEndpointInjection(CamelContext camelContext,
                                            String uri,
                                            String ref,
                                            String injectionPointName,
                                            boolean mandatory)
Evaluates the @EndpointInject annotation using the given context


getMaximumCachePoolSize

public static int getMaximumCachePoolSize(CamelContext camelContext)
                                   throws IllegalArgumentException
Gets the maximum cache pool size.

Will use the property set on CamelContext with the key Exchange.MAXIMUM_CACHE_POOL_SIZE. If no property has been set, then it will fallback to return a size of 1000.

Parameters:
camelContext - the camel context
Returns:
the maximum cache size
Throws:
IllegalArgumentException - is thrown if the property is illegal

getMaximumEndpointCacheSize

public static int getMaximumEndpointCacheSize(CamelContext camelContext)
                                       throws IllegalArgumentException
Gets the maximum endpoint cache size.

Will use the property set on CamelContext with the key Exchange.MAXIMUM_ENDPOINT_CACHE_SIZE. If no property has been set, then it will fallback to return a size of 1000.

Parameters:
camelContext - the camel context
Returns:
the maximum cache size
Throws:
IllegalArgumentException - is thrown if the property is illegal

parseText

public static String parseText(CamelContext camelContext,
                               String text)
                        throws Exception
Parses the given text and handling property placeholders as well

Parameters:
camelContext - the camel context
text - the text
Returns:
the parsed text, or null if the text was null
Throws:
Exception - is thrown if illegal argument

parseInteger

public static Integer parseInteger(CamelContext camelContext,
                                   String text)
                            throws Exception
Parses the given text and converts it to an Integer and handling property placeholders as well

Parameters:
camelContext - the camel context
text - the text
Returns:
the integer vale, or null if the text was null
Throws:
Exception - is thrown if illegal argument or type conversion not possible

parseLong

public static Long parseLong(CamelContext camelContext,
                             String text)
                      throws Exception
Parses the given text and converts it to an Long and handling property placeholders as well

Parameters:
camelContext - the camel context
text - the text
Returns:
the long vale, or null if the text was null
Throws:
Exception - is thrown if illegal argument or type conversion not possible

parseDouble

public static Double parseDouble(CamelContext camelContext,
                                 String text)
                          throws Exception
Parses the given text and converts it to a Double and handling property placeholders as well

Parameters:
camelContext - the camel context
text - the text
Returns:
the double vale, or null if the text was null
Throws:
Exception - is thrown if illegal argument or type conversion not possible

parseBoolean

public static Boolean parseBoolean(CamelContext camelContext,
                                   String text)
                            throws Exception
Parses the given text and converts it to an Boolean and handling property placeholders as well

Parameters:
camelContext - the camel context
text - the text
Returns:
the boolean vale, or null if the text was null
Throws:
Exception - is thrown if illegal argument or type conversion not possible


Apache CAMEL