You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cmoulliard <cm...@gmail.com> on 2008/10/10 15:34:52 UTC

@Autowired, @EndpointInject, @ContextConfiguration

Hi,

I have a quick question. Can I use @annotation to create a java class (which
is not a TEST class) where I would like to start camelcontext, add endpoints
and routes ?

If the answer is yes, where can I find an example in camel-source ?

Is there an annotation to define routes ?

Charles Moulliard

-----
Enterprise Architect

Xpectis
12, route d'Esch
L-1470 Luxembourg

Phone +352 25 10 70 470
Mobile +352 621 45 36 22

e-mail : cmoulliard@xpectis.com
web site :  www.xpectis.com www.xpectis.com 
My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: http://www.nabble.com/%40Autowired%2C-%40EndpointInject%2C-%40ContextConfiguration-tp19918229s22882p19918229.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: @Autowired, @EndpointInject, @ContextConfiguration

Posted by James Strachan <ja...@gmail.com>.
2008/10/10 cmoulliard <cm...@gmail.com>:
> Hi,
>
> I have a quick question. Can I use @annotation to create a java class (which
> is not a TEST class) where I would like to start camelcontext, add endpoints
> and routes ?
>
> If the answer is yes, where can I find an example in camel-source ?
>
> Is there an annotation to define routes ?

You can create a RouteBuilder and have a spring.xml instantiate it
(either using component scanning or explicitly defining it in your
spring XML).

There's currently no way to create/instantiate a CamelContext via an
annotation though; it has to be done via the spring.xml right now.
Though if you implement CamelContextAware it'll be injected into your
bean if you want it.

You can then route endpoints using the Java DSL and either using URIs
to endpoints or injecting endpoints into your bean
http://activemq.apache.org/camel/bean-injection.html

Another approach if you have simple routes is to use POJO based
consuming or producing
http://activemq.apache.org/camel/pojo-consuming.html
http://activemq.apache.org/camel/pojo-producing.html

there are some routing annotations too - e.g.
http://activemq.apache.org/camel/recipientlist-annotation.html

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com