1 22 package fr.dyade.aaa.agent; 23 24 import java.util.Enumeration ; 25 26 import fr.dyade.aaa.util.*; 27 import fr.dyade.aaa.agent.conf.*; 28 29 public class SCServer implements SCServerMBean { 30 public SCServer() { 31 } 32 33 public short getServerId() { 34 return AgentServer.getServerId(); 35 } 36 37 public String getName() { 38 return AgentServer.getName(); 39 } 40 41 public void start() { 42 try { 43 AgentServer.start(); 44 } catch (Throwable exc) { 45 } 46 } 47 48 public void stop() { 49 AgentServer.stop(false); 50 } 51 52 public int getStatus() { 53 return AgentServer.getStatus(); 54 } 55 56 public String getStatusInfo() { 57 return AgentServer.getStatusInfo(); 58 } 59 60 public String [] getServers() { 61 Enumeration e = AgentServer.elementsServerDesc(); 62 String [] servers = new String [AgentServer.getServerNb()]; 63 StringBuffer strBuf = new StringBuffer (); 64 for (int i=0; e.hasMoreElements(); i++) { 65 ServerDesc server = (ServerDesc) e.nextElement(); 66 strBuf.append("sid=").append(server.sid); 67 strBuf.append(",name=").append(server.name); 68 if (server.gateway == -1) { 69 strBuf.append(",gateway=").append(server.gateway); 70 } else { 71 strBuf.append(",host=").append(server.getHostname()) 72 .append(':').append(server.getPort()); 73 strBuf.append(",active=").append(server.active); 74 strBuf.append(",last=").append(server.last); 75 } 76 servers[i] = strBuf.toString(); 77 strBuf.setLength(0); 78 } 79 return servers; 80 } 81 } 82 | Popular Tags |