KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > utils > xml > HandlerDesc


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial Developer : Delplanque Xavier & Sauthier Guillaume
22  * --------------------------------------------------------------------------
23  * $Id: HandlerDesc.java,v 1.1 2003/11/21 10:40:42 joaninh Exp $
24  * --------------------------------------------------------------------------
25 */

26
27 package com.bull.eclipse.jonas.utils.xml;
28
29 import java.util.Hashtable JavaDoc;
30 import java.util.List JavaDoc;
31 import java.util.Map JavaDoc;
32 import java.util.Vector JavaDoc;
33
34 //import javax.xml.namespace.QName;
35
//
36
//import org.objectweb.jonas_lib.deployment.xml.InitParam;
37
//import org.objectweb.jonas_lib.deployment.xml.Handler;
38

39
40 /**
41  * The Handler class describe both
42  * - a Handler reference to use on the client side of a Web Service,
43  * - and a Handler description.
44  * The difference is that the port-names attribute is present for a handler reference,
45  * and the port-names attribute does not exist for a handler description.
46  *
47  * @author Guillaume Sauthier
48  * @author Xavier Delplanque
49  * @author Helene Joanin
50  */

51 public class HandlerDesc {
52
53     /** The name of the handler (must be unique) */
54     private String JavaDoc name;
55
56     /** The classname of the Handler */
57     private String JavaDoc className;
58
59     /** The handler class */
60     private Class JavaDoc clazz;
61
62     /** Params needed to initialize the handler */
63     private Map JavaDoc params = new Hashtable JavaDoc();
64
65     /** The list of SOAP Headers the handler will access */
66     private List JavaDoc headers = new Vector JavaDoc();
67
68     /** The list of SOAP actor the handler will play as a role */
69     private List JavaDoc roles = new Vector JavaDoc();
70
71     /** List of port names the handler is associated with */
72     private List JavaDoc portNames = new Vector JavaDoc();
73
74     /**
75      * Creates a new HandlerRef object.
76      *
77      * @param classLoader ejbjar classLoader
78      * @param handler contains informations defined in web deployment
79      * descriptor (service-ref)
80      *
81      * @throws DeploymentDescException When Construction fails.
82      */

83 // public HandlerDesc(ClassLoader classLoader, Handler handler)
84
// throws DeploymentDescException {
85
//
86
// name = handler.getHandlerName();
87
//
88
// className = handler.getHandlerClass();
89
//
90
// try {
91
// clazz = classLoader.loadClass(className);
92
// } catch (ClassNotFoundException e) {
93
// throw new DeploymentDescException("handler class not found", e);
94
// }
95
//
96
// // fill init params table
97
// List iparams = handler.getInitParamList();
98
// try {
99
// for (int i = 0; i < iparams.size(); i++) {
100
// // add in params table each init parameter name and associated value
101
// InitParam p = (InitParam) iparams.get(i);
102
//
103
// if (p != null) {
104
// params.put(p.getParamName(), p.getParamValue());
105
// }
106
// }
107
// } catch (NullPointerException e) {
108
// throw new DeploymentDescException("parameter name missing", e);
109
// }
110
//
111
// // fill headers a list containing soap header QNames
112
// List shl = handler.getSoapHeaderList();
113
// for (int i = 0; i < shl.size(); i++) {
114
// // build qnames and add it in the table
115
// org.objectweb.jonas_lib.deployment.xml.Qname sh = (org.objectweb.jonas_lib.deployment.xml.Qname) shl.get(i);
116
//
117
// if (sh != null) {
118
// QName qn = sh.getQName();
119
// headers.add(qn);
120
// }
121
// }
122
//
123
// // fill roles a list containing soap role names
124
// List srl = handler.getSoapRoleList();
125
// for (int i = 0; i < srl.size(); i++) {
126
// String role = (String) srl.get(i);
127
// if (role != null) {
128
// roles.add(role);
129
// }
130
// }
131
//
132
// // fill portNames a list containing ports names
133
// List pnl = handler.getPortNameList();
134
// for (int i = 0; i < pnl.size(); i++) {
135
// String pn = (String) pnl.get(i);
136
// if (pn != null) {
137
// portNames.add(pn);
138
// }
139
// }
140
// }
141

142     /**
143      * Return the name of the Handler.
144      *
145      * @return the name of the Handler.
146      */

147     public String JavaDoc getName() {
148         return name;
149     }
150
151
152     /**
153      * Return the name of class of the Handler.
154      *
155      * @return the name of class of the Handler.
156      */

157     public String JavaDoc getHandlerClassName() {
158         return className;
159     }
160
161     /**
162      * Return the Handler implementation class.
163      *
164      * @return the Handler class
165      */

166     public Class JavaDoc getHandlerClass() {
167         return clazz;
168     }
169
170     /**
171      * Return all the init-params of the Handler.
172      *
173      * @return the init-params of the Handler
174      */

175     public Map JavaDoc getInitParams() {
176         return params;
177     }
178
179     /**
180      * Return the value of an init-param.
181      *
182      * @param pname The key of init-param map.
183      *
184      * @return the value of an init-param
185      */

186     public String JavaDoc getInitParam(String JavaDoc pname) {
187         return (String JavaDoc) params.get(pname);
188     }
189
190     /**
191      * Return the list of Headers the Handlers will access.
192      *
193      * @return the list of Headers the Handlers will access.
194      */

195     public List JavaDoc getSOAPHeaders() {
196         return headers;
197     }
198
199     /**
200      * Return the list of SOAP Actor Definitions the Handler will play as a
201      * role.
202      *
203      * @return the list of Role the Handler will play
204      */

205     public List JavaDoc getSOAPRoles() {
206         return roles;
207     }
208
209     /**
210      * Return the list of port name the Handler is associated with. The names
211      * match the localPart of the Port QName.
212      *
213      * @return the list of port name the Handler is associated with.
214      */

215     public List JavaDoc getPortNames() {
216         return portNames;
217     }
218
219     /**
220      * Test Equality between 2 Objects.
221      *
222      * @param other The object to compare.
223      *
224      * @return true if the objects are equals in value, else false.
225      */

226     public boolean equals(Object JavaDoc other) {
227         if (other == null) {
228             return false;
229         }
230         if (!(other instanceof HandlerDesc)) {
231             return false;
232         }
233         HandlerDesc ref = (HandlerDesc) other;
234         if (!name.equals(ref.getName())) {
235             return false;
236         }
237         if (!clazz.getName().equals(ref.getHandlerClass().getName())) {
238             return false;
239         }
240         if (!params.equals(ref.getInitParams())) {
241             return false;
242         }
243         if (!headers.equals(ref.getSOAPHeaders())) {
244             return false;
245         }
246         if (!roles.equals(ref.getSOAPRoles())) {
247             return false;
248         }
249         if (!portNames.equals(ref.getPortNames())) {
250             return false;
251         }
252         // After all theses tests, the 2 objects are equals in value
253
return true;
254     }
255
256     public String JavaDoc toString() {
257         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
258         sb.append("\n" + getClass().getName());
259         sb.append("\ngetName()=" + getName());
260         sb.append("\ngetClassname()=" + getHandlerClassName());
261         sb.append("\ngetSOAPRoles()=" + getSOAPRoles());
262         sb.append("\ngetSOAPHeaders()=" + getSOAPHeaders());
263         sb.append("\ngetInitParams()=" + getInitParams());
264         sb.append("\ngetPortNames()=" + getPortNames());
265         return sb.toString();
266     }
267
268 }
269
Popular Tags