View Javadoc
1   /*
2    * $Id$
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  package org.apache.struts.chain.commands;
22  
23  import org.apache.struts.chain.contexts.ActionContext;
24  import org.apache.struts.config.ActionConfig;
25  import org.slf4j.Logger;
26  import org.slf4j.LoggerFactory;
27  
28  /**
29   * <p>Select and cache the include for this <code>ActionConfig</code> if
30   * specified.</p>
31   *
32   * @version $Rev$ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
33   *          $
34   */
35  public class SelectInclude extends ActionCommandBase {
36      // ------------------------------------------------------ Instance Variables
37  
38      /**
39       * The {@code Log} instance for this class.
40       */
41      private final Logger log =
42          LoggerFactory.getLogger(SelectInclude.class);
43  
44      // ---------------------------------------------------------- Public Methods
45  
46      /**
47       * <p>Select and cache the include uri for this <code>ActionConfig</code>
48       * if specified.</p>
49       *
50       * @param actionCtx The <code>Context</code> for the current request
51       * @return <code>false</code> so that processing continues
52       * @throws Exception on any error
53       */
54      @Override
55      protected boolean execute_(ActionContext actionCtx)
56          throws Exception {
57          // Acquire configuration objects that we need
58          ActionConfig actionConfig = actionCtx.getActionConfig();
59  
60          // Cache an include uri if found
61          String include = actionConfig.getInclude();
62  
63          if (include != null) {
64              log.debug("Including {}", include);
65  
66              actionCtx.setInclude(include);
67          }
68  
69          return CONTINUE_PROCESSING;
70      }
71  }