How do I add a component
So you can write an implementation of the Component interface, typically deriving from DefaultComponent .
You can then register your component explicitly via
CamelContext context = new DefaultCamelContext(); context.addComponent("foo", new FooComponent(context));
However you can use the auto-discovery feature of Camel where by Camel will automatically add a Component when an endpoint URI is used. To do this you would create a file called
/META-INF/services/org/apache/camel/component/foo
with contents
class=org.acme.FooComponent
(you can add other property configurations in there too if you like)
Then if you refer to an endpoint as foo://somethingOrOther Camel will auto-discover your component and register it.
The FooComponent can then be auto-injected with resources using the Injector, such as to support Spring based auto-wiring, or to support @Resource (EJB3 style) injection or Guice style @Inject injection.
Working with Spring XML
Due to the auto-discover and injection of components based on their initial use via an endpoint URI you don't have to explicitly add a <fooComponent> element to your Spring XML if you don't want to. However if you do want to then you could use xbean-spring which tries to automate most of this work for you.
If you look in camel-spring at CamelNamespaceHandler you'll see how we handle the Spring XML stuff (warning its kinda hairy code to look at . If you wanted <fooComponent> to be a standard part of the core Camel schema then you'd hack that file to add your component & conftribute a patch to the camel XSD. Otherwise you could write your own namespace & schema if you prefer.