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: */
017:
018: package org.apache.catalina.deploy;
019:
020: import java.io.Serializable;
021: import java.util.ArrayList;
022: import java.util.Iterator;
023: import java.util.HashMap;
024:
025: /**
026: * Representation of a handler reference for a web service, as
027: * represented in a <code><handler></code> element in the
028: * deployment descriptor.
029: *
030: * @author Fabien Carrion
031: */
032:
033: public class ContextHandler extends ResourceBase implements
034: Serializable {
035:
036: // ------------------------------------------------------------- Properties
037:
038: /**
039: * The Handler reference class.
040: */
041: private String handlerclass = null;
042:
043: public String getHandlerclass() {
044: return (this .handlerclass);
045: }
046:
047: public void setHandlerclass(String handlerclass) {
048: this .handlerclass = handlerclass;
049: }
050:
051: /**
052: * A list of QName specifying the SOAP Headers the handler will work on.
053: * -namespace and locapart values must be found inside the WSDL.
054: *
055: * A service-qname is composed by a namespaceURI and a localpart.
056: *
057: * soapHeader[0] : namespaceURI
058: * soapHeader[1] : localpart
059: */
060: private HashMap soapHeaders = new HashMap();
061:
062: public Iterator getLocalparts() {
063: return soapHeaders.keySet().iterator();
064: }
065:
066: public String getNamespaceuri(String localpart) {
067: return (String) soapHeaders.get(localpart);
068: }
069:
070: public void addSoapHeaders(String localpart, String namespaceuri) {
071: soapHeaders.put(localpart, namespaceuri);
072: }
073:
074: /**
075: * Set a configured property.
076: */
077: public void setProperty(String name, String value) {
078: this .setProperty(name, (Object) value);
079: }
080:
081: /**
082: * The soapRole.
083: */
084: private ArrayList<String> soapRoles = new ArrayList();
085:
086: public String getSoapRole(int i) {
087: return this .soapRoles.get(i);
088: }
089:
090: public int getSoapRolesSize() {
091: return this .soapRoles.size();
092: }
093:
094: public void addSoapRole(String soapRole) {
095: this .soapRoles.add(soapRole);
096: }
097:
098: /**
099: * The portName.
100: */
101: private ArrayList<String> portNames = new ArrayList();
102:
103: public String getPortName(int i) {
104: return this .portNames.get(i);
105: }
106:
107: public int getPortNamesSize() {
108: return this .portNames.size();
109: }
110:
111: public void addPortName(String portName) {
112: this .portNames.add(portName);
113: }
114:
115: // --------------------------------------------------------- Public Methods
116:
117: /**
118: * Return a String representation of this object.
119: */
120: public String toString() {
121:
122: StringBuffer sb = new StringBuffer("ContextHandler[");
123: sb.append("name=");
124: sb.append(getName());
125: if (handlerclass != null) {
126: sb.append(", class=");
127: sb.append(handlerclass);
128: }
129: if (this .soapHeaders != null) {
130: sb.append(", soap-headers=");
131: sb.append(this .soapHeaders);
132: }
133: if (this .getSoapRolesSize() > 0) {
134: sb.append(", soap-roles=");
135: sb.append(soapRoles);
136: }
137: if (this .getPortNamesSize() > 0) {
138: sb.append(", port-name=");
139: sb.append(portNames);
140: }
141: if (this .listProperties() != null) {
142: sb.append(", init-param=");
143: sb.append(this .listProperties());
144: }
145: sb.append("]");
146: return (sb.toString());
147:
148: }
149:
150: }
|