1 14 15 package org.quickserver.net.qsadmin; 16 17 import java.net.*; 18 import java.io.*; 19 import java.util.StringTokenizer ; 20 21 import org.quickserver.net.server.ClientCommandHandler; 22 import org.quickserver.net.server.ClientEventHandler; 23 import org.quickserver.net.server.ClientHandler; 24 import org.quickserver.net.server.QuickServer; 25 import org.quickserver.net.AppException; 26 27 import java.util.logging.*; 28 29 import org.quickserver.util.*; 30 import org.quickserver.util.pool.thread.*; 31 import java.util.*; 32 import org.quickserver.util.pool.*; 33 import org.apache.commons.pool.ObjectPool; 34 import org.quickserver.net.server.ClientIdentifier; 35 36 151 public class CommandHandler implements ClientCommandHandler, ClientEventHandler { 152 private static Logger logger = Logger.getLogger(CommandHandler.class.getName()); 153 154 private CommandPlugin plugin; 155 private Runtime runtime; 156 StringBuffer temp = new StringBuffer (); 157 158 public void gotConnected(ClientHandler handler) 160 throws SocketTimeoutException, IOException { 161 logger.fine("Connection opened : " + handler.getHostAddress()); 162 163 handler.sendClientMsg("+OK +++++++++++++++++++++++++++++++++"); 164 handler.sendClientMsg("+OK Welcome to QsAdminServer v 1.0 "); 165 handler.sendClientMsg("+OK +++++++++++++++++++++++++++++++++"); 166 167 if(plugin==null || runtime==null) { 169 plugin = (CommandPlugin) 170 handler.getServer().getStoreObjects()[1]; 171 runtime = Runtime.getRuntime(); 173 } 174 } 175 176 public void lostConnection(ClientHandler handler) 177 throws IOException { 178 logger.fine("Connection lost : " + handler.getHostAddress()); 179 } 180 public void closingConnection(ClientHandler handler) 181 throws IOException { 182 logger.fine("Connection closing : " + handler.getHostAddress()); 183 } 184 186 public void handleCommand(ClientHandler handler, String command) 187 throws SocketTimeoutException, IOException { 188 if(command==null || command.trim().equals("")) { 189 handler.sendClientMsg("-ERR No command"); 190 return; 191 } 192 193 if( plugin != null && plugin.handleCommand(handler,command) ) { 195 logger.fine("Handled by plugin."); 196 return; 197 } 198 QSAdminServer adminServer = (QSAdminServer) 199 handler.getServer().getStoreObjects()[2]; 200 201 StringTokenizer st = new StringTokenizer (command," "); 202 String cmd = null; 203 cmd = st.nextToken().toLowerCase(); 204 String param[] = new String [st.countTokens()]; 205 206 QuickServer target = null; 207 for (int i=0;st.hasMoreTokens();i++) 208 param[i] = st.nextToken(); 209 210 if(command.equals("start console")) { 211 QSAdminShell.getInstance( 212 (QuickServer) handler.getServer().getStoreObjects()[0], null); 213 handler.sendClientMsg("+OK QSAdminShell is started."); 214 return; 215 } else if(command.equals("stop console")) { 216 QSAdminShell shell = QSAdminShell.getInstance(null, null); 217 if(shell!=null) { 218 try { 219 shell.stopShell(); 220 } catch(Exception err) { 221 handler.sendClientMsg("-ERR Error stopping QSAdminShell: "+err); 222 } 223 handler.sendClientMsg("+OK QSAdminShell is stopped."); 224 } else { 225 handler.sendClientMsg("-ERR QSAdminShell is not running."); 226 } 227 return; 228 } 229 230 if(param.length > 0) { 231 if( param[0].equals("server") ) 232 target = (QuickServer) handler.getServer().getStoreObjects()[0]; 233 else if( param[0].equals("self") ) 234 target = handler.getServer(); 235 else { 236 handler.sendClientMsg("-ERR Bad <<target>> : "+param[0]); 237 return; 238 } 239 } 240 241 if(cmd.equals("help")) { 242 handler.sendClientMsg("+OK info follows"+"\r\n"+ 243 "Refer Api Docs for org.quickserver.net.qsadmin.CommandHandler"); 244 handler.sendClientMsg("."); 245 return; 246 } else if(cmd.equals("quit")) { 247 handler.sendClientMsg("+OK Bye ;-)"); 248 handler.closeConnection(); 249 return; 250 } else if(cmd.equals("shutdown")) { 251 try { 252 QuickServer controlServer = 253 (QuickServer) handler.getServer().getStoreObjects()[0]; 254 if(controlServer!=null && controlServer.isClosed()==false) { 255 controlServer.stopServer(); 256 } 257 if(handler.getServer()!=null && handler.getServer().isClosed()==false) { 258 handler.getServer().stopServer(); 259 } 260 261 QSAdminShell shell = QSAdminShell.getInstance(null, null); 262 if(shell!=null) { 263 try { 264 shell.stopShell(); 265 } catch(Exception err) { 266 logger.warning("Error stoping shell: "+err); 267 } 268 } 269 270 handler.sendClientMsg("+OK Done"); 271 } catch (AppException e) { 272 handler.sendClientMsg("-ERR "+e); 273 } 274 return; 275 } else if(cmd.equals("version")) { 276 handler.sendClientMsg("+OK "+QuickServer.getVersion()); 277 return; 278 } else if(cmd.equals("kill") || cmd.equals("exit")) { 279 StringBuffer errBuf = new StringBuffer (); 280 QuickServer controlServer = 281 (QuickServer) handler.getServer().getStoreObjects()[0]; 282 int exitCode = 0; 283 284 if(param.length!=0) { 285 try { 286 exitCode = Integer.parseInt(param[0]); 287 } catch(Exception nfe) {} 288 } 289 290 try { 291 if(controlServer!=null && controlServer.isClosed()==false) { 292 try { 293 controlServer.stopServer(); 294 } catch(AppException ae) { 295 errBuf.append(ae.toString()); 296 } 297 } 298 if(handler.getServer()!=null && handler.getServer().isClosed()==false) { 299 try { 300 handler.getServer().stopServer(); 301 } catch(AppException ae) { 302 errBuf.append(ae.toString()); 303 } 304 } 305 306 QSAdminShell shell = QSAdminShell.getInstance(null, null); 307 if(shell!=null) { 308 try { 309 shell.stopShell(); 310 } catch(Exception err) { 311 errBuf.append(err.toString()); 312 } 313 } 314 315 if(errBuf.length()==0) 316 handler.sendClientMsg("+OK Done"); 317 else 318 handler.sendClientMsg("+OK Done, Errors: "+errBuf.toString()); 319 } catch (Exception e) { 320 handler.sendClientMsg("-ERR Exception : "+e+"\r\n"+errBuf.toString()); 321 if(exitCode==0) exitCode = 1; 322 } finally { 323 try { 324 if(controlServer!=null) 325 controlServer.closeAllPools(); 326 if(handler.getServer()!=null) 327 handler.getServer().closeAllPools(); 328 } catch(Exception er) { 329 logger.warning("Error closing pools: "+er); 330 } 331 System.exit(exitCode); 332 } 333 return; 334 } else if(cmd.equals("memoryinfo")) { 335 float totalMemory = (float) runtime.totalMemory(); 337 float usedMemory = totalMemory - (float) runtime.freeMemory(); 338 float maxMemory = (float) runtime.maxMemory(); 339 handler.sendClientMsg("+OK "+totalMemory+":"+usedMemory+":"+maxMemory); 340 return; 341 } else if(cmd.equals("systeminfo")) { 342 handler.sendClientMsg("+OK info follows"); 343 handler.sendClientMsg(MyString.getSystemInfo(target.getVersion())); 344 handler.sendClientMsg("."); 345 return; 346 } else if(param.length==0) { 347 handler.sendClientMsg("-ERR Bad Command or No Param : ->"+cmd+"<-"); 348 return; 349 } 350 351 if(cmd.equals("start")) { 352 try { 353 target.startServer(); 354 handler.sendClientMsg("+OK Server Started"); 355 } catch (AppException e) { 356 handler.sendClientMsg("-ERR "+e); 357 } 358 return; 359 } else if(cmd.equals("stop")) { 360 try { 361 target.stopServer(); 362 handler.sendClientMsg("+OK Server Stopped"); 363 } catch (AppException e) { 364 handler.sendClientMsg("-ERR "+e); 365 } 366 return; 367 } else if(cmd.equals("restart")) { 368 try { 369 target.stopServer(); 370 target.startServer(); 371 handler.sendClientMsg("+OK Server Restarted"); 372 } catch (AppException e) { 373 handler.sendClientMsg("-ERR "+e); 374 } 375 return; 376 } else if(cmd.equals("info")) { 377 handler.sendClientMsg("+OK info follows"); 378 handler.sendClientMsg(""+target); 379 handler.sendClientMsg("Running : "+!target.isClosed()); 380 handler.sendClientMsg("Max Client Allowed : "+target.getMaxConnection() ); 381 handler.sendClientMsg("No Client Connected : "+target.getClientCount() ); 382 if(target.isRunningSecure()==true) { 383 handler.sendClientMsg("Running in secure mode : "+ 384 target.getSecure().getProtocol() ); 385 } else { 386 handler.sendClientMsg("Running in non-secure mode"); 387 } 388 handler.sendClientMsg("Server Mode : "+target.getBasicConfig().getServerMode()); 389 handler.sendClientMsg("."); 390 return; 391 } else if(cmd.equals("noclient")) { 392 handler.sendClientMsg("+OK "+target.getClientCount() ); 393 return; 394 } else if(cmd.equals("running")) { 395 handler.sendClientMsg("+OK "+!target.isClosed() ); 396 return; 397 } else if(cmd.equals("suspendservice")) { 398 handler.sendClientMsg("+OK "+target.suspendService() ); 399 return; 400 } else if(cmd.equals("resumeservice")) { 401 handler.sendClientMsg("+OK "+target.resumeService() ); 402 return; 403 } else if(cmd.equals("client-thread-pool-info")) { 404 temp.setLength(0); if(PoolHelper.isPoolOpen(target.getClientPool().getObjectPool())==true) { 406 temp.append(target.getClientPool().getNumActive()); 407 temp.append(':'); 408 temp.append(target.getClientPool().getNumIdle()); 409 } else { 410 temp.append("0:0"); 411 } 412 handler.sendClientMsg("+OK "+temp.toString() ); 413 return; 414 } else if(cmd.equals("client-thread-pool-dump")) { 415 if(PoolHelper.isPoolOpen(target.getClientPool().getObjectPool())==true) { 416 handler.sendClientMsg("+OK info follows"); 417 ClientThread ct = null; 418 synchronized(target.getClientPool().getObjectToSynchronize()) { 419 Iterator iterator = target.getClientPool().getAllClientThread(); 420 while(iterator.hasNext()) { 421 ct = (ClientThread)iterator.next(); 422 handler.sendClientMsg(ct.toString()); 423 } 424 } 425 handler.sendClientMsg("."); 426 } else { 427 handler.sendClientMsg("-ERR Pool Closed"); 428 } 429 return; 430 } else if(cmd.equals("client-handler-pool-dump")) { 431 432 ObjectPool objectPool = target.getClientHandlerPool(); 433 434 if(PoolHelper.isPoolOpen(objectPool)==true) { 435 if(QSObjectPool.class.isInstance(objectPool)==false) { 436 handler.sendClientMsg("-ERR System Error!"); 437 } 438 439 ClientIdentifier clientIdentifier = target.getClientIdentifier(); 440 ClientHandler foundClientHandler = null; 441 synchronized(clientIdentifier.getObjectToSynchronize()) { 442 Iterator iterator = clientIdentifier.findAllClient(); 443 handler.sendClientMsg("+OK info follows"); 444 while(iterator.hasNext()) { 445 foundClientHandler = (ClientHandler) iterator.next(); 446 handler.sendClientMsg(foundClientHandler.info()); 447 } 448 } 449 handler.sendClientMsg("."); 450 } else { 451 handler.sendClientMsg("-ERR Pool Closed"); 452 } 453 return; 454 } else if(cmd.equals("client-data-pool-info")) { 455 temp.setLength(0); if(target.getClientDataPool()!=null) { 457 if(PoolHelper.isPoolOpen(target.getClientDataPool())==true) { 458 temp.append(target.getClientDataPool().getNumActive()); 459 temp.append(':'); 460 temp.append(target.getClientDataPool().getNumIdle()); 461 handler.sendClientMsg("+OK "+temp.toString() ); 462 } else { 463 handler.sendClientMsg("-ERR Client Data Pool Closed"); 464 } 465 } else { 466 handler.sendClientMsg("-ERR No Client Data Pool"); 467 } 468 return; 469 } if(cmd.equals("byte-buffer-pool-info")) { 470 temp.setLength(0); if(target.getByteBufferPool()!=null) { 472 if(PoolHelper.isPoolOpen(target.getByteBufferPool())==true) { 473 temp.append(target.getByteBufferPool().getNumActive()); 474 temp.append(':'); 475 temp.append(target.getByteBufferPool().getNumIdle()); 476 handler.sendClientMsg("+OK "+temp.toString() ); 477 } else { 478 handler.sendClientMsg("-ERR ByteBuffer Pool Closed"); 479 } 480 } else { 481 handler.sendClientMsg("-ERR No ByteBuffer Pool"); 482 } 483 return; 484 } else if(cmd.equals("all-pool-info")) { 485 handler.sendClientMsg("+OK info follows"); 486 temp.setLength(0); 488 if(PoolHelper.isPoolOpen(target.getClientPool().getObjectPool())==true) { 489 temp.append("Client Thread Pool - "); 490 temp.append("Num Active: "); 491 temp.append(target.getClientPool().getNumActive()); 492 temp.append(", Num Idle: "); 493 temp.append(target.getClientPool().getNumIdle()); 494 temp.append(", Max Idle: "); 495 temp.append(target.getClientPool().getPoolConfig().getMaxIdle()); 496 temp.append(", Max Active: "); 497 temp.append(target.getClientPool().getPoolConfig().getMaxActive()); 498 } else { 499 temp.append("Byte Buffer Pool - Closed"); 500 } 501 handler.sendClientMsg(temp.toString()); 502 temp.setLength(0); 503 504 if(PoolHelper.isPoolOpen(target.getClientHandlerPool())==true) { 505 temp.append("Client Handler Pool - "); 506 temp.append("Num Active: "); 507 temp.append(target.getClientHandlerPool().getNumActive()); 508 temp.append(", Num Idle: "); 509 temp.append(target.getClientHandlerPool().getNumIdle()); 510 temp.append(", Max Idle: "); 511 temp.append(target.getBasicConfig().getObjectPoolConfig().getClientHandlerObjectPoolConfig().getMaxIdle()); 512 temp.append(", Max Active: "); 513 temp.append(target.getBasicConfig().getObjectPoolConfig().getClientHandlerObjectPoolConfig().getMaxActive()); 514 } else { 515 temp.append("Client Handler Pool - Closed"); 516 } 517 handler.sendClientMsg(temp.toString()); 518 temp.setLength(0); 519 520 if(target.getByteBufferPool()!=null) { 521 if(PoolHelper.isPoolOpen(target.getByteBufferPool())==true) { 522 temp.append("ByteBuffer Pool - "); 523 temp.append("Num Active: "); 524 temp.append(target.getByteBufferPool().getNumActive()); 525 temp.append(", Num Idle: "); 526 temp.append(target.getByteBufferPool().getNumIdle()); 527 temp.append(", Max Idle: "); 528 temp.append(target.getBasicConfig().getObjectPoolConfig().getByteBufferObjectPoolConfig().getMaxIdle()); 529 temp.append(", Max Active: "); 530 temp.append(target.getBasicConfig().getObjectPoolConfig().getByteBufferObjectPoolConfig().getMaxActive()); 531 } else { 532 temp.append("Byte Buffer Pool - Closed"); 533 } 534 } else { 535 temp.append("Byte Buffer Pool - Not Used"); 536 } 537 handler.sendClientMsg(temp.toString()); 538 temp.setLength(0); 539 540 if(target.getClientDataPool()!=null) { 541 if(PoolHelper.isPoolOpen(target.getClientDataPool())==true) { 542 temp.append("Client Data Pool - "); 543 temp.append("Num Active: "); 544 temp.append(target.getClientDataPool().getNumActive()); 545 temp.append(", Num Idle: "); 546 temp.append(target.getClientDataPool().getNumIdle()); 547 temp.append(", Max Idle: "); 548 temp.append(target.getBasicConfig().getObjectPoolConfig().getClientDataObjectPoolConfig().getMaxIdle()); 549 temp.append(", Max Active: "); 550 temp.append(target.getBasicConfig().getObjectPoolConfig().getClientDataObjectPoolConfig().getMaxActive()); 551 } else { 552 temp.append("Client Data Pool - Closed"); 553 } 554 } else { 555 temp.append("Client Data Pool - Not Used"); 556 } 557 handler.sendClientMsg(temp.toString()); 558 temp.setLength(0); 559 560 handler.sendClientMsg("."); 561 return; 562 } else if(cmd.equals("set")) { 563 if(param.length < 3) { 564 handler.sendClientMsg("-ERR "+"insufficient param"); 565 return; 566 } 567 if(param[2].equals("null")) 568 param[2]=null; 569 try { 570 if(param[1].equals("maxClient")) { 571 long no = Long.parseLong(param[2]); 572 target.setMaxConnection(no); 573 } else if(param[1].equals("maxClientMsg")) { 574 target.setMaxConnectionMsg(param[2]); 575 } else if(param[1].equals("port")) { 576 long no = Long.parseLong(param[2]); 577 target.setPort((int)no); 578 } else if(param[1].equals("port")) { 579 long no = Long.parseLong(param[2]); 580 target.setPort((int)no); 581 } else if(param[1].equals("maxAuthTry")) { 582 int no = Integer.parseInt(param[2]); 583 target.setMaxAuthTry(no); 584 } else if(param[1].equals("maxAuthTryMsg")) { 585 target.setMaxAuthTryMsg(param[2]); 586 } else if(param[1].equals("clientEventHandler")) { 587 target.setClientEventHandler(param[2]); 588 } else if(param[1].equals("clientCommandHandler")) { 589 target.setClientCommandHandler(param[2]); 590 } else if(param[1].equals("clientWriteHandler")) { 591 target.setClientWriteHandler(param[2]); 592 } else if(param[1].equals("clientObjectHandler")) { 593 target.setClientObjectHandler(param[2]); 594 } else if(param[1].equals("clientAuthenticationHandler")) { 595 target.setClientAuthenticationHandler(param[2]); 596 } else if(param[1].equals("clientData")) { 597 target.setClientData(param[2]); 598 } else if(param[1].equals("clientExtendedEventHandler")) { 599 target.setClientExtendedEventHandler(param[2]); 600 } else if(param[1].equals("timeout")) { 601 long no = Long.parseLong(param[2]); 602 target.setTimeout((int)no); 603 } else if(param[1].equals("timeoutMsg")) { 604 target.setTimeoutMsg(param[2]); 605 } else if(param[1].equals("plugin")) { 606 if(param[0].equals("self")) { 607 try { 608 adminServer.setCommandPlugin(param[2]); 609 } catch(Exception e) { 610 handler.sendClientMsg("-ERR not set : "+e); 611 return; 612 } 613 } else { 614 handler.sendClientMsg("-ERR Bad target : "+param[0]+" self is only allowed."); 615 return; 616 } 617 } else if(param[1].equals("consoleLoggingFormatter")) { 618 target.setConsoleLoggingFormatter(param[2]); 619 } else if(param[1].equals("consoleLoggingLevel")) { 620 if(param[2].endsWith("SEVERE")) 621 target.setConsoleLoggingLevel(Level.SEVERE); 622 else if(param[2].endsWith("WARNING")) 623 target.setConsoleLoggingLevel(Level.WARNING); 624 else if(param[2].endsWith("INFO")) 625 target.setConsoleLoggingLevel(Level.INFO); 626 else if(param[2].endsWith("CONFIG")) 627 target.setConsoleLoggingLevel(Level.CONFIG); 628 else if(param[2].endsWith("FINE")) 629 target.setConsoleLoggingLevel(Level.FINE); 630 else if(param[2].endsWith("FINER")) 631 target.setConsoleLoggingLevel(Level.FINER); 632 else if(param[2].endsWith("FINEST")) 633 target.setConsoleLoggingLevel(Level.FINEST); 634 else if(param[2].endsWith("ALL")) 635 target.setConsoleLoggingLevel(Level.ALL); 636 else if(param[2].endsWith("OFF")) 637 target.setConsoleLoggingLevel(Level.OFF); 638 else { 639 handler.sendClientMsg("-ERR Bad Level "+param[2]); 640 return; 641 } 642 } else if(param[1].equals("loggingLevel")) { 643 if(param[2].endsWith("SEVERE")) 644 target.setLoggingLevel(Level.SEVERE); 645 else if(param[2].endsWith("WARNING")) 646 target.setLoggingLevel(Level.WARNING); 647 else if(param[2].endsWith("INFO")) 648 target.setLoggingLevel(Level.INFO); 649 else if(param[2].endsWith("CONFIG")) 650 target.setLoggingLevel(Level.CONFIG); 651 else if(param[2].endsWith("FINE")) 652 target.setLoggingLevel(Level.FINE); 653 else if(param[2].endsWith("FINER")) 654 target.setLoggingLevel(Level.FINER); 655 else if(param[2].endsWith("FINEST")) 656 target.setLoggingLevel(Level.FINEST); 657 else if(param[2].endsWith("ALL")) 658 target.setLoggingLevel(Level.ALL); 659 else if(param[2].endsWith("OFF")) 660 target.setLoggingLevel(Level.OFF); 661 else { 662 handler.sendClientMsg("-ERR Bad Level "+param[2]); 663 return; 664 } 665 } else if(param[1].equals("communicationLogging")) { 666 if(param[2].equals("true")) 667 target.setCommunicationLogging(true); 668 else 669 target.setCommunicationLogging(false); 670 } else if(param[1].equals("objectPoolConfig-maxActive")) { 671 int no = Integer.parseInt(param[2]); 672 target.getConfig().getObjectPoolConfig().setMaxActive(no); 673 } else if(param[1].equals("objectPoolConfig-maxIdle")) { 674 int no = Integer.parseInt(param[2]); 675 target.getConfig().getObjectPoolConfig().setMaxIdle(no); 676 } else if(param[1].equals("objectPoolConfig-initSize")) { 677 int no = Integer.parseInt(param[2]); 678 target.getConfig().getObjectPoolConfig().setInitSize(no); 679 } else { 680 handler.sendClientMsg("-ERR Bad Set Key : "+param[1]); 681 return; 682 } 683 handler.sendClientMsg("+OK Set"); 684 } catch(Exception e) { 685 handler.sendClientMsg("-ERR "+e); 686 } 687 return; 688 } else if(cmd.equals("get")) { 689 if(param.length < 2) { 690 handler.sendClientMsg("-ERR "+"insufficient param"); 691 return; 692 } 693 try { 694 if(param[1].equals("maxClient")) { 695 long no = target.getMaxConnection(); 696 handler.sendClientMsg("+OK "+no); 697 } else if(param[1].equals("maxClientMsg")) { 698 String msg = target.getMaxConnectionMsg(); 699 msg = MyString.replaceAll(msg, "\n", "\\n"); 700 handler.sendClientMsg("+OK "+msg); 701 } else if(param[1].equals("port")) { 702 long no = target.getPort(); 703 handler.sendClientMsg("+OK "+no); 704 } else if(param[1].equals("maxAuthTry")) { 705 int no = target.getMaxAuthTry(); 706 handler.sendClientMsg("+OK "+no); 707 } else if(param[1].equals("maxAuthTryMsg")) { 708 String msg=target.getMaxAuthTryMsg(); 709 msg = MyString.replaceAll(msg, "\n", "\\n"); 710 handler.sendClientMsg("+OK "+msg); 711 } else if(param[1].equals("clientEventHandler")) { 712 String msg=target.getClientEventHandler(); 713 handler.sendClientMsg("+OK "+msg); 714 } else if(param[1].equals("clientCommandHandler")) { 715 String msg=target.getClientCommandHandler(); 716 handler.sendClientMsg("+OK "+msg); 717 } else if(param[1].equals("clientWriteHandler")) { 718 String msg=target.getClientWriteHandler(); 719 handler.sendClientMsg("+OK "+msg); 720 } else if(param[1].equals("clientObjectHandler")) { 721 String msg=target.getClientObjectHandler(); 722 handler.sendClientMsg("+OK "+msg); 723 } else if(param[1].equals("clientAuthenticationHandler")) { 724 String msg=target.getClientAuthenticationHandler(); 725 handler.sendClientMsg("+OK "+msg); 726 } else if(param[1].equals("clientData")) { 727 String msg=target.getClientData(); 728 handler.sendClientMsg("+OK "+msg); 729 } else if(param[1].equals("clientExtendedEventHandler")) { 730 String msg=target.getClientExtendedEventHandler(); 731 handler.sendClientMsg("+OK "+msg); 732 } else if(param[1].equals("timeout")) { 733 String msg=""+target.getTimeout(); 734 handler.sendClientMsg("+OK "+msg); 735 } else if(param[1].equals("timeoutMsg")) { 736 String msg=""+target.getTimeoutMsg(); 737 msg = MyString.replaceAll(msg, "\n", "\\n"); 738 handler.sendClientMsg("+OK "+msg); 739 } else if(param[1].equals("plugin")) { 740 if(param[0].equals("self")) { 741 String msg = adminServer.getCommandPlugin(); 742 handler.sendClientMsg("+OK "+msg); 743 } else { 744 handler.sendClientMsg("-ERR Bad target : "+param[0]+" self is only allowed."); 745 } 746 } else if(param[1].equals("consoleLoggingFormatter")) { 747 String msg=""+target.getConsoleLoggingFormatter(); 748 handler.sendClientMsg("+OK "+msg); 749 } else if(param[1].equals("consoleLoggingLevel")) { 750 String msg=""+target.getConsoleLoggingLevel(); 751 handler.sendClientMsg("+OK "+msg); 752 } else if(param[1].equals("serviceState")) { 753 int state=target.getServiceState(); 754 if(state==org.quickserver.net.Service.INIT) 755 handler.sendClientMsg("+OK INIT"); 756 else if(state==org.quickserver.net.Service.RUNNING) 757 handler.sendClientMsg("+OK RUNNING"); 758 else if(state==org.quickserver.net.Service.STOPPED) 759 handler.sendClientMsg("+OK STOPPED"); 760 else if(state==org.quickserver.net.Service.SUSPENDED) 761 handler.sendClientMsg("+OK SUSPENDED"); 762 else 763 handler.sendClientMsg("+OK UNKNOWN"); 764 } else if(param[1].equals("communicationLogging")) { 765 String msg=""+target.getCommunicationLogging(); 766 handler.sendClientMsg("+OK "+msg); 767 } else if(param[1].equals("objectPoolConfig-maxActive")) { 768 String msg=""+target.getConfig().getObjectPoolConfig().getMaxActive(); 769 handler.sendClientMsg("+OK "+msg); 770 } else if(param[1].equals("objectPoolConfig-maxIdle")) { 771 String msg=""+target.getConfig().getObjectPoolConfig().getMaxIdle(); 772 handler.sendClientMsg("+OK "+msg); 773 } else if(param[1].equals("objectPoolConfig-initSize")) { 774 String msg=""+target.getConfig().getObjectPoolConfig().getInitSize(); 775 handler.sendClientMsg("+OK "+msg); 776 } else { 777 handler.sendClientMsg("-ERR Bad Get Key : "+param[1]); 778 } 779 } catch(Exception e) { 780 handler.sendClientMsg("-ERR "+e); 781 } 782 return; 783 } else { 784 handler.sendClientMsg("-ERR Bad Command : "+cmd); 785 } 786 return; 787 } 788 } 789 | Popular Tags |