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: *
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or 1any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
020: * USA
021: *
022: * Initial developer: JOnAS team
023: * --------------------------------------------------------------------------
024: * $Id: JonasEjbJar.java 7467 2005-10-04 12:53:14Z sauthieg $
025: * --------------------------------------------------------------------------
026: */package org.objectweb.jonas_ejb.deployment.xml;
027:
028: import org.objectweb.jonas_ejb.deployment.api.JonasEjbjarSchemas;
029:
030: import org.objectweb.jonas_lib.deployment.xml.AbsElement;
031: import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
032: import org.objectweb.jonas_lib.deployment.xml.JonasMessageDestination;
033: import org.objectweb.jonas_lib.deployment.xml.TopLevelElement;
034:
035: /**
036: * This class defines the implementation of the element jonas-ejb-jar
037: *
038: * @author JOnAS team
039: */
040:
041: public class JonasEjbJar extends AbsElement implements TopLevelElement {
042:
043: /**
044: * Header (with right XSD version) for XML
045: */
046: private String header = null;
047:
048: /**
049: * jonas-session
050: */
051: private JLinkedList jonasSessionList = null;
052:
053: /**
054: * jonas-entity
055: */
056: private JLinkedList jonasEntityList = null;
057:
058: /**
059: * jonas-message-driven
060: */
061: private JLinkedList jonasMessageDrivenList = null;
062:
063: /**
064: * jonas-ejb-relation
065: */
066: private JLinkedList jonasEjbRelationList = null;
067:
068: /**
069: * jonas-message-destination
070: */
071: private JLinkedList jonasMessageDestinationList = null;
072:
073: /**
074: * jonas-run-as-mapping
075: */
076: private JLinkedList jonasRunAsMappingList = null;
077:
078: /**
079: * jonas-ejb-jar element XML header
080: */
081: public static final String JONAS_EJBJAR_ELEMENT = "<?xml version=\"1.0\"?>\n"
082: + "<jonas-ejb-jar xmlns=\"http://www.objectweb.org/jonas/ns\"\n"
083: + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
084: + " xsi:schemaLocation=\"http://www.objectweb.org/jonas/ns\n"
085: + " http://www.objectweb.org/jonas/ns/"
086: + JonasEjbjarSchemas.getLastSchema() + "\">\n";
087:
088: /**
089: * Constructor
090: */
091: public JonasEjbJar() {
092: super ();
093: jonasSessionList = new JLinkedList("jonas-session");
094: jonasEntityList = new JLinkedList("jonas-entity");
095: jonasMessageDrivenList = new JLinkedList("jonas-message-driven");
096: jonasEjbRelationList = new JLinkedList("jonas-ejb-relation");
097: jonasMessageDestinationList = new JLinkedList(
098: "jonas-message-destination");
099: jonasRunAsMappingList = new JLinkedList("jonas-run-as-mapping");
100:
101: header = JONAS_EJBJAR_ELEMENT;
102: }
103:
104: /**
105: * Gets the jonas-run-as-mapping
106: * @return the jonas-run-as-mapping
107: */
108: public JLinkedList getJonasRunAsMappingList() {
109: return jonasRunAsMappingList;
110: }
111:
112: /**
113: * Gets the jonas-session
114: * @return the jonas-session
115: */
116: public JLinkedList getJonasSessionList() {
117: return jonasSessionList;
118: }
119:
120: /**
121: * Set the jonas-session
122: * @param jonasSessionList jonasSession
123: */
124: public void setJonasSessionList(JLinkedList jonasSessionList) {
125: this .jonasSessionList = jonasSessionList;
126: }
127:
128: /**
129: * Add a new jonas-run-as-mapping element to this object
130: * @param jonasRunAsMapping the jonasRunAsMapping object
131: */
132: public void addJonasRunAsMapping(JonasRunAsMapping jonasRunAsMapping) {
133: jonasRunAsMappingList.add(jonasRunAsMapping);
134: }
135:
136: /**
137: * Add a new jonas-session element to this object
138: * @param jonasSession the jonasSessionobject
139: */
140: public void addJonasSession(JonasSession jonasSession) {
141: jonasSessionList.add(jonasSession);
142: }
143:
144: /**
145: * Gets the jonas-entity
146: * @return the jonas-entity
147: */
148: public JLinkedList getJonasEntityList() {
149: return jonasEntityList;
150: }
151:
152: /**
153: * Set the jonas-entity
154: * @param jonasEntityList jonasEntity
155: */
156: public void setJonasEntityList(JLinkedList jonasEntityList) {
157: this .jonasEntityList = jonasEntityList;
158: }
159:
160: /**
161: * Add a new jonas-entity element to this object
162: * @param jonasEntity the jonasEntityobject
163: */
164: public void addJonasEntity(JonasEntity jonasEntity) {
165: jonasEntityList.add(jonasEntity);
166: }
167:
168: /**
169: * Gets the jonas-message-driven
170: * @return the jonas-message-driven
171: */
172: public JLinkedList getJonasMessageDrivenList() {
173: return jonasMessageDrivenList;
174: }
175:
176: /**
177: * Set the jonas-message-driven
178: * @param jonasMessageDrivenList jonasMessageDriven
179: */
180: public void setJonasMessageDrivenList(
181: JLinkedList jonasMessageDrivenList) {
182: this .jonasMessageDrivenList = jonasMessageDrivenList;
183: }
184:
185: /**
186: * Add a new jonas-message-driven element to this object
187: * @param jonasMessageDriven the jonasMessageDrivenobject
188: */
189: public void addJonasMessageDriven(
190: JonasMessageDriven jonasMessageDriven) {
191: jonasMessageDrivenList.add(jonasMessageDriven);
192: }
193:
194: /**
195: * Gets the jonas-ejb-relation
196: * @return the jonas-ejb-relation
197: */
198: public JLinkedList getJonasEjbRelationList() {
199: return jonasEjbRelationList;
200: }
201:
202: /**
203: * Set the jonas-ejb-relation
204: * @param jonasEjbRelationList jonasEjbRelation
205: */
206: public void setJonasEjbRelationList(JLinkedList jonasEjbRelationList) {
207: this .jonasEjbRelationList = jonasEjbRelationList;
208: }
209:
210: /**
211: * Add a new jonas-ejb-relation element to this object
212: * @param jonasEjbRelation the jonasEjbRelationobject
213: */
214: public void addJonasEjbRelation(JonasEjbRelation jonasEjbRelation) {
215: jonasEjbRelationList.add(jonasEjbRelation);
216: }
217:
218: /**
219: * @return the list of all jonas-message-destination elements
220: */
221: public JLinkedList getJonasMessageDestinationList() {
222: return jonasMessageDestinationList;
223: }
224:
225: /**
226: * Set the jonas-message-destination
227: * @param jonasMessageDestinationList jonasMessageDestination
228: */
229: public void setJonasMessageDestinationList(
230: JLinkedList jonasMessageDestinationList) {
231: this .jonasMessageDestinationList = jonasMessageDestinationList;
232: }
233:
234: /**
235: * Add a new jonas-message-destination element to this object
236: * @param jonasMessageDestination the jonas-message-destination object
237: */
238: public void addJonasMessageDestination(
239: JonasMessageDestination jonasMessageDestination) {
240: jonasMessageDestinationList.add(jonasMessageDestination);
241: }
242:
243: /**
244: * Represents this element by it's XML description.
245: * @param indent use this indent for prexifing XML representation.
246: * @return the XML description of this object.
247: */
248: public String toXML(int indent) {
249: StringBuffer sb = new StringBuffer();
250: sb.append(indent(indent));
251: if (header != null) {
252: sb.append(header);
253: } else {
254: sb.append("<jonas-ejb-jar>");
255: }
256:
257: indent += 2;
258:
259: // jonas-session
260: sb.append(jonasSessionList.toXML(indent));
261: // jonas-entity
262: sb.append(jonasEntityList.toXML(indent));
263: // jonas-message-driven
264: sb.append(jonasMessageDrivenList.toXML(indent));
265: // jonas-ejb-relation
266: sb.append(jonasEjbRelationList.toXML(indent));
267: // jonas-message-destination
268: sb.append(jonasMessageDestinationList.toXML(indent));
269: // jonas-run-as-mapping
270: sb.append(jonasRunAsMappingList.toXML(indent));
271: indent -= 2;
272: sb.append(indent(indent));
273: sb.append("</jonas-ejb-jar>\n");
274:
275: return sb.toString();
276: }
277:
278: /**
279: * @return the header.
280: */
281: public String getHeader() {
282: return header;
283: }
284:
285: /**
286: * @param header The header to set.
287: */
288: public void setHeader(String header) {
289: this.header = header;
290: }
291: }
|