Hello,
 
Not sure if this is a Struts 2 or Spring question but I'll start here.
 
I'm using Struts 2 along with Spring 2.5.  In our Struts 2 Actions, we
use the @Autowired annotation to inject our service beans into the
Action class:
 
@Autowired
private MyService myService;
 
Note that we do *not* have a public setter method; just the @Autowired
annotation.
 
In our Spring config file, we have this tag which (supposedly) tells
Spring that autowiring will be used:
 
<context:annotation-config/>
 
When an Action is executed all of the @Autowired dependencies have been
injected.  There's a lot of magic going on there so I have some
questions:
 
1.  How and when (and preferably, in what class) is the Action for a
request created?
 
2.  How and when does Spring inject the @Autowired dependencies into the
Action, especially considering there are no public setter methods for
the dependencies?  If I create an Action using the "new" operator none
of the dependencies are injected, but somehow when Struts 2 creates the
Action, the dependencies are injected.  How or when does this happen?
How does Spring "know" what to inject and when to do it?
 
Thank you!!!
 
-Ryan
 
 
 

Ryan Asleson | Lead Developer

BI | Technology Solutions Group

www.biworldwide.com <http://www.biworldwide.com/> 


 

Please consider the environment before printing.


 

This e-mail message is being sent solely for use by the intended recipient(s) 
and may contain confidential information.  Any unauthorized review, use, 
disclosure or distribution is prohibited.  If you are not the intended 
recipient, please contact the sender by phone or reply by e-mail, delete the 
original message and destroy all copies. Thank you.

Reply via email to