cedric 2002/07/11 09:46:41
Modified: src/share/org/apache/struts/tiles/actions
DefinitionDispatcherAction.java NoOpAction.java
ReloadDefinitionsAction.java TilesAction.java
ViewDefinitionsAction.java
Log:
Change TilesAction to use execute() instead of perform().
This is consistent with the new Struts behavior.
Change is backward compatible : Classes implementing old tilesAction's perform()
method should still working.
Revision Changes Path
1.2 +12 -15
jakarta-struts/src/share/org/apache/struts/tiles/actions/DefinitionDispatcherAction.java
Index: DefinitionDispatcherAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/actions/DefinitionDispatcherAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefinitionDispatcherAction.java 25 Jun 2002 03:15:42 -0000 1.1
+++ DefinitionDispatcherAction.java 11 Jul 2002 16:46:40 -0000 1.2
@@ -113,26 +113,23 @@
/**
* Process the specified HTTP request, and create the corresponding HTTP
- * response (or forward to another web component that will create it).
- * Return an <code>ActionForward</code> instance describing where and how
- * control should be forwarded, or <code>null</code> if the response has
- * already been completed.
+ * response (or forward to another web component that will create it),
+ * with provision for handling exceptions thrown by the business logic.
*
- * @param servlet The ActionServlet making this request
* @param mapping The ActionMapping used to select this instance
- * @param actionForm The optional ActionForm bean for this request (if any)
+ * @param form The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet exception occurs
+ * @exception Exception if the application business logic throws
+ * an exception
+ * @since Struts 1.1
*/
- public ActionForward perform(
- ActionMapping mapping,
+ public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
- throws IOException, ServletException
+ throws Exception
{
// Identify the request parameter containing the method name
// If none defined, use "def"
1.2 +15 -19
jakarta-struts/src/share/org/apache/struts/tiles/actions/NoOpAction.java
Index: NoOpAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/actions/NoOpAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NoOpAction.java 25 Jun 2002 03:15:42 -0000 1.1
+++ NoOpAction.java 11 Jul 2002 16:46:40 -0000 1.2
@@ -81,8 +81,8 @@
/**
- * Implementation of <strong>Action</strong> that populates an instance of
- * <code>SubscriptionForm</code> from the currently specified subscription.
+ * Implementation of <strong>Action</strong> that do nothing but a forward to
+ * "success".
*
* @author Cedric Dumoulin
* @version $Revision$ $Date$
@@ -90,29 +90,25 @@
public final class NoOpAction extends Action {
-
- // --------------------------------------------------------- Public Methods
-
-
/**
- * No op action.
- * Action doing nothing.
+ * Process the specified HTTP request, and create the corresponding HTTP
+ * response (or forward to another web component that will create it),
+ * with provision for handling exceptions thrown by the business logic.
*
- * @param servlet The ActionServlet making this request
* @param mapping The ActionMapping used to select this instance
- * @param actionForm The optional ActionForm bean for this request (if any)
+ * @param form The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet exception occurs
+ * @exception Exception if the application business logic throws
+ * an exception
+ * @since Struts 1.1
*/
- public ActionForward perform(
- ActionMapping mapping,
+ public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
- throws IOException, ServletException
+ throws Exception
{
// No op action.
return (mapping.findForward("success"));
1.2 +15 -17
jakarta-struts/src/share/org/apache/struts/tiles/actions/ReloadDefinitionsAction.java
Index: ReloadDefinitionsAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/actions/ReloadDefinitionsAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ReloadDefinitionsAction.java 25 Jun 2002 03:15:42 -0000 1.1
+++ ReloadDefinitionsAction.java 11 Jul 2002 16:46:40 -0000 1.2
@@ -64,7 +64,7 @@
import org.apache.struts.tiles.DefinitionsUtil;
import org.apache.struts.tiles.DefinitionsFactoryException;
-import org.apache.struts.tiles.definition.ReloadableDefinitionsFactory;
+import org.apache.struts.tiles.DefinitionsFactory;
import java.io.IOException;
import java.io.PrintWriter;
@@ -95,33 +95,31 @@
/**
* Process the specified HTTP request, and create the corresponding HTTP
- * response (or forward to another web component that will create it).
- * Return an <code>ActionForward</code> instance describing where and how
- * control should be forwarded, or <code>null</code> if the response has
- * already been completed.
+ * response (or forward to another web component that will create it),
+ * with provision for handling exceptions thrown by the business logic.
*
* @param mapping The ActionMapping used to select this instance
- * @param actionForm The optional ActionForm bean for this request (if any)
+ * @param form The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet exception occurs
+ * @exception Exception if the application business logic throws
+ * an exception
+ * @since Struts 1.1
*/
- public ActionForward perform(
- ActionMapping mapping,
+ public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
- throws IOException, ServletException
+ throws Exception
{
response.setContentType("text/plain");
PrintWriter writer = response.getWriter();
try {
ServletContext context = getServlet().getServletContext();
- ReloadableDefinitionsFactory factory =
(ReloadableDefinitionsFactory)DefinitionsUtil.getDefinitionsFactory(context );
- factory.reload(context);
+ DefinitionsFactory factory =
DefinitionsUtil.getDefinitionsFactory(context );
+ factory.setConfig(factory.getConfig(), context);
writer.println("OK");
} catch (ClassCastException e) {
writer.println("FAIL - " + e.toString());
1.2 +64 -29
jakarta-struts/src/share/org/apache/struts/tiles/actions/TilesAction.java
Index: TilesAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/actions/TilesAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TilesAction.java 25 Jun 2002 03:15:42 -0000 1.1
+++ TilesAction.java 11 Jul 2002 16:46:40 -0000 1.2
@@ -77,35 +77,38 @@
/**
* Base class for Tiles Actions.
- * This class as the same role as Struts Action. It provides a method perform(...)
- * called when action is invoked. The difference is that the perform() method takes
+ * This class has the same role as Struts Action. It provides a method execute(...)
+ * called when action is invoked. The difference is that the execute() method takes
* an additional parameter : tile context.
- * This class extends Struts Action. Subclasses should implements new perform()
method
- * instead of Struts perform() method.
+ * This class extends Struts Action. Subclasses should override
+ * execute(ComponentContext ...) method instead of Struts
+ * execute(ActionMapping ...) method.
+ * Backward compatibility is ensure with the perform(ComponentContext ...) method.
* @version $Revision$ $Date$
*/
public abstract class TilesAction extends Action
{
- /**
- * Original Struts Action's method.
- * Retrieve current Tile context, and call Tile's perform method.
- *
- * @param mapping The ActionMapping used to select this instance
- * @param actionForm The optional ActionForm bean for this request (if any)
- * @param request The HTTP request we are processing
- * @param response The HTTP response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet exception occurs
- */
- public ActionForward perform(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException
+ /**
+ * Original Struts Action's method.
+ * Retrieve current Tile context, and call TilesAction execute method.
+ * Do not overload this method !
+ *
+ * @param mapping The ActionMapping used to select this instance
+ * @param form The optional ActionForm bean for this request (if any)
+ * @param request The HTTP request we are processing
+ * @param response The HTTP response we are creating
+ *
+ * @exception Exception if the application business logic throws
+ * an exception
+ * @since Struts 1.1
+ */
+ public ActionForward execute(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception
{
// Try to retrieve tile context
ComponentContext context = ComponentContext.getContext( request );
@@ -114,6 +117,34 @@
throw new ServletException( "Can't find Tile context for '" +
this.getClass().getName()
+ "'. TilesAction subclasses must be called from a
Tile" );
}
+ return execute( context, mapping, form, request, response );
+ }
+
+ /**
+ * Process the specified HTTP request, and create the corresponding HTTP
+ * response (or forward to another web component that will create it),
+ * with provision for handling exceptions thrown by the business logic.
+ * <br>
+ * Override this method to provide functionality
+ *
+ * @param context The current Tile context, containing Tile attributes
+ * @param mapping The ActionMapping used to select this instance
+ * @param form The optional ActionForm bean for this request (if any)
+ * @param request The HTTP request we are processing
+ * @param response The HTTP response we are creating
+ *
+ * @exception Exception if the application business logic throws
+ * an exception
+ * @since Struts 1.1
+ */
+ public ActionForward execute(ComponentContext context,
+ ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception
+ {
+ // Call old method for backward compatibility.
return perform( context, mapping, form, request, response );
}
@@ -123,7 +154,6 @@
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
- * This method should be implemented by subclasses.
*
* @param context The current Tile context, containing Tile attributes
* @param mapping The ActionMapping used to select this instance
@@ -133,11 +163,16 @@
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
+ * @deprecated Use the <code>execute()</code> method instead
*/
- abstract public ActionForward perform( ComponentContext context,
+ public ActionForward perform( ComponentContext context,
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
- throws IOException, ServletException;
+ throws IOException, ServletException
+ {
+ return null;
+ }
+
}
1.2 +15 -17
jakarta-struts/src/share/org/apache/struts/tiles/actions/ViewDefinitionsAction.java
Index: ViewDefinitionsAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/actions/ViewDefinitionsAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ViewDefinitionsAction.java 25 Jun 2002 03:15:42 -0000 1.1
+++ ViewDefinitionsAction.java 11 Jul 2002 16:46:40 -0000 1.2
@@ -64,7 +64,7 @@
import org.apache.struts.tiles.DefinitionsUtil;
import org.apache.struts.tiles.DefinitionsFactoryException;
-import org.apache.struts.tiles.ComponentDefinitionsFactory;
+import org.apache.struts.tiles.DefinitionsFactory;
import java.io.IOException;
import java.io.PrintWriter;
@@ -95,33 +95,31 @@
/**
* Process the specified HTTP request, and create the corresponding HTTP
- * response (or forward to another web component that will create it).
- * Return an <code>ActionForward</code> instance describing where and how
- * control should be forwarded, or <code>null</code> if the response has
- * already been completed.
+ * response (or forward to another web component that will create it),
+ * with provision for handling exceptions thrown by the business logic.
*
* @param mapping The ActionMapping used to select this instance
- * @param actionForm The optional ActionForm bean for this request (if any)
+ * @param form The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet exception occurs
+ * @exception Exception if the application business logic throws
+ * an exception
+ * @since Struts 1.1
*/
- public ActionForward perform(
- ActionMapping mapping,
+ public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
- throws IOException, ServletException
+ throws Exception
{
response.setContentType("text/plain");
PrintWriter writer = response.getWriter();
try {
ServletContext context = getServlet().getServletContext();
- ComponentDefinitionsFactory factory =
DefinitionsUtil.getDefinitionsFactory(context );
- writer.println( factory );
+ DefinitionsFactory factory =
DefinitionsUtil.getDefinitionsFactory(context );
+ writer.println( factory.toString() );
} catch (Exception e) {
writer.println("FAIL - " + e.toString());
getServlet().log("ReloadAction", e);
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>