001: /*
002: * $Id: PlugInConfig.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts.config;
022:
023: import java.io.Serializable;
024:
025: import java.util.HashMap;
026: import java.util.Map;
027:
028: /**
029: * <p>A JavaBean representing the configuration information of a
030: * <code><plug-in></code> element in a Struts configuration file.</p>
031: * <p>Note that this class does not extend <code>BaseConfig</code> because it
032: * is more "internal" than the other classes which do, and because this class
033: * has an existing "properties" object which collides with the one in
034: * <code>BaseConfig</code>. Also, since one always writes a concrete PlugIn
035: * implementation, there seems to be less call for an arbitrary property map;
036: * one can simply use bean properties instead.</p>
037: *
038: * @version $Rev: 471754 $ $Date: 2005-05-12 18:41:19 -0400 (Thu, 12 May 2005)
039: * $
040: * @since Struts 1.1
041: */
042: public class PlugInConfig implements Serializable {
043: // ----------------------------------------------------- Instance Variables
044:
045: /**
046: * Has this component been completely configured?
047: */
048: protected boolean configured = false;
049:
050: /**
051: * A <code>Map</code> of the name-value pairs that will be used to
052: * configure the property values of a <code>PlugIn</code> instance.
053: */
054: protected Map properties = new HashMap();
055:
056: // ------------------------------------------------------------- Properties
057:
058: /**
059: * The fully qualified Java class name of the <code>PlugIn</code>
060: * implementation class being configured.
061: */
062: protected String className = null;
063:
064: public String getClassName() {
065: return (this .className);
066: }
067:
068: public void setClassName(String className) {
069: this .className = className;
070: }
071:
072: // --------------------------------------------------------- Public Methods
073:
074: /**
075: * Add a new property name and value to the set that will be used to
076: * configure the <code>PlugIn</code> instance.
077: *
078: * @param name Property name
079: * @param value Property value
080: */
081: public void addProperty(String name, String value) {
082: if (configured) {
083: throw new IllegalStateException("Configuration is frozen");
084: }
085:
086: properties.put(name, value);
087: }
088:
089: /**
090: * Freeze the configuration of this component.
091: */
092: public void freeze() {
093: configured = true;
094: }
095:
096: /**
097: * Return the properties that will be used to configure a
098: * <code>PlugIn</code> instance.
099: */
100: public Map getProperties() {
101: return (properties);
102: }
103: }
|