001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.management.geronimo;
017:
018: import java.util.List;
019: import java.util.ArrayList;
020: import java.beans.PropertyEditor;
021:
022: import org.apache.geronimo.gbean.AbstractName;
023: import org.apache.geronimo.common.propertyeditor.PropertyEditors;
024:
025: /**
026: * Specialization of NetworkManager for web containers.
027: *
028: * @version $Rev: 562293 $ $Date: 2007-08-02 16:54:48 -0700 (Thu, 02 Aug 2007) $
029: */
030: public interface WebManager extends NetworkManager {
031: public final static String PROTOCOL_HTTP = "HTTP";
032: public final static String PROTOCOL_HTTPS = "HTTPS";
033: public final static String PROTOCOL_AJP = "AJP";
034:
035: /**
036: * Gets the WebAccessLog implementation for a web container.
037: * May be null if the access log cannot be managed.
038: *
039: * @param container The container whose access log is interesting
040: *
041: */
042: public WebAccessLog getAccessLog(WebContainer container);
043:
044: List<ConnectorType> getConnectorTypes();
045:
046: List<ConnectorAttribute> getConnectorAttributes(
047: ConnectorType connectorType);
048:
049: AbstractName getConnectorConfiguration(ConnectorType connectorType,
050: List<ConnectorAttribute> connectorAttributes,
051: WebContainer container, String uniqueName);
052:
053: ConnectorType getConnectorType(AbstractName connectorName);
054:
055: public class ConnectorType {
056: private final String description;
057:
058: public ConnectorType(String description) {
059: this .description = description;
060: }
061:
062: public String getDescription() {
063: return description;
064: }
065:
066: @Override
067: public int hashCode() {
068: final int PRIME = 31;
069: int result = 1;
070: result = PRIME
071: * result
072: + ((description == null) ? 0 : description
073: .hashCode());
074: return result;
075: }
076:
077: @Override
078: public boolean equals(Object obj) {
079: if (this == obj)
080: return true;
081: if (obj == null)
082: return false;
083: if (getClass() != obj.getClass())
084: return false;
085: final ConnectorType other = (ConnectorType) obj;
086: if (description == null) {
087: if (other.description != null)
088: return false;
089: } else if (!description.equals(other.description))
090: return false;
091: return true;
092: }
093: }
094:
095: public class ConnectorAttribute<T> {
096: private final String attributeName;
097: private String stringValue;
098: private final Class<T> clazz;
099: private T value;
100: private final String description;
101: private boolean required;
102:
103: public ConnectorAttribute(String attributeName, T value,
104: String description, Class<T> clazz, boolean required) {
105: this .attributeName = attributeName;
106: this .value = value;
107: this .description = description;
108: this .clazz = clazz;
109: this .required = required;
110: }
111:
112: public ConnectorAttribute(String attributeName, T value,
113: String description, Class<T> clazz) {
114: this (attributeName, value, description, clazz, false);
115: }
116:
117: public ConnectorAttribute(
118: ConnectorAttribute<T> connectorAttribute) {
119: this .attributeName = connectorAttribute.attributeName;
120: this .value = connectorAttribute.value;
121: this .description = connectorAttribute.description;
122: this .clazz = connectorAttribute.clazz;
123: this .required = connectorAttribute.required;
124: }
125:
126: public String getAttributeName() {
127: return attributeName;
128: }
129:
130: public String getStringValue() {
131: // Class<T> clazz = getClass().getTypeParameters();
132: if (value == null)
133: return null;
134: PropertyEditor propertyEditor = PropertyEditors
135: .getEditor(clazz);
136: propertyEditor.setValue(value);
137: return propertyEditor.getAsText();
138: }
139:
140: public void setStringValue(String stringValue) {
141: PropertyEditor propertyEditor = PropertyEditors
142: .getEditor(clazz);
143: propertyEditor.setAsText(stringValue);
144: this .value = (T) propertyEditor.getValue();
145: }
146:
147: public T getValue() {
148: return value;
149: }
150:
151: public void setValue(T value) {
152: this .value = value;
153: }
154:
155: public String getDescription() {
156: return description;
157: }
158:
159: public static List<ConnectorAttribute> copy(
160: List<ConnectorAttribute> source) {
161: List<ConnectorAttribute> copy = new ArrayList<ConnectorAttribute>(
162: source.size());
163: for (ConnectorAttribute connectorAttribute : source) {
164: copy.add(new ConnectorAttribute(connectorAttribute));
165: }
166: return copy;
167: }
168:
169: public Class<T> getAttributeClass() {
170: return clazz;
171: }
172:
173: public boolean isRequired() {
174: return required;
175: }
176:
177: public void setRequired(boolean required) {
178: this.required = required;
179: }
180:
181: }
182: }
|