KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_client > deployment > api > ClientContainerDeploymentDesc


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 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: Florent BENOIT
22  * --------------------------------------------------------------------------
23  * $Id: ClientContainerDeploymentDesc.java,v 1.12 2004/06/16 15:57:47 benoitf Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas_client.deployment.api;
28
29
30 // import java
31
import org.objectweb.jonas_client.deployment.xml.ApplicationClient;
32 import org.objectweb.jonas_client.deployment.xml.JonasClient;
33 import org.objectweb.jonas_client.deployment.xml.JonasSecurity;
34
35 import org.objectweb.jonas_lib.deployment.api.DeploymentDescException;
36 import org.objectweb.jonas_lib.deployment.api.EjbRefDesc;
37 import org.objectweb.jonas_lib.deployment.api.EnvEntryDesc;
38 import org.objectweb.jonas_lib.deployment.api.JndiEnvRefsGroupDesc;
39 import org.objectweb.jonas_lib.deployment.api.MessageDestinationRefDesc;
40 import org.objectweb.jonas_lib.deployment.api.ResourceEnvRefDesc;
41 import org.objectweb.jonas_lib.deployment.api.ResourceRefDesc;
42
43 /**
44  * This class do the parsing of the application-client.xml file and jonas-client.xml files and
45  * contruct a data structure associated to these two files.
46  * @author Florent Benoit
47  * @author Philippe Coq
48  */

49 public class ClientContainerDeploymentDesc extends JndiEnvRefsGroupDesc {
50
51     /**
52      * The name of the callback handler
53      */

54     private String JavaDoc callbackHandler = null;
55
56     /**
57      * The name of the jaas config file
58      */

59     private String JavaDoc jaasFile = null;
60
61     /**
62      * The name of the jaas entry
63      */

64     private String JavaDoc jaasEntry = null;
65
66     /**
67      * The username to use for the callback handler
68      */

69     private String JavaDoc username = null;
70
71     /**
72      * The password to use for the callback handler
73      */

74     private String JavaDoc password = null;
75
76     /**
77      * Xml content of the standard deployement descriptor file
78      */

79     private String JavaDoc xmlContent = "";
80
81     /**
82      * Xml content of the JOnAS deployement descriptor file
83      */

84     private String JavaDoc jonasXmlContent = "";
85
86     /**
87      * Construct an instance of a ClientContainerDeploymentDesc.<BR>
88      * Constructor is private, call one of the static getInstance
89      * method instead.
90      * @param classLoader the classloader for the classes.
91      * @param applicationClient the data structure of the application-client (application-client.xml)
92      * @param jonasClient the data structure of the jonas-client (jonas-client.xml)
93      * @throws DeploymentDescException if the deployment
94      * descriptors are corrupted.
95      */

96     public ClientContainerDeploymentDesc(ClassLoader JavaDoc classLoader,
97                                           ApplicationClient applicationClient,
98                                           JonasClient jonasClient)
99         throws DeploymentDescException {
100         super(classLoader, applicationClient, jonasClient, null);
101
102         // callbackHandler
103
callbackHandler = null;
104         if (applicationClient.getCallbackHandler() != null) {
105             callbackHandler = applicationClient.getCallbackHandler();
106         }
107
108         JonasSecurity jonasSecurity = jonasClient.getJonasSecurity();
109         if (jonasSecurity != null) {
110             // jaas config file
111
jaasFile = null;
112             if (jonasSecurity.getJaasfile() != null) {
113                 jaasFile = jonasSecurity.getJaasfile();
114             }
115
116             // jaas entry
117
jaasEntry = null;
118             if (jonasSecurity.getJaasentry() != null) {
119                 jaasEntry = jonasSecurity.getJaasentry();
120             }
121
122             // username
123
username = null;
124             if (jonasSecurity.getUsername() != null) {
125                 username = jonasSecurity.getUsername();
126             }
127
128             // password
129
password = null;
130             if (jonasSecurity.getPassword() != null) {
131                 password = jonasSecurity.getPassword();
132             }
133         }
134
135
136     }
137
138     /**
139      * Get the name of the jaas configuration file
140      * @return the name of the jaas configuration file
141      */

142     public String JavaDoc getJaasFile() {
143         return jaasFile;
144     }
145
146     /**
147      * Get the entry in the jaas configuration file
148      * @return the entry in the jaas configuration file
149      */

150     public String JavaDoc getJaasEntry() {
151         return jaasEntry;
152     }
153
154     /**
155      * Get the username used for a callback handler
156      * @return the username used for a callback handler
157      */

158     public String JavaDoc getUsername() {
159         return username;
160     }
161
162     /**
163      * Get the password used for a callback handler
164      * @return the password used for a callback handler
165      */

166     public String JavaDoc getPassword() {
167         return password;
168     }
169
170     /**
171      * Get the callback handler of this client application.
172      * @return the callback handler of this client application.
173      */

174     public String JavaDoc getCallbackHandler() {
175         return callbackHandler;
176     }
177
178     /**
179      * Return the content of the web.xml file
180      * @return the content of the web.xml file
181      */

182     public String JavaDoc getXmlContent() {
183         return xmlContent;
184     }
185
186     /**
187      * Return the content of the jonas-web.xml file
188      * @return the content of the jonas-web.xml file
189      */

190     public String JavaDoc getJOnASXmlContent() {
191         return jonasXmlContent;
192     }
193
194     /**
195      * @param xmlContent XML Content
196      */

197     public void setXmlContent(String JavaDoc xmlContent) {
198         this.xmlContent = xmlContent;
199     }
200
201     /**
202      * @param jonasXmlContent XML Content
203      */

204     public void setJOnASXmlContent(String JavaDoc jonasXmlContent) {
205         this.jonasXmlContent = jonasXmlContent;
206     }
207
208     /**
209      * Return a String representation of the ClientContainerDeploymentDesc.
210      * @return a String representation of the ClientContainerDeploymentDesc.
211      */

212     public String JavaDoc toString() {
213         StringBuffer JavaDoc ret = new StringBuffer JavaDoc();
214
215         // Return the displayName
216
ret.append("\ngetDisplayName()=" + getDisplayName());
217
218         // Return the resource-env-ref
219
ResourceEnvRefDesc[] rer = getResourceEnvRefDesc();
220         for (int i = 0; i < rer.length; i++) {
221             ret.append("\ngetResourceEnvRefDesc(" + i + ")=" + rer[i].getClass().getName());
222             ret.append(rer[i].toString());
223         }
224
225         // Return the resource-ref
226
ResourceRefDesc[] resourceRefDesc = getResourceRefDesc();
227         for (int i = 0; i < resourceRefDesc.length; i++) {
228             ret.append("\ngetResourceRefDesc(" + i + ")=" + resourceRefDesc[i].getClass().getName());
229             ret.append(resourceRefDesc[i].toString());
230         }
231
232         // Return the env-entry
233
EnvEntryDesc[] envEntries = getEnvEntryDesc();
234         for (int i = 0; i < envEntries.length; i++) {
235             ret.append("\ngetEnvEntryDesc(" + i + ")=" + envEntries[i].getClass().getName());
236             ret.append(envEntries[i].toString());
237         }
238
239         // Return the ejb-ref
240
EjbRefDesc[] ejbRefDesc = getEjbRefDesc();
241         for (int i = 0; i < ejbRefDesc.length; i++) {
242             ret.append("\ngetEjbRefDesc(" + i + ")=" + ejbRefDesc[i].getClass().getName());
243             ret.append(ejbRefDesc[i].toString());
244         }
245
246         // Return the message-destination-ref
247
MessageDestinationRefDesc[] mdRefDesc = getMessageDestinationRefDesc();
248         for (int i = 0; i < mdRefDesc.length; i++) {
249             ret.append("\ngetMessageDestinationRefDesc(" + i + ")=" + mdRefDesc[i].getClass().getName());
250             ret.append(mdRefDesc[i].toString());
251         }
252
253         // Return the callbackHandler
254
ret.append("\ngetCallbackHandler()=" + getCallbackHandler());
255
256         return ret.toString();
257     }
258 }
259
Popular Tags