Reputation: 17697
I know this sounds strange, mixing CDI (Weld) and Spring for the controller.
But imagine this situation :
Now one question arise is that, inside my controller, how can i access my service object ?
Something like this wouldnt work i think :
@Named
@ConversationScoped
public class MyBean {
@Named
private SomeOtherBeanManagedByCDI myOtherBean; // this will work
@Autowired
private MySpringBean mySpringBean; // dont think that this will work
....
}
Any ideas on how to make use of spring beans inside a cdi bean ? Thank you !
I've just tested the solution from this article, and so far it works fine, and i feel relieved.
Thank you !
Upvotes: 4
Views: 4123
Reputation: 2040
Also, if you're trying to manage state across a series of pages, and want the effective of conversation management for Struts or JSF or Spring MVC, Spring Web Flow provides just what you need, complete with flow-scoped beans that live for the duration of a flow, more or less equivalent to a conversation in Seam / CDI. If you want a more long lived flow managment solution, the Activiti SPring module makes it dead simple to configure some beans that live for the duration of the process scope, akin to the functionality that Seam had for jBPM.
Upvotes: 1
Reputation: 27050
There is still a good accepted answer and some good edits in the OP, but I think there still is time to point out the Seam Spring module.
Upvotes: 2
Reputation: 730
Rick Hightower wrote a nice Extension library which supports to inject Spring beans into CDI beans and vice versa:
http://rick-hightower.blogspot.com/2011/04/cdi-and-spring-living-in-harmony.html
Upvotes: 5