KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_web > deployment > xml > JonasWebApp


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: JonasWebApp.java,v 1.7 2004/07/22 11:37:08 benoitf Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas_web.deployment.xml;
28
29 import org.objectweb.jonas_lib.deployment.xml.AbsJonasEnvironmentElement;
30 import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
31 import org.objectweb.jonas_lib.deployment.xml.JonasMessageDestination;
32 import org.objectweb.jonas_lib.deployment.xml.TopLevelElement;
33
34 /**
35  * This class defines the implementation of the element jonas-web-app.
36  * @author Florent Benoit
37  */

38 public class JonasWebApp extends AbsJonasEnvironmentElement implements TopLevelElement {
39
40     /**
41      * Header (with right XSD version) for XML
42      */

43     private String JavaDoc header = null;
44
45     /**
46      * Host element
47      */

48     private String JavaDoc host = null;
49
50     /**
51      * Context-root element
52      */

53     private String JavaDoc contextRoot = null;
54
55
56     /**
57      * Port to use (used by web services)
58      */

59     private String JavaDoc port = null;
60
61     /**
62      * Follow the java 2 delegation model or not
63      */

64     private String JavaDoc java2DelegationModel = null;
65
66     /**
67      * jonas-message-destination
68      */

69     private JLinkedList jonasMessageDestinationList = null;
70
71     /**
72      * Constructor : build a new WebApp object
73      */

74     public JonasWebApp() {
75         super();
76         jonasMessageDestinationList = new JLinkedList("jonas-message-destination");
77     }
78
79
80     // Setters
81

82
83
84     /**
85      * Set the host element of this object
86      * @param host host element of this object
87      */

88     public void setHost(String JavaDoc host) {
89         this.host = host;
90     }
91
92
93     /**
94      * Set the context-root element of this object
95      * @param contextRoot context-root element of this object
96      */

97     public void setContextRoot(String JavaDoc contextRoot) {
98         this.contextRoot = contextRoot;
99     }
100
101
102     /**
103      * Set the port element of this object
104      * @param port port element of this object
105      */

106     public void setPort(String JavaDoc port) {
107         this.port = port;
108     }
109
110
111     /**
112      * Set the java 2 delegation model element of this object
113      * @param java2DelegationModel java2-delegation-model element of this object
114      */

115     public void setJava2DelegationModel(String JavaDoc java2DelegationModel) {
116         this.java2DelegationModel = java2DelegationModel;
117     }
118
119
120     /**
121      * Set the jonas-message-destination
122      * @param jonasMessageDestinationList jonasMessageDestination
123      */

124     public void setJonasMessageDestinationList(JLinkedList jonasMessageDestinationList) {
125         this.jonasMessageDestinationList = jonasMessageDestinationList;
126     }
127
128     /**
129      * Add a new jonas-message-destination element to this object
130      * @param jonasMessageDestination the jonas-message-destination object
131      */

132     public void addJonasMessageDestination(JonasMessageDestination jonasMessageDestination) {
133         jonasMessageDestinationList.add(jonasMessageDestination);
134     }
135
136     // Getters
137

138
139     /**
140      * @return the host element
141      */

142     public String JavaDoc getHost() {
143         return host;
144     }
145
146     /**
147      * @return the context-root element
148      */

149     public String JavaDoc getContextRoot() {
150         return contextRoot;
151     }
152
153     /**
154      * @return the port element
155      */

156     public String JavaDoc getPort() {
157         return port;
158     }
159
160     /**
161      * @return the java2-delegation-model element
162      */

163     public String JavaDoc getJava2DelegationModel() {
164         return java2DelegationModel;
165     }
166
167     /**
168      * @return the list of all jonas-message-destination elements
169      */

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

181     public String JavaDoc toXML(int indent) {
182         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
183         sb.append(indent(indent));
184         if (header != null) {
185             sb.append(header);
186         } else {
187             sb.append("<jonas-web-app>\n");
188         }
189
190         indent += 2;
191
192         // jonas-resource-env
193
sb.append(getJonasResourceEnvList().toXML(indent));
194
195         // jonas-resource
196
sb.append(getJonasResourceList().toXML(indent));
197
198         // jonas-ejb-ref
199
sb.append(getJonasEjbRefList().toXML(indent));
200
201         // jonas-message-destination-ref
202
sb.append(getJonasMessageDestinationRefList().toXML(indent));
203
204         // jonas-message-destination
205
sb.append(jonasMessageDestinationList.toXML(indent));
206
207         // jonas-service-ref
208
sb.append(getJonasServiceRefList().toXML(indent));
209
210         // host
211
sb.append(xmlElement(host, "host", indent));
212
213         // context-root
214
sb.append(xmlElement(contextRoot, "context-root", indent));
215
216         // port
217
sb.append(xmlElement(port, "port", indent));
218
219         // java2-delegation-model
220
sb.append(xmlElement(java2DelegationModel, "java2-delegation-model", indent));
221
222         indent -= 2;
223         sb.append(indent(indent));
224         sb.append("</jonas-web-app>");
225
226         return sb.toString();
227     }
228
229     /**
230      * @return the header.
231      */

232     public String JavaDoc getHeader() {
233         return header;
234     }
235
236     /**
237      * @param header The header to set.
238      */

239     public void setHeader(String JavaDoc header) {
240         this.header = header;
241     }
242
243
244 }
245
Popular Tags