⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 a3cmlconfig.java

📁 一个类似于openJMS分布在ObjectWeb之下的JMS消息中间件。
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * Copyright (C) 2001 - 2004 ScalAgent Distributed Technologies  * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or any later version. *  * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. *  * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 * USA. */package fr.dyade.aaa.agent.conf;import java.io.*;import java.util.*;import org.objectweb.util.monolog.api.BasicLevel;import org.objectweb.util.monolog.api.Logger;import fr.dyade.aaa.util.Transaction;import fr.dyade.aaa.agent.Debug;import fr.dyade.aaa.agent.AgentServer;public class A3CMLConfig implements Serializable {  /** use serialVersionUID for interoperability */  private static final long serialVersionUID = -2497621374376654935L;  /** Hashtable of all domains */  public Hashtable domains = null;  /** Hashtable of all servers (persitent and transient) */  public Hashtable servers = null;  /** Hashtable of all global properties */  public Hashtable properties = null;  /** Hashtable of all clusters */  public Hashtable clusters = null;  public A3CMLConfig() {    domains = new Hashtable();    servers = new Hashtable();    properties = new Hashtable();    clusters = new Hashtable();  }  /**   * Adds a domain.   *   * @param domain 	The description of added domain.   * @exception DuplicateDomainException   *			If the domain already exist.   */  public final void addDomain(A3CMLDomain domain) throws DuplicateDomainException {    if (domains.containsKey(domain.name))      throw new DuplicateDomainException("Duplicate domain " + domain.name);    domains.put(domain.name, domain);  }  /**   * Removes a domain.   *   * @param name 	The domain name.   * @return		The domain description if exist.   * @exception UnknownDomainException   *			If the domain don't exist.   */  public final A3CMLDomain removeDomain(String name) throws UnknownDomainException {    A3CMLDomain domain = null;    if (domains.containsKey(name))      domain = (A3CMLDomain) domains.remove(name);    else      throw new UnknownDomainException("Unknown domain " + name);    return domain;  }  /**   * Returns true if it exists a domain with this name, false otherwise.   *   * @param name 	The domain name.   * @return	 	True if the domain is declared, false otherwise.   */  public final boolean containsDomain(String name) {    return domains.containsKey(name);  }  /**   * Returns the description of a domain.   *   * @param name 	The domain name.   * @return	 	The domain description if exist.   * @exception UnknownDomainException   *			If the domain don't exist.   */  public final A3CMLDomain getDomain(String name) throws UnknownDomainException {    A3CMLDomain domain = (A3CMLDomain) domains.get(name);    if (domain == null)      throw new UnknownDomainException("Unknown domain " + name);    return domain;  }  /**   * Adds a cluster.   *   * @param cluster 	The description of added cluster.   * @exception DuplicateClusterException   *			If the cluster already exist.   */  public final void addCluster(A3CMLCluster cluster) throws DuplicateClusterException {    Short id = new Short(cluster.sid);    if (clusters.containsKey(id))      throw new DuplicateClusterException("Duplicate cluster " + cluster.sid);    clusters.put(id, cluster);  }  /**   * Returns the description of a cluster.   *   * @param sid 	The cluster identifier.   * @return	 	The cluster description if exist.   * @exception UnknownClusterException   * 		 	If the cluster does not exist.   */  public final A3CMLCluster getCluster(short sid) throws UnknownClusterException {    A3CMLCluster cluster = (A3CMLCluster) clusters.get(new Short(sid));    if (cluster == null)      throw new UnknownClusterException("Unknown cluster id. #" + sid);    return cluster;  }    /**   * Returns the description of a cluster.   *   * @param name 	The cluster name.   * @return	 	The cluster description if exist.   * @exception UnknownClusterException   * 		 	If the cluster does not exist.   */  public final A3CMLCluster getCluster(String name) throws UnknownClusterException {    for (Enumeration c = clusters.elements(); c.hasMoreElements(); ) {      A3CMLCluster cluster = (A3CMLCluster) c.nextElement();      if (cluster.name.equals(name)) return cluster;    }    throw new UnknownClusterException("Unknown cluster id for cluster " + name);  }  /**   * Gets a cluster identifier from its name.   *   * @param name 	The cluster name.   * @return	 	The cluster identifier.   * @exception UnknownClusterException   * 		 	If the cluster does not exist.   */  public short getClusterIdByName(String name) throws UnknownClusterException {    for (Enumeration c = clusters.elements(); c.hasMoreElements(); ) {      A3CMLCluster cluster = (A3CMLCluster) c.nextElement();      if (cluster.name.equals(name)) return cluster.sid;    }    throw new UnknownClusterException("Unknown cluster " + name);  }  /**   * Returns true if the configuration contains a cluster with specified name.   *   * @param name cluster name   * @return	 true if contain name; false otherwise.   */  public final boolean containsCluster(String name) {    try {      getClusterIdByName(name);    } catch (UnknownClusterException exc) {      return false;    }    return true;  }  /**   * Returns true if the configuration contains a cluster with specified id.   *   * @param sid  cluster id   * @return	 true if contain sid; false otherwise.   */  public final boolean containsCluster(short sid) {    return clusters.containsKey(new Short(sid));  }  /**   * Removes a cluster.   *   * @param sid  	The unique cluster identifier.   * @return	 	The cluster description if exists.   * @exception UnknownClusterException   * 		 	If the server does not exist.   */  public final A3CMLCluster removeCluster(short sid) throws UnknownClusterException {    A3CMLCluster cluster = null;    Short id = new Short(sid);    if (clusters.containsKey(id))      cluster = (A3CMLCluster) clusters.remove(id);    else      throw new UnknownClusterException("Unknown cluster id. #" + sid);    return cluster;  }    /**   * Remove a cluster.   *   * @param name 	The cluster name.   * @return	 	The cluster description if exists.   * @exception UnknownClusterException   *			If the server does not exist.   */  public final A3CMLCluster removeCluster(String name) throws UnknownClusterException {    return removeCluster(getClusterIdByName(name));  }  /**   * Adds a server.   *   * @param server	The description of added server.   * @exception DuplicateServerException   *			If the server already exist.   */  public final void addServer(A3CMLServer server) throws DuplicateServerException {    Short id = new Short(server.sid);    if (servers.containsKey(id))      throw new DuplicateServerException("Duplicate server id. #" + server.sid);    servers.put(id, server);  }    /**   * Removes a server.   *   * @param sid  	The unique server identifier.   * @return	 	The server description if exists.   * @exception UnknownServerException   * 		 	If the server does not exist.   */  public final A3CMLServer removeServer(short sid) throws UnknownServerException {    A3CMLServer server = null;    Short id = new Short(sid);    if (servers.containsKey(id)) {      server = (A3CMLServer) servers.remove(id);    } else {      throw new UnknownServerException("Unknown server id. #" + sid);    }    for (int i = 0; i < server.networks.size(); i++) {      A3CMLNetwork network = (A3CMLNetwork)server.networks.elementAt(i);      A3CMLDomain domain = (A3CMLDomain)domains.get(network.domain);      domain.removeServer(sid);    }    return server;  }    /**   * Remove a server.   *   * @param name 	The server name.   * @return	 	The server description if exists.   * @exception UnknownServerException   *			If the server does not exist.   */  public final A3CMLServer removeServer(String name) throws UnknownServerException {    return removeServer(getServerIdByName(name));  }    /**   * Returns true if the configuration contains a server with specified id.   *   * @param sid  server id   * @return	 true if contain sid; false otherwise.   */  public final boolean containsServer(short sid) {    return servers.containsKey(new Short(sid));  }    /**   * Gets a server identifier from its name.   *   * @param name 	The server name.   * @return	 	The server identifier.   * @exception UnknownServerException   * 		 	If the server does not exist.   */  public short getServerIdByName(String name) throws UnknownServerException {    for (Enumeration s = servers.elements(); s.hasMoreElements(); ) {      A3CMLServer server = (A3CMLServer) s.nextElement();      if (server.name.equals(name)) return server.sid;    }    throw new UnknownServerException("Unknown server " + name);  }  /**   * Returns true if the configuration contains a server with specified name.   *   * @param name server name   * @return	 true if contain name; false otherwise.   */  public final boolean containsServer(String name) {    try {      getServerIdByName(name);    } catch (UnknownServerException exc) {      return false;    }    return true;  }  /**   * Returns the description of a server.   *   * @param sid 	The server identifier.   * @return	 	The server description if exist.   * @exception UnknownServerException   * 		 	If the server does not exist.   */  public final A3CMLServer getServer(short sid) throws UnknownServerException {    return getServer(sid, AgentServer.NULL_ID);  }  /**   * Returns the description of a server.   *   * @param sid 	The server identifier.   * @param cid 	The cluster identifier.   * @return	 	The server description if exist.   * @exception UnknownServerException   * 		 	If the server does not exist.   */  public final A3CMLServer getServer(short sid, short cid) throws UnknownServerException {    A3CMLServer server = null;    if (cid == AgentServer.NULL_ID)      server = (A3CMLServer) servers.get(new Short(sid));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -