KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > dyade > aaa > agent > SCServer


1 /*
2  * Copyright (C) 2001 - 2004 ScalAgent Distributed Technologies
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA.
18  *
19  * Initial developer(s): ScalAgent Distributed Technologies
20  * Contributor(s):
21  */

22 package fr.dyade.aaa.agent;
23
24 import java.util.Enumeration JavaDoc;
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 JavaDoc getName() {
38     return AgentServer.getName();
39   }
40
41   public void start() {
42     try {
43       AgentServer.start();
44     } catch (Throwable JavaDoc 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 JavaDoc getStatusInfo() {
57     return AgentServer.getStatusInfo();
58   }
59
60   public String JavaDoc[] getServers() {
61     Enumeration JavaDoc e = AgentServer.elementsServerDesc();
62     String JavaDoc[] servers = new String JavaDoc[AgentServer.getServerNb()];
63     StringBuffer JavaDoc strBuf = new StringBuffer JavaDoc();
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