Hi,
Iam using struts + spring + hibernate
I have an Action class , to which I pass the command object like this
This entry goes into my action-servlet.xml file
<bean name="/ReadOnlyAction" class="org.med.core.Command.ReadOnlyAction" singleton="false">
<property name="commandObject"><ref bean="productDAO"/></property>
</bean>
This entry goes into my struts-config.xml file
<action path="/ReadOnlyAction" type="org.springframework.web.struts.DelegatingAct ionProxy">
<forward name="menu" path="/core/order.jsp"></forward>
</action>
Now If you notice the action class, the DAO is set as instance variable of my
Action class , but struts strongly discourages this kind of design,
In my application the same action class might get called with diffrent DAO impl,
does this pose any danger to the thread safety etc, as Struts creates only one
instance of action classes.
Is this the best way to inject Spring managed beans into Struts Action classes ?
public class ReadOnlyAction extends Action {
/**
* @return Returns the commandObject.
*/
public Command getCommandObject() {
return commandObject;
}
/**
* @param commandObject The commandObject to set.
*/
public void setCommandObject(Command commandObject) {
this.commandObject = commandObject;
}
Command commandObject = null;
...
...
..
.


Reply With Quote