M Sach
M Sach

Reputation: 34424

how dependencies are injected in struts2 action with spring?

I have one legacy web application based on struts2 (primarily using annotation). While debugging i find that all the dependencies (like service layer and dao layer) are injected automatically in struts 2 action. I was expecting there must be some spring interceptor defined in struts.xml which must be doing this.

But i did not find any spring related interceptor over there. Also in web.xml i did not find any related stuff which must be doing this kind of work. I am not sure how dependencies (with spring) are injected in struts2 action...

I can see struts2-convention-plugin-2.2.3.1.jar file in class path. Does it mean filterDispatcher looks for this jar at run time and if it finds it, inject the dependencies in action. Does any Interceptor also help during this process?

Upvotes: 4

Views: 5527

Answers (3)

user1431390
user1431390

Reputation:

Please refer to struts-plugin.xml of struts2-spring-plugin-x.x.x.x.jar, you can find the config about object factory and autowiring interceptor . It uses the plugin feature of struts2, and you may search 'plugin' from Struts Guide for details.

Upvotes: 4

VolkerK
VolkerK

Reputation: 1510

If the Dependency Injection is done with spring, check out the spring plugin.

If not, struts2 has its own Dependency Injection Implementation
Take a look at the Core Developers Guide

Upvotes: 1

Rajesh
Rajesh

Reputation: 3014

There must be an interceptor ..which is getting executed before action class and is doing this dependency injection using Java reflection API..or Struts 2 Reflection tool..http://struts.apache.org/2.3.4/struts2-plugins/struts2-convention-plugin/apidocs/org/apache/struts2/convention/ReflectionTools.html Check the interceptor stack.

Upvotes: 0

Related Questions