Is it possible to do dependency injection using spring into a jsr168 Portlet?
Asked
Active
Viewed 699 times
1 Answers
3
Yes - have a look at the portlet chapter in the spring reference.
Notice that you need to implement the special spring portlet controller interface, and not the standard portlet. These controller as well as the injected beans should be in the spring context file specified in the contextConfigLocation parameter. I guess that the usual applicationContext.xml will work as well (if you register the spring servlet context listener)

David Rabinowitz
- 29,904
- 14
- 93
- 125
-
ok cool so JSR168's portlet.xml file works kinda like a regular spring applicationContext.xml. My question however is, do i need to create a separate xml file containing the name of the Portlet class i want to inject or can i do it through the Portlet.xml file? Also, would there be a conflict if this class is created as a bean in both xml files? Thanks – cdugga Sep 17 '09 at 16:11
-
I've added some info. notice that the portlet.xml is not a spring context file. You define in it a spring implementation of a portlet, which knows to delegate the requests to other beans (this is similar to web.xml and the DispatcherServlet) – David Rabinowitz Sep 17 '09 at 18:48