KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > WebServiceHandler


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.deployment;
24
25 import java.util.Collection JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.HashSet JavaDoc;
28
29 import javax.xml.namespace.QName JavaDoc;
30
31 import com.sun.enterprise.deployment.Descriptor;
32 import com.sun.enterprise.deployment.NameValuePairDescriptor;
33
34 /**
35  * This class describes a web service message handler.
36  *
37  * @author Jerome Dochez
38  * @author Kenneth Saks
39  */

40 public class WebServiceHandler extends Descriptor {
41     
42     private String JavaDoc handlerName = null;
43
44     private String JavaDoc handlerClass = null;
45
46     private Collection JavaDoc initParams = new HashSet JavaDoc();
47     
48     private Collection JavaDoc soapHeaders = new HashSet JavaDoc();
49     
50     private Collection JavaDoc soapRoles = new HashSet JavaDoc();
51
52     private Collection JavaDoc portNames = new HashSet JavaDoc();
53     
54     /**
55     * copy constructor.
56     */

57     public WebServiceHandler(WebServiceHandler other) {
58     super(other);
59     handlerName = other.handlerName; // String
60
handlerClass = other.handlerClass; // String
61
portNames.addAll(other.portNames); // Set of String
62
soapRoles.addAll(other.soapRoles); // Set of String
63
soapHeaders.addAll(other.soapHeaders); // Set of QName (immutable)
64
for (Iterator JavaDoc i = other.initParams.iterator(); i.hasNext();) {
65         initParams.add(new NameValuePairDescriptor((NameValuePairDescriptor)i.next()));
66     }
67     }
68
69     public WebServiceHandler() {
70     }
71
72     /**
73      * Sets the class name for this handler
74      * @param class name
75      */

76     public void setHandlerClass(String JavaDoc className) {
77         handlerClass = className;
78         super.changed();
79     }
80     
81     /**
82      * @return the class name for this handler
83      */

84     public String JavaDoc getHandlerClass() {
85         return handlerClass;
86     }
87     
88     public void setHandlerName(String JavaDoc name) {
89         handlerName = name;
90         super.changed();
91     }
92
93     public String JavaDoc getHandlerName() {
94         return handlerName;
95     }
96   
97     /**
98      * add an init param to this handler
99      * @param the init param
100      */

101     public void addInitParam(NameValuePairDescriptor newInitParam) {
102         initParams.add(newInitParam);
103         super.changed();
104     }
105   
106     /**
107      * remove an init param from this handler
108      * @param the init param
109      */

110     public void removeInitParam(NameValuePairDescriptor initParamToRemove) {
111         initParams.remove(initParamToRemove);
112         super.changed();
113     }
114
115     /**
116      * @return the list of init params for this handler
117      */

118     public Collection JavaDoc getInitParams() {
119         return initParams;
120     }
121     
122     public void addSoapHeader(QName JavaDoc soapHeader) {
123         soapHeaders.add(soapHeader);
124         super.changed();
125     }
126
127     public void removeSoapHeader(QName JavaDoc soapHeader) {
128         soapHeaders.remove(soapHeader);
129         super.changed();
130     }
131
132     // Collection of soap header QNames
133
public Collection JavaDoc getSoapHeaders() {
134         return soapHeaders;
135     }
136
137     public void addSoapRole(String JavaDoc soapRole) {
138         soapRoles.add(soapRole);
139         super.changed();
140     }
141
142     public void removeSoapRole(String JavaDoc soapRole) {
143         soapRoles.remove(soapRole);
144         super.changed();
145     }
146
147     public Collection JavaDoc getSoapRoles() {
148         return soapRoles;
149     }
150
151     public void addPortName(String JavaDoc portName) {
152         portNames.add(portName);
153         super.changed();
154     }
155
156     public void removePortName(String JavaDoc portName) {
157         portNames.remove(portName);
158         super.changed();
159     }
160
161     // Collection of port name Strings
162
public Collection JavaDoc getPortNames() {
163         return portNames;
164     }
165     
166     /**
167      * @return a string describing the values I hold
168      */

169     public void print(StringBuffer JavaDoc toStringBuffer) {
170         toStringBuffer.append("\nHandler name = ").append(handlerName).append(
171             "Handler class name = ").append(handlerClass);
172         for (Iterator JavaDoc i=getInitParams().iterator(); i.hasNext(); ) {
173             toStringBuffer.append("\n").append(i.next().toString());
174         }
175     }
176
177 }
178
Popular Tags