You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2006/01/21 12:58:07 UTC
svn commit: r371016 [2/3] - in
/struts/action/trunk/src/java/org/apache/struts: ./ action/ chain/
chain/commands/ chain/commands/generic/ chain/commands/servlet/
chain/commands/util/ chain/contexts/ mock/
Modified: struts/action/trunk/src/java/org/apache/struts/action/DynaActionForm.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/DynaActionForm.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/DynaActionForm.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/DynaActionForm.java Sat Jan 21 03:57:42 2006
@@ -59,8 +59,8 @@
protected DynaActionFormClass dynaClass = null;
/**
- * <p>The set of property values for this <code>DynaActionForm</code>,
- * keyed by property name.</p>
+ * <p>The set of property values for this <code>DynaActionForm</code>, keyed
+ * by property name.</p>
*/
protected HashMap dynaValues = new HashMap();
@@ -68,8 +68,8 @@
/**
* <p>Initialize all bean properties to their initial values, as specified
- * in the {@link FormPropertyConfig} elements associated with the
- * definition of this <code>DynaActionForm</code>.</p>
+ * in the {@link FormPropertyConfig} elements associated with the definition
+ * of this <code>DynaActionForm</code>.</p>
*
* @param mapping The mapping used to select this instance
*/
@@ -110,8 +110,8 @@
* <p>Reset bean properties to their default state, as needed. This method
* is called before the properties are repopulated by the controller.</p>
*
- * <p>The default implementation attempts to forward to the HTTP version
- * of this method.</p>
+ * <p>The default implementation attempts to forward to the HTTP version of
+ * this method.</p>
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
@@ -122,9 +122,9 @@
/**
* <p>Reset the properties to their <code>initial</code> value if their
- * <code>reset</code> configuration is set to true or if
- * <code>reset</code> is set to a list of HTTP request methods that
- * includes the method of given <code>request</code> object.</p>
+ * <code>reset</code> configuration is set to true or if <code>reset</code>
+ * is set to a list of HTTP request methods that includes the method of
+ * given <code>request</code> object.</p>
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
@@ -188,9 +188,10 @@
* @param name Name of the property to check
* @param key Name of the key to check
* @return <code>true</code> if the specified mapped property contains a
- * value for the specified key value; <code>true</code>
- * otherwise.
- * @throws IllegalArgumentException if there is no property of the
+ * value for the specified key value; <code>true</code> otherwise.
+ * @throws NullPointerException if there is no property of the specified
+ * name
+ * @throws IllegalArgumentException if there is no mapped property of the
* specified name
*/
public boolean contains(String name, String key) {
@@ -213,8 +214,8 @@
*
* @param name Name of the property whose value is to be retrieved
* @return The value of a simple property with the specified name.
- * @throws IllegalArgumentException if there is no property of the
- * specified name
+ * @throws IllegalArgumentException if there is no property of the specified
+ * name
* @throws NullPointerException if the type specified for the property
* is invalid
*/
@@ -261,20 +262,17 @@
}
/**
- * <p>Return the value of an indexed property with the specified name.
- * </p>
+ * <p>Return the value of an indexed property with the specified name. </p>
*
* @param name Name of the property whose value is to be retrieved
* @param index Index of the value to be retrieved
* @return The value of an indexed property with the specified name.
- * @throws IllegalArgumentException if there is no property of the
- * specified name
- * @throws IllegalArgumentException if the specified property exists, but
- * is not indexed
- * @throws IndexOutOfBoundsException if the specified index is outside the
- * range of the underlying property
- * @throws NullPointerException if no array or List has been
- * initialized for this property
+ * @throws IllegalArgumentException if there is no property of the specified
+ * name
+ * @throws IllegalArgumentException if the specified property exists, but is
+ * not indexed
+ * @throws NullPointerException if no array or List has been initialized
+ * for this property
*/
public Object get(String name, int index) {
Object value = dynaValues.get(name);
@@ -300,10 +298,10 @@
* @param key Key of the value to be retrieved
* @return The value of a mapped property with the specified name, or
* <code>null</code> if there is no value for the specified key.
- * @throws IllegalArgumentException if there is no property of the
- * specified name
- * @throws IllegalArgumentException if the specified property exists, but
- * is not mapped
+ * @throws NullPointerException if there is no property of the specified
+ * name
+ * @throws IllegalArgumentException if the specified property exists, but is
+ * not mapped
*/
public Object get(String name, String key) {
Object value = dynaValues.get(name);
@@ -321,15 +319,15 @@
}
/**
- * <p>Return the value of a <code>String</code> property with the
- * specified name. This is equivalent to calling <code>(String)
+ * <p>Return the value of a <code>String</code> property with the specified
+ * name. This is equivalent to calling <code>(String)
* dynaForm.get(name)</code>.</p>
*
* @param name Name of the property whose value is to be retrieved.
* @return The value of a <code>String</code> property with the specified
* name.
- * @throws IllegalArgumentException if there is no property of the
- * specified name
+ * @throws IllegalArgumentException if there is no property of the specified
+ * name
* @throws NullPointerException if the type specified for the property
* is invalid
* @throws ClassCastException if the property is not a String.
@@ -345,10 +343,10 @@
* dynaForm.get(name)</code>.</p>
*
* @param name Name of the property whose value is to be retrieved.
- * @return The value of a <code>String[]</code> property with the
- * specified name.
- * @throws IllegalArgumentException if there is no property of the
- * specified name
+ * @return The value of a <code>String[]</code> property with the specified
+ * name.
+ * @throws IllegalArgumentException if there is no property of the specified
+ * name
* @throws NullPointerException if the type specified for the property
* is invalid
* @throws ClassCastException if the property is not a String[].
@@ -398,7 +396,9 @@
*
* @param name Name of the property for which a value is to be removed
* @param key Key of the value to be removed
- * @throws IllegalArgumentException if there is no property of the
+ * @throws NullPointerException if there is no property of the specified
+ * name
+ * @throws IllegalArgumentException if there is no mapped property of the
* specified name
*/
public void remove(String name, String key) {
@@ -422,14 +422,14 @@
* @param name Name of the property whose value is to be set
* @param value Value to which this property is to be set
* @throws ConversionException if the specified value cannot be
- * converted to the type required for
- * this property
- * @throws IllegalArgumentException if there is no property of the
- * specified name
+ * converted to the type required for this
+ * property
+ * @throws IllegalArgumentException if there is no property of the specified
+ * name
* @throws NullPointerException if the type specified for the property
* is invalid
- * @throws NullPointerException if an attempt is made to set a
- * primitive property to null
+ * @throws NullPointerException if an attempt is made to set a primitive
+ * property to null
*/
public void set(String name, Object value) {
DynaProperty descriptor = getDynaProperty(name);
@@ -444,8 +444,7 @@
throw new NullPointerException("Primitive value for '" + name
+ "'");
}
- } else
- if (!isDynaAssignable(descriptor.getType(), value.getClass())) {
+ } else if (!isDynaAssignable(descriptor.getType(), value.getClass())) {
throw new ConversionException("Cannot assign value of type '"
+ value.getClass().getName() + "' to property '" + name
+ "' of type '" + descriptor.getType().getName() + "'");
@@ -461,9 +460,9 @@
* @param index Index of the property to be set
* @param value Value to which this property is to be set
* @throws ConversionException if the specified value cannot be
- * converted to the type required for
- * this property
- * @throws IllegalArgumentException if there is no property of the
+ * converted to the type required for this
+ * property
+ * @throws NullPointerException if there is no property of the
* specified name
* @throws IllegalArgumentException if the specified property exists, but
* is not indexed
@@ -481,8 +480,7 @@
} else if (prop instanceof List) {
try {
((List) prop).set(index, value);
- }
- catch (ClassCastException e) {
+ } catch (ClassCastException e) {
throw new ConversionException(e.getMessage());
}
} else {
@@ -497,13 +495,10 @@
* @param name Name of the property whose value is to be set
* @param key Key of the property to be set
* @param value Value to which this property is to be set
- * @throws ConversionException if the specified value cannot be
- * converted to the type required for
- * this property
- * @throws IllegalArgumentException if there is no property of the
- * specified name
- * @throws IllegalArgumentException if the specified property exists, but
- * is not mapped
+ * @throws NullPointerException if there is no property of the specified
+ * name
+ * @throws IllegalArgumentException if the specified property exists, but is
+ * not mapped
*/
public void set(String name, String key, Object value) {
Object prop = dynaValues.get(name);
@@ -630,8 +625,8 @@
*
* @param name Name of the property for which to retrieve the descriptor
* @return The property descriptor for the specified property name.
- * @throws IllegalArgumentException if this is not a valid property name
- * for our DynaClass
+ * @throws IllegalArgumentException if this is not a valid property name for
+ * our DynaClass
*/
protected DynaProperty getDynaProperty(String name) {
DynaProperty descriptor = getDynaClass().getDynaProperty(name);
@@ -651,8 +646,8 @@
*
* @param dest Destination class
* @param source Source class
- * @return <code>true</code> if the source is assignable to the
- * destination; <code>false</code> otherwise.
+ * @return <code>true</code> if the source is assignable to the destination;
+ * <code>false</code> otherwise.
*/
protected boolean isDynaAssignable(Class dest, Class source) {
if (dest.isAssignableFrom(source)
Modified: struts/action/trunk/src/java/org/apache/struts/action/DynaActionFormClass.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/DynaActionFormClass.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/DynaActionFormClass.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/DynaActionFormClass.java Sat Jan 21 03:57:42 2006
@@ -20,8 +20,6 @@
import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.beanutils.DynaClass;
import org.apache.commons.beanutils.DynaProperty;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.struts.config.FormBeanConfig;
import org.apache.struts.config.FormPropertyConfig;
import org.apache.struts.util.RequestUtils;
@@ -41,7 +39,6 @@
* @since Struts 1.1
*/
public class DynaActionFormClass implements DynaClass, Serializable {
- private static Log log = LogFactory.getLog(DynaActionFormClass.class);
// ----------------------------------------------------- Instance Variables
@@ -79,9 +76,8 @@
/**
* <p>Construct a new <code>DynaActionFormClass</code> for the specified
* form bean configuration. This constructor is private;
- * <code>DynaActionFormClass</code> instances will be created as needed
- * via calls to the static <code>createDynaActionFormClass()</code>
- * method.</p>
+ * <code>DynaActionFormClass</code> instances will be created as needed via
+ * calls to the static <code>createDynaActionFormClass()</code> method.</p>
*
* @param config The FormBeanConfig instance describing the properties of
* the bean to be created
@@ -109,8 +105,8 @@
}
/**
- * <p>Return a property descriptor for the specified property, if it
- * exists; otherwise, return <code>null</code>.</p>
+ * <p>Return a property descriptor for the specified property, if it exists;
+ * otherwise, return <code>null</code>.</p>
*
* @param name Name of the dynamic property for which a descriptor is
* requested
@@ -142,10 +138,9 @@
/**
* <p>Instantiate and return a new {@link DynaActionForm} instance,
- * associated with this <code>DynaActionFormClass</code>. The properties
- * of the returned {@link DynaActionForm} will have been initialized to
- * the default values specified in the form bean configuration
- * information.</p>
+ * associated with this <code>DynaActionFormClass</code>. The properties of
+ * the returned {@link DynaActionForm} will have been initialized to the
+ * default values specified in the form bean configuration information.</p>
*
* @return A new {@link DynaActionForm} instance.
* @throws IllegalAccessException if the Class or the appropriate
@@ -219,9 +214,9 @@
/**
* <p>Return the implementation class we are using to construct new
- * instances, re-introspecting our {@link FormBeanConfig} if necessary
- * (that is, after being deserialized, since <code>beanClass</code> is
- * marked transient).</p>
+ * instances, re-introspecting our {@link FormBeanConfig} if necessary (that
+ * is, after being deserialized, since <code>beanClass</code> is marked
+ * transient).</p>
*
* @return The implementation class used to construct new instances.
*/
@@ -250,8 +245,7 @@
// Validate the ActionFormBean implementation class
try {
beanClass = RequestUtils.applicationClass(config.getType());
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
throw new IllegalArgumentException(
"Cannot instantiate ActionFormBean class '"
+ config.getType()
Modified: struts/action/trunk/src/java/org/apache/struts/action/ExceptionHandler.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/ExceptionHandler.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/ExceptionHandler.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/ExceptionHandler.java Sat Jan 21 03:57:42 2006
@@ -42,8 +42,7 @@
* <p>The name of a configuration property which can be set to specify an
* alternative path which should be used when the <code>HttpServletResponse</code>
* has already been committed.</p> <p>To use this, in your
- * <code>struts-config.xml</code> specify the exception handler like
- * this:
+ * <code>struts-config.xml</code> specify the exception handler like this:
* <pre>
* <exception
* key="GlobalExceptionHandler.default"
@@ -52,8 +51,8 @@
* <set-property key="INCLUDE_PATH" value="/error.jsp" />
* </exception>
* </pre>
- * </p> <p>You would want to use this when your normal ExceptionHandler
- * path is a Tiles definition or otherwise unsuitable for use in an
+ * </p> <p>You would want to use this when your normal ExceptionHandler path
+ * is a Tiles definition or otherwise unsuitable for use in an
* <code>include</code> context. If you do not use this, and you do not
* specify "SILENT_IF_COMMITTED" then the ExceptionHandler will attempt to
* forward to the same path which would be used in normal circumstances,
@@ -67,11 +66,10 @@
/**
* <p>The name of a configuration property which indicates that Struts
* should do nothing if the response has already been committed. This
- * suppresses the default behavior, which is to use an "include" rather
- * than a "forward" in this case in hopes of providing some meaningful
+ * suppresses the default behavior, which is to use an "include" rather than
+ * a "forward" in this case in hopes of providing some meaningful
* information to the browser.</p> <p>To use this, in your
- * <code>struts-config.xml</code> specify the exception handler like
- * this:
+ * <code>struts-config.xml</code> specify the exception handler like this:
* <pre>
* <exception
* key="GlobalExceptionHandler.default"
@@ -80,11 +78,11 @@
* <set-property key="SILENT_IF_COMMITTED" value="true" />
* </exception>
* </pre>
- * To be effective, this value must be defined to the literal String
- * "true". If it is not defined or defined to any other value, the
- * default behavior will be used. </p> <p>You only need to use this if you
- * do not want error information displayed in the browser when Struts
- * intercepts an exception after the response has been committed.</p>
+ * To be effective, this value must be defined to the literal String "true".
+ * If it is not defined or defined to any other value, the default behavior
+ * will be used. </p> <p>You only need to use this if you do not want error
+ * information displayed in the browser when Struts intercepts an exception
+ * after the response has been committed.</p>
*
* @since Struts 1.3
*/
@@ -93,7 +91,7 @@
/**
* <p>Commons logging instance.</p>
*/
- private static final Log log = LogFactory.getLog(ExceptionHandler.class);
+ private static final Log LOG = LogFactory.getLog(ExceptionHandler.class);
/**
* <p>The message resources for this package.</p>
@@ -102,9 +100,8 @@
.getMessageResources("org.apache.struts.action.LocalStrings");
/**
- * <p>Handle the <code>Exception</code>. Return the
- * <code>ActionForward</code> instance (if any) returned by the called
- * <code>ExceptionHandler</code>.
+ * <p>Handle the <code>Exception</code>. Return the <code>ActionForward</code>
+ * instance (if any) returned by the called <code>ExceptionHandler</code>.
*
* @param ex The exception to handle
* @param ae The ExceptionConfig corresponding to the exception
@@ -112,8 +109,8 @@
* @param formInstance The ActionForm we are processing
* @param request The servlet request we are processing
* @param response The servlet response we are creating
- * @return The <code>ActionForward</code> instance (if any) returned by
- * the called <code>ExceptionHandler</code>.
+ * @return The <code>ActionForward</code> instance (if any) returned by the
+ * called <code>ExceptionHandler</code>.
* @throws ServletException if a servlet exception occurs
* @since Struts 1.1
*/
@@ -123,11 +120,11 @@
HttpServletRequest request,
HttpServletResponse response)
throws ServletException {
- log.debug("ExceptionHandler executing for exception " + ex);
+ LOG.debug("ExceptionHandler executing for exception " + ex);
- ActionForward forward = null;
- ActionMessage error = null;
- String property = null;
+ ActionForward forward;
+ ActionMessage error;
+ String property;
// Build the forward from the exception mapping if it exists
// or from the form input
@@ -156,14 +153,13 @@
return forward;
}
- log.debug(
- "Response is already committed, so forwarding will not work. Attempt alternate handling.");
-
+ LOG.debug("Response is already committed, so forwarding will not work."
+ + " Attempt alternate handling.");
if (!silent(ae)) {
handleCommittedResponse(ex, ae, mapping, formInstance, request,
response, forward);
} else {
- log.warn("ExceptionHandler configured with " + SILENT_IF_COMMITTED
+ LOG.warn("ExceptionHandler configured with " + SILENT_IF_COMMITTED
+ " and response is committed.", ex);
}
@@ -172,18 +168,18 @@
/**
* <p>Attempt to give good information when the response has already been
- * committed when the exception was thrown. This happens often when Tiles
- * is used. Base implementation will see if the INCLUDE_PATH property has
- * been set, or if not, it will attempt to use the same path to which
- * control would have been forwarded.</p>
+ * committed when the exception was thrown. This happens often when Tiles is
+ * used. Base implementation will see if the INCLUDE_PATH property has been
+ * set, or if not, it will attempt to use the same path to which control
+ * would have been forwarded.</p>
*
- * @param ex
- * @param config
- * @param mapping
- * @param formInstance
- * @param request
- * @param response
- * @param actionForward
+ * @param ex The exception to handle
+ * @param config The ExceptionConfig we are processing
+ * @param mapping The ActionMapping we are processing
+ * @param formInstance The ActionForm we are processing
+ * @param request The servlet request we are processing
+ * @param response The servlet response we are creating
+ * @param actionForward The ActionForward we are processing
* @since Struts 1.3
*/
protected void handleCommittedResponse(Exception ex,
@@ -197,7 +193,7 @@
if (includePath != null) {
if (includePath.startsWith("/")) {
- log.debug(
+ LOG.debug(
"response committed, but attempt to include results of actionForward path");
RequestDispatcher requestDispatcher = request
@@ -207,28 +203,26 @@
requestDispatcher.include(request, response);
return;
- }
- catch (IOException e) {
- log.error(
+ } catch (IOException e) {
+ LOG.error(
"IOException when trying to include the error page path "
+ includePath,
e);
- }
- catch (ServletException e) {
- log.error(
+ } catch (ServletException e) {
+ LOG.error(
"ServletException when trying to include the error page path "
+ includePath,
e);
}
} else {
- log.warn(
+ LOG.warn(
"Suspicious includePath doesn't seem likely to work, so skipping it: "
+ includePath
+ "; expected path to start with '/'");
}
}
- log.debug(
+ LOG.debug(
"Include not available or failed; try writing to the response directly.");
try {
@@ -236,23 +230,22 @@
response.getWriter().println("<!-- ");
ex.printStackTrace(response.getWriter());
response.getWriter().println("-->");
- }
- catch (IOException e) {
- log.error("Error giving minimal information about exception", e);
- log.error("Original exception: ", ex);
+ } catch (IOException e) {
+ LOG.error("Error giving minimal information about exception", e);
+ LOG.error("Original exception: ", ex);
}
}
/**
- * <p>Return a path to which an include should be attempted in the case
- * when the response was committed before the <code>ExceptionHandler</code>
- * was invoked. </p> <p>If the <code>ExceptionConfig</code> has the
- * property <code>INCLUDE_PATH</code> defined, then the value of that
- * property will be returned.</p>
+ * <p>Return a path to which an include should be attempted in the case when
+ * the response was committed before the <code>ExceptionHandler</code> was
+ * invoked. </p> <p>If the <code>ExceptionConfig</code> has the property
+ * <code>INCLUDE_PATH</code> defined, then the value of that property will
+ * be returned. Otherwise, the ActionForward path is returned. </p>
*
- * @param config
- * @param actionForward
- * @return
+ * @param config Configuration element
+ * @param actionForward Forward to use on error
+ * @return Path of resource to include
* @since Struts 1.3
*/
protected String determineIncludePath(ExceptionConfig config,
@@ -269,27 +262,27 @@
/**
* <p>Logs the <code>Exception</code> using commons-logging.</p>
*
- * @param e The Exception to log.
+ * @param e The Exception to LOG.
* @since Struts 1.2
*/
protected void logException(Exception e) {
- log.debug(messages.getMessage("exception.log"), e);
+ LOG.debug(messages.getMessage("exception.LOG"), e);
}
/**
* <p>Default implementation for handling an <code>ActionMessage</code>
* generated from an <code>Exception</code> during <code>Action</code>
* delegation. The default implementation is to set an attribute of the
- * request or session, as defined by the scope provided (the scope from
- * the exception mapping). An <code>ActionMessages</code> instance is
- * created, the error is added to the collection and the collection is set
- * under the <code>Globals.ERROR_KEY</code>.</p>
+ * request or session, as defined by the scope provided (the scope from the
+ * exception mapping). An <code>ActionMessages</code> instance is created,
+ * the error is added to the collection and the collection is set under the
+ * <code>Globals.ERROR_KEY</code>.</p>
*
* @param request The request we are handling
* @param property The property name to use for this error
* @param error The error generated from the exception mapping
- * @param forward The forward generated from the input path (from the
- * form or exception mapping)
+ * @param forward The forward generated from the input path (from the form
+ * or exception mapping)
* @param scope The scope of the exception mapping.
* @since Struts 1.2
*/
@@ -313,8 +306,8 @@
* <code>"true"</code> for the property "SILENT_IF_COMMITTED" in the
* ExceptionConfig.</p>
*
- * @param config
- * @return
+ * @param config The ExceptionConfiguration we are handling
+ * @return True if Handler is silent
* @since Struts 1.3
*/
private boolean silent(ExceptionConfig config) {
Modified: struts/action/trunk/src/java/org/apache/struts/action/PlugIn.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/PlugIn.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/PlugIn.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/PlugIn.java Sat Jan 21 03:57:42 2006
@@ -22,23 +22,21 @@
import javax.servlet.ServletException;
/**
- * <p>A <strong>PlugIn</strong> is a configuration wrapper for a
- * module-specific resource or service that needs to be notified about
- * application startup and application shutdown events (corresponding to when
- * the container calls <code>init</code> and <code>destroy</code> on the
- * corresponding {@link ActionServlet} instance). <code>PlugIn</code> objects
- * can be configured in the <code>struts-config.xml</code> file, without the
- * need to subclass {@link ActionServlet} simply to perform application
- * lifecycle activities.</p>
+ * <p>A <strong>PlugIn</strong> is a configuration wrapper for a module-specific
+ * resource or service that needs to be notified about application startup and
+ * application shutdown events (corresponding to when the container calls
+ * <code>init</code> and <code>destroy</code> on the corresponding {@link
+ * ActionServlet} instance). <code>PlugIn</code> objects can be configured in
+ * the <code>struts-config.xml</code> file, without the need to subclass {@link
+ * ActionServlet} simply to perform application lifecycle activities.</p>
*
- * <p>Implementations of this interface must supply a zero-argument
- * constructor for use by {@link ActionServlet}. Configuration can be
- * accomplished by providing standard JavaBeans property setter methods, which
- * will all have been called before the <code>init()</code> method is
- * invoked.</p>
+ * <p>Implementations of this interface must supply a zero-argument constructor
+ * for use by {@link ActionServlet}. Configuration can be accomplished by
+ * providing standard JavaBeans property setter methods, which will all have
+ * been called before the <code>init()</code> method is invoked.</p>
*
- * <p>This interface can be applied to any class, including an Action
- * subclass. </p>
+ * <p>This interface can be applied to any class, including an Action subclass.
+ * </p>
*
* @version $Rev$ $Date: 2005-05-14 01:09:32 -0400 (Sat, 14 May 2005)
* $
@@ -54,8 +52,8 @@
* <p>Receive notification that the specified module is being started
* up.</p>
*
- * @param servlet ActionServlet that is managing all the modules in this
- * web application
+ * @param servlet ActionServlet that is managing all the modules in this web
+ * application
* @param config ModuleConfig for the module with which this plug-in is
* associated
* @throws ServletException if this <code>PlugIn</code> cannot be
Modified: struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java Sat Jan 21 03:57:42 2006
@@ -43,8 +43,8 @@
* <p><strong>RequestProcessor</strong> contains the processing logic that the
* {@link ActionServlet} performs as it receives each servlet request from the
* container. You can customize the request processing behavior by subclassing
- * this class and overriding the method(s) whose behavior you are interested
- * in changing.</p>
+ * this class and overriding the method(s) whose behavior you are interested in
+ * changing.</p>
*
* @version $Rev$ $Date: 2005-11-09 00:11:45 -0500 (Wed, 09 Nov 2005)
* $
@@ -228,8 +228,8 @@
* @param request The servlet request we are processing
* @param response The servlet response we are creating
* @param mapping The mapping we are using
- * @return An <code>Action</code> instance that will be used to process
- * the current request.
+ * @return An <code>Action</code> instance that will be used to process the
+ * current request.
* @throws IOException if an input/output error occurs
*/
protected Action processActionCreate(HttpServletRequest request,
@@ -243,10 +243,10 @@
log.debug(" Looking for Action instance for class " + className);
}
- // :TODO: If there were a mapping property indicating whether
+ // If there were a mapping property indicating whether
// an Action were a singleton or not ([true]),
// could we just instantiate and return a new instance here?
- Action instance = null;
+ Action instance;
synchronized (actions) {
// Return any existing Action instance of this class
@@ -269,10 +269,9 @@
instance =
(Action) RequestUtils.applicationInstance(className);
- // :TODO: Maybe we should propagate this exception
+ // Maybe we should propagate this exception
// instead of returning null.
- }
- catch (Exception e) {
+ } catch (Exception e) {
log.error(getInternal().getMessage("actionCreate",
mapping.getPath()), e);
@@ -335,8 +334,8 @@
/**
* <p>Forward or redirect to the specified destination, by the specified
- * mechanism. This method uses a <code>ForwardConfig</code> object
- * instead an <code>ActionForward</code>.</p>
+ * mechanism. This method uses a <code>ForwardConfig</code> object instead
+ * an <code>ActionForward</code>.</p>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
@@ -357,7 +356,7 @@
}
String forwardPath = forward.getPath();
- String uri = null;
+ String uri;
// paths not starting with / should be passed through without any
// processing (ie. they're absolute)
@@ -385,18 +384,17 @@
// ServletException?
/**
- * <P>Ask the specified <code>Action</code> instance to handle this
- * request. Return the <code>ActionForward</code> instance (if any)
- * returned by the called <code>Action</code> for further processing.
- * </P>
+ * <P>Ask the specified <code>Action</code> instance to handle this request.
+ * Return the <code>ActionForward</code> instance (if any) returned by the
+ * called <code>Action</code> for further processing. </P>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
* @param action The Action instance to be used
* @param form The ActionForm instance to pass to this Action
* @param mapping The ActionMapping instance to pass to this Action
- * @return The <code>ActionForward</code> instance (if any) returned by
- * the called <code>Action</code>.
+ * @return The <code>ActionForward</code> instance (if any) returned by the
+ * called <code>Action</code>.
* @throws IOException if an input/output error occurs
* @throws ServletException if a servlet exception occurs
*/
@@ -408,8 +406,7 @@
throws IOException, ServletException {
try {
return (action.execute(mapping, form, request, response));
- }
- catch (Exception e) {
+ } catch (Exception e) {
return (processException(request, response, e, form, mapping));
}
}
@@ -455,9 +452,9 @@
/**
* <p>Set the default content type (with optional character encoding) for
- * all responses if requested. <strong>NOTE</strong> - This header will
- * be overridden automatically if a <code>RequestDispatcher.forward</code>
- * call is ultimately invoked.</p>
+ * all responses if requested. <strong>NOTE</strong> - This header will be
+ * overridden automatically if a <code>RequestDispatcher.forward</code> call
+ * is ultimately invoked.</p>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
@@ -482,8 +479,8 @@
* @param exception The exception being handled
* @param form The ActionForm we are processing
* @param mapping The ActionMapping we are using
- * @return The <code>ActionForward</code> instance (if any) returned by
- * the called <code>ExceptionHandler</code>.
+ * @return The <code>ActionForward</code> instance (if any) returned by the
+ * called <code>ExceptionHandler</code>.
* @throws IOException if an input/output error occurs
* @throws ServletException if a servlet exception occurs
*/
@@ -516,8 +513,7 @@
return (handler.execute(exception, config, mapping, form, request,
response));
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new ServletException(e);
}
}
@@ -532,6 +528,8 @@
* @param mapping The ActionMapping we are using
* @return <code>true</code> to continue normal processing;
* <code>false</code> if a response has been created.
+ * @throws IOException if an input/output error occurs
+ * @throws ServletException if a servlet exception occurs
*/
protected boolean processForward(HttpServletRequest request,
HttpServletResponse response,
@@ -581,8 +579,7 @@
/**
* <p>Automatically select a <code>Locale</code> for the current user, if
* requested. <strong>NOTE</strong> - configuring Locale selection will
- * trigger the creation of a new <code>HttpSession</code> if
- * necessary.</p>
+ * trigger the creation of a new <code>HttpSession</code> if necessary.</p>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
@@ -621,8 +618,7 @@
* @param request The servlet request we are processing
* @param response The servlet response we are creating
* @param path The portion of the request URI for selecting a mapping
- * @return The mapping used to process the selection path for this
- * request.
+ * @return The mapping used to process the selection path for this request.
* @throws IOException if an input/output error occurs
*/
protected ActionMapping processMapping(HttpServletRequest request,
@@ -687,9 +683,8 @@
/**
* <p>Set the no-cache headers for all responses, if requested.
- * <strong>NOTE</strong> - This header will be overridden automatically if
- * a <code>RequestDispatcher.forward</code> call is ultimately
- * invoked.</p>
+ * <strong>NOTE</strong> - This header will be overridden automatically if a
+ * <code>RequestDispatcher.forward</code> call is ultimately invoked.</p>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
@@ -705,10 +700,10 @@
}
/**
- * <p>Identify and return the path component (from the request URI) that
- * we will use to select an <code>ActionMapping</code> with which to
- * dispatch. If no such path can be identified, create an error response
- * and return <code>null</code>.</p>
+ * <p>Identify and return the path component (from the request URI) that we
+ * will use to select an <code>ActionMapping</code> with which to dispatch.
+ * If no such path can be identified, create an error response and return
+ * <code>null</code>.</p>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
@@ -718,7 +713,7 @@
protected String processPath(HttpServletRequest request,
HttpServletResponse response)
throws IOException {
- String path = null;
+ String path;
// For prefix matching, match on the path info (if any)
path = (String) request.getAttribute(INCLUDE_PATH_INFO);
@@ -800,17 +795,16 @@
// Set the cancellation request attribute if appropriate
if ((request.getParameter(Globals.CANCEL_PROPERTY) != null)
- || (request.getParameter(Globals.CANCEL_PROPERTY_X) != null))
- {
+ || (request.getParameter(Globals.CANCEL_PROPERTY_X) != null)) {
request.setAttribute(Globals.CANCEL_KEY, Boolean.TRUE);
}
}
/**
- * <p>General-purpose preprocessing hook that can be overridden as
- * required by subclasses. Return <code>true</code> if you want standard
- * processing to continue, or <code>false</code> if the response has
- * already been completed. The default implementation does nothing.</p>
+ * <p>General-purpose preprocessing hook that can be overridden as required
+ * by subclasses. Return <code>true</code> if you want standard processing
+ * to continue, or <code>false</code> if the response has already been
+ * completed. The default implementation does nothing.</p>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
@@ -824,8 +818,8 @@
/**
* <p>If this action is protected by security roles, make sure that the
- * current user possesses at least one of them. Return <code>true</code>
- * to continue normal processing, or <code>false</code> if an appropriate
+ * current user possesses at least one of them. Return <code>true</code> to
+ * continue normal processing, or <code>false</code> if an appropriate
* response has been created and processing should terminate.</p>
*
* @param request The servlet request we are processing
@@ -877,9 +871,8 @@
* ActionMapping} has not disabled validation, call the
* <code>validate</code> method of the specified {@link ActionForm}, and
* forward to the input path if there were any errors. Return
- * <code>true</code> if we should continue processing, or
- * <code>false</code> if we have already forwarded control back to the
- * input form.</p>
+ * <code>true</code> if we should continue processing, or <code>false</code>
+ * if we have already forwarded control back to the input form.</p>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
@@ -972,12 +965,14 @@
* <p>Do a module relative forward to specified URI using request
* dispatcher. URI is relative to the current module. The real URI is
* compute by prefixing the module name.</p> <p>This method is used
- * internally and is not part of the public API. It is advised to not use
- * it in subclasses. </p>
+ * internally and is not part of the public API. It is advised to not use it
+ * in subclasses. </p>
*
* @param uri Module-relative URI to forward to
* @param request Current page request
* @param response Current page response
+ * @throws IOException if an input/output error occurs
+ * @throws ServletException if a servlet exception occurs
* @since Struts 1.1
*/
protected void internalModuleRelativeForward(String uri,
@@ -1000,12 +995,14 @@
* <p>Do a module relative include to specified URI using request
* dispatcher. URI is relative to the current module. The real URI is
* compute by prefixing the module name.</p> <p>This method is used
- * internally and is not part of the public API. It is advised to not use
- * it in subclasses.</p>
+ * internally and is not part of the public API. It is advised to not use it
+ * in subclasses.</p>
*
* @param uri Module-relative URI to include
* @param request Current page request
* @param response Current page response
+ * @throws IOException if an input/output error occurs
+ * @throws ServletException if a servlet exception occurs
* @since Struts 1.1
*/
protected void internalModuleRelativeInclude(String uri,
@@ -1026,12 +1023,13 @@
/**
* <p>Do a forward to specified URI using a <code>RequestDispatcher</code>.
- * This method is used by all internal method needing to do a
- * forward.</p>
+ * This method is used by all internal method needing to do a forward.</p>
*
* @param uri Context-relative URI to forward to
* @param request Current page request
* @param response Current page response
+ * @throws IOException if an input/output error occurs
+ * @throws ServletException if a servlet exception occurs
* @since Struts 1.1
*/
protected void doForward(String uri, HttpServletRequest request,
@@ -1051,12 +1049,13 @@
/**
* <p>Do an include of specified URI using a <code>RequestDispatcher</code>.
- * This method is used by all internal method needing to do an
- * include.</p>
+ * This method is used by all internal method needing to do an include.</p>
*
* @param uri Context-relative URI to include
* @param request Current page request
* @param response Current page response
+ * @throws IOException if an input/output error occurs
+ * @throws ServletException if a servlet exception occurs
* @since Struts 1.1
*/
protected void doInclude(String uri, HttpServletRequest request,
Modified: struts/action/trunk/src/java/org/apache/struts/chain/ComposableRequestProcessor.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/ComposableRequestProcessor.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/ComposableRequestProcessor.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/ComposableRequestProcessor.java Sat Jan 21 03:57:42 2006
@@ -1,5 +1,7 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * $Id$
+ *
+ * Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,43 +44,55 @@
* <p><strong>ComposableRequestProcessor</strong> uses the <em>Chain Of
* Resposibility</em> design pattern (as implemented by the commons-chain
* package in Jakarta Commons) to support external configuration of command
- * chains to be used. It is configured via the following context
- * initialization parameters:</p> <ul> <li><strong>org.apache.struts.chain.CATALOG_NAME</strong>
+ * chains to be used. It is configured via the following context initialization
+ * parameters:</p> <ul> <li><strong>org.apache.struts.chain.CATALOG_NAME</strong>
* - Name of the <code>Catalog</code> in which we will look up the
- * <code>Command</code> to be executed for each request. If not specified,
- * the default value is <code>struts</code>.</li> <li><strong>org.apache.struts.chain.COMMAND_NAME</strong>
- * - Name of the <code>Command</code> which we will execute for each request,
- * to be looked up in the specified <code>Catalog</code>. If not specified,
- * the default value is <code>servlet-standard</code>.</li> </ul>
+ * <code>Command</code> to be executed for each request. If not specified, the
+ * default value is <code>struts</code>.</li> <li><strong>org.apache.struts.chain.COMMAND_NAME</strong>
+ * - Name of the <code>Command</code> which we will execute for each request, to
+ * be looked up in the specified <code>Catalog</code>. If not specified, the
+ * default value is <code>servlet-standard</code>.</li> </ul>
*
* @version $Rev$ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
* $
* @since Struts 1.1
*/
public class ComposableRequestProcessor extends RequestProcessor {
+
// ------------------------------------------------------ Instance Variables
+
+ /**
+ * Cache for constructor discovered by <strong>setActionContextClass</strong>
+ * method.
+ */
private static final Class[] SERVLET_ACTION_CONTEXT_CTOR_SIGNATURE =
new Class[]{
ServletContext.class, HttpServletRequest.class,
HttpServletResponse.class
};
+
+
+ /**
+ * <p> Token for ActionContext clazss so that it can be stored in the
+ * ControllerConfig. </p>
+ */
public static final String ACTION_CONTEXT_CLASS = "ACTION_CONTEXT_CLASS";
/**
* <p>The <code>Log</code> instance for this class.</p>
*/
- protected static final Log log =
+ protected static final Log LOG =
LogFactory.getLog(ComposableRequestProcessor.class);
/**
- * <p>The {@link CatalogFactory} from which catalog containing the the
- * base request-processing {@link Command} will be retrieved.</p>
+ * <p>The {@link CatalogFactory} from which catalog containing the the base
+ * request-processing {@link Command} will be retrieved.</p>
*/
protected CatalogFactory catalogFactory = null;
/**
- * <p>The {@link Catalog} containing all of the available command chains
- * for this module.
+ * <p>The {@link Catalog} containing all of the available command chains for
+ * this module.
*/
protected Catalog catalog = null;
@@ -86,7 +100,17 @@
* <p>The {@link Command} to be executed for each request.</p>
*/
protected Command command = null;
+
+ /**
+ * <p> ActionContext class as cached by <code>createActionContextInstance</code>
+ * method. </p>
+ */
private Class actionContextClass;
+
+ /**
+ * <p> ActionContext constructor as cached by <code>createActionContextInstance</code>
+ * method. </p>
+ */
private Constructor servletActionContextConstructor = null;
// ---------------------------------------------------------- Public Methods
@@ -112,7 +136,7 @@
*/
public void init(ActionServlet servlet, ModuleConfig moduleConfig)
throws ServletException {
- log.info(
+ LOG.info(
"Initializing composable request processor for module prefix '"
+ moduleConfig.getPrefix() + "'");
super.init(servlet, moduleConfig);
@@ -144,13 +168,16 @@
ACTION_CONTEXT_CLASS));
}
- private void setActionContextClass(Class actionContextClass)
- throws ServletException {
+ /**
+ * <p> Set and cache ActionContext class. </p><p> If there is a custom class
+ * provided and if it uses our "preferred" constructor, cache a reference to
+ * that constructor rather than looking it up every time. </p>
+ *
+ * @param actionContextClass
+ */
+ private void setActionContextClass(Class actionContextClass) {
this.actionContextClass = actionContextClass;
- // if there is a custom class provided and if it uses our "preferred"
- // constructor, cache a reference to that constructor rather than
- // looking it up every time.
if (actionContextClass != null) {
this.servletActionContextConstructor = ConstructorUtils
.getAccessibleConstructor(actionContextClass,
@@ -161,18 +188,20 @@
}
/**
- * <p>Make sure that the specified <code>className</code> identfies a
- * class which can be found and which implements the
- * <code>ActionContext</code> interface.</p>
+ * <p>Make sure that the specified <code>className</code> identfies a class
+ * which can be found and which implements the <code>ActionContext</code>
+ * interface.</p>
*
- * @param className
- * @throws ServletException
+ * @param className Fully qualified name of
+ * @throws ServletException If an error occurs during initialization
+ * @throws UnavailableException if class does not implement ActionContext or
+ * is not found
*/
private void setActionContextClassName(String className)
throws ServletException {
if ((className != null) && (className.trim().length() > 0)) {
- if (log.isDebugEnabled()) {
- log.debug(
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(
"setActionContextClassName: requested context class: "
+ className);
}
@@ -181,22 +210,20 @@
Class actionContextClass =
RequestUtils.applicationClass(className);
- if (!ActionContext.class.isAssignableFrom(actionContextClass))
- {
+ if (!ActionContext.class.isAssignableFrom(actionContextClass)) {
throw new UnavailableException("ActionContextClass " + "["
+ className + "]"
+ " must implement ActionContext interface.");
}
this.setActionContextClass(actionContextClass);
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
throw new UnavailableException("ActionContextClass "
+ className + " not found.");
}
} else {
- if (log.isDebugEnabled()) {
- log.debug("setActionContextClassName: no className specified");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("setActionContextClassName: no className specified");
}
this.setActionContextClass(null);
@@ -211,8 +238,8 @@
* unless the <code>catalogFactory</code> property of this object has
* already been set, in which case it is not changed.</p>
*
- * @param servlet
- * @param moduleConfig
+ * @param servlet The ActionServlet we are processing
+ * @param moduleConfig The ModuleConfig we are processing
*/
protected void initCatalogFactory(ActionServlet servlet,
ModuleConfig moduleConfig) {
@@ -243,13 +270,12 @@
// Create and execute the command.
try {
- if (log.isDebugEnabled()) {
- log.debug("Using processing chain for this request");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Using processing chain for this request");
}
command.execute(context);
- }
- catch (Exception e) {
+ } catch (Exception e) {
// Execute the exception processing chain??
throw new ServletException(e);
}
@@ -259,15 +285,15 @@
}
/**
- * <p>Provide the initialized <code>ActionContext</code> instance which
- * will be used by this request. Internally, this simply calls
+ * <p>Provide the initialized <code>ActionContext</code> instance which will
+ * be used by this request. Internally, this simply calls
* <code>createActionContextInstance</code> followed by
* <code>initializeActionContext</code>.</p>
*
- * @param request
- * @param response
- * @return
- * @throws ServletException
+ * @param request The servlet request we are processing
+ * @param response The servlet response we are creating
+ * @return Initiliazed ActionContext
+ * @throws ServletException if a processing exception occurs
*/
protected ActionContext contextInstance(HttpServletRequest request,
HttpServletResponse response)
@@ -283,22 +309,22 @@
/**
* <p>Create a new instance of <code>ActionContext</code> according to
- * configuration. If no alternative was specified at initialization, a
- * new instance <code>ServletActionContext</code> is returned. If an
+ * configuration. If no alternative was specified at initialization, a new
+ * instance <code>ServletActionContext</code> is returned. If an
* alternative was specified using the <code>ACTION_CONTEXT_CLASS</code>
* property, then that value is treated as a classname, and an instance of
* that class is created. If that class implements the same constructor
* that <code>ServletActionContext</code> does, then that constructor will
* be used: <code>ServletContext, HttpServletRequest,
- * HttpServletResponse</code>; otherwise, it is assumed that the class has
- * a no-arguments constructor. If these constraints do not suit you,
- * simply override this method in a subclass.</p>
- *
- * @param servletContext
- * @param request
- * @param response
- * @return
- * @throws ServletException
+ * HttpServletResponse</code>; otherwise, it is assumed that the class has a
+ * no-arguments constructor. If these constraints do not suit you, simply
+ * override this method in a subclass.</p>
+ *
+ * @param servletContext The servlet context we are processing
+ * @param request The servlet request we are processing
+ * @param response The servlet response we are creating
+ * @return New instance of ActionContext
+ * @throws ServletException if a processing exception occurs
*/
protected ActionContext createActionContextInstance(
ServletContext servletContext, HttpServletRequest request,
@@ -318,8 +344,7 @@
return (ActionContext) this.servletActionContextConstructor
.newInstance(new Object[]{servletContext, request,
response});
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new ServletException(
"Error creating ActionContext instance of type "
+ this.actionContextClass, e);
@@ -327,14 +352,14 @@
}
/**
- * <p>Set common properties on the given <code>ActionContext</code>
- * instance so that commands in the chain can count on their presence.
- * Note that while this method does not require that its argument be an
- * instance of <code>ServletActionContext</code>, at this time many common
- * Struts commands will be expecting to receive an <code>ActionContext</code>
- * which is also a <code>ServletActionContext</code>.</p>
+ * <p>Set common properties on the given <code>ActionContext</code> instance
+ * so that commands in the chain can count on their presence. Note that
+ * while this method does not require that its argument be an instance of
+ * <code>ServletActionContext</code>, at this time many common Struts
+ * commands will be expecting to receive an <code>ActionContext</code> which
+ * is also a <code>ServletActionContext</code>.</p>
*
- * @param context
+ * @param context The ActionContext we are processing
*/
protected void initializeActionContext(ActionContext context) {
if (context instanceof ServletActionContext) {
@@ -345,10 +370,11 @@
}
/**
- * If this is a multipart request, wrap it with a special wrapper.
- * Otherwise, return the request unchanged.
+ * <p>If this is a multipart request, wrap it with a special wrapper.
+ * Otherwise, return the request unchanged.</p>
*
* @param request The HttpServletRequest we are processing
+ * @return Original or wrapped request as appropriate
*/
protected HttpServletRequest processMultipart(
HttpServletRequest request) {
@@ -368,11 +394,11 @@
/**
* <p>Set the <code>CatalogFactory</code> instance which should be used to
- * find the request-processing command. In the base implementation, if
- * this value is not already set, then it will be initialized when {@link
+ * find the request-processing command. In the base implementation, if this
+ * value is not already set, then it will be initialized when {@link
* #initCatalogFactory} is called. </p>
*
- * @param catalogFactory
+ * @param catalogFactory Our CatalogFactory instance
*/
public void setCatalogFactory(CatalogFactory catalogFactory) {
this.catalogFactory = catalogFactory;
Modified: struts/action/trunk/src/java/org/apache/struts/chain/Constants.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/Constants.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/Constants.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/Constants.java Sat Jan 21 03:57:42 2006
@@ -1,5 +1,7 @@
/*
- * Copyright 2003,2004 The Apache Software Foundation.
+ * $Id$
+ *
+ * Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,27 +25,26 @@
// -------------------------------------------------- Context Attribute Keys
/**
- * <p>The default context attribute under which the <code>Action</code>
- * for the current request will be stored.</p>
+ * <p>The default context attribute under which the <code>Action</code> for
+ * the current request will be stored.</p>
*/
public static final String ACTION_KEY = "action";
/**
- * <p>The default context attribute under which the
- * <code>ActionConfig</code> for the current request will be stored.</p>
+ * <p>The default context attribute under which the <code>ActionConfig</code>
+ * for the current request will be stored.</p>
*/
public static final String ACTION_CONFIG_KEY = "actionConfig";
/**
- * <p>The default context attribute under which the
- * <code>ActionForm</code> for the current request will be stored.</p>
+ * <p>The default context attribute under which the <code>ActionForm</code>
+ * for the current request will be stored.</p>
*/
public static final String ACTION_FORM_KEY = "actionForm";
/**
- * <p>The default context attribute under which the
- * <code>ActionServet</code> for the current application will be
- * stored.</p>
+ * <p>The default context attribute under which the <code>ActionServet</code>
+ * for the current application will be stored.</p>
*/
public static final String ACTION_SERVLET_KEY = "actionServlet";
@@ -60,8 +61,8 @@
public static final String EXCEPTION_KEY = "exception";
/**
- * <p>The default context attribute under which the
- * <code>ForwardConfig</code> for the current request will be stored.</p>
+ * <p>The default context attribute under which the <code>ForwardConfig</code>
+ * for the current request will be stored.</p>
*/
public static final String FORWARD_CONFIG_KEY = "forwardConfig";
@@ -72,21 +73,20 @@
public static final String INCLUDE_KEY = "include";
/**
- * <p>The default context attribute under which the <code>Locale</code>
- * for the current request will be stored.</p>
+ * <p>The default context attribute under which the <code>Locale</code> for
+ * the current request will be stored.</p>
*/
public static final String LOCALE_KEY = "locale";
/**
- * <p>The default context attribute under which the
- * <code>MessageResources</code> for the current request will be
- * stored.</p>
+ * <p>The default context attribute under which the <code>MessageResources</code>
+ * for the current request will be stored.</p>
*/
public static final String MESSAGE_RESOURCES_KEY = "messageResources";
/**
- * <p>The default context attribute under which the
- * <code>ModuleConfig</code> for the current request will be stored.</p>
+ * <p>The default context attribute under which the <code>ModuleConfig</code>
+ * for the current request will be stored.</p>
*/
public static final String MODULE_CONFIG_KEY = "moduleConfig";
@@ -101,15 +101,15 @@
/**
* <p>The base part of the context attribute under which a Map containing
- * the <code>Action</code> instances associated with this module are
- * stored. This value must be suffixed with the module prefix in order to
- * create a unique key per module.</p>
+ * the <code>Action</code> instances associated with this module are stored.
+ * This value must be suffixed with the module prefix in order to create a
+ * unique key per module.</p>
*/
public static final String ACTIONS_KEY = "actions";
/**
- * <p>The context attribute under which the <code>Catalog</code>
- * containing our defined command chains has been stored.</p>
+ * <p>The context attribute under which the <code>Catalog</code> containing
+ * our defined command chains has been stored.</p>
*/
public static final String CATALOG_ATTR =
"org.apache.struts.chain.CATALOG";
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractAuthorizeAction.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractAuthorizeAction.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractAuthorizeAction.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractAuthorizeAction.java Sat Jan 21 03:57:42 2006
@@ -1,5 +1,7 @@
/*
- * Copyright 2003,2004 The Apache Software Foundation.
+ * $Id$
+ *
+ * Copyright 2000-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,16 +23,20 @@
import org.apache.struts.config.ActionConfig;
/**
- * <p>Determine whether the requested action is authorized for the current
- * user. If not, abort chain processing and perferably, return an error
- * message of some kind.</p>
+ * <p>Determine whether the requested action is authorized for the current user.
+ * If not, abort chain processing and perferably, return an error message of
+ * some kind.</p>
*
* @version $Rev$ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
* $
*/
public abstract class AbstractAuthorizeAction extends ActionCommandBase {
// ------------------------------------------------------ Instance Variables
- private static final Log log =
+
+ /**
+ * Provide a Commons logging instance for this class.
+ */
+ private static final Log LOG =
LogFactory.getLog(AbstractAuthorizeAction.class);
// ---------------------------------------------------------- Public Methods
@@ -43,6 +49,7 @@
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> if the user is authorized for the selected
* action, else <code>true</code> to abort processing.
+ * @throws Exception if authorization fails
*/
public boolean execute(ActionContext actionCtx)
throws Exception {
@@ -54,15 +61,14 @@
return (false);
}
- boolean throwEx = false;
+ boolean throwEx;
try {
throwEx = !(isAuthorized(actionCtx, actionConfig.getRoleNames(),
actionConfig));
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
throwEx = true;
- log.error("Unable to complete authorization process", ex);
+ LOG.error("Unable to complete authorization process", ex);
}
if (throwEx) {
@@ -76,8 +82,8 @@
/**
* <p>Must authorization rules be consulted? The base implementation
- * returns <code>true</code> if the given <code>ActionConfig</code> has
- * one or more roles defined.</p>
+ * returns <code>true</code> if the given <code>ActionConfig</code> has one
+ * or more roles defined.</p>
*
* @param actionConfig the current ActionConfig object
* @return true if the <code>isAuthorized</code> method should be
@@ -106,6 +112,14 @@
ActionConfig actionConfig)
throws Exception;
+
+ /**
+ * <p> Retrieve error message from context. </p>
+ *
+ * @param context The <code>Context</code> for the current request
+ * @param actionConfig The current action mapping
+ * @return error message
+ */
protected abstract String getErrorMessage(ActionContext context,
ActionConfig actionConfig);
}
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractCreateAction.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractCreateAction.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractCreateAction.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractCreateAction.java Sat Jan 21 03:57:42 2006
@@ -1,5 +1,7 @@
/*
- * Copyright 2003,2004 The Apache Software Foundation.
+ * $Id$
+ *
+ * Copyright 2000-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,15 +24,20 @@
import org.apache.struts.config.ActionConfig;
/**
- * <p>Create (if necessary) and cache an <code>Action</code> for this request.
+ * <p> Create (if necessary) and cache an <code>Action</code> for this request.
* </p>
*
* @version $Rev$ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
* $
*/
public abstract class AbstractCreateAction extends ActionCommandBase {
+
// ------------------------------------------------------ Instance Variables
- private static final Log log =
+
+ /**
+ * Provide a Commons logging instance for this class.
+ */
+ private static final Log LOG =
LogFactory.getLog(AbstractCreateAction.class);
// ---------------------------------------------------------- Public Methods
@@ -41,6 +48,8 @@
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> so that processing continues
+ * @throws Exception if there are any problems instantiating the Action
+ * class.
*/
public boolean execute(ActionContext actionCtx)
throws Exception {
@@ -48,14 +57,14 @@
Boolean valid = actionCtx.getFormValid();
if ((valid == null) || !valid.booleanValue()) {
- log.trace("Invalid form; not going to execute.");
+ LOG.trace("Invalid form; not going to execute.");
return (false);
}
// Check to see if an action has already been created
if (actionCtx.getAction() != null) {
- log.trace(
+ LOG.trace(
"already have an action [" + actionCtx.getAction() + "]");
return (false);
@@ -66,7 +75,7 @@
String type = actionConfig.getType();
if (type == null) {
- log.trace("no type for " + actionConfig.getPath());
+ LOG.trace("no type for " + actionConfig.getPath());
return (false);
}
@@ -74,8 +83,8 @@
// Create (if necessary) and cache an Action instance
Action action = getAction(actionCtx, type, actionConfig);
- if (log.isTraceEnabled()) {
- log.trace("setting action to " + action);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("setting action to " + action);
}
actionCtx.setAction(action);
@@ -86,18 +95,18 @@
// ------------------------------------------------------- Protected Methods
/**
- * Create and return the appropriate <code>Action</code> class for the
- * given <code>type</code> and <code>actionConfig</code>.
+ * <p> Create and return the appropriate <code>Action</code> class for the
+ * given <code>type</code> and <code>actionConfig</code>. </p> <p> NOTE: The
+ * dependence on ActionServlet suggests that this should be broken up along
+ * the lines of the other Abstract/concrete pairs in the
+ * org.apache.struts.chain.commands package. </p>
*
- * @param context
- * @param type
- * @param actionConfig
- * @return
+ * @param context The <code>Context</code> for this request
+ * @param type Name of class to instantiate
+ * @param actionConfig The {@link ActionConfig} for this request
+ * @return Instantiated Action class
* @throws Exception if there are any problems instantiating the Action
* class.
- * @todo The dependence on ActionServlet suggests that this should be
- * broken up along the lines of the other Abstract/concrete pairs in the
- * org.apache.struts.chain.commands package.
*/
protected abstract Action getAction(ActionContext context, String type,
ActionConfig actionConfig)
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExceptionHandler.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExceptionHandler.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExceptionHandler.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExceptionHandler.java Sat Jan 21 03:57:42 2006
@@ -1,5 +1,7 @@
/*
- * Copyright 2003,2004 The Apache Software Foundation.
+ * $Id$
+ *
+ * Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,28 +26,33 @@
import org.apache.struts.config.ModuleConfig;
/**
- * <p>Invoke the local or global exception handler configured for the
- * exception class that occurred.</p>
+ * <p>Invoke the local or global exception handler configured for the exception
+ * class that occurred.</p>
*
* @version $Rev$ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
* $
*/
public abstract class AbstractExceptionHandler extends ActionCommandBase {
+
// ------------------------------------------------------ Instance Variables
- private static final Log log =
+
+ /**
+ * Provide a Commons logging instance for this class.
+ */
+ private static final Log LOG =
LogFactory.getLog(AbstractExceptionHandler.class);
// ---------------------------------------------------------- Public Methods
/**
- * <p>Invoke the appropriate <code>Action</code> for this request, and
- * cache the returned <code>ActionForward</code>.</p>
+ * <p>Invoke the appropriate <code>Action</code> for this request, and cache
+ * the returned <code>ActionForward</code>.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> if a <code>ForwardConfig</code> is returned,
* else <code>true</code> to complete processing
- * @throws InvalidPathException if no valid action can be identified for
- * this request
+ * @throws Exception if thrown by the Action class and not declared by an
+ * Exception Handler
*/
public boolean execute(ActionContext actionCtx)
throws Exception {
@@ -53,7 +60,7 @@
Exception exception = actionCtx.getException();
if (exception == null) {
- log.warn("No Exception found in ActionContext");
+ LOG.warn("No Exception found in ActionContext");
return (true);
}
@@ -64,8 +71,8 @@
ModuleConfig moduleConfig = actionCtx.getModuleConfig();
if (actionConfig != null) {
- if (log.isDebugEnabled()) {
- log.debug("See if actionConfig " + actionConfig
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("See if actionConfig " + actionConfig
+ " has an exceptionConfig for "
+ exception.getClass().getName());
}
@@ -73,8 +80,8 @@
exceptionConfig =
actionConfig.findException(exception.getClass());
} else if (moduleConfig != null) {
- if (log.isDebugEnabled()) {
- log.debug("No action yet, see if moduleConfig " + moduleConfig
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("No action yet, see if moduleConfig " + moduleConfig
+ " has an exceptionConfig "
+ exception.getClass().getName());
}
@@ -85,7 +92,7 @@
// Handle the exception in the configured manner
if (exceptionConfig == null) {
- log.warn("Unhandled exception", exception);
+ LOG.warn("Unhandled exception", exception);
throw exception;
}
@@ -111,8 +118,9 @@
* @param exceptionConfig The corresponding {@link ExceptionConfig}
* @param actionConfig The {@link ActionConfig} for this request
* @param moduleConfig The {@link ModuleConfig} for this request
- * @return the <code>ForwardConfig</code> to be processed next (if any),
- * or <code>null</code> if processing has been completed
+ * @return the <code>ForwardConfig</code> to be processed next (if any), or
+ * <code>null</code> if processing has been completed
+ * @throws Exception if there are any problems handling the exception
*/
protected abstract ForwardConfig handle(ActionContext context,
Exception exception,
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExecuteAction.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExecuteAction.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExecuteAction.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractExecuteAction.java Sat Jan 21 03:57:42 2006
@@ -1,5 +1,7 @@
/*
- * Copyright 2003,2004 The Apache Software Foundation.
+ * $Id$
+ *
+ * Copyright 2000-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,8 +24,8 @@
import org.apache.struts.config.ForwardConfig;
/**
- * <p>Invoke the appropriate <code>Action</code> for this request, and cache
- * the returned <code>ActionForward</code>.</p>
+ * <p>Invoke the appropriate <code>Action</code> for this request, and cache the
+ * returned <code>ActionForward</code>.</p>
*
* @version $Rev$ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
* $
@@ -32,13 +34,12 @@
// ---------------------------------------------------------- Public Methods
/**
- * <p>Invoke the appropriate <code>Action</code> for this request, and
- * cache the returned <code>ActionForward</code>.</p>
+ * <p>Invoke the appropriate <code>Action</code> for this request, and cache
+ * the returned <code>ActionForward</code>.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> so that processing continues
- * @throws InvalidPathException if no valid action can be identified for
- * this request
+ * @throws Exception if thrown by the Action class
*/
public boolean execute(ActionContext actionCtx)
throws Exception {
@@ -77,8 +78,8 @@
* @param context The <code>Context</code> for this request
* @param action The <code>Action</code> to be executed
* @param actionConfig The <code>ActionConfig</code> defining this action
- * @param actionForm The <code>ActionForm</code> (if any) for this
- * action
+ * @param actionForm The <code>ActionForm</code> (if any) for this action
+ * @return ForwardConfig The next location, or null
* @throws Exception if thrown by the <code>Action</code>
*/
protected abstract ForwardConfig execute(ActionContext context,
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformForward.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformForward.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformForward.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformForward.java Sat Jan 21 03:57:42 2006
@@ -1,5 +1,7 @@
/*
- * Copyright 2003,2004 The Apache Software Foundation.
+ * $Id$
+ *
+ * Copyright 2000-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +36,7 @@
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>true</code> so that processing completes
+ * @throws Exception if thrown by the <code>Action</code>
*/
public boolean execute(ActionContext actionCtx)
throws Exception {
@@ -58,6 +61,7 @@
*
* @param context The context for this request
* @param forwardConfig The forward to be performed
+ * @throws Exception if thrown by the <code>Action</code>
*/
protected abstract void perform(ActionContext context,
ForwardConfig forwardConfig)
Modified: struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformInclude.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformInclude.java?rev=371016&r1=371015&r2=371016&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformInclude.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/chain/commands/AbstractPerformInclude.java Sat Jan 21 03:57:42 2006
@@ -1,5 +1,7 @@
/*
- * Copyright 2003,2004 The Apache Software Foundation.
+ * $Id$
+ *
+ * Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +35,7 @@
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>true</code> so that processing completes
+ * @throws Exception if thrown by the <code>Action</code>
*/
public boolean execute(ActionContext actionCtx)
throws Exception {
@@ -57,11 +60,11 @@
// ------------------------------------------------------- Protected Methods
/**
- * <p>Perform the appropriate processing on the specified include
- * uri.</p>
+ * <p>Perform the appropriate processing on the specified include uri.</p>
*
* @param context The context for this request
* @param include The forward to be performed
+ * @throws Exception if thrown by the <code>Action</code>
*/
protected abstract void perform(ActionContext context, String include)
throws Exception;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org