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