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.config;
22  
23  import java.io.Serializable;
24  
25  /**
26   * <p>The collection of static configuration information that describes a
27   * Struts-based module.  Multiple modules are identified by a <em>prefix</em>
28   * at the beginning of the context relative portion of the request URI.  If no
29   * module prefix can be matched, the default configuration (with a prefix
30   * equal to a zero-length string) is selected, which is elegantly backwards
31   * compatible with the previous Struts behavior that only supported one
32   * module.</p>
33   *
34   * @version $Rev$ $Date: 2005-08-06 04:12:10 -0400 (Sat, 06 Aug 2005)
35   *          $
36   * @since Struts 1.1
37   */
38  public interface ModuleConfig extends Serializable {
39      /**
40       * <p> Has this module been completely configured yet.  Once this flag has
41       * been set, any attempt to modify the configuration will return an
42       * IllegalStateException. </p>
43       */
44      boolean getConfigured();
45  
46      /**
47       * <p> The controller configuration object for this module. </p>
48       */
49      ControllerConfig getControllerConfig();
50  
51      /**
52       * <p> The controller configuration object for this module. </p>
53       *
54       * @param cc The controller configuration object for this module.
55       */
56      void setControllerConfig(ControllerConfig cc);
57  
58      /**
59       * <p> The prefix of the context-relative portion of the request URI, used
60       * to select this configuration versus others supported by the controller
61       * servlet.  A configuration with a prefix of a zero-length String is the
62       * default configuration for this web module. </p>
63       */
64      String getPrefix();
65  
66      /**
67       * <p> The prefix of the context-relative portion of the request URI, used
68       * to select this configuration versus others supported by the controller
69       * servlet.  A configuration with a prefix of a zero-length String is the
70       * default configuration for this web module. </p>
71       *
72       * @param prefix The prefix of the context-relative portion of the request
73       *               URI.
74       */
75      public void setPrefix(String prefix);
76  
77      /**
78       * <p> The default class name to be used when creating action form bean
79       * instances. </p>
80       */
81      String getActionFormBeanClass();
82  
83      /**
84       * <p> The default class name to be used when creating action form bean
85       * instances. </p>
86       *
87       * @param actionFormBeanClass default class name to be used when creating
88       *                            action form bean instances.
89       */
90      void setActionFormBeanClass(String actionFormBeanClass);
91  
92      /**
93       * <p> The default class name to be used when creating action mapping
94       * instances. </p>
95       */
96      String getActionMappingClass();
97  
98      /**
99       * <p> The default class name to be used when creating action mapping
100      * instances. </p>
101      *
102      * @param actionMappingClass default class name to be used when creating
103      *                           action mapping instances.
104      */
105     void setActionMappingClass(String actionMappingClass);
106 
107     /**
108      * <p> Add a new <code>ActionConfig</code> instance to the set associated
109      * with this module. </p>
110      *
111      * @param config The new configuration instance to be added
112      * @throws IllegalStateException if this module configuration has been
113      *                               frozen
114      */
115     void addActionConfig(ActionConfig config);
116 
117     /**
118      * <p> Add a new <code>ExceptionConfig</code> instance to the set
119      * associated with this module. </p>
120      *
121      * @param config The new configuration instance to be added
122      * @throws IllegalStateException if this module configuration has been
123      *                               frozen
124      */
125     void addExceptionConfig(ExceptionConfig config);
126 
127     /**
128      * <p> Add a new <code>FormBeanConfig</code> instance to the set
129      * associated with this module. </p>
130      *
131      * @param config The new configuration instance to be added
132      * @throws IllegalStateException if this module configuration has been
133      *                               frozen
134      */
135     void addFormBeanConfig(FormBeanConfig config);
136 
137     /**
138      * <p> The default class name to be used when creating action forward
139      * instances. </p>
140      */
141     String getActionForwardClass();
142 
143     /**
144      * <p> The default class name to be used when creating action forward
145      * instances. </p>
146      *
147      * @param actionForwardClass default class name to be used when creating
148      *                           action forward instances.
149      */
150     void setActionForwardClass(String actionForwardClass);
151 
152     /**
153      * <p> Add a new <code>ForwardConfig</code> instance to the set of global
154      * forwards associated with this module. </p>
155      *
156      * @param config The new configuration instance to be added
157      * @throws IllegalStateException if this module configuration has been
158      *                               frozen
159      */
160     void addForwardConfig(ForwardConfig config);
161 
162     /**
163      * <p> Add a new <code>MessageResourcesConfig</code> instance to the set
164      * associated with this module. </p>
165      *
166      * @param config The new configuration instance to be added
167      * @throws IllegalStateException if this module configuration has been
168      *                               frozen
169      */
170     void addMessageResourcesConfig(MessageResourcesConfig config);
171 
172     /**
173      * <p> Add a newly configured {@link PlugInConfig} instance to the set of
174      * plug-in Actions for this module. </p>
175      *
176      * @param plugInConfig The new configuration instance to be added
177      */
178     void addPlugInConfig(PlugInConfig plugInConfig);
179 
180     /**
181      * <p> Return the action configuration for the specified path, if any;
182      * otherwise return <code>null</code>. </p>
183      *
184      * @param path Path of the action configuration to return
185      */
186     ActionConfig findActionConfig(String path);
187 
188     /**
189      * <p> Return the action configurations for this module.  If there are
190      * none, a zero-length array is returned. </p>
191      */
192     ActionConfig[] findActionConfigs();
193 
194     /**
195      * <p>Returns the action configuration for the specifed action
196      * action identifier.</p>
197      *
198      * @param actionId the action identifier
199      * @return the action config if found; otherwise <code>null</code>
200      * @see ActionConfig#getActionId()
201      * @since Struts 1.3.6
202      */
203     ActionConfig findActionConfigId(String actionId);
204 
205     /**
206      * <p> Return the exception configuration for the specified type, if any;
207      * otherwise return <code>null</code>. </p>
208      *
209      * @param type Exception class name to find a configuration for
210      */
211     ExceptionConfig findExceptionConfig(String type);
212 
213     /**
214      * <p> Perform a recursive search for an ExceptionConfig registered for
215      * this class, or for any superclass.  This should only be used in the
216      * case when an <code>ActionConfig</code> is not available; otherwise, use
217      * <code>ActionConfig.findException(Class)</code> to preserve the search
218      * order. </p>
219      *
220      * @param type Exception class name to find a configuration for
221      * @see ActionConfig findException(Class)
222      */
223     ExceptionConfig findException(Class<?> type);
224 
225     /**
226      * <p> Return the exception configurations for this module.  If there are
227      * none, a zero-length array is returned. </p>
228      */
229     ExceptionConfig[] findExceptionConfigs();
230 
231     /**
232      * <p> Return the form bean configuration for the specified key, if any;
233      * otherwise return <code>null</code>.
234      *
235      * @param name Name of the form bean configuration to return
236      */
237     FormBeanConfig findFormBeanConfig(String name);
238 
239     /**
240      * <p> Return the form bean configurations for this module.  If there are
241      * none, a zero-length array is returned. </p>
242      */
243     FormBeanConfig[] findFormBeanConfigs();
244 
245     /**
246      * <p> Return the forward configuration for the specified key, if any;
247      * otherwise return <code>null</code>. </p>
248      *
249      * @param name Name of the forward configuration to return
250      */
251     ForwardConfig findForwardConfig(String name);
252 
253     /**
254      * <p> Return the form bean configurations for this module.  If there are
255      * none, a zero-length array is returned. </p>
256      */
257     ForwardConfig[] findForwardConfigs();
258 
259     /**
260      * <p> Return the message resources configuration for the specified key,
261      * if any; otherwise return <code>null</code>. </p>
262      *
263      * @param key Key of the data source configuration to return
264      */
265     MessageResourcesConfig findMessageResourcesConfig(String key);
266 
267     /**
268      * <p> Return the message resources configurations for this module. If
269      * there are none, a zero-length array is returned. </p>
270      */
271     MessageResourcesConfig[] findMessageResourcesConfigs();
272 
273     /**
274      * <p> Return the configured plug-in actions for this module.  If there
275      * are none, a zero-length array is returned. </p>
276      */
277     PlugInConfig[] findPlugInConfigs();
278 
279     /**
280      * <p> Freeze the configuration of this module.  After this method
281      * returns, any attempt to modify the configuration will return an
282      * IllegalStateException. </p>
283      */
284     void freeze();
285 
286     /**
287      * <p> Remove the specified action configuration instance. </p>
288      *
289      * @param config ActionConfig instance to be removed
290      * @throws IllegalStateException if this module configuration has been
291      *                               frozen
292      */
293     void removeActionConfig(ActionConfig config);
294 
295     /**
296      * <p> Remove the specified exception configuration instance. </p>
297      *
298      * @param config ActionConfig instance to be removed
299      * @throws IllegalStateException if this module configuration has been
300      *                               frozen
301      */
302     void removeExceptionConfig(ExceptionConfig config);
303 
304     /**
305      * <p> Remove the specified form bean configuration instance. </p>
306      *
307      * @param config FormBeanConfig instance to be removed
308      * @throws IllegalStateException if this module configuration has been
309      *                               frozen
310      */
311     void removeFormBeanConfig(FormBeanConfig config);
312 
313     /**
314      * <p> Remove the specified forward configuration instance. </p>
315      *
316      * @param config ForwardConfig instance to be removed
317      * @throws IllegalStateException if this module configuration has been
318      *                               frozen
319      */
320     void removeForwardConfig(ForwardConfig config);
321 
322     /**
323      * <p> Remove the specified message resources configuration instance.
324      * </p>
325      *
326      * @param config MessageResourcesConfig instance to be removed
327      * @throws IllegalStateException if this module configuration has been
328      *                               frozen
329      */
330     void removeMessageResourcesConfig(MessageResourcesConfig config);
331 }