001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 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(s): Eric HARDESTY
022: * --------------------------------------------------------------------------
023: * $Id: RarDeploymentDesc.java 5459 2004-09-17 22:33:33Z ehardesty $
024: * --------------------------------------------------------------------------
025: */package org.objectweb.jonas_rar.deployment.api;
026:
027: import java.util.Iterator;
028: import java.util.List;
029: import java.util.Vector;
030:
031: import org.objectweb.jonas_lib.deployment.api.AbsDeploymentDesc;
032:
033: import org.objectweb.jonas_rar.deployment.api.ConnectorDesc;
034: import org.objectweb.jonas_rar.deployment.api.JonasConnectorDesc;
035: import org.objectweb.jonas_rar.deployment.api.ConfigPropertyDesc;
036: import org.objectweb.jonas_rar.deployment.api.JonasConfigPropertyDesc;
037: import org.objectweb.jonas_rar.deployment.api.ResourceadapterDesc;
038: import org.objectweb.jonas_rar.deployment.xml.ConfigProperty;
039: import org.objectweb.jonas_rar.deployment.xml.Connector;
040: import org.objectweb.jonas_rar.deployment.xml.JonasConfigProperty;
041: import org.objectweb.jonas_rar.deployment.xml.JonasConnector;
042:
043: /**
044: * This class extends the AbsDeploymentDescriptor class of JOnAS
045: * It provides a description of the specific RAR desployment descriptor
046: *
047: * @author Eric Hardesty
048: */
049: public class RarDeploymentDesc extends AbsDeploymentDesc {
050:
051: /**
052: * Vector of raConfigPropTags (config-property objects).
053: */
054: private Vector raConfigPropTags = null;
055:
056: /**
057: * Vector of jonasConfigPropTags (config-property objects).
058: */
059: private Vector jonasConfigPropTags = null;
060:
061: /**
062: * Connector
063: */
064: private Connector connector = null;
065:
066: /**
067: * Connector
068: */
069: private ConnectorDesc connectorDesc = null;
070:
071: /**
072: * Jonas Connector
073: */
074: private JonasConnectorDesc jonasConnectorDesc = null;
075:
076: /**
077: * Xml content of the ra.xml file
078: */
079: private String xmlContent = "";
080:
081: /**
082: * Xml content of the jonas-ra.xml file
083: */
084: private String jonasXmlContent = "";
085:
086: /**
087: * Construct an instance of a RarDeploymentDesc.
088: * Called by the RarDeploymentDescManager.getInstance() method.
089: *
090: * @param classLoader ClassLoader of the classes .
091: * @param connector ra.xml parsed file.
092: * @param jonasConnector jonas-ra.xml parsed file.
093: *
094: * @throws RarDeploymentDescException if we can't build an instance.
095: */
096: public RarDeploymentDesc(ClassLoader classLoader,
097: Connector connector, JonasConnector jonasConnector)
098: throws RarDeploymentDescException {
099:
100: // test classloader
101: if (classLoader == null) {
102: throw new RarDeploymentDescException(
103: "DeploymentDesc: Classloader is null");
104: }
105:
106: this .connector = connector;
107: this .connectorDesc = new ConnectorDesc(connector);
108: this .jonasConnectorDesc = new JonasConnectorDesc(jonasConnector);
109:
110: if (connectorDesc != null) {
111: // display name
112: displayName = null;
113: if (connectorDesc.getDisplayName() != null) {
114: displayName = connectorDesc.getDisplayName();
115: }
116:
117: raConfigPropTags = new Vector();
118: //Tags
119: ResourceadapterDesc rd = connectorDesc
120: .getResourceadapterDesc();
121: if (rd != null) {
122: for (Iterator i = rd.getConfigPropertyList().iterator(); i
123: .hasNext();) {
124: raConfigPropTags.add((ConfigPropertyDesc) i.next());
125: }
126: }
127: }
128:
129: if (jonasConnectorDesc != null
130: && jonasConnectorDesc.getJonasConfigPropertyList() != null) {
131: jonasConfigPropTags = new Vector();
132: //Tags
133: for (Iterator i = jonasConnectorDesc
134: .getJonasConfigPropertyList().iterator(); i
135: .hasNext();) {
136: jonasConfigPropTags.add((JonasConfigPropertyDesc) i
137: .next());
138: }
139: }
140:
141: }
142:
143: /**
144: * Set the config-property tags of the ra.xml file.
145: * @param conn the Connector objeect with the config-property tags of the ra.xml file.
146: */
147: public void setRaConfigPropTags(Connector conn) {
148: //Tags
149: for (Iterator i = conn.getResourceadapter()
150: .getConfigPropertyList().iterator(); i.hasNext();) {
151: if (raConfigPropTags == null) {
152: raConfigPropTags = new Vector();
153: }
154: raConfigPropTags.add(new ConfigPropertyDesc(
155: (ConfigProperty) i.next()));
156: }
157: if (raConfigPropTags == null) {
158: return;
159: }
160: ConfigPropertyDesc[] tmp = new ConfigPropertyDesc[raConfigPropTags
161: .size()];
162: raConfigPropTags.copyInto(tmp);
163: }
164:
165: /**
166: * Get the config-property tags of the ra.xml file.
167: * @return the config-property tags of the ra.xml file.
168: */
169: public ConfigPropertyDesc[] getRaConfigPropTags() {
170: if (raConfigPropTags == null) {
171: return null;
172: }
173: ConfigPropertyDesc[] tmp = new ConfigPropertyDesc[raConfigPropTags
174: .size()];
175: raConfigPropTags.copyInto(tmp);
176: return tmp;
177: }
178:
179: /**
180: * Get the config-property tags of the jonas-ra.xml file.
181: * @return the config-property tags of the jonas-ra.xml file.
182: */
183: public JonasConfigPropertyDesc[] getJonasConfigPropTags() {
184: if (jonasConfigPropTags == null) {
185: return null;
186: }
187: if (jonasConfigPropTags != null) {
188: JonasConfigPropertyDesc[] tmp = new JonasConfigPropertyDesc[jonasConfigPropTags
189: .size()];
190: jonasConfigPropTags.copyInto(tmp);
191: return tmp;
192: }
193: return null;
194: }
195:
196: /**
197: * Return a String representation of the RarDeploymentDesc.
198: * @return a String representation of the RarDeploymentDesc.
199: */
200: public String toString() {
201: String ret = "Connector :";
202:
203: return ret;
204: }
205:
206: /**
207: * Get the current Connector
208: * @return the current Connector.
209: */
210: public Connector getConnector() {
211: return connector;
212: }
213:
214: /**
215: * Get the current ConnectorDesc.
216: * @return the current ConnectorDesc.
217: */
218: public ConnectorDesc getConnectorDesc() {
219: return connectorDesc;
220: }
221:
222: /**
223: * Get the current JonasConnectorDesc.
224: * @return the current JonasConnectorDesc.
225: */
226: public JonasConnectorDesc getJonasConnectorDesc() {
227: return jonasConnectorDesc;
228: }
229:
230: /**
231: * Return the content of the ra.xml file
232: * @return the content of the ra.xml file
233: */
234: public String getXmlContent() {
235: return xmlContent;
236: }
237:
238: /**
239: * Return the content of the jonas-ra.xml file
240: * @return the content of the jonas-ra.xml file
241: */
242: public String getJOnASXmlContent() {
243: return jonasXmlContent;
244: }
245:
246: /**
247: * Set the content of the ra.xml file
248: * @param xml the content of the file
249: */
250: public void setXmlContent(String xml) {
251: xmlContent = xml;
252: }
253:
254: /**
255: * Set the content of the jonas-ra.xml file
256: * @param jXml the content of the file
257: */
258: public void setJOnASXmlContent(String jXml) {
259: jonasXmlContent = jXml;
260: }
261: }
|