001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2005 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: * --------------------------------------------------------------------------
023: * $Id: Cluster.java 7757 2005-12-08 15:24:55Z danesa $
024: * --------------------------------------------------------------------------
025: */package org.objectweb.jonas_domain.xml;
026:
027: import org.objectweb.jonas_lib.deployment.xml.AbsElement;
028: import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
029:
030: public class Cluster extends AbsElement {
031:
032: private String name = null;
033:
034: /**
035: * description
036: */
037: private String description = null;
038: /**
039: * servers in the cluster
040: */
041: private JLinkedList serverList = null;
042:
043: /**
044: * sub-clusters
045: */
046: private JLinkedList clusterList = null;
047:
048: /**
049: * Constructor
050: */
051: public Cluster() {
052: super ();
053: serverList = new JLinkedList("server");
054: clusterList = new JLinkedList("cluster");
055: }
056:
057: /**
058: * @return Returns the name.
059: */
060: public String getName() {
061: return name;
062: }
063:
064: /**
065: * @param name The name to set.
066: */
067: public void setName(String name) {
068: this .name = name;
069: }
070:
071: /**
072: * @return Returns the description.
073: */
074: public String getDescription() {
075: return description;
076: }
077:
078: /**
079: * @param description The description to set.
080: */
081: public void setDescription(String description) {
082: this .description = description;
083: }
084:
085: /**
086: * Add a new sub-cluster (cluster element) to this object
087: * @param cluster the Cluster object representing a sub-cluster
088: */
089: public void addCluster(Cluster cluster) {
090: clusterList.add(cluster);
091: }
092:
093: /**
094: * Add a new server element to this object
095: * @param server the Server object
096: */
097: public void addServer(Server server) {
098: serverList.add(server);
099: }
100:
101: /**
102: * @return Returns the clusterList.
103: */
104: public JLinkedList getClusterList() {
105: return clusterList;
106: }
107:
108: /**
109: * @param clusterList The clusterList to set.
110: */
111: public void setClusterList(JLinkedList clusterList) {
112: this .clusterList = clusterList;
113: }
114:
115: /**
116: * @return Returns the serverList.
117: */
118: public JLinkedList getServerList() {
119: return serverList;
120: }
121:
122: /**
123: * @param serverList The serverList to set.
124: */
125: public void setServerList(JLinkedList serverList) {
126: this .serverList = serverList;
127: }
128:
129: /**
130: * Represents this element by it's XML description.
131: * @param indent use this indent for prexifing XML representation.
132: * @return the XML description of this object.
133: */
134: public String toXML(int indent) {
135: StringBuffer sb = new StringBuffer();
136: sb.append(indent(indent));
137: sb.append("<cluster>\n");
138:
139: indent += 2;
140:
141: // cluster name
142: if (name != null) {
143: sb.append(xmlElement(name, "name", indent));
144: }
145: // description
146: if (getDescription() != null) {
147: sb.append(xmlElement(getDescription(), "description",
148: indent));
149: }
150: // servers
151: sb.append(getServerList().toXML(indent));
152: // clusters
153: sb.append(getClusterList().toXML(indent));
154: indent -= 2;
155: sb.append(indent(indent));
156: sb.append("</cluster>\n");
157:
158: return sb.toString();
159: }
160: }
|