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: * 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: * --------------------------------------------------------------------------
022: * $Id: DomainMap.java 9256 2006-07-28 06:35:47Z durieuxp $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas_domain.api;
025:
026: import java.util.Enumeration;
027: import java.util.Iterator;
028: import java.util.Vector;
029:
030: import org.objectweb.jonas_domain.xml.Cluster;
031: import org.objectweb.jonas_domain.xml.ClusterDaemon;
032: import org.objectweb.jonas_domain.xml.Domain;
033: import org.objectweb.jonas_domain.xml.Server;
034:
035: import org.objectweb.jonas_lib.deployment.api.AbsDeploymentDesc;
036:
037: /**
038: * This class provides the map of the domain as described by the
039: * domain description file.
040: * It extends the AbsDeploymentDesc which requires to implement toString()
041: * and provides getSAXMsg() method (displayName is not used by DomainMap).
042: * @author Adriana Danes
043: */
044: public class DomainMap extends AbsDeploymentDesc {
045:
046: /**
047: * the domain name
048: */
049: private String name = null;
050:
051: /**
052: * the domain description
053: */
054: private String description = null;
055:
056: /**
057: * the clusterDaemons in the domain
058: */
059: private Vector clusterDaemons = null;
060:
061: /**
062: * the clusters in the domain
063: */
064: private Vector clusters = null;
065:
066: /**
067: * the servers in the domain
068: */
069: private Vector servers = null;
070:
071: /**
072: * @return Returns the clusterDaemons.
073: */
074: public Vector getClusterDaemons() {
075: return clusterDaemons;
076: }
077:
078: /**
079: * @param clusters The clusterDaemons to set.
080: */
081: public void setClusterDaemons(Vector clusterDaemons) {
082: this .clusterDaemons = clusterDaemons;
083: }
084:
085: /**
086: * @return Returns the clusters.
087: */
088: public Vector getClusters() {
089: return clusters;
090: }
091:
092: /**
093: * @param clusters The clusters to set.
094: */
095: public void setClusters(Vector clusters) {
096: this .clusters = clusters;
097: }
098:
099: /**
100: * @return Returns the description.
101: */
102: public String getDescription() {
103: return description;
104: }
105:
106: /**
107: * @param description The description to set.
108: */
109: public void setDescription(String description) {
110: this .description = description;
111: }
112:
113: /**
114: * @return Returns the name.
115: */
116: public String getName() {
117: return name;
118: }
119:
120: /**
121: * @param name The name to set.
122: */
123: public void setName(String name) {
124: this .name = name;
125: }
126:
127: /**
128: * @return Returns the servers.
129: */
130: public Vector getServers() {
131: return servers;
132: }
133:
134: /**
135: * @param servers The servers to set.
136: */
137: public void setServers(Vector servers) {
138: this .servers = servers;
139: }
140:
141: /**
142: * Constructor
143: * @param domain domain
144: */
145: public DomainMap(Domain domain) {
146: name = domain.getName();
147: description = domain.getDescription();
148: clusterDaemons = new Vector();
149: clusters = new Vector();
150: servers = new Vector();
151:
152: for (Iterator i = domain.getClusterDaemonList().iterator(); i
153: .hasNext();) {
154: ClusterDaemon clusterDaemon = (ClusterDaemon) i.next();
155: clusterDaemons.add(clusterDaemon);
156: }
157:
158: for (Iterator i = domain.getClusterList().iterator(); i
159: .hasNext();) {
160: Cluster cluster = (Cluster) i.next();
161: clusters.add(cluster);
162: }
163:
164: for (Iterator i = domain.getServerList().iterator(); i
165: .hasNext();) {
166: Server server = (Server) i.next();
167: servers.add(server);
168: }
169:
170: }
171:
172: /**
173: * Return a String representation of the DomainMap
174: * @return a String representation of the DomainMap
175: */
176: public String toString() {
177:
178: StringBuffer ret = new StringBuffer();
179: ret.append("\nname=" + name);
180: ret.append("\ndescription=" + description);
181:
182: ret.append("\nclusterDaemons=");
183: for (Enumeration e = clusterDaemons.elements(); e
184: .hasMoreElements();) {
185: ret.append(e.nextElement() + ",");
186: }
187:
188: ret.append("\nservers=");
189: for (Enumeration e = servers.elements(); e.hasMoreElements();) {
190: ret.append(e.nextElement() + ",");
191: }
192: ret.append("\nclusters=");
193: for (Enumeration e = clusters.elements(); e.hasMoreElements();) {
194: ret.append(e.nextElement() + ",");
195: }
196:
197: return ret.toString();
198: }
199: }
|