Question

I am creating a stand alone camel application. I want to use only java (because the compiler tells whats wrong). To make my code less coupled and reusable by tests i want to decouple the creation of context and registry to separate classes. I just started to extend DefaultCamelContext - is this a good idea or should i extend/implement some other class? Within this class i want to use my own registry (it binds some bean instances) class. I found method setRegistry(org.apache.camel.spi.Registry).

But how to implement such an registry? Is there also a "defaultRegistry"? (for tests there is an createRegistry(), is there something for outside the tests?)

At the end i want to use dependency injection (guice) to glue all stuff together: the registry will inject bean-instances, the registry is then injected in context and context is injected in my main-class than creates "main", sets context and "run()"s it.

Was it helpful?

Solution

Camel supports a pluggable registry strategy...so you should be able to implement the org.apache.camel.spi.Registry interface and call setRegistry(myImpl)...

there are several (Simple, Jndi, etc) registries that are supported that might meet your needs or serve as an example...

for example, here is the SimpleRegistry implementation class...

https://git-wip-us.apache.org/repos/asf?p=camel.git;a=blob_plain;f=camel-core/src/main/java/org/apache/camel/impl/SimpleRegistry.java;h=d2a4a21c9f9fbc70f45fd485d1c46c8a20b9afea;hb=HEAD

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top