KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_rar > deployment > api > RarDeploymentDesc


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(s): Eric HARDESTY
22  * --------------------------------------------------------------------------
23  * $Id: RarDeploymentDesc.java,v 1.10 2004/09/17 22:33:32 ehardesty Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas_rar.deployment.api;
28
29 import java.util.Iterator JavaDoc;
30 import java.util.List JavaDoc;
31 import java.util.Vector JavaDoc;
32
33 import org.objectweb.jonas_lib.deployment.api.AbsDeploymentDesc;
34
35 import org.objectweb.jonas_rar.deployment.api.ConnectorDesc;
36 import org.objectweb.jonas_rar.deployment.api.JonasConnectorDesc;
37 import org.objectweb.jonas_rar.deployment.api.ConfigPropertyDesc;
38 import org.objectweb.jonas_rar.deployment.api.JonasConfigPropertyDesc;
39 import org.objectweb.jonas_rar.deployment.api.ResourceadapterDesc;
40 import org.objectweb.jonas_rar.deployment.xml.ConfigProperty;
41 import org.objectweb.jonas_rar.deployment.xml.Connector;
42 import org.objectweb.jonas_rar.deployment.xml.JonasConfigProperty;
43 import org.objectweb.jonas_rar.deployment.xml.JonasConnector;
44
45
46 /**
47  * This class extends the AbsDeploymentDescriptor class of JOnAS
48  * It provides a description of the specific RAR desployment descriptor
49  *
50  * @author Eric Hardesty
51  */

52 public class RarDeploymentDesc extends AbsDeploymentDesc {
53
54
55     /**
56      * Vector of raConfigPropTags (config-property objects).
57      */

58     private Vector JavaDoc raConfigPropTags = null;
59
60     /**
61      * Vector of jonasConfigPropTags (config-property objects).
62      */

63     private Vector JavaDoc jonasConfigPropTags = null;
64
65     /**
66      * Connector
67      */

68     private Connector connector = null;
69
70     /**
71      * Connector
72      */

73     private ConnectorDesc connectorDesc = null;
74
75     /**
76      * Jonas Connector
77      */

78     private JonasConnectorDesc jonasConnectorDesc = null;
79
80     /**
81      * Xml content of the ra.xml file
82      */

83     private String JavaDoc xmlContent = "";
84
85     /**
86      * Xml content of the jonas-ra.xml file
87      */

88     private String JavaDoc jonasXmlContent = "";
89
90
91     /**
92      * Construct an instance of a RarDeploymentDesc.
93      * Called by the RarDeploymentDescManager.getInstance() method.
94      *
95      * @param classLoader ClassLoader of the classes .
96      * @param connector ra.xml parsed file.
97      * @param jonasConnector jonas-ra.xml parsed file.
98      *
99      * @throws RarDeploymentDescException if we can't build an instance.
100      */

101     public RarDeploymentDesc(
102         ClassLoader JavaDoc classLoader,
103         Connector connector,
104         JonasConnector jonasConnector)
105         throws RarDeploymentDescException {
106
107         // test classloader
108
if (classLoader == null) {
109             throw new RarDeploymentDescException("DeploymentDesc: Classloader is null");
110         }
111
112         this.connector = connector;
113         this.connectorDesc = new ConnectorDesc(connector);
114         this.jonasConnectorDesc = new JonasConnectorDesc(jonasConnector);
115
116         if (connectorDesc != null) {
117             // display name
118
displayName = null;
119             if (connectorDesc.getDisplayName() != null) {
120                 displayName = connectorDesc.getDisplayName();
121             }
122
123             raConfigPropTags = new Vector JavaDoc();
124             //Tags
125
ResourceadapterDesc rd = connectorDesc.getResourceadapterDesc();
126             if (rd != null) {
127                 for (Iterator JavaDoc i = rd.getConfigPropertyList().iterator(); i.hasNext(); ) {
128                     raConfigPropTags.add((ConfigPropertyDesc) i.next());
129                 }
130             }
131         }
132
133         if (jonasConnectorDesc != null &&
134             jonasConnectorDesc.getJonasConfigPropertyList() != null) {
135             jonasConfigPropTags = new Vector JavaDoc();
136             //Tags
137
for (Iterator JavaDoc i =
138                 jonasConnectorDesc.getJonasConfigPropertyList().iterator();
139                 i.hasNext();
140                 ) {
141                 jonasConfigPropTags.add((JonasConfigPropertyDesc) i.next());
142             }
143         }
144
145     }
146
147     /**
148      * Set the config-property tags of the ra.xml file.
149      * @param conn the Connector objeect with the config-property tags of the ra.xml file.
150      */

151     public void setRaConfigPropTags(Connector conn) {
152         //Tags
153
for (Iterator JavaDoc i =
154             conn.getResourceadapter().getConfigPropertyList().iterator();
155             i.hasNext();
156             ) {
157             if (raConfigPropTags == null) {
158                 raConfigPropTags = new Vector JavaDoc();
159             }
160             raConfigPropTags.add(new ConfigPropertyDesc((ConfigProperty) i.next()));
161         }
162         if (raConfigPropTags == null) {
163             return;
164         }
165         ConfigPropertyDesc[] tmp = new ConfigPropertyDesc[raConfigPropTags.size()];
166         raConfigPropTags.copyInto(tmp);
167     }
168
169     /**
170      * Get the config-property tags of the ra.xml file.
171      * @return the config-property tags of the ra.xml file.
172      */

173     public ConfigPropertyDesc[] getRaConfigPropTags() {
174         if (raConfigPropTags == null) {
175             return null;
176         }
177         ConfigPropertyDesc[] tmp = new ConfigPropertyDesc[raConfigPropTags.size()];
178         raConfigPropTags.copyInto(tmp);
179         return tmp;
180     }
181
182     /**
183      * Get the config-property tags of the jonas-ra.xml file.
184      * @return the config-property tags of the jonas-ra.xml file.
185      */

186     public JonasConfigPropertyDesc[] getJonasConfigPropTags() {
187         if (jonasConfigPropTags == null) {
188             return null;
189         }
190         if (jonasConfigPropTags != null) {
191             JonasConfigPropertyDesc[] tmp =
192                 new JonasConfigPropertyDesc[jonasConfigPropTags.size()];
193             jonasConfigPropTags.copyInto(tmp);
194             return tmp;
195         }
196         return null;
197     }
198
199     /**
200      * Return a String representation of the RarDeploymentDesc.
201      * @return a String representation of the RarDeploymentDesc.
202      */

203     public String JavaDoc toString() {
204         String JavaDoc ret = "Connector :";
205
206         return ret;
207     }
208
209     /**
210      * Get the current Connector
211      * @return the current Connector.
212      */

213     public Connector getConnector() {
214         return connector;
215     }
216
217     /**
218      * Get the current ConnectorDesc.
219      * @return the current ConnectorDesc.
220      */

221     public ConnectorDesc getConnectorDesc() {
222         return connectorDesc;
223     }
224
225     /**
226      * Get the current JonasConnectorDesc.
227      * @return the current JonasConnectorDesc.
228      */

229     public JonasConnectorDesc getJonasConnectorDesc() {
230         return jonasConnectorDesc;
231     }
232     /**
233      * Return the content of the ra.xml file
234      * @return the content of the ra.xml file
235      */

236     public String JavaDoc getXmlContent() {
237         return xmlContent;
238     }
239
240     /**
241      * Return the content of the jonas-ra.xml file
242      * @return the content of the jonas-ra.xml file
243      */

244     public String JavaDoc getJOnASXmlContent() {
245         return jonasXmlContent;
246     }
247
248     /**
249      * Set the content of the ra.xml file
250      * @param xml the content of the file
251      */

252     public void setXmlContent(String JavaDoc xml) {
253         xmlContent = xml;
254     }
255
256     /**
257      * Set the content of the jonas-ra.xml file
258      * @param jXml the content of the file
259      */

260     public void setJOnASXmlContent(String JavaDoc jXml) {
261         jonasXmlContent = jXml;
262     }
263 }
264
Popular Tags