1 19 package fr.dyade.aaa.agent.conf; 20 21 import java.io.*; 22 import java.util.*; 23 24 27 public class A3CMLPServer extends A3CMLServer implements Serializable { 28 29 public String domain = null; 30 34 public int port = -1; 35 36 public A3CMLPServer(short sid, 37 String name, 38 String hostname) throws Exception { 39 super(sid, name, hostname); 40 } 41 42 public void addNetwork(A3CMLNetwork newNetwork) throws Exception { 43 for (int i = 0; i < networks.size(); i++) { 44 A3CMLNetwork network = (A3CMLNetwork)networks.elementAt(i); 45 if (network.domain.equals(newNetwork.domain)) { 46 throw new Exception("Network " + newNetwork.domain + "already added"); 47 } 48 } 49 networks.addElement(newNetwork); 50 } 51 52 public void removeNetwork(String domainName) { 53 for (int i = 0; i < networks.size(); i++) { 54 A3CMLNetwork network = (A3CMLNetwork)networks.elementAt(i); 55 if (network.domain.equals(domainName)) { 56 networks.removeElementAt(i); 57 } 58 } 59 } 60 61 public A3CMLPServer duplicate(Hashtable context) throws Exception { 62 A3CMLPServer clone = null; 63 Short serverSid = new Short(sid); 64 if (!context.containsKey(serverSid)) { 65 clone = duplicate(); 66 context.put(serverSid,clone); 67 } else 68 clone = (A3CMLPServer) context.get(serverSid); 69 return clone; 70 } 71 72 public A3CMLPServer duplicate() throws Exception { 73 A3CMLPServer clone = new A3CMLPServer(sid, 74 name, 75 hostname); 76 if (networks != null) { 77 for (Enumeration n = networks.elements(); n.hasMoreElements(); ) 78 clone.networks.addElement( 79 ((A3CMLNetwork) n.nextElement()).duplicate()); 80 } 81 clone.gateway = gateway; 82 clone.domain = domain; 83 clone.port = port; 84 85 clone.visited = visited; 87 if (services != null) { 88 for (Enumeration e = services.elements(); e.hasMoreElements(); ) 89 clone.services.addElement( 90 ((A3CMLService) e.nextElement()).duplicate()); 91 } 92 if (properties != null) { 93 for (Enumeration e = properties.keys(); e.hasMoreElements(); ) { 94 Short sid = (Short) e.nextElement(); 95 clone.properties.put(sid, 96 ((A3CMLProperty) properties.get(sid)).duplicate()); 97 } 98 } 99 if (nat != null) { 100 for (Enumeration e = nat.elements(); e.hasMoreElements(); ) 101 clone.addNat( 102 ((A3CMLNat) e.nextElement()).duplicate()); 103 } 104 clone.jvmArgs = jvmArgs; 105 106 return clone; 107 } 108 109 public String toString() { 110 StringBuffer strBuf = new StringBuffer(); 111 strBuf.append("("); 112 strBuf.append(super.toString()); 113 strBuf.append(",port=").append(port); 114 strBuf.append(",domain=").append(domain); 115 strBuf.append(")"); 116 return strBuf.toString(); 117 } 118 119 public boolean equals(Object obj) { 120 if (obj == null) return false; 121 122 if (obj instanceof A3CMLPServer) { 123 A3CMLPServer server = (A3CMLPServer) obj; 124 if (super.equals(server) && 125 ((domain == server.domain) || 126 ((domain != null) && domain.equals(server.domain))) && 127 (port == server.port)) 128 return true; 129 } 130 return false; 131 } 132 133 139 } 147 | Popular Tags |