org.ow2.jonas.camel.component
Class RouteBuilderComponent

java.lang.Object
  extended by org.apache.camel.builder.BuilderSupport
      extended by org.apache.camel.builder.RouteBuilder
          extended by org.ow2.jonas.camel.component.RouteBuilderComponent
All Implemented Interfaces:
org.apache.camel.RoutesBuilder

public abstract class RouteBuilderComponent
extends org.apache.camel.builder.RouteBuilder

iPOJO component that creates a CAMEL context with:

In order to use it:


Field Summary
protected  org.osgi.framework.BundleContext bundleContext
          The OSGi bundle context.
protected  String camelContextName
          The Camel context name.
protected  ICamelService camelService
          The Camel service.
protected  Map<String,String> registryReplacements
          Replacements to do in the registry.
static String TRACE_LOGGER_NAME
           
protected  String traceDestination
          The external trace destination, might be null.
 
Fields inherited from class org.apache.camel.builder.RouteBuilder
log
 
Constructor Summary
RouteBuilderComponent(org.osgi.framework.BundleContext bundleContext)
          Saves the bundle context and gets the JONAS_BASE/conf folder.
 
Method Summary
 void configure()
          Configures the Camel context with the tracer.
protected  void configureCamelComponents(org.apache.camel.CamelContext camelContext, List<String> registryFilesContent)
          Configure CAMEL components, called just before registry injection.

By default, the jms component is configured to use the JCF connection factory on JNDI.

You can override this method to configure other components, for example jdbc.
 File getConfigurationFolder()
           
 File getFileEndpointFile(String url)
           
 String getRegistryPropertyOrReplacement(String key)
          Returns the value of a certain key in the contents of all camel*.properties files in JONAS_BASE/conf merged with registryReplacements.
 String getRouteName()
           
 void setCamelService(ICamelService camelService)
           
 void start()
          Start the Camel context.
 void stop()
          Stop the Camel context.
 
Methods inherited from class org.apache.camel.builder.RouteBuilder
addRoutes, addRoutesToCamelContext, checkInitialized, configureRoute, configureRoutes, createContainer, errorHandler, from, from, from, from, fromF, getContext, getRouteCollection, includeRoutes, intercept, interceptFrom, interceptFrom, interceptSendToEndpoint, onCompletion, onException, onException, populateRoutes, setErrorHandlerBuilder, setRouteCollection, toString
 
Methods inherited from class org.apache.camel.builder.BuilderSupport
bean, bean, bean, bean, body, body, constant, createErrorHandlerBuilder, deadLetterChannel, deadLetterChannel, defaultErrorHandler, endpoint, endpoint, endpoints, endpoints, exceptionMessage, faultBody, faultBodyAs, getErrorHandlerBuilder, header, loggingErrorHandler, loggingErrorHandler, loggingErrorHandler, loggingErrorHandler, method, method, method, method, noErrorHandler, outBody, outBody, property, regexReplaceAll, regexReplaceAll, sendTo, setContext, setContext, simple, simple, systemProperty, systemProperty, xpath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TRACE_LOGGER_NAME

public static final String TRACE_LOGGER_NAME
See Also:
Constant Field Values

bundleContext

protected org.osgi.framework.BundleContext bundleContext
The OSGi bundle context. Obtained via constructor.


camelService

protected ICamelService camelService
The Camel service. Injected by the container.


registryReplacements

protected Map<String,String> registryReplacements
Replacements to do in the registry.


camelContextName

protected String camelContextName
The Camel context name.


traceDestination

protected String traceDestination
The external trace destination, might be null.

Constructor Detail

RouteBuilderComponent

public RouteBuilderComponent(org.osgi.framework.BundleContext bundleContext)
Saves the bundle context and gets the JONAS_BASE/conf folder.

Method Detail

start

public void start()
           throws Throwable
Start the Camel context.

Throws:
Throwable

stop

public void stop()
          throws Throwable
Stop the Camel context.

Throws:
Throwable

configureCamelComponents

protected void configureCamelComponents(org.apache.camel.CamelContext camelContext,
                                        List<String> registryFilesContent)
                                 throws Exception
Configure CAMEL components, called just before registry injection.

By default, the jms component is configured to use the JCF connection factory on JNDI.

You can override this method to configure other components, for example jdbc.

Parameters:
camelContext - CAMEL context.
registryFilesContent - Actual contents of the CAMEL registry files (with all variables replaced).
Throws:
Exception

configure

public void configure()
               throws Exception
Configures the Camel context with the tracer.

Specified by:
configure in class org.apache.camel.builder.RouteBuilder
Throws:
Exception

setCamelService

public void setCamelService(ICamelService camelService)
Parameters:
camelService - Camel service to inject.

getConfigurationFolder

public final File getConfigurationFolder()
Returns:
The JONAS_BASE/conf folder.

getRegistryPropertyOrReplacement

public final String getRegistryPropertyOrReplacement(String key)
Returns the value of a certain key in the contents of all camel*.properties files in JONAS_BASE/conf merged with registryReplacements.

Parameters:
key - the key to look for.
Returns:
the corresponding value.
Throws:
IllegalArgumentException - if key not found.

getRouteName

public String getRouteName()
Returns:
The route bundle's symbolic name. This implementation generates the name based on the OSGi bundle JAR's location.

getFileEndpointFile

public File getFileEndpointFile(String url)
Returns:
The File object (source or target) of a Camel endpoint of type "file".


Copyright © 2013 OW2 Consortium. All Rights Reserved.