KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > jmx > example > CentralController


1 package org.sapia.soto.jmx.example;
2
3 import org.sapia.soto.Service;
4
5 import java.util.HashSet JavaDoc;
6 import java.util.Set JavaDoc;
7
8
9 /**
10  * This class is meant to demonstrate the use of the JMX layer.
11  *
12  * @author Yanick Duchesne
13  *
14  * <dl>
15  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
16  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
17  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
18  * </dl>
19  */

20 public class CentralController implements Service {
21   private int _maxThreads = 50;
22   private String JavaDoc _jndiName;
23   private Set JavaDoc _users = new HashSet JavaDoc();
24
25   ///////////////// Management Methods //////////////////
26
public int getMaxThreads() {
27     return _maxThreads;
28   }
29
30   public void setMaxThreads(int max) {
31     _maxThreads = max;
32   }
33
34   public String JavaDoc getJndiName() {
35     return _jndiName;
36   }
37
38   public void setJndiName(String JavaDoc name) {
39     _jndiName = name;
40   }
41
42   public int getRequestsPerSecond() {
43     return 125;
44   }
45
46   public void addUser(String JavaDoc username, String JavaDoc password) {
47     String JavaDoc login = username + ":" + password;
48     _users.add(login);
49   }
50
51   public void removeUser(String JavaDoc username, String JavaDoc password) {
52     String JavaDoc login = username + ":" + password;
53     _users.remove(login);
54   }
55
56   public void login(String JavaDoc username, String JavaDoc password) throws Exception JavaDoc {
57     String JavaDoc login = username + ":" + password;
58
59     if (!_users.contains(login)) {
60       throw new Exception JavaDoc("Invalid username/password");
61     }
62   }
63
64   ///////////////// Service Methods //////////////////
65
public void dispose() {
66   }
67
68   public void init() throws Exception JavaDoc {
69   }
70
71   public void start() throws Exception JavaDoc {
72   }
73 }
74
Popular Tags