org.ow2.jonas.camel.service.impl
Class CamelService

java.lang.Object
  extended by org.ow2.jonas.camel.service.impl.CamelService
All Implemented Interfaces:
ICamelService

public class CamelService
extends Object
implements ICamelService

Camel service.

Author:
Guillaume Renault

Constructor Summary
CamelService(org.osgi.framework.BundleContext context)
          Constructor, needed to get the bundle context.
 
Method Summary
 void addComponent(String componentName, org.apache.camel.Component component, String camelContextName)
          Add a component on the given camel context.
 void addRegistry(InputStream input, String camelContextName)
          Add values to the registry component.
 void addRoutes(org.apache.camel.builder.RouteBuilder builder, String camelContextName)
          Add a Route to the given context, by providing a RouteBuilder
 org.apache.camel.CamelContext getCamelContext(String name)
          Get an instance of Camel.
 List<String> getContextNames()
          Get the names of Camel contexts managed by the service.
 org.apache.camel.ProducerTemplate getProducerTemplate(String camelContextName)
          Get a producer template for the given camel context.
 List<org.apache.camel.model.RouteDefinition> getRouteDefinitions(String camelContextName)
          Get the list of existing routes.
 org.apache.camel.impl.SimpleRegistry getSimpleRegistryOfCamelContext(String name)
          Get a simple registry instance of Camel context.
 void removeRegistry(InputStream input, String camelContextName)
          Remove entries from the registry component.
 void start()
          Initializes the service.
 org.apache.camel.CamelContext startAndGetNewContext(org.osgi.framework.BundleContext bundleContext)
          Start a new camel context using a given OSGi BundleContext and return context.
 String startNewContext(org.osgi.framework.BundleContext bundleContext)
          Start a new camel context using a given OSGi BundleContext and return camel context name.
 void stop()
          Stops all Camel contexts.
 void stop(String name)
          Stop an instance of Camel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CamelService

public CamelService(org.osgi.framework.BundleContext context)
Constructor, needed to get the bundle context.

Parameters:
context - the bundle context.
Method Detail

start

public void start()
Initializes the service.


stop

public void stop()
Stops all Camel contexts.


getContextNames

public List<String> getContextNames()
Get the names of Camel contexts managed by the service.

Specified by:
getContextNames in interface ICamelService
Returns:
Names of Camel contexts managed by the service.

startNewContext

public String startNewContext(org.osgi.framework.BundleContext bundleContext)
                       throws Exception
Start a new camel context using a given OSGi BundleContext and return camel context name.

Specified by:
startNewContext in interface ICamelService
Parameters:
bundleContext - OSGi bundle context to use.
Returns:
the camel context name.
Throws:
Exception - If starting the context fails.

stop

public void stop(String name)
          throws Exception
Stop an instance of Camel.

Specified by:
stop in interface ICamelService
Parameters:
name - the camel context name to stop.
Throws:
Exception - If stopping any CAMEL console fails.

getCamelContext

public org.apache.camel.CamelContext getCamelContext(String name)
Get an instance of Camel.

Specified by:
getCamelContext in interface ICamelService
Parameters:
name - the camel context name
Returns:
the camel context

getSimpleRegistryOfCamelContext

public org.apache.camel.impl.SimpleRegistry getSimpleRegistryOfCamelContext(String name)
Get a simple registry instance of Camel context.

Parameters:
name - the camel context name
Returns:
the registry instance

startAndGetNewContext

public org.apache.camel.CamelContext startAndGetNewContext(org.osgi.framework.BundleContext bundleContext)
                                                    throws Exception
Start a new camel context using a given OSGi BundleContext and return context.

Specified by:
startAndGetNewContext in interface ICamelService
Parameters:
bundleContext - OSGi bundle context to use.
Returns:
the camel context.
Throws:
Exception - If starting the context fails.

addRoutes

public void addRoutes(org.apache.camel.builder.RouteBuilder builder,
                      String camelContextName)
               throws Exception
Description copied from interface: ICamelService
Add a Route to the given context, by providing a RouteBuilder

Specified by:
addRoutes in interface ICamelService
Parameters:
builder - the route to add.
camelContextName - the camel context name on which the route has to be set.
Throws:
Exception - If adding route fails.

getRouteDefinitions

public List<org.apache.camel.model.RouteDefinition> getRouteDefinitions(String camelContextName)
Get the list of existing routes.

Specified by:
getRouteDefinitions in interface ICamelService
Parameters:
camelContextName - the identifier of the camel context to check.
Returns:
the list of existing routes for the given camel context..

getProducerTemplate

public org.apache.camel.ProducerTemplate getProducerTemplate(String camelContextName)
Get a producer template for the given camel context.

Specified by:
getProducerTemplate in interface ICamelService
Parameters:
camelContextName - the camel context name on which the producer has to be taken.
Returns:
the producer template.

addRegistry

public void addRegistry(InputStream input,
                        String camelContextName)
                 throws Exception
Add values to the registry component.

Specified by:
addRegistry in interface ICamelService
Parameters:
input - the stream that contains the entries to add.
camelContextName - the camel context name that contains the registry to update.
Throws:
Exception

removeRegistry

public void removeRegistry(InputStream input,
                           String camelContextName)
Remove entries from the registry component.

Specified by:
removeRegistry in interface ICamelService
Parameters:
input - the input stream that contains all the entries to remove
camelContextName - the camel context name to remove the entries on.

addComponent

public void addComponent(String componentName,
                         org.apache.camel.Component component,
                         String camelContextName)
Add a component on the given camel context.

Specified by:
addComponent in interface ICamelService
Parameters:
componentName - the component name.
component - the component.
camelContextName - the camel name context.


Copyright © 2011 OW2 Consortium. All Rights Reserved.