1 23 package org.objectweb.joram.client.jms.admin; 24 25 import java.net.ConnectException ; 26 import java.net.UnknownHostException ; 27 import java.util.List ; 28 29 import fr.dyade.aaa.util.management.MXWrapper; 30 import org.objectweb.joram.shared.JoramTracing; 31 import org.objectweb.util.monolog.api.BasicLevel; 32 33 36 public class PlatformAdmin 37 implements PlatformAdminMBean { 38 39 public PlatformAdmin() 40 throws ConnectException , AdminException { 41 connect("root", "root", 60); 42 registerMBean(); 43 } 44 45 public PlatformAdmin(String hostName, 46 int port, 47 String name, 48 String password, 49 int cnxTimer, 50 String reliableClass) 51 throws UnknownHostException , ConnectException , AdminException { 52 connect(hostName,port,name,password,cnxTimer,reliableClass); 53 registerMBean(); 54 } 55 56 public PlatformAdmin(String hostName, 57 int port, 58 String name, 59 String password, 60 int cnxTimer) 61 throws UnknownHostException , ConnectException , AdminException { 62 connect(hostName,port,name,password,cnxTimer, 63 "org.objectweb.joram.client.jms.tcp.ReliableTcpClient"); 64 registerMBean(); 65 } 66 67 public PlatformAdmin(String name, 68 String password) 69 throws ConnectException , AdminException { 70 collocatedConnect(name,password); 71 registerMBean(); 72 } 73 74 public PlatformAdmin(javax.jms.TopicConnectionFactory cnxFact, 75 String name, 76 String password) 77 throws ConnectException , AdminException { 78 connect(cnxFact,name,password); 79 registerMBean(); 80 } 81 82 private void registerMBean() { 83 try { 84 MXWrapper.registerMBean(this, 85 "joramClient", 86 "type=PlatformAdmin"); 87 } catch (Exception e) { 88 if (JoramTracing.dbgClient.isLoggable(BasicLevel.DEBUG)) 89 JoramTracing.dbgClient.log(BasicLevel.DEBUG, 90 "registerMBean",e); 91 } 92 } 93 94 private void unregisterMBean() { 95 try { 96 MXWrapper.unregisterMBean("joramClient", 97 "type=PlatformAdmin"); 98 } catch (Exception e) { 99 if (JoramTracing.dbgClient.isLoggable(BasicLevel.DEBUG)) 100 JoramTracing.dbgClient.log(BasicLevel.DEBUG, 101 "unregisterMBean",e); 102 } 103 } 104 105 106 119 public void connect(javax.jms.TopicConnectionFactory cnxFact, 120 String name, 121 String password) 122 throws ConnectException , AdminException { 123 AdminModule.connect(cnxFact,name,password); 124 } 125 126 143 public void connect(String hostName, 144 int port, 145 String name, 146 String password, 147 int cnxTimer, 148 String reliableClass) 149 throws UnknownHostException , ConnectException , AdminException { 150 AdminModule.connect(hostName,port,name,password,cnxTimer,reliableClass); 151 } 152 153 167 public void connect(String name, String password, int cnxTimer) 168 throws ConnectException , AdminException { 169 try { 170 connect("localhost", 171 16010, 172 name, 173 password, 174 cnxTimer, 175 "org.objectweb.joram.client.jms.tcp.ReliableTcpClient"); 176 } catch (UnknownHostException exc) { 177 throw new AdminException(exc.getMessage()); 178 } 179 } 180 181 191 public void collocatedConnect(String name, String password) 192 throws ConnectException , AdminException { 193 AdminModule.collocatedConnect(name,password); 194 } 195 196 197 public void disconnect() { 198 AdminModule.disconnect(); 199 } 200 201 204 public void exit() { 205 disconnect(); 206 unregisterMBean(); 207 } 208 209 219 public void stopServer(int serverId) 220 throws ConnectException , AdminException { 221 AdminModule.stopServer(serverId); 222 } 223 224 230 public void stopServer() 231 throws ConnectException , AdminException { 232 AdminModule.stopServer(); 233 } 234 235 247 public void addServer(int sid, 248 String hostName, 249 String domainName, 250 int port, 251 String serverName) 252 throws ConnectException , AdminException { 253 AdminModule.addServer(sid,hostName,domainName,port,serverName); 254 } 255 256 264 public void removeServer(int sid) 265 throws ConnectException , AdminException { 266 AdminModule.removeServer(sid); 267 } 268 269 281 public void addDomain(String domainName, 282 int sid, 283 int port) 284 throws ConnectException , AdminException { 285 AdminModule.addDomain(domainName,sid,port); 286 } 287 288 296 public void removeDomain(String domainName) 297 throws ConnectException , AdminException { 298 AdminModule.removeDomain(domainName); 299 } 300 301 307 public String getConfiguration() 308 throws ConnectException , AdminException { 309 return AdminModule.getConfiguration(); 310 } 311 312 315 public List getServersIds() { 316 try { 317 return AdminModule.getServersIds(); 318 } catch (Exception exc) { 319 return null; 320 } 321 } 322 323 330 public List getServersIds(String domainName) 331 throws ConnectException , AdminException { 332 return AdminModule.getServersIds(domainName); 333 } 334 335 342 public String [] getDomainNames(int serverId) 343 throws ConnectException , AdminException { 344 return AdminModule.getDomainNames(serverId); 345 } 346 347 359 public void setDefaultThreshold(int serverId, int threshold) 360 throws ConnectException , AdminException { 361 AdminModule.setDefaultThreshold(serverId,threshold); 362 } 363 364 373 public void setDefaultThreshold(int threshold) 374 throws ConnectException , AdminException { 375 AdminModule.setDefaultThreshold(threshold); 376 } 377 378 386 public int getDefaultThreshold(int serverId) 387 throws ConnectException , AdminException { 388 return AdminModule.getDefaultThreshold(serverId); 389 } 390 391 397 public int getDefaultThreshold() 398 throws ConnectException , AdminException { 399 return AdminModule.getDefaultThreshold(); 400 } 401 402 407 public int getLocalServerId() 408 throws ConnectException { 409 return AdminModule.getLocalServerId(); 410 } 411 412 417 public String getLocalHost() 418 throws ConnectException { 419 return AdminModule.getLocalHost(); 420 } 421 422 427 public int getLocalPort() 428 throws ConnectException { 429 return AdminModule.getLocalPort(); 430 } 431 } 432 | Popular Tags |