1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts.config;
19
20 import java.io.Serializable;
21
22 import java.util.HashMap;
23 import java.util.Map;
24
25 /***
26 * <p>A JavaBean representing the configuration information of a
27 * <code><plug-in></code> element in a Struts configuration file.</p>
28 * <p>Note that this class does not extend <code>BaseConfig</code> because it
29 * is more "internal" than the other classes which do, and because this class
30 * has an existing "properties" object which collides with the one in
31 * <code>BaseConfig</code>. Also, since one always writes a concrete PlugIn
32 * implementation, there seems to be less call for an arbitrary property map;
33 * one can simply use bean properties instead.</p>
34 *
35 * @version $Rev: 421119 $ $Date: 2005-05-12 18:41:19 -0400 (Thu, 12 May 2005)
36 * $
37 * @since Struts 1.1
38 */
39 public class PlugInConfig implements Serializable {
40
41
42 /***
43 * Has this component been completely configured?
44 */
45 protected boolean configured = false;
46
47 /***
48 * A <code>Map</code> of the name-value pairs that will be used to
49 * configure the property values of a <code>PlugIn</code> instance.
50 */
51 protected Map properties = new HashMap();
52
53
54
55 /***
56 * The fully qualified Java class name of the <code>PlugIn</code>
57 * implementation class being configured.
58 */
59 protected String className = null;
60
61 public String getClassName() {
62 return (this.className);
63 }
64
65 public void setClassName(String className) {
66 this.className = className;
67 }
68
69
70
71 /***
72 * Add a new property name and value to the set that will be used to
73 * configure the <code>PlugIn</code> instance.
74 *
75 * @param name Property name
76 * @param value Property value
77 */
78 public void addProperty(String name, String value) {
79 if (configured) {
80 throw new IllegalStateException("Configuration is frozen");
81 }
82
83 properties.put(name, value);
84 }
85
86 /***
87 * Freeze the configuration of this component.
88 */
89 public void freeze() {
90 configured = true;
91 }
92
93 /***
94 * Return the properties that will be used to configure a
95 * <code>PlugIn</code> instance.
96 */
97 public Map getProperties() {
98 return (properties);
99 }
100 }