KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > chain > SelectInclude


1 /*
2  * Copyright 2003,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.struts.chain;
18
19
20 import org.apache.commons.chain.Command;
21 import org.apache.commons.chain.Context;
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.struts.config.ActionConfig;
25
26
27 /**
28  * <p>Select and cache the include for this
29  * <code>ActionConfig</code> if specified.</p>
30  *
31  * @author Don Brown
32  * @version $Rev: 54933 $ $Date: 2004-10-16 18:04:52 +0100 (Sat, 16 Oct 2004) $
33  */

34
35 public class SelectInclude implements Command {
36
37
38     // ------------------------------------------------------ Instance Variables
39

40
41     private String JavaDoc actionConfigKey = Constants.ACTION_CONFIG_KEY;
42     private String JavaDoc includeKey = Constants.INCLUDE_KEY;
43     
44     private static final Log log =
45         LogFactory.getLog(SelectInclude.class);
46
47     
48     // -------------------------------------------------------------- Properties
49

50
51     /**
52      * <p>Return the context attribute key under which the
53      * <code>ActionConfig</code> for the currently selected application
54      * action is stored.</p>
55      */

56     public String JavaDoc getActionConfigKey() {
57
58         return (this.actionConfigKey);
59
60     }
61
62
63     /**
64      * <p>Set the context attribute key under which the
65      * <code>ActionConfig</code> for the currently selected application
66      * action is stored.</p>
67      *
68      * @param actionConfigKey The new context attribute key
69      */

70     public void setActionConfigKey(String JavaDoc actionConfigKey) {
71
72         this.actionConfigKey = actionConfigKey;
73
74     }
75
76
77     /**
78      * <p>Return the context attribute key under which the
79      * include uri is stored.</p>
80      */

81     public String JavaDoc getIncludeKey() {
82
83         return (this.includeKey);
84
85     }
86
87
88     /**
89      * <p>Set the context attribute key under which the
90      * include uri is stored.</p>
91      *
92      * @param includeKey The new context attribute key
93      */

94     public void setIncludeKey(String JavaDoc includeKey) {
95
96         this.includeKey = includeKey;
97
98     }
99
100
101     // ---------------------------------------------------------- Public Methods
102

103
104     /**
105      * <p>Select and cache the include uri for this
106      * <code>ActionConfig</code> if specified.</p>
107      *
108      * @param context The <code>Context</code> for the current request
109      *
110      * @return <code>false</code> so that processing continues
111      */

112     public boolean execute(Context context) throws Exception JavaDoc {
113
114         // Acquire configuration objects that we need
115
ActionConfig actionConfig = (ActionConfig)
116             context.get(getActionConfigKey());
117             
118         // Cache an include uri if found
119
String JavaDoc include = actionConfig.getInclude();
120         if (include != null) {
121             if (log.isDebugEnabled()) {
122                 log.debug("Including " + include);
123             }
124             context.put(getIncludeKey(), include);
125         }
126         return (false);
127
128     }
129
130 }
131
Popular Tags