-
1. Re: Using @Bean and @Inject annotations in blueprint route
davsclaus Jan 15, 2013 9:19 AM (in response to salex)What package names does these 2 annotations have?
-
2. Re: Using @Bean and @Inject annotations in blueprint route
salex Jan 15, 2013 11:17 AM (in response to davsclaus)It's
import org.apache.aries.blueprint.annotation.Bean; import org.apache.aries.blueprint.annotation.Inject;
-
3. Re: Using @Bean and @Inject annotations in blueprint route
davsclaus Jan 15, 2013 11:19 AM (in response to salex)And did you define the bean in the blueprint file or something?
<bean id="processor" class="..."/>
Or some other way to bootstrap the IoC procedure?
-
4. Re: Using @Bean and @Inject annotations in blueprint route
salex Jan 15, 2013 11:24 AM (in response to davsclaus)No, because if I did, what good would the annotation be for?
When I define the bean in the blueprint file, I don't need the annotation.
My intense is, to replace the definition in the xml file with the annotation.
Best,
Alexander.
-
5. Re: Using @Bean and @Inject annotations in blueprint route
davsclaus Jan 15, 2013 11:37 AM (in response to salex)See this page
http://aries.apache.org/modules/blueprintannotation.html
Seems like you need to add some osgi header to the MANIFEST.MF file to enable it. And maybe it only works if no blueprint XML file either.
-
6. Re: Using @Bean and @Inject annotations in blueprint route
salex Jan 16, 2013 9:32 AM (in response to davsclaus)As long as I keep the blueprint file, the bootstrap will not be done even if I include the flag in the manifest file.
But if I remove the blueprint.xml, how do I describe my camelContext?
Anyway - this technique does not seem to be usable at the moment. According to the page you mentioned, blueprint annotations are still in prototype state.
Thanks, Alexander.
-
7. Re: Using @Bean and @Inject annotations in blueprint route
scardis Oct 1, 2013 4:14 PM (in response to salex)I realize this is a little bit older thread, but it is completely relevant to some open questions/concerns I am having.
I was looking to use the Blueprint annotation support as well, but think the "bundle contains no blueprint definition XML" requirement (see: http://aries.apache.org/modules/blueprintannotation.html) is a show stopper. I second your question of "But if I remove the blueprint.xml, how do I describe my camelContext?".
One of the things I like about the Spring container is the ability to scan AND declare application context files - nothing forced about a path to take. Hope as the Blueprint project matures this will be possible.
I'm having a hard time deciding on which container to use. Part of me feels like I should stick with the more mature (Spring) framework - I already know and understand how to do unit testing and mocking with this container. However, it seems that Blueprint is definitely the future for OSGi and I like not having to muddle with the "Import-Package" elements of the "maven-bundle-plugin" as much.
Would love to hear other opinions on the matter.
Steve Ardis
-
8. Re: Using @Bean and @Inject annotations in blueprint route
salex Jun 2, 2016 6:18 AM (in response to scardis)For all people interested in how to do injections with blueprint nicely, I'd like to share how we do it nowadays.
With the help of Apache Aries - blueprint-maven-plugin it's possible to use compile-time annotations that generate the necessary blueprint file with all the wiring stuff in it.
Although it's not as flexible and capable as writing blueprint file directly, most of the features arte supported.
-
9. Re: Using @Bean and @Inject annotations in blueprint route
oliverweise Jan 5, 2017 6:21 AM (in response to salex)There now seems to be a straightforward way to register bean via annotation using Camel CDI. Just annotate your bean with @Named("yourBeanName") and (once you get CDI flying in your project) it will be available under ref "yourBeanName".
According to "Referring Beans From Endpoint URIs" on the Camel CDI Page (http://camel.apache.org/cdi.html ) you need to prefix the ref with "#" when using it inside an endpoint URI.
Just tried it with bean("yourBeanName") in Java-DSL and "jetty: .... httpBindingRef=#yourBeanName" in Endpoint URI and both seem to work fine without any blueprint/spring XML.