View Javadoc

1   /*
2    * $Id: ActionCommandBase.java 421119 2006-07-12 04:49:11Z wsmoak $
3    *
4    * Copyright 2005-2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts.chain.commands;
19  
20  import org.apache.commons.logging.Log;
21  import org.apache.commons.logging.LogFactory;
22  import org.apache.commons.chain.Context;
23  import org.apache.struts.chain.contexts.ActionContext;
24  
25  /***
26   * <p>Simple abstract class which avoids frequent casting to
27   * <code>ActionContext</code> in commands explicitly intended for use with
28   * that class.</p>
29   */
30  public abstract class ActionCommandBase implements ActionCommand {
31  
32      /***
33       * <p> Provide Commons Logging instance for this class. </p>
34       */
35      private static final Log LOG =
36          LogFactory.getLog(ActionCommandBase.class);
37  
38      // See interface for Javadoc
39      public abstract boolean execute(ActionContext actionContext)
40          throws Exception;
41  
42      // See interface for Javadoc
43      public boolean execute(Context context)
44          throws Exception {
45          if (LOG.isDebugEnabled()) {
46              LOG.debug("Executing " + getClass().getName());
47          }
48          return execute((ActionContext) context);
49      }
50  }