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:
$Revision: 751221 $

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 name, String injectionPointName, boolean mandatory)
          Evaluates the @EndpointInject annotation using the given context
<T> List<T>
getEndpoints(CamelContext camelContext, Class<T> type)
          Returns a list of all endpoints of the given type
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
<T> List<T>
getSingletonEndpoints(CamelContext camelContext, Class<T> type)
          Returns a list of all singleton endpoints of the given type
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 IllegalArgumentException 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 IllegalArgumentException 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 Expression resolveMandatoryExpression(CamelContext camelContext, String languageName, String expressionText)
          Resolves the mandatory language name and expression text into a Expression instance throwing an exception if it could not be created
static Language resolveMandatoryLanguage(CamelContext camelContext, String languageName)
          Resolves the given language name into a Language or throws an exception if it could not be converted
 
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


getEndpoints

public <T> List<T> getEndpoints(CamelContext camelContext,
                                Class<T> type)
Returns a list of all endpoints of the given type

Parameters:
camelContext - the camel context
type - the type of the endpoints requested
Returns:
a list which may be empty of all the endpoint instances of the given type

getSingletonEndpoints

public static <T> List<T> getSingletonEndpoints(CamelContext camelContext,
                                                Class<T> type)
Returns a list of all singleton endpoints of the given type

Parameters:
camelContext - the camel context
type - the type of the endpoints requested
Returns:
a list which may be empty of all the endpoint instances of the given type

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 IllegalArgumentException 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 IllegalArgumentException if not found.


resolveMandatoryLanguage

public static Language resolveMandatoryLanguage(CamelContext camelContext,
                                                String languageName)
Resolves the given language name into a Language or throws an exception if it could not be converted


resolveMandatoryExpression

public static Expression resolveMandatoryExpression(CamelContext camelContext,
                                                    String languageName,
                                                    String expressionText)
Resolves the mandatory language name and expression text into a Expression instance throwing an exception if it could not be created


getEndpointInjection

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



Apache CAMEL