struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From RogerV <roger.var...@googlemail.com>
Subject Struts 2 Spring Plugin Usage
Date Mon, 02 Nov 2009 16:16:16 GMT

In Mannings "Struts 2 in Action" there's an example of Spring
setter-injection by simply specifying the bean to be injected with a basic
applicationContext.xml like;

<beans>
<bean id="securityManager" class="com.myApp.security.PasswordChecker" />
</beans>

and everywhere where my action classes have a setSecurityManager() method
the PasswordChecker is injected. This works brilliantly. 

However how far down the "tree" can I go with this simple approach? For
example, the securityManager in turn has a setService(Service service)
method, and defining an additional <bean id="service" class="........"/> is
not working as expected - the injection is not happening whereas 

<bean id="securityManager"
	class="com.myApp.security.PasswordChecker">
	<property name="service"><ref local="Service"/>
	</property>
</bean>

<bean id="Service" class="com.myApp.services.ServicesImpl"/> 

injects the SecurityManager with the service and then injects the
SecurityManager into my Action. Have I missed something or is this working
as it should and I'm misunderstanding the book?

Regards
-- 
View this message in context: http://old.nabble.com/Struts-2-Spring-Plugin-Usage-tp26157722p26157722.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message