001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2005-2006 Bull S.A.S.
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: * --------------------------------------------------------------------------
023: * $Id: Domain.java 9869 2006-11-27 08:30:31Z sauthieg $
024: * --------------------------------------------------------------------------
025: */package org.objectweb.jonas_domain.xml;
026:
027: import org.objectweb.jonas_domain.api.DomainSchemas;
028: import org.objectweb.jonas_lib.deployment.xml.AbsDescriptionElement;
029: import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
030: import org.objectweb.jonas_lib.deployment.xml.TopLevelElement;
031:
032: /**
033: * This class defines the implementation of the domain
034: *
035: * @author Adriana Danes
036: */
037:
038: public class Domain extends AbsDescriptionElement implements
039: TopLevelElement {
040:
041: /**
042: * Version UID
043: */
044: private static final long serialVersionUID = 3866056043763651049L;
045:
046: /**
047: * domain element XML header.
048: */
049: public static final String DOMAIN_ELEMENT = "<?xml version=\"1.0\"?>\n"
050: + "<domain xmlns=\"http://www.objectweb.org/jonas/ns\"\n"
051: + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
052: + " xsi:schemaLocation=\"http://www.objectweb.org/jonas/ns\n"
053: + " http://www.objectweb.org/jonas/ns/"
054: + DomainSchemas.getLastSchema() + "\">\n";
055:
056: /**
057: * servers
058: */
059: private JLinkedList serverList = null;
060:
061: /**
062: * cluster daemons
063: */
064: private JLinkedList clusterDaemonList = null;
065:
066: /**
067: * cluster
068: */
069: private JLinkedList clusterList = null;
070:
071: /**
072: * Domain name
073: */
074: private String name = null;
075:
076: /**
077: * Constructor
078: */
079: public Domain() {
080: super ();
081: serverList = new JLinkedList("server");
082: clusterList = new JLinkedList("cluster");
083: clusterDaemonList = new JLinkedList("clusterDaemon");
084: }
085:
086: /**
087: * @return Returns the name.
088: */
089: public String getName() {
090: return name;
091: }
092:
093: /**
094: * @param name The name to set.
095: */
096: public void setName(String name) {
097: this .name = name;
098: }
099:
100: /**
101: * Add a new cluster element to this object
102: * @param cluster the Cluster object
103: */
104: public void addCluster(Cluster cluster) {
105: clusterList.add(cluster);
106: }
107:
108: /**
109: * Add a new cluster daemon element to this object
110: * @param clusterDaemon the ClusterDaemon object
111: */
112: public void addClusterDaemon(ClusterDaemon clusterDaemon) {
113: clusterDaemonList.add(clusterDaemon);
114: }
115:
116: /**
117: * Add a new server element to this object
118: * @param server the Server object
119: */
120: public void addServer(Server server) {
121: serverList.add(server);
122: }
123:
124: /**
125: * @return Returns the clusterList.
126: */
127: public JLinkedList getClusterList() {
128: return clusterList;
129: }
130:
131: /**
132: * @param clusterList The clusterList to set.
133: */
134: public void setClusterList(JLinkedList clusterList) {
135: this .clusterList = clusterList;
136: }
137:
138: /**
139: * @param clusterDaemonList The clusterDaemonList to set.
140: */
141: public void setClusterDaemonList(JLinkedList clusterDaemonList) {
142: this .clusterDaemonList = clusterDaemonList;
143: }
144:
145: /**
146: * @return Returns the clusterDaemonList.
147: */
148: public JLinkedList getClusterDaemonList() {
149: return clusterDaemonList;
150: }
151:
152: /**
153: * @return Returns the serverList.
154: */
155: public JLinkedList getServerList() {
156: return serverList;
157: }
158:
159: /**
160: * @param serverList The serverList to set.
161: */
162: public void setServerList(JLinkedList serverList) {
163: this .serverList = serverList;
164: }
165:
166: /**
167: * Represents this element by it's XML description.
168: * @param indent use this indent for prexifing XML representation.
169: * @return the XML description of this object.
170: */
171: public String toXML(int indent) {
172: StringBuffer sb = new StringBuffer();
173: sb.append(indent(indent));
174: sb.append(DOMAIN_ELEMENT);
175: indent += 2;
176:
177: // name
178: if (name != null) {
179: sb.append(xmlElement(getName(), "name", indent));
180: }
181: // description
182: if (getDescription() != null) {
183: sb.append(xmlElement(getDescription(), "description",
184: indent));
185: }
186: // cluster daemons
187: sb.append(getClusterDaemonList().toXML(indent));
188:
189: // servers
190: sb.append(getServerList().toXML(indent));
191:
192: // clusters
193: sb.append(getClusterList().toXML(indent));
194:
195: indent -= 2;
196: sb.append(indent(indent));
197: sb.append("</domain>\n");
198:
199: return sb.toString();
200: }
201:
202: }
|