1 /*
2 * $Id: PlugInConfig.java 471754 2006-11-06 14:55:09Z husted $
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 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 // ----------------------------------------------------- Instance Variables
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 // ------------------------------------------------------------- Properties
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 // --------------------------------------------------------- Public Methods
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 }