You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Writing Components

Apache Camel is designed to make it very easy to drop in new componnets whether they be routing components, transformers, transports etc.

Here are the main steps to writing a component.

  • write a POJO which implements the Component interface. The simplest approach is just to derive from DefaultComponent
  • to support auto-discovery of your component add a file to META-INF/services/org/apache/camel/component/FOO where FOO is the URI scheme for your component

Users can then either explicitly create your component, configure it and register with a CamelContext or users can use a URI which auto-creates your component.

Dependency injection and auto-discovery

When using auto-discovery the CamelContext will default to its Injector implementation to inject any required or optional dependencies on the component. This allows you to use auto-discovery of components via URIs while still getting the benefits of dependency injection.

For example your component can depend on a JDBC DataSource or JMS ConnectionFactory which can be provided in the ApplicationContext in Spring or Module in Guice.

  • No labels