001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999-2004 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * Initial developer: Florent BENOIT
022: * --------------------------------------------------------------------------
023: * $Id: ClientContainerDeploymentDesc.java 4960 2004-06-16 15:57:47Z benoitf $
024: * --------------------------------------------------------------------------
025: */package org.objectweb.jonas_client.deployment.api;
026:
027: // import java
028: import org.objectweb.jonas_client.deployment.xml.ApplicationClient;
029: import org.objectweb.jonas_client.deployment.xml.JonasClient;
030: import org.objectweb.jonas_client.deployment.xml.JonasSecurity;
031:
032: import org.objectweb.jonas_lib.deployment.api.DeploymentDescException;
033: import org.objectweb.jonas_lib.deployment.api.EjbRefDesc;
034: import org.objectweb.jonas_lib.deployment.api.EnvEntryDesc;
035: import org.objectweb.jonas_lib.deployment.api.JndiEnvRefsGroupDesc;
036: import org.objectweb.jonas_lib.deployment.api.MessageDestinationRefDesc;
037: import org.objectweb.jonas_lib.deployment.api.ResourceEnvRefDesc;
038: import org.objectweb.jonas_lib.deployment.api.ResourceRefDesc;
039:
040: /**
041: * This class do the parsing of the application-client.xml file and jonas-client.xml files and
042: * contruct a data structure associated to these two files.
043: * @author Florent Benoit
044: * @author Philippe Coq
045: */
046: public class ClientContainerDeploymentDesc extends JndiEnvRefsGroupDesc {
047:
048: /**
049: * The name of the callback handler
050: */
051: private String callbackHandler = null;
052:
053: /**
054: * The name of the jaas config file
055: */
056: private String jaasFile = null;
057:
058: /**
059: * The name of the jaas entry
060: */
061: private String jaasEntry = null;
062:
063: /**
064: * The username to use for the callback handler
065: */
066: private String username = null;
067:
068: /**
069: * The password to use for the callback handler
070: */
071: private String password = null;
072:
073: /**
074: * Xml content of the standard deployement descriptor file
075: */
076: private String xmlContent = "";
077:
078: /**
079: * Xml content of the JOnAS deployement descriptor file
080: */
081: private String jonasXmlContent = "";
082:
083: /**
084: * Construct an instance of a ClientContainerDeploymentDesc.<BR>
085: * Constructor is private, call one of the static getInstance
086: * method instead.
087: * @param classLoader the classloader for the classes.
088: * @param applicationClient the data structure of the application-client (application-client.xml)
089: * @param jonasClient the data structure of the jonas-client (jonas-client.xml)
090: * @throws DeploymentDescException if the deployment
091: * descriptors are corrupted.
092: */
093: public ClientContainerDeploymentDesc(ClassLoader classLoader,
094: ApplicationClient applicationClient, JonasClient jonasClient)
095: throws DeploymentDescException {
096: super (classLoader, applicationClient, jonasClient, null);
097:
098: // callbackHandler
099: callbackHandler = null;
100: if (applicationClient.getCallbackHandler() != null) {
101: callbackHandler = applicationClient.getCallbackHandler();
102: }
103:
104: JonasSecurity jonasSecurity = jonasClient.getJonasSecurity();
105: if (jonasSecurity != null) {
106: // jaas config file
107: jaasFile = null;
108: if (jonasSecurity.getJaasfile() != null) {
109: jaasFile = jonasSecurity.getJaasfile();
110: }
111:
112: // jaas entry
113: jaasEntry = null;
114: if (jonasSecurity.getJaasentry() != null) {
115: jaasEntry = jonasSecurity.getJaasentry();
116: }
117:
118: // username
119: username = null;
120: if (jonasSecurity.getUsername() != null) {
121: username = jonasSecurity.getUsername();
122: }
123:
124: // password
125: password = null;
126: if (jonasSecurity.getPassword() != null) {
127: password = jonasSecurity.getPassword();
128: }
129: }
130:
131: }
132:
133: /**
134: * Get the name of the jaas configuration file
135: * @return the name of the jaas configuration file
136: */
137: public String getJaasFile() {
138: return jaasFile;
139: }
140:
141: /**
142: * Get the entry in the jaas configuration file
143: * @return the entry in the jaas configuration file
144: */
145: public String getJaasEntry() {
146: return jaasEntry;
147: }
148:
149: /**
150: * Get the username used for a callback handler
151: * @return the username used for a callback handler
152: */
153: public String getUsername() {
154: return username;
155: }
156:
157: /**
158: * Get the password used for a callback handler
159: * @return the password used for a callback handler
160: */
161: public String getPassword() {
162: return password;
163: }
164:
165: /**
166: * Get the callback handler of this client application.
167: * @return the callback handler of this client application.
168: */
169: public String getCallbackHandler() {
170: return callbackHandler;
171: }
172:
173: /**
174: * Return the content of the web.xml file
175: * @return the content of the web.xml file
176: */
177: public String getXmlContent() {
178: return xmlContent;
179: }
180:
181: /**
182: * Return the content of the jonas-web.xml file
183: * @return the content of the jonas-web.xml file
184: */
185: public String getJOnASXmlContent() {
186: return jonasXmlContent;
187: }
188:
189: /**
190: * @param xmlContent XML Content
191: */
192: public void setXmlContent(String xmlContent) {
193: this .xmlContent = xmlContent;
194: }
195:
196: /**
197: * @param jonasXmlContent XML Content
198: */
199: public void setJOnASXmlContent(String jonasXmlContent) {
200: this .jonasXmlContent = jonasXmlContent;
201: }
202:
203: /**
204: * Return a String representation of the ClientContainerDeploymentDesc.
205: * @return a String representation of the ClientContainerDeploymentDesc.
206: */
207: public String toString() {
208: StringBuffer ret = new StringBuffer();
209:
210: // Return the displayName
211: ret.append("\ngetDisplayName()=" + getDisplayName());
212:
213: // Return the resource-env-ref
214: ResourceEnvRefDesc[] rer = getResourceEnvRefDesc();
215: for (int i = 0; i < rer.length; i++) {
216: ret.append("\ngetResourceEnvRefDesc(" + i + ")="
217: + rer[i].getClass().getName());
218: ret.append(rer[i].toString());
219: }
220:
221: // Return the resource-ref
222: ResourceRefDesc[] resourceRefDesc = getResourceRefDesc();
223: for (int i = 0; i < resourceRefDesc.length; i++) {
224: ret.append("\ngetResourceRefDesc(" + i + ")="
225: + resourceRefDesc[i].getClass().getName());
226: ret.append(resourceRefDesc[i].toString());
227: }
228:
229: // Return the env-entry
230: EnvEntryDesc[] envEntries = getEnvEntryDesc();
231: for (int i = 0; i < envEntries.length; i++) {
232: ret.append("\ngetEnvEntryDesc(" + i + ")="
233: + envEntries[i].getClass().getName());
234: ret.append(envEntries[i].toString());
235: }
236:
237: // Return the ejb-ref
238: EjbRefDesc[] ejbRefDesc = getEjbRefDesc();
239: for (int i = 0; i < ejbRefDesc.length; i++) {
240: ret.append("\ngetEjbRefDesc(" + i + ")="
241: + ejbRefDesc[i].getClass().getName());
242: ret.append(ejbRefDesc[i].toString());
243: }
244:
245: // Return the message-destination-ref
246: MessageDestinationRefDesc[] mdRefDesc = getMessageDestinationRefDesc();
247: for (int i = 0; i < mdRefDesc.length; i++) {
248: ret.append("\ngetMessageDestinationRefDesc(" + i + ")="
249: + 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: }
|