1. opensymphony
  2. webwork

Commits

jcarreira  committed df45b8c

Removing the client dispatcher from webwork. It needs to be put into webwork-optional.

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@593573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits db126e0
  • Branches master

Comments (0)

Files changed (30)

File lib/optional/bsh.jar

  • Ignore whitespace
Binary file removed.

File lib/optional/cglib-full.jar

  • Ignore whitespace
Binary file removed.

File lib/optional/commons-beanutils.jar

  • Ignore whitespace
Binary file removed.

File lib/optional/commons-collections.jar

  • Ignore whitespace
Binary file removed.

File lib/optional/commons-digester.jar

  • Ignore whitespace
Binary file removed.

File lib/optional/jnlp-servlet.jar

  • Ignore whitespace
Binary file removed.

File lib/optional/object-dispatcher.jar

  • Ignore whitespace
Binary file removed.

File src/java/com/opensymphony/webwork/dispatcher/client/ClientException.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-
-/**
- * Generic exception used by classes in the
- * <code>com.opensymphony.webwork.dispatcher.client</code> package.
- *
- * @version $Id$
- * @author Ben Alex (<a href="mailto:ben.alex@acegi.com.au">ben.alex@acegi.com.au</a>)
- */
-public class ClientException extends Exception {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    private String text;
-    private Throwable cause;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    public ClientException(Throwable cause) {
-        super(cause.getMessage());
-        this.cause = cause;
-    }
-
-    public ClientException(String text) {
-        this.text = text;
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public Throwable getCause() {
-        return cause;
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/ClientRequest.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-
-/**
- * Interface that must be implemented by any client-side object that needs to
- * be processed by the Client Dispatcher. Generally, normal XWork Action
- * objects will implement this interface and thus enable them to be used on
- * both the client and the server tiers.
- *
- * @version $Id$
- * @author Ben Alex (<a href="mailto:ben.alex@acegi.com.au">ben.alex@acegi.com.au</a>)
- */
-public interface ClientRequest {
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    /**
-     * Sets the {@link ClientRequestInvocation ClientRequestInvocation}
-     * that is specific to this <code>ClientRequest</code> proxy object. This
-     * method should only be called by
-     * {@link TransportFactory#createClientRequestProxy(ClientRequest)
-     * TransportFactory.createClientRequestProxy(ClientRequest)}.
-     */
-    public void setClientRequestInvocation(ClientRequestInvocation clientRequestInvocation);
-
-    /**
-     * Provides the {@link ClientRequestInvocation ClientRequestInvocation}
-     * that is specific to this <code>ClientRequest</code> proxy object.
-     */
-    public ClientRequestInvocation getClientRequestInvocation();
-}

File src/java/com/opensymphony/webwork/dispatcher/client/ClientRequestInvocation.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-import com.opensymphony.xwork.Action;
-
-import java.io.Serializable;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * Holds information specific to a unique {@link ClientRequest
- * ClientRequest} proxy object.
- *
- * @version $Id$
- * @author Ben Alex (<a href="mailto:ben.alex@acegi.com.au">ben.alex@acegi.com.au</a>)
- * @author Philipp Meier (meier@meisterbohne.de)
- */
-public class ClientRequestInvocation implements Serializable {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    private transient TransportFactory transportFactory;
-    private Action resultAction;
-    private Map parameters;
-    private String remoteActionName;
-    private String resultCode;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    /**
-     * Should not be called directly by users. A
-     * <code>ClientRequestInvocation</code> will be generated for a given
-     * {@link ClientRequest ClientRequest} whilst executing
-     * {@link TransportFactory#createClientRequestProxy(ClientRequest)
-     * TransportFactory.createClientRequestProxy(ClientRequest)}.
-     */
-    public ClientRequestInvocation(TransportFactory transportFactory, String remoteActionName) {
-        this.transportFactory = transportFactory;
-        this.remoteActionName = remoteActionName;
-        this.parameters = new HashMap();
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    /**
-     * Should not be called directly by users. The
-     * {@link ClientRequestProxy ClientRequestProxy} will record each parameter
-     * <code>set</code> performed against the associated
-     * {@link ClientRequest ClientRequest} proxy object. These are ultimately
-     * transferred to the server side of the Client Dispatcher.
-     */
-    public void setParameter(Object key, Object value) {
-        parameters.put(key, value);
-    }
-
-    /**
-     * Returns the list of parameters <code>set</code> against a
-     * {@link ClientRequest ClientRequest} proxy object.
-     * This method is not normally used by users, as the
-     * {@link TransportFactory#execute(ClientRequestInvocation)
-     * TransportFactory.execute(ClientRequestInvocation)}
-     * method will serialize this information to the remote side of the
-     * Client Dispatcher.
-     */
-    public Map getParameters() {
-        return parameters;
-    }
-
-    /**
-     * Sets the action name that will be executed on the remote side of the
-     * Client Dispatcher. This remote name must match an action defined in
-     * <code>xwork.xml</code> through a
-     * <code>&lt;action name="remoteActionName"
-     * class="com.some.company.class"&gt;</code>
-     * setting.<BR><BR>
-     *
-     * {@link TransportFactory TransportFactory} implementations usually set
-     * a remote action name to be equal to the class name of the
-     * {@link ClientRequest ClientRequest}.<BR><BR>
-     *
-     * Users should ensure this method is used to correctly set the intended
-     * remote action.
-     */
-    public void setRemoteActionName(String remoteActionName) {
-        this.remoteActionName = remoteActionName;
-    }
-
-    /**
-     * Return the action name that will be executed on the server side of the
-     * Client Dispatcher.
-     */
-    public String getRemoteActionName() {
-        return remoteActionName;
-    }
-
-    /**
-     * Should not be called by users. This sets the final remote action that
-     * was executed on the XWork Value Stack. This method is called by the
-     * {@link ClientRequestProxy#execute ClientRequestProxy.execute} method.
-     */
-    public void setResultAction(Action resultAction) {
-        this.resultAction = resultAction;
-    }
-
-    /**
-     * After the {@link ClientRequestInvocation#execute()
-     * ClientRequestInvocation.execute()} method has been called via the
-     * {@link ClientRequest ClientRequest} proxy object, this method returns
-     * the final action that was in the server's XWork Value Stack.
-     * This is a serialized copy of that Action and is therefore limited
-     * to normal serialization behaviour (eg objects marked
-     * <code>transient</code> or that do not implement <code>
-     * java.io.Serializable</code> will not be serialized).
-     */
-    public Action getResultAction() {
-        return resultAction;
-    }
-
-    /**
-     * Should not be called by users. This sets the final remote
-     * <code>String</code> result code. This method is called by the
-     * {@link ClientRequestProxy#execute ClientRequestProxy.execute} method.
-     */
-    public void setResultCode(String resultCode) {
-        this.resultCode = resultCode;
-    }
-
-    /**
-     * After the {@link ClientRequestInvocation#execute()
-     * ClientRequestInvocation.execute()} method has been called via the
-     * {@link ClientRequest ClientRequest} proxy object, this method returns
-     * the <code>String</code> result code from the remote action's
-     * <code>execute()</code> method. This is typically <code>SUCCESS</code>,
-     * <code>INPUT</code>, <code>ERROR</code> etc.
-     */
-    public String getResultCode() {
-        return resultCode;
-    }
-
-    /**
-     * Should not be called directly by users. The
-     * {@link ClientRequestProxy ClientRequestProxy} will call this
-     * method as part of its interception of the <code>execute</code> method
-     * of the {@link ClientRequest ClientRequest} proxy object.
-     */
-    public RemoteResult execute() throws ClientException {
-        return transportFactory.execute(this);
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/ClientRequestProxy.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-import net.sf.cglib.proxy.MethodInterceptor;
-import net.sf.cglib.proxy.MethodProxy;
-
-import java.lang.reflect.Method;
-
-
-/**
- * This class represents an interceptor added to {@link ClientRequest
- * ClientRequest} proxy objects. This class is added via the
- * {@link TransportFactory#createClientRequestProxy(ClientRequest)
- * TransportFactory.createClientRequestProxy(ClientRequest)}
- * method.<BR><BR>
- *
- * This class is responsible for ensuring the {@link ClientRequestInvocation
- * ClientRequestInvocation} associated with a given {@link ClientRequest
- * ClientRequest} proxy object is properly notified whenever calls are made to
- * <code>set</code> methods and the <code>execute</code> method.<BR><BR>
- *
- * Users should not need to interact directly with this class.
- *
- * @version $Id$
- * @author Ben Alex (<a href="mailto:ben.alex@acegi.com.au">ben.alex@acegi.com.au</a>)
- */
-public class ClientRequestProxy implements MethodInterceptor {
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
-        ClientRequest clientAction = (ClientRequest) obj;
-        Object result = null;
-
-        if (method.getName().equals("execute")) {
-            RemoteResult car = clientAction.getClientRequestInvocation().execute();
-            clientAction.getClientRequestInvocation().setResultAction(car.getAction());
-            clientAction.getClientRequestInvocation().setResultCode(car.getResultCode());
-            result = car.getResultCode();
-        } else if (method.getName().startsWith("set")) {
-            String propertyName = method.getName().substring(3, method.getName().length());
-            result = proxy.invokeSuper(obj, args);
-            clientAction.getClientRequestInvocation().setParameter(propertyName, args[0]);
-        }
-
-        return result;
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/HTTPClientActionProxyFactory.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-import com.opensymphony.xwork.ActionInvocation;
-import com.opensymphony.xwork.ActionProxy;
-import com.opensymphony.xwork.DefaultActionProxyFactory;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.Map;
-
-
-/**
- * This class is intended for use in conjunction with {@link HTTPClientObjectFactory HTTPClientObjectFactory}
- * to allow the remote action invocation to be placed on the value stack on the client rather
- * than the local one.
- * @author Peter Kelley
- */
-public class HTTPClientActionProxyFactory extends DefaultActionProxyFactory {
-    //~ Static fields/initializers /////////////////////////////////////////////
-
-    /** logger for this class */
-    private static final Log log = LogFactory.getLog(HTTPClientActionProxyFactory.class);
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    /**
-     * Default constructor
-     */
-    public HTTPClientActionProxyFactory() {
-        super();
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    /**
-     * This method adds a pre result listener to allow replacement of the object at the top of the
-     * value stack with the one returned from the server..
-     *
-     * @param actionProxy The action proxy to create the invocation for
-     * @return a {@link com.opensymphony.xwork.DefaultActionInvocation DefaultActionInvocation} with
-     * a {link HTTPClientPreResultListener HTTPClientPreResultListener} added.
-     * @throws Exception if something goes wrong
-     */
-    public ActionInvocation createActionInvocation(ActionProxy actionProxy) throws Exception {
-        ActionInvocation result = super.createActionInvocation(actionProxy);
-
-        if (log.isDebugEnabled()) {
-            log.debug("Adding pre result listener");
-        }
-
-        result.addPreResultListener(new HTTPClientPreResultListener());
-
-        return result;
-    }
-
-    /**
-     * This method adds a pre result listener to allow replacement of the object at the top of the
-     * value stack with the one returned from the server..
-     *
-     * @param actionProxy The action proxy to create the invocation for
-     * @param extraContext Extra information needed for this action invocation
-     * @return a {@link com.opensymphony.xwork.DefaultActionInvocation DefaultActionInvocation}
-     *   with a {link HTTPClientPreResultListener HTTPClientPreResultListener} added.
-     * @throws Exception if something goes wrong
-     */
-    public ActionInvocation createActionInvocation(ActionProxy actionProxy, Map extraContext) throws Exception {
-        ActionInvocation result = super.createActionInvocation(actionProxy, extraContext);
-
-        if (log.isDebugEnabled()) {
-            log.debug("Adding pre result listener");
-        }
-
-        result.addPreResultListener(new HTTPClientPreResultListener());
-
-        return result;
-    }
-
-    /**
-     * This method adds a pre result listener to allow replacement of the object at the top of the
-     * value stack with the one returned from the server..
-     *
-     * @param actionProxy The action proxy to create the invocation for
-     * @param extraContext Extra information needed for this action invocation
-     * @param pushAction whether to oput this action on the value stack after invocation
-     * @return a {@link com.opensymphony.xwork.DefaultActionInvocation DefaultActionInvocation}
-     *   with a {link HTTPClientPreResultListener HTTPClientPreResultListener} added.
-     * @throws Exception if something goes wrong
-     */
-    public ActionInvocation createActionInvocation(ActionProxy actionProxy, Map extraContext, boolean pushAction) throws Exception {
-        ActionInvocation result = super.createActionInvocation(actionProxy, extraContext, pushAction);
-
-        if (pushAction) {
-            result.addPreResultListener(new HTTPClientPreResultListener());
-            log.debug("Adding pre result listener");
-        } else {
-            log.debug("Not adding pre result listener as action is not on the stack");
-        }
-
-        return result;
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/HTTPClientObjectFactory.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-import com.opensymphony.xwork.Action;
-import com.opensymphony.xwork.ObjectFactory;
-import com.opensymphony.xwork.config.entities.ActionConfig;
-
-
-/**
- * DOCUMENT ME!
- *
- * @author $author$
- * @version $Revision$
- */
-public class HTTPClientObjectFactory extends ObjectFactory {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    /** transport factory used to talk to the server */
-    private TransportFactory transportFactory;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    /**
- * Default constructor
- * @param transport The transport factory implementation to use to communicate with the remote
- * server
- */
-    public HTTPClientObjectFactory(TransportFactory transport) {
-        if (transport == null) {
-            throw new IllegalArgumentException("Transport factory must not be null");
-        }
-
-        transportFactory = transport;
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    /**
- * Build an action from the configuration
- *
- * @param config The action configuration to use to find the action. The action referenced
- * must implement {@link ClientRequest ClientRequest} for this to work.
- * @throws Exception If there is a problem creating the action. In particular the action must
- * implement {@link ClientRequest ClientRequest} or a class cast execption will occur.
- * @return An action set up to be called remotely
- */
-    public Action buildAction(ActionConfig config) throws Exception {
-        Action localAction = (Action) buildBean(config.getClassName());
-        String namespace = config.getPackageName();
-        Action remoteAction = (Action) transportFactory.createClientRequestProxy((ClientRequest) localAction, namespace);
-
-        return remoteAction;
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/HTTPClientPreResultListener.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-import com.opensymphony.xwork.ActionInvocation;
-import com.opensymphony.xwork.interceptor.PreResultListener;
-import com.opensymphony.xwork.util.OgnlValueStack;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Class to replace the action at the top of the stack with the one returned from the server.
- * @author Peter Kelley
- */
-public class HTTPClientPreResultListener implements PreResultListener {
-    //~ Static fields/initializers /////////////////////////////////////////////
-
-    /** logger for this class */
-    private static final Log log = LogFactory.getLog(HTTPClientPreResultListener.class);
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    /**
-     * Default constructor
-     */
-    public HTTPClientPreResultListener() {
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    /**
-     * Replace the action at the top of the stack with the one returned from the server. This
-     * method assumes that the object at the top of the stack is a
-     * {@link ClientRequestInvocation ClientRequestInvocation}.
-     * This callback method will be called after the Action execution and before the Result execution.
-     *
-     * @param invocation The action invocation that is being processed
-     * @param resultCode The result of the action invocation
-     */
-    public void beforeResult(ActionInvocation invocation, String resultCode) {
-        OgnlValueStack stack = invocation.getStack();
-
-        if (log.isDebugEnabled()) {
-            log.debug("Object at top of stack was: " + stack.peek());
-        }
-
-        ClientRequest localAction = (ClientRequest) stack.pop();
-        ClientRequestInvocation clientRequestInvocation = (localAction).getClientRequestInvocation();
-        Object resultAction = clientRequestInvocation.getResultAction();
-
-        if (log.isDebugEnabled()) {
-            log.debug("Replacing " + localAction + " with " + resultAction);
-        }
-
-        stack.push(resultAction);
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/ProgressConsumer.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-
-/**
- * Interface this is implemented by classes wishing to receive
- * progress notifications whilst
- * {@link TransportFactory#execute(ClientRequestInvocation)
- * TransportFactory.execute(ClientRequestInvocation)} is running.
- *
- * Users should use the {@link
- * TransportFactory#setProgressConsumer(ProgressConsumer)
- * TransportFactory.setProgressConsumer(ProgressConsumer)} method to denote
- * which <code>ProgressConsumer</code> should be used.
- *
- * @version $Id$
- * @author Ben Alex (<a href="mailto:ben.alex@acegi.com.au">ben.alex@acegi.com.au</a>)
- */
-public interface ProgressConsumer {
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    /**
-     * Notifies the <code>ProgressConsumer</code> implementation that another
-     * stage of request procesing has occurred. The details of the progress
-     * are contained in the {@link ProgressNotification ProgressNotification}.
-     */
-    public void notify(ProgressNotification progressNotification);
-}

File src/java/com/opensymphony/webwork/dispatcher/client/ProgressConsumerNull.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-
-/**
- * Consumes process notifications, but does nothing with them.
- * A {@link TransportFactory TransportFactory} should
- * use this class as its default {@link ProgressConsumer ProgressConsumer},
- * in case the user has not set one via the
- * {@link TransportFactory#setProgressConsumer(ProgressConsumer)
- * TransportFactory.setProgressConsumer(ProgressConsumer)} method.
- *
- * @version $Id$
- * @author Ben Alex (<a href="mailto:ben.alex@acegi.com.au">ben.alex@acegi.com.au</a>)
- */
-public class ProgressConsumerNull implements ProgressConsumer {
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public void notify(ProgressNotification progressNotification) {
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/ProgressConsumerString.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-
-/**
- * A {@link ProgressConsumer ProgressConsumer} that writes notifications to the
- * standard output stream.
- *
- * @version $Id$
- * @author Ben Alex (<a href="mailto:ben.alex@acegi.com.au">ben.alex@acegi.com.au</a>)
- */
-public class ProgressConsumerString implements ProgressConsumer {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    private String lastStartedId = "none";
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public synchronized void notify(ProgressNotification progressNotification) {
-        String status = "uknown";
-        boolean showProgress = false;
-        int completed = 0;
-        int ofTotal = -1;
-
-        if (progressNotification.getStatus() == ProgressNotification.STATUS_NONE) {
-            status = "Not Executing";
-        } else if (progressNotification.getStatus() == ProgressNotification.STATUS_CONNECTING) {
-            status = "Connecting to Remote";
-        } else if (progressNotification.getStatus() == ProgressNotification.STATUS_PROCESSING) {
-            status = "Remote is Processing";
-        } else if (progressNotification.getStatus() == ProgressNotification.STATUS_RECEIVING) {
-            status = "Receiving from Remote";
-            showProgress = true;
-            completed = progressNotification.getInputReceived();
-            ofTotal = progressNotification.getInputSize();
-        } else if (progressNotification.getStatus() == ProgressNotification.STATUS_RECEIVED) {
-            status = "Received";
-        } else if (progressNotification.getStatus() == ProgressNotification.STATUS_RETRY_DELAY) {
-            status = "Retrying";
-        } else if (progressNotification.getStatus() == ProgressNotification.STATUS_SENDING) {
-            status = "Sending to Remote";
-            showProgress = true;
-            completed = progressNotification.getOutputTransmitted();
-            ofTotal = progressNotification.getOutputSize();
-        } else {
-            status = "Unsupported Status";
-        }
-
-        if (progressNotification.getStatus() == ProgressNotification.STATUS_SENDING) {
-            if (!lastStartedId.equals(progressNotification.getId())) {
-                System.out.println("ID: " + progressNotification.getId() + "; Factory: " + progressNotification.getFactoryInformation() + "; Security: " + progressNotification.getSecurityInformation());
-                lastStartedId = progressNotification.getId();
-            }
-        }
-
-        if (showProgress) {
-            System.out.println("ID: " + progressNotification.getId() + "; " + status + "; " + completed + " of " + ofTotal);
-        } else {
-            System.out.println("ID: " + progressNotification.getId() + "; " + status);
-        }
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/ProgressInputStream.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import java.util.Date;
-import java.util.Properties;
-
-
-/**
- * Monitors the progress of reading from an InputStream. Links in with a
- * {@link ProgressConsumer ProgressConsumer} and <code>Properties</code> from
- * a {@link TransportFactory TransportFactory}.
- *
- * @version $Id$
- * @author Ben Alex (<a href="mailto:ben.alex@acegi.com.au">ben.alex@acegi.com.au</a>)
- */
-public class ProgressInputStream extends FilterInputStream {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    private ProgressConsumer progressConsumer;
-    private ProgressNotification notification;
-    private int lastNotificationStatus;
-    private int nread = 0;
-    private int size = 0;
-    private long lastUpdate;
-    private long updateFrequency;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    /**
-     * Monitors the progress of an input stream.<BR><BR>
-     *
-     * The <code>Properties</code> may contain an optional value for
-     * <code>updateFrequency</code>. The <code>updateFrequency</code> specifies
-     * the number of milliseconds that must pass between notifications to
-     * the {@link ProgressConsumer ProgressConsumer} concerning standard
-     * stream processing. Certain major processing events such as stream
-     * establishment and closure will always result in a notification,
-     * irrespective of the <code>updateFrequency</code>. The default value
-     * for <code>updateFrequency</code> is 250.
-     */
-    public ProgressInputStream(ProgressNotification notification, ProgressConsumer progressConsumer, Properties props, InputStream in, int contentLength) {
-        super(in);
-        size = contentLength;
-        this.notification = notification;
-        this.progressConsumer = progressConsumer;
-        this.lastUpdate = new Date().getTime();
-        this.lastNotificationStatus = notification.getStatus();
-        notification.setInputSize(size);
-
-        try {
-            this.updateFrequency = new Long(props.getProperty("updateFrequency", "250")).longValue();
-        } catch (NumberFormatException nfe) {
-            updateFrequency = 500;
-        }
-
-        try {
-            notification.setStatus(ProgressNotification.STATUS_RECEIVING);
-        } catch (ClientException ignored) {
-        }
-
-        updateBytes(nread);
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    /**
-     * Overrides <code>FilterInputStream.close</code>
-     * to update the progress monitor and close the stream.
-     */
-    public void close() throws IOException {
-        updateBytes(nread);
-        in.close();
-    }
-
-    /**
-     * Overrides <code>FilterInputStream.read</code>
-     * to update the progress monitor after the read.
-     */
-    public int read() throws IOException {
-        int c = in.read();
-
-        if (c >= 0) {
-            ++nread;
-            updateBytes(nread);
-        }
-
-        return c;
-    }
-
-    /**
-     * Overrides <code>FilterInputStream.read</code>
-     * to update the progress monitor after the read.
-     */
-    public int read(byte[] b) throws IOException {
-        int nr = in.read(b);
-
-        if (nr > 0) {
-            nread += nr;
-            updateBytes(nread);
-        }
-
-        return nr;
-    }
-
-    /**
-     * Overrides <code>FilterInputStream.read</code>
-     * to update the progress monitor after the read.
-     */
-    public int read(byte[] b, int off, int len) throws IOException {
-        int nr = in.read(b, off, len);
-
-        if (nr > 0) {
-            nread += nr;
-            updateBytes(nread);
-        }
-
-        return nr;
-    }
-
-    /**
-     * Overrides <code>FilterInputStream.reset</code>
-     * to reset the progress monitor as well as the stream.
-     */
-    public synchronized void reset() throws IOException {
-        in.reset();
-        nread = size - in.available();
-        updateBytes(nread);
-    }
-
-    /**
-     * Overrides <code>FilterInputStream.skip</code>
-     * to update the progress monitor after the skip.
-     */
-    public long skip(long n) throws IOException {
-        long nr = in.skip(n);
-
-        if (nr > 0) {
-            nread += nr;
-            updateBytes(nread);
-        }
-
-        return nr;
-    }
-
-    /**
-     * Causes the progress monitor to be notified if appropriate.
-     */
-    private void updateBytes(int nowRead) {
-        boolean update = false;
-
-        if (nowRead >= size) {
-            if (notification.getStatus() == ProgressNotification.STATUS_RECEIVING) {
-                try {
-                    notification.setStatus(ProgressNotification.STATUS_RECEIVED);
-                } catch (ClientException ignored) {
-                }
-            }
-        }
-
-        if (lastNotificationStatus != notification.getStatus()) {
-            update = true;
-        }
-
-        long currentTime = new Date().getTime();
-
-        if (notification.getStatus() == ProgressNotification.STATUS_RECEIVING) {
-            if (currentTime > (lastUpdate + updateFrequency)) {
-                update = true;
-            }
-        }
-
-        if (update == true) {
-            lastUpdate = currentTime;
-            lastNotificationStatus = notification.getStatus();
-            notification.setInputReceived(nowRead);
-            progressConsumer.notify(notification);
-        }
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/ProgressNotification.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-import java.util.Date;
-import java.util.Properties;
-
-
-/**
- * Stores information of interest to {@link ProgressConsumer ProgressConsumer}
- * implementations. This information is updated by
- * {@link TransportFactory#execute(ClientRequestInvocation)
- * TransportFactory.execute(ClientRequestInvocation)},
- * {@link ProgressInputStream ProgressInputStream} and
- * {@link ProgressOutputStream ProgressOutputStream}.
- *
- * @version $Id$
- * @author Ben Alex (<a href="mailto:ben.alex@acegi.com.au">ben.alex@acegi.com.au</a>)
- */
-public class ProgressNotification {
-    //~ Static fields/initializers /////////////////////////////////////////////
-
-    /**
-     * The {@link TransportFactory TransportFactory} is trying to initially
-     * contact the remote server.
-     */
-    public static final int STATUS_CONNECTING = 1;
-
-    /**
-     * The {@link TransportFactory TransportFactory} is sending the request
-     * to the remote server.
-     */
-    public static final int STATUS_SENDING = 2;
-
-    /**
-     * The {@link TransportFactory TransportFactory} is awaiting a result from
-     * the remote server.
-     */
-    public static final int STATUS_PROCESSING = 3;
-
-    /**
-     * The {@link TransportFactory TransportFactory} is receiving a result from
-     * the remote server.
-     */
-    public static final int STATUS_RECEIVING = 4;
-
-    /**
-     * The {@link TransportFactory TransportFactory} sucessfully received the
-     * result from the remote server.
-     */
-    public static final int STATUS_RECEIVED = 5;
-
-    /**
-     * The {@link TransportFactory TransportFactory} experienced a connection
-     * problem, and is currently pausing before it will attempt to retry.
-     */
-    public static final int STATUS_RETRY_DELAY = 6;
-
-    /**
-     * The {@link TransportFactory TransportFactory} is not attempting any
-     * operation. This does not indicate success or failure. This status
-     * indicates the {@link ProgressNotification ProgressNotification} object
-     * has just been created (ie just before
-     * {@link ProgressNotification#STATUS_SENDING
-     * ProgressNotification.STATUS_SENDING}
-     * or it has finished (ie after
-     * {@link ProgressNotification#STATUS_RECEIVING
-     * ProgressNotification.STATUS_RECEIVING}
-     * or
-     * {@link ProgressNotification# STATUS_RETRY_DELAY
-     * ProgressNotification. STATUS_RETRY_DELAY}).
-     */
-    public static final int STATUS_NONE = 10;
-
-    /**
-     * The {@link TransportFactory TransportFactory} does not assert there is
-     * any encryption or identification of the remote server.
-     */
-    public static final int SECURITY_NONE = 1;
-
-    /**
-     * The {@link TransportFactory TransportFactory} asserts that communications
-     * with the remote server are encrypted, but does not assert the identity of
-     * the remote server.
-     */
-    public static final int SECURITY_ENCRYPTED = 2;
-
-    /**
-     * The {@link TransportFactory TransportFactory} asserts that communications
-     * with the remote server are both encrypted, and the identity of the remote
-     * server has been validated. A {@link TransportFactory TransportFactory}
-     * should not make this assertion if the identity of the remote server
-     * has not been confirmed by an appropriate public key certificate chain.
-     */
-    public static final int SECURITY_IDENTIFIED = 3;
-
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    private Date execution;
-    private Properties factoryInformation = new Properties();
-    private Properties securityInformation = new Properties();
-    private String id;
-    private int inputReceived;
-    private int inputSize;
-    private int outputSize;
-    private int outputTransmitted;
-    private int security;
-    private int status;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    /**
-     * Create a new {@link ProgressNotification ProgressNotification} for the
-     * provided <code>id</code>. Because a
-     * {@link TransportFactory#execute(ClientRequestInvocation)
-     * TransportFactory.execute(ClientRequestInvocation)} will likely have many
-     * stages to its execution (none, create, sending, processing, receiving
-     * etc), many {@link ProgressNotification ProgressNotification}s may be
-     * created. The <code>id</code> is guaranteed by the
-     * {@link TransportFactory TransportFactory} to remain the same between
-     * successive {@link ProgressNotification ProgressNotification}s for a
-     * single {@link TransportFactory#execute(ClientRequestInvocation)
-     * TransportFactory.execute(ClientRequestInvocation)} method call.
-     */
-    public ProgressNotification(String id) throws ClientException {
-        if (id != null) {
-            this.id = id;
-            this.execution = new Date();
-            setStatus(STATUS_NONE);
-            setSecurity(SECURITY_NONE);
-        } else {
-            throw new ClientException("ID invalid");
-        }
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public Date getExecution() {
-        return execution;
-    }
-
-    /**
-     * Sets a representation of information about the
-     * {@link TransportFactory TransportFactory}. By convention, this
-     * information is likely to be available to end users of the application.
-     */
-    public void setFactoryInformation(Properties factoryInformation) throws ClientException {
-        if (factoryInformation != null) {
-            this.factoryInformation = factoryInformation;
-        } else {
-            throw new ClientException("Invalid factory information");
-        }
-    }
-
-    public Properties getFactoryInformation() {
-        return this.factoryInformation;
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setInputReceived(int inputReceived) {
-        if (inputReceived > inputSize) {
-            this.inputReceived = inputSize;
-        } else {
-            this.inputReceived = inputReceived;
-        }
-    }
-
-    /**
-     * Returns number of bytes received of the
-     * {@link RemoteResult RemoteResult}. It should not be
-     * expected that this will ever equal <code>inputSize</code>. Instead,
-     * the status will change to STATUS_RECEIVED when the input has been fully
-     * received.
-     */
-    public int getInputReceived() {
-        return inputReceived;
-    }
-
-    public void setInputSize(int inputSize) {
-        this.inputSize = inputSize;
-        this.inputReceived = 0;
-    }
-
-    public int getInputSize() {
-        return inputSize;
-    }
-
-    public void setOutputSize(int outputSize) {
-        this.outputTransmitted = 0;
-        this.outputSize = outputSize;
-    }
-
-    public int getOutputSize() {
-        return outputSize;
-    }
-
-    public void setOutputTransmitted(int outputTransmitted) {
-        if (outputTransmitted > outputSize) {
-            this.outputTransmitted = outputSize;
-        } else {
-            this.outputTransmitted = outputTransmitted;
-        }
-    }
-
-    /**
-     * Returns number of bytes transmitted of the
-     * {@link ClientRequestInvocation ClientRequestInvocation}. It should not
-     * be expected that this will ever equal <code>outputSize</code>. Instead,
-     * the status will change to STATUS_PROCESSING when the output has been
-     * fully sent.
-     */
-    public int getOutputTransmitted() {
-        return outputTransmitted;
-    }
-
-    public void setSecurity(int security) throws ClientException {
-        if ((security == SECURITY_NONE) || (security == SECURITY_ENCRYPTED) || (security == SECURITY_IDENTIFIED)) {
-            this.security = security;
-        } else {
-            throw new ClientException("Invalid security");
-        }
-    }
-
-    public int getSecurity() {
-        return this.security;
-    }
-
-    /**
-     * Sets a representation of information about the security of
-     * the connection (if any). By convention, this information is likely
-     * to be available to end users of the application.
-     */
-    public void setSecurityInformation(Properties securityInformation) throws ClientException {
-        if (securityInformation != null) {
-            this.securityInformation = securityInformation;
-        } else {
-            throw new ClientException("Invalid security information");
-        }
-    }
-
-    public Properties getSecurityInformation() {
-        return this.securityInformation;
-    }
-
-    public void setStatus(int status) throws ClientException {
-        if ((status == STATUS_SENDING) || (status == STATUS_CONNECTING) || (status == STATUS_RECEIVED) || (status == STATUS_PROCESSING) || (status == STATUS_RECEIVING) || (status == STATUS_RETRY_DELAY) || (status == STATUS_NONE)) {
-            this.status = status;
-        } else {
-            throw new ClientException("Invalid status");
-        }
-    }
-
-    public int getStatus() {
-        return this.status;
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/ProgressOutputStream.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import java.util.Date;
-import java.util.Properties;
-
-
-/**
- * Monitors the progress of writing to an OutputStream. Links in with a
- * {@link ProgressConsumer ProgressConsumer} and <code>Properties</code> from
- * a {@link TransportFactory TransportFactory}.
- *
- * @version $Id$
- * @author Ben Alex (<a href="mailto:ben.alex@acegi.com.au">ben.alex@acegi.com.au</a>)
- */
-public class ProgressOutputStream extends FilterOutputStream {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    private ProgressConsumer progressConsumer;
-    private ProgressNotification notification;
-    private int lastNotificationStatus;
-    private int nwritten = 0;
-    private int size = 0;
-    private long lastUpdate;
-    private long updateFrequency;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    /**
-     * Monitors the progress of an output stream.<BR><BR>
-     *
-     * The <code>Properties</code> may contain an optional value for
-     * <code>updateFrequency</code>. The <code>updateFrequency</code> specifies
-     * the number of milliseconds that must pass between notifications to
-     * the {@link ProgressConsumer ProgressConsumer} concerning standard
-     * stream processing. Certain major processing events such as stream
-     * establishment and closure will always result in a notification,
-     * irrespective of the <code>updateFrequency</code>. The default value
-     * for <code>updateFrequency</code> is 250.
-     */
-    public ProgressOutputStream(ProgressNotification notification, ProgressConsumer progressConsumer, Properties props, OutputStream out, int contentLength) {
-        super(out);
-        size = contentLength;
-        this.notification = notification;
-        this.progressConsumer = progressConsumer;
-        this.lastUpdate = new Date().getTime();
-        this.lastNotificationStatus = notification.getStatus();
-        notification.setOutputSize(size);
-
-        try {
-            this.updateFrequency = new Long(props.getProperty("updateFrequency", "250")).longValue();
-        } catch (NumberFormatException nfe) {
-            updateFrequency = 500;
-        }
-
-        try {
-            notification.setStatus(ProgressNotification.STATUS_SENDING);
-        } catch (ClientException cae) {
-        }
-
-        updateBytes(nwritten);
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    /**
-     * Overrides <code>FilterOutputStream.close</code>
-     * to update the progress monitor and close the stream.
-     */
-    public void close() throws IOException {
-        try {
-            flush();
-        } catch (IOException ignored) {
-        }
-
-        updateBytes(nwritten);
-        out.close();
-    }
-
-    /**
-     * Overrides <code>FilterOutputStream.flush</code>
-     * to update the progress monitor after the flush.
-     */
-    public void flush() throws IOException {
-        out.flush();
-        updateBytes(nwritten);
-    }
-
-    /**
-     * Overrides <code>FilterOutputStream.write</code>
-     * to update the progress monitor after the write.
-     */
-    public void write(int b) throws IOException {
-        out.write(b);
-        ++nwritten;
-        updateBytes(nwritten);
-    }
-
-    /**
-     * Overrides <code>FilterOutputStream.read</code>
-     * to update the progress monitor after the write.
-     */
-    public void write(byte[] b) throws IOException {
-        int length = b.length;
-        out.write(b);
-
-        if (length > 0) {
-            nwritten += length;
-            updateBytes(nwritten);
-        }
-    }
-
-    /**
-     * Overrides <code>FilterOutputStream.write</code>
-     * to update the progress monitor after the write.
-     */
-    public void write(byte[] b, int off, int len) throws IOException {
-        if ((off | len | (b.length - (len + off)) | (off + len)) < 0) {
-            throw new IndexOutOfBoundsException();
-        }
-
-        for (int i = 0; i < len; i++) {
-            write(b[off + i]);
-        }
-    }
-
-    /**
-     * Causes the progress monitor to be notified if appropriate.
-     */
-    private void updateBytes(int nowWritten) {
-        boolean update = false;
-
-        if (nowWritten >= size) {
-            if (notification.getStatus() == ProgressNotification.STATUS_SENDING) {
-                try {
-                    notification.setStatus(ProgressNotification.STATUS_PROCESSING);
-                } catch (ClientException ignored) {
-                }
-            }
-        }
-
-        if (lastNotificationStatus != notification.getStatus()) {
-            update = true;
-        }
-
-        long currentTime = new Date().getTime();
-
-        if (notification.getStatus() == ProgressNotification.STATUS_SENDING) {
-            if (currentTime > (lastUpdate + updateFrequency)) {
-                update = true;
-            }
-        }
-
-        if (update == true) {
-            lastUpdate = currentTime;
-            lastNotificationStatus = notification.getStatus();
-            notification.setOutputTransmitted(nowWritten);
-            progressConsumer.notify(notification);
-        }
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/README.TXT

  • Ignore whitespace
-==========================
-WebWork2 Client Dispatcher
-==========================
-
-See the demo.properties file for important information.

File src/java/com/opensymphony/webwork/dispatcher/client/RemoteResult.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-import com.opensymphony.xwork.Action;
-
-import java.io.Serializable;
-
-
-/**
- * Holds information related to the outcome of a server action execution.
- * Upon receipt on the client, the contents of the <code>RemoteResult</code>
- * are copied into the {@link ClientRequestInvocation ClientRequestInvocation}
- * and are made available through
- * {@link ClientRequestInvocation#getResultAction()
- * ClientRequestInvocation.getResultAction()} and
- * {@link ClientRequestInvocation#getResultCode()()
- * ClientRequestInvocation.getResultCode()}.<BR><BR>
- *
- * This class should never be used directly by end users.
- *
- * @version $Id$
- * @author Ben Alex (<a href="mailto:ben.alex@acegi.com.au">ben.alex@acegi.com.au</a>)
- */
-public class RemoteResult implements Serializable {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    private Action action;
-    private String resultCode;
-    private String sessionId;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    public RemoteResult(Action action, String resultCode, String sessionId) {
-        this.action = action;
-        this.resultCode = resultCode;
-        this.sessionId = sessionId;
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public Action getAction() {
-        return action;
-    }
-
-    public String getResultCode() {
-        return resultCode;
-    }
-
-    public String getSessionId() {
-        return sessionId;
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/ServerHttpDispatcher.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-import com.opensymphony.util.FileManager;
-
-import com.opensymphony.webwork.WebWorkStatics;
-import com.opensymphony.webwork.config.Configuration;
-import com.opensymphony.webwork.dispatcher.ApplicationMap;
-import com.opensymphony.webwork.dispatcher.SessionMap;
-import com.opensymphony.webwork.dispatcher.multipart.MultiPartRequest;
-import com.opensymphony.webwork.dispatcher.multipart.MultiPartRequestWrapper;
-
-import com.opensymphony.xwork.ActionContext;
-import com.opensymphony.xwork.ActionProxy;
-import com.opensymphony.xwork.ActionProxyFactory;
-import com.opensymphony.xwork.interceptor.component.ComponentInterceptor;
-import com.opensymphony.xwork.interceptor.component.ComponentManager;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.PrintWriter;
-
-import java.util.HashMap;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-
-/**
- * Server side receiver of connections from {@link TransportHttp
- * TransportHttp}. You must configure this servlet in your <code>web.xml</code>
- * file. For example:<BR><BR>
- *
- * <code>
- *   &lt;servlet&gt;<BR>
- *       &lt;servlet-name&gt;client&lt;/servlet-name&gt;<BR>
- *       &lt;servlet-class&gt;com.opensymphony.webwork.dispatcher.client.ServerHttpDispatcher&lt;/servlet-class&gt;<BR>
- *   &lt;/servlet&gt;<BR><BR>
- *
- *  &lt;servlet-mapping&gt;<BR>
- *       &lt;servlet-name&gt;client&lt;/servlet-name&gt;<BR>
- *       &lt;url-pattern&gt;ClientDispatcher&lt;/url-pattern&gt;<BR>
- *   &lt;/servlet-mapping&gt;<BR><BR>
- * </code>
- *
- * @version $Id$
- * @author Ben Alex (<a href="mailto:ben.alex@acegi.com.au">ben.alex@acegi.com.au</a>)
- * @author Philipp Meier (meier@meisterbohne.de)
- * @author Rickard �berg (rickard@middleware-company.com)
- * @author Matt Baldree (matt@smallleap.com)
- */
-public class ServerHttpDispatcher extends HttpServlet implements WebWorkStatics {
-    //~ Static fields/initializers /////////////////////////////////////////////
-
-    protected static final Log log = LogFactory.getLog(ServerHttpDispatcher.class);
-
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    Integer maxSize;
-    String saveDir;
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public static String getNamespaceFromServletPath(String servletPath) {
-        servletPath = servletPath.substring(0, servletPath.lastIndexOf("/"));
-
-        return servletPath;
-    }
-
-    public void init(ServletConfig config) throws ServletException {
-        super.init(config);
-
-        //check for configuration reloading
-        if ("true".equalsIgnoreCase(Configuration.getString("webwork.configuration.xml.reload"))) {
-            FileManager.setReloadingConfigs(true);
-        }
-
-        //load multipart configuration
-        //saveDir
-        saveDir = Configuration.getString("webwork.multipart.saveDir").trim();
-
-        if (saveDir.equals("")) {
-            File tempdir = (File) config.getServletContext().getAttribute("javax.servlet.context.tempdir");
-            log.warn("Unable to find 'webwork.multipart.saveDir' property setting. Defaulting to javax.servlet.context.tempdir");
-
-            if (tempdir != null) {
-                saveDir = tempdir.toString();
-            }
-        } else {
-            File multipartSaveDir = new File(saveDir);
-
-            if (!multipartSaveDir.exists()) {
-                multipartSaveDir.mkdir();
-            }
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug("saveDir=" + saveDir);
-        }
-
-        //maxSize
-        try {
-            String maxSizeStr = Configuration.getString("webwork.multipart.maxSize");
-
-            if (maxSizeStr != null) {
-                try {
-                    maxSize = new Integer(maxSizeStr);
-                } catch (NumberFormatException e) {
-                    maxSize = new Integer(Integer.MAX_VALUE);
-                    log.warn("Unable to format 'webwork.multipart.maxSize' property setting. Defaulting to Integer.MAX_VALUE");
-                }
-            } else {
-                maxSize = new Integer(Integer.MAX_VALUE);
-                log.warn("Unable to format 'webwork.multipart.maxSize' property setting. Defaulting to Integer.MAX_VALUE");
-            }
-        } catch (IllegalArgumentException e1) {
-            maxSize = new Integer(Integer.MAX_VALUE);
-            log.warn("Unable to format 'webwork.multipart.maxSize' property setting. Defaulting to Integer.MAX_VALUE");
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug("maxSize=" + maxSize);
-        }
-    }
-
-    /**
- * Service a request.
- * Read ClientActionInvocation from request and execute action.
- */
-    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        if (log.isDebugEnabled()) {
-            log.debug("Servicing request");
-        }
-
-        //wrap request if needed
-        try {
-            request = wrapRequest(request);
-        } catch (IOException e) {
-            String message = "Could not wrap servlet request with MultipartRequestWrapper!";
-            log.error(message, e);
-            throw new ServletException(message, e);
-        }
-
-        // Get action
-        String servletPath = (String) request.getAttribute("javax.servlet.include.servlet_path");
-
-        if (servletPath == null) {
-            servletPath = request.getServletPath();
-        }
-
-        ObjectInputStream in = new ObjectInputStream(request.getInputStream());
-        final ClientRequestInvocation invocation;
-
-        try {
-            invocation = (ClientRequestInvocation) in.readObject();
-
-            if (log.isDebugEnabled()) {
-                log.debug("Have a ClientRequestInvocation object");
-            }
-        } catch (ClassNotFoundException cnfe) {
-            String message = "Could not deserialise ClientActionInvocation!";
-            log.error(message, cnfe);
-            throw new ServletException(message, cnfe);
-        }
-
-        // Path is always original path, even if it is included in page with another path
-        //String actionPath = request.getServletPath();
-        //actionPath = getNamespaceFromServletPath(actionPath);
-        String actionName = getActionName(invocation.getRemoteActionName());
-        String actionPath = getNamespaceFromServletPath(invocation.getRemoteActionName());
-
-        if (log.isDebugEnabled()) {
-            log.debug("Executing action: " + actionName + " with namespace: " + actionPath);
-        }
-
-        HashMap extraContext = new HashMap();
-        extraContext.put(ActionContext.PARAMETERS, invocation.getParameters());
-        extraContext.put(ActionContext.SESSION, new SessionMap(request));
-        extraContext.put(ActionContext.APPLICATION, new ApplicationMap(getServletContext()));
-        extraContext.put(HTTP_REQUEST, request);
-        extraContext.put(HTTP_RESPONSE, response);
-        extraContext.put(SERVLET_CONFIG, getServletConfig());
-        extraContext.put(ComponentInterceptor.COMPONENT_MANAGER, request.getAttribute(ComponentManager.COMPONENT_MANAGER_KEY));
-        extraContext.put(SERLVET_DISPATCHER, this);
-
-        try {
-            ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy(actionPath, actionName, extraContext);
-            request.setAttribute("webwork.valueStack", proxy.getInvocation().getStack());
-            proxy.execute();
-        } catch (Exception e) {
-            try {
-                response.setContentType("text/html");
-                response.setLocale(Configuration.getLocale());
-
-                PrintWriter writer = response.getWriter();
-                writer.write("Error executing action: " + e.getMessage());
-                writer.println("<pre>\n");
-                e.printStackTrace(response.getWriter());
-                writer.print("</pre>\n");
-
-                log.error("Could not execute action", e);
-            } catch (IOException e1) {
-            }
-        }
-    }
-
-    /**
- * Determine action name by extracting last string and removing
- * extension. (/.../.../Foo.action -> Foo)
- */
-    String getActionName(String name) {
-        // Get action name ("Foo.action" -> "Foo" action)
-        int beginIdx = name.lastIndexOf("/");
-        int endIdx = name.lastIndexOf(".");
-
-        return name.substring(((beginIdx == -1) ? 0 : (beginIdx + 1)), (endIdx == -1) ? name.length() : endIdx);
-    }
-
-    /**
- * Wrap servlet request with the appropriate request. It will check to
- * see if request is a multipart request and wrap in appropriately.
- *
- * @param request
- * @return wrapped request or original request
- */
-    private HttpServletRequest wrapRequest(HttpServletRequest request) throws IOException {
-        // don't wrap more than once
-        if (request instanceof MultiPartRequestWrapper) {
-            return request;
-        }
-
-        if (MultiPartRequest.isMultiPart(request)) {
-            request = new MultiPartRequestWrapper(request, saveDir, maxSize.intValue());
-        }
-
-        return request;
-    }
-}

File src/java/com/opensymphony/webwork/dispatcher/client/ServerHttpDispatcherResult.java

  • Ignore whitespace
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.webwork.dispatcher.client;
-
-import com.opensymphony.webwork.ServletActionContext;
-import com.opensymphony.webwork.WebWorkStatics;
-
-import com.opensymphony.xwork.Action;
-import com.opensymphony.xwork.ActionInvocation;
-import com.opensymphony.xwork.Result;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-
-/**
- * Server side transmitter of {@link RemoteResult RemoteResult}s to the
- * {@link TransportHttp TransportHttp}. Pulls the
- * <code>HttpServletResponse</code> object from the action context, and
- * sends back a serialised {@link RemoteResult RemoteResult} to the
- * remote {@link TransportHttp TransportHttp}. No params are required.<BR><BR>
- *
- * You must configure this as a result in your <code>xwork.xml</code>.
- * For example:<BR><BR>
- *
- * <code>
- * &lt;result-types&gt;<BR>
- *   &lt;result-type name="client" class="com.opensymphony.webwork.dispatcher.client.ServerHttpDispatcherResult"/&gt;<BR>
- * &lt;/result-types&gt;<BR><BR>
- * </code>
- *
- * You must also ensure your <code>xwork.xml</code> is correctly setup to
- * reference the new <code>result-type</code>. An example mapping might be:<BR><BR>
- *
- * <code>&lt;action name="remoteActionName"
- * class="com.some.company.class"&gt;<BR>
- * &lt;result name="success" type="client"/&gt;<BR>