|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts.action.Action
org.springframework.web.struts.DelegatingActionProxy
Proxy for a Spring-managed Struts 1.1 Action that's defined in ContextLoaderPlugIn's WebApplicationContext.
The proxy is defined in the Struts config file, specifying this class as action class. It will delegate to a Struts Action bean in the ContextLoaderPlugIn context.
<action path="/login" type="org.springframework.web.struts.DelegatingActionProxy"/>The name of the Action bean in the WebApplicationContext will be determined from the mapping path and module prefix. This can be customized by overriding the
determineActionBeanName
method.
Example:
A corresponding bean definition in the ContextLoaderPlugin context looks as follows, being able to fully leverage Spring's configuration facilities:
<bean name="/login" class="myapp.MyAction"> <property name="...">...</property> </bean>Note: The idea of delegating to Spring-managed Struts Actions originated in Don Brown's Spring Struts Plugin. ContextLoaderPlugIn and DelegatingActionProxy constitute a clean-room implementation of the same idea, essentially superseding the original plugin. Many thanks to Don Brown and Matt Raible for the original work, and for the agreement to reimplement the idea in standard Spring!
ContextLoaderPlugIn
,
determineActionBeanName(org.apache.struts.action.ActionMapping)
Field Summary | |
protected org.apache.commons.logging.Log |
logger
|
Fields inherited from class org.apache.struts.action.Action |
ACTION_SERVLET_KEY, APPLICATION_KEY, DATA_SOURCE_KEY, defaultLocale, ERROR_KEY, EXCEPTION_KEY, FORM_BEANS_KEY, FORWARDS_KEY, LOCALE_KEY, MAPPING_KEY, MAPPINGS_KEY, MESSAGE_KEY, MESSAGES_KEY, MULTIPART_KEY, PLUG_INS_KEY, REQUEST_PROCESSOR_KEY, servlet, SERVLET_KEY, TRANSACTION_TOKEN_KEY |
Constructor Summary | |
DelegatingActionProxy()
|
Method Summary | |
protected java.lang.String |
determineActionBeanName(org.apache.struts.action.ActionMapping mapping)
Determine the name of the Action bean, to be looked up in the WebApplicationContext. |
org.apache.struts.action.ActionForward |
execute(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Pass the execute call on to the Spring-managed delegate Action. |
protected org.apache.struts.action.Action |
getDelegateAction(org.apache.struts.action.ActionMapping mapping)
Return the delegate Action for the given mapping. |
protected WebApplicationContext |
getWebApplicationContext()
Return the WebApplicationContext that this proxy delegates to. |
protected WebApplicationContext |
initWebApplicationContext(org.apache.struts.action.ActionServlet actionServlet)
Fetch ContextLoaderPlugIn's WebApplicationContext from the ServletContext, containing the Struts Action beans to delegate to. |
void |
setServlet(org.apache.struts.action.ActionServlet actionServlet)
Initialize the WebApplicationContext for this Action. |
Methods inherited from class org.apache.struts.action.Action |
execute, generateToken, getDataSource, getDataSource, getLocale, getResources, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, perform, perform, resetToken, saveErrors, saveMessages, saveToken, setLocale, toHex |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final org.apache.commons.logging.Log logger
Constructor Detail |
public DelegatingActionProxy()
Method Detail |
public void setServlet(org.apache.struts.action.ActionServlet actionServlet)
initWebApplicationContext(org.apache.struts.action.ActionServlet)
protected WebApplicationContext initWebApplicationContext(org.apache.struts.action.ActionServlet actionServlet) throws java.lang.IllegalStateException
actionServlet
- the associated ActionServlet
java.lang.IllegalStateException
- if no WebApplicationContext could be foundContextLoaderPlugIn.SERVLET_CONTEXT_ATTRIBUTE
protected final WebApplicationContext getWebApplicationContext()
public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
java.lang.Exception
getDelegateAction(org.apache.struts.action.ActionMapping)
protected org.apache.struts.action.Action getDelegateAction(org.apache.struts.action.ActionMapping mapping)
The default implementation determines a bean name from the given ActionMapping and looks up the corresponding bean in the WebApplicationContext.
mapping
- the Struts ActionMapping
determineActionBeanName(org.apache.struts.action.ActionMapping)
protected java.lang.String determineActionBeanName(org.apache.struts.action.ActionMapping mapping)
The default implementation takes the mapping path and prepends the module prefix, if any.
mapping
- the Struts ActionMapping
ActionConfig.getPath()
,
ModuleConfig.getPrefix()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |