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