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: JonasClient.java 7467 2005-10-04 12:53:14Z sauthieg $
025: * --------------------------------------------------------------------------
026: */package org.objectweb.jonas_client.deployment.xml;
027:
028: import org.objectweb.jonas_client.deployment.api.JonasAppClientSchemas;
029:
030: import org.objectweb.jonas_lib.deployment.xml.AbsJonasEnvironmentElement;
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-client
037: * @author jonas-team
038: */
039:
040: public class JonasClient extends AbsJonasEnvironmentElement implements
041: TopLevelElement {
042:
043: /**
044: * Header (with right XSD version) for XML
045: */
046: private String header = null;
047:
048: /**
049: * jonas-security
050: */
051: private JonasSecurity jonasSecurity = null;
052:
053: /**
054: * jonas-message-destination
055: */
056: private JLinkedList jonasMessageDestinationList = null;
057:
058: /**
059: * jonas-client element XML header
060: */
061: public static final String JONAS_CLIENT_ELEMENT = "<?xml version=\"1.0\"?>\n"
062: + "<jonas-client xmlns=\"http://www.objectweb.org/jonas/ns\"\n"
063: + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
064: + " xsi:schemaLocation=\"http://www.objectweb.org/jonas/ns\n"
065: + " http://www.objectweb.org/jonas/ns/"
066: + JonasAppClientSchemas.getLastSchema() + "\">\n";
067:
068: /**
069: * Default constructor
070: */
071: public JonasClient() {
072: super ();
073: jonasMessageDestinationList = new JLinkedList(
074: "jonas-message-destination");
075:
076: header = JONAS_CLIENT_ELEMENT;
077: }
078:
079: /**
080: * @return the jonas-security
081: */
082: public JonasSecurity getJonasSecurity() {
083: return jonasSecurity;
084: }
085:
086: /**
087: * Set the jonas-security
088: * @param jonasSecurity jonasSecurity
089: */
090: public void setJonasSecurity(JonasSecurity jonasSecurity) {
091: this .jonasSecurity = jonasSecurity;
092: }
093:
094: /**
095: * @return the list of all jonas-message-destination elements
096: */
097: public JLinkedList getJonasMessageDestinationList() {
098: return jonasMessageDestinationList;
099: }
100:
101: /**
102: * Set the jonas-message-destination
103: * @param jonasMessageDestinationList jonasMessageDestination
104: */
105: public void setJonasMessageDestinationList(
106: JLinkedList jonasMessageDestinationList) {
107: this .jonasMessageDestinationList = jonasMessageDestinationList;
108: }
109:
110: /**
111: * Add a new jonas-message-destination element to this object
112: * @param jonasMessageDestination the jonas-message-destination object
113: */
114: public void addJonasMessageDestination(
115: JonasMessageDestination jonasMessageDestination) {
116: jonasMessageDestinationList.add(jonasMessageDestination);
117: }
118:
119: /**
120: * Represents this element by it's XML description.
121: * @param indent use this indent for prexifing XML representation.
122: * @return the XML description of this object.
123: */
124: public String toXML(int indent) {
125: StringBuffer sb = new StringBuffer();
126: sb.append(indent(indent));
127: if (header != null) {
128: sb.append(header);
129: } else {
130: sb.append("<jonas-client>\n");
131: }
132:
133: indent += 2;
134:
135: // jonas-ejb-ref
136: sb.append(getJonasEjbRefList().toXML(indent));
137: // jonas-resource
138: sb.append(getJonasResourceList().toXML(indent));
139: // jonas-resource-env
140: sb.append(getJonasResourceEnvList().toXML(indent));
141: // jonas-security
142: if (jonasSecurity != null) {
143: sb.append(jonasSecurity.toXML(indent));
144: }
145: // jonas-service-ref
146: sb.append(getJonasServiceRefList().toXML(indent));
147: // jonas-message-destination-ref
148: sb.append(getJonasMessageDestinationRefList().toXML(indent));
149: // jonas-message-destination
150: sb.append(jonasMessageDestinationList.toXML(indent));
151: indent -= 2;
152: sb.append(indent(indent));
153: sb.append("</jonas-client>\n");
154:
155: return sb.toString();
156: }
157:
158: /**
159: * @return the header.
160: */
161: public String getHeader() {
162: return header;
163: }
164:
165: /**
166: * @param header The header to set.
167: */
168: public void setHeader(String header) {
169: this.header = header;
170: }
171: }
|