KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_lib > deployment > xml > Handler


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 1any 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: Florent BENOIT
22  * --------------------------------------------------------------------------
23  * $Id: Handler.java,v 1.2 2004/05/10 12:04:39 sauthieg Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas_lib.deployment.xml;
28
29 /**
30  * This class defines the implementation of the element handler.
31  * @author Florent Benoit
32  */

33 public class Handler extends AbsElement {
34
35     /**
36      * Name of the handler
37      */

38     private String JavaDoc handlerName = null;
39
40     /**
41      * List of elements init-param
42      */

43     private JLinkedList initParamList = null;
44
45     /**
46      * List of elements soap-header
47      */

48     private JLinkedList soapHeaderList = null;
49
50     /**
51      * List of elements soap-role
52      */

53     private JLinkedList soapRoleList = null;
54
55     /**
56      * List of elements port-name
57      */

58     private JLinkedList portNameList = null;
59
60
61     /**
62      * Class of the handler
63      */

64     private String JavaDoc handlerClass = null;
65
66     /**
67      * Constructor : build a new Handler object
68      */

69     public Handler() {
70         super();
71         initParamList = new JLinkedList("init-param");
72         soapHeaderList = new JLinkedList("soap-header");
73         soapRoleList = new JLinkedList("soap-role");
74         portNameList = new JLinkedList("port-name");
75     }
76
77
78     // Setters
79

80     /**
81      * Sets the name
82      * @param handlerName the name to use
83      */

84     public void setHandlerName(String JavaDoc handlerName) {
85         this.handlerName = handlerName;
86     }
87
88     /**
89      * Add a new port-name element to this object
90      * @param portName the port-name object
91      */

92     public void addPortName(String JavaDoc portName) {
93         portNameList.add(portName);
94     }
95
96
97     /**
98      * Add a new soap-role element to this object
99      * @param soapRole the soap-role object
100      */

101     public void addSoapRole(String JavaDoc soapRole) {
102         soapRoleList.add(soapRole);
103     }
104
105     /**
106      * Add a new soap-header element to this object
107      * @param soapHeader the soap-header object
108      */

109     public void addSoapHeader(Qname soapHeader) {
110         soapHeaderList.add(soapHeader);
111     }
112
113     /**
114      * Add a new init-param element to this object
115      * @param initParam the init-param object
116      */

117     public void addInitParam(InitParam initParam) {
118         initParamList.add(initParam);
119     }
120
121     /**
122      * Sets the class
123      * @param handlerClass the class to use
124      */

125     public void setHandlerClass(String JavaDoc handlerClass) {
126         this.handlerClass = handlerClass;
127     }
128
129     // Getters
130

131     /**
132      * @return the name of the handler
133      */

134     public String JavaDoc getHandlerName() {
135         return handlerName;
136     }
137
138     /**
139      * @return the class of the handler
140      */

141     public String JavaDoc getHandlerClass() {
142         return handlerClass;
143     }
144
145     /**
146      * @return the list of all init-param elements
147      */

148     public JLinkedList getInitParamList() {
149         return initParamList;
150     }
151
152     /**
153      * @return the list of all soap-header elements
154      */

155     public JLinkedList getSoapHeaderList() {
156         return soapHeaderList;
157     }
158
159     /**
160      * @return the list of all soap-role elements
161      */

162     public JLinkedList getSoapRoleList() {
163         return soapRoleList;
164     }
165
166     /**
167      * @return the list of all port-name elements
168      */

169     public JLinkedList getPortNameList() {
170         return portNameList;
171     }
172
173     /**
174      * Represents this element by it's XML description.
175      * @param indent use this indent for prexifing XML representation.
176      * @return the XML description of this object.
177      */

178     public String JavaDoc toXML(int indent) {
179         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
180         sb.append(indent(indent));
181         sb.append("<handler>\n");
182
183         indent += 2;
184
185         // handler-name
186
sb.append(xmlElement(handlerName, "handler-name", indent));
187
188         // handler-class
189
sb.append(xmlElement(handlerClass, "handler-class", indent));
190
191         // init-param
192
sb.append(initParamList.toXML(indent));
193
194         // soap-header
195
sb.append(soapHeaderList.toXML(indent));
196
197         // soap-role
198
sb.append(soapRoleList.toXML(indent));
199
200         // port-name
201
sb.append(portNameList.toXML(indent));
202
203         indent -= 2;
204         sb.append(indent(indent));
205         sb.append("</handler>\n");
206
207         return sb.toString();
208     }
209
210
211 }
212
Popular Tags