Apache Struts 2 Documentation > Home > Guides > Core Developers Guide > Action Proxy & ActionProxy Factory
Added by tm_jee, last edited by Philip Luppens on Jul 03, 2008  (view change)

The ActionProxy obtains the Action class and calls the appropriate method. By default, Actions are obtained through local instantiation, but an Action could also be obtained remotely if an alternative ActionProxy were provided.

An alternative ActionProxy can be configured through ActionProxyFactory. Typically, an ActionProxy will utilize the ActionInvocation to encapsulate the execution of a particular request.

The ActionInvocation determines how an Action is handled: Is it being intercepted, is there a PreResultListener acting on it.

Essentially, ActionProxy encapsulates how an Action can be obtained. ActionInvocation encapsulates how the Action is executed when a request is invoked.

Customization

ActionProxyFactory

 ActionProxyFactory.setFactory(new MyActionProxyFactory() {
    .....
 });

ActionProxy

 ActionProxyFactory.getFactory(new MyActionProxyFactory() {
    ....
    public ActionProxy createActionProxy(Configuration config, 
           String namespace, String actionName, Map extraContext) 
           throws Exception {
        createActionProxy(config, namespace, actionName, extraContext, true);
    }
    public ActionProxy createActionProxy(Configuration config, 
           String namespace, String actionName, Map extraContext, 
           boolean executeResult, boolean cleanupContext) 
           throws Exception {
        ....
   }
   ....
 });

ActionInvocation

 ActionProxyFactory.getFactory(new MyActionProxyFactory() {
    ...
    public ActionInvocation createActionInvocation(ActionProxy actionProxy) 
                            throws Exception {
          createActionInvocation(actionProxy, new LinkedHashMap());
    }
    public ActionInvocation createActionInvocation(ActionProxy actionProxy, 
                            Map extraContext) throws Exception {
          createActionInvocation(actionProxy, extraContext, true);
    }
    public ActionInvocation createActionInvocation(ActionProxy actionProxy, 
                            Map extraContext, boolean pushAction) 
                            throws Exception {
          // do implementation of ActionInvocation herer
          .....
    }
    ...
 });

Next: Configuration Provider & Configuration