Examples of QuickServer


Examples of org.quickserver.net.server.QuickServer

    StringTokenizer st = new StringTokenizer(command," ");
    String cmd = null;
    cmd = st.nextToken().toLowerCase();
    String param[] = new String[st.countTokens()];
   
    QuickServer target = null;   
    for (int i=0;st.hasMoreTokens();i++)
      param[i] = st.nextToken();

    if(command.equals("start console")) { /*v1.4.5*/
      QSAdminShell.getInstance(
        (QuickServer) handler.getServer().getStoreObjects()[0], null);
      handler.sendClientMsg("+OK QSAdminShell is started.");
      return;
    } else if(command.equals("stop console")) { /*v1.4.5*/
      QSAdminShell shell = QSAdminShell.getInstance(null, null);
      if(shell!=null) {
        try {
          shell.stopShell();
        } catch(Exception err) {
          handler.sendClientMsg("-ERR Error stopping QSAdminShell: "+err);
        }       
        handler.sendClientMsg("+OK QSAdminShell is stopped.");
      } else {
        handler.sendClientMsg("-ERR QSAdminShell is not running.");
      }
      return;
    }

    if(param.length > 0) {
      if( param[0].equals("server") )
        target = (QuickServer) handler.getServer().getStoreObjects()[0];
      else if( param[0].equals("self") )
        target = handler.getServer();
      else {
        handler.sendClientMsg("-ERR Bad <<target>> : "+param[0]);
        return;
      }
    }
    if(cmd.equals("help")) {
      handler.sendClientMsg("+OK info follows"+"\r\n"+
        "Refer Api Docs for org.quickserver.net.qsadmin.CommandHandler");
      handler.sendClientMsg(".");
      return;
    } else if(cmd.equals("quit")) {
      handler.sendClientMsg("+OK Bye ;-)");
      handler.closeConnection();
      return;
    } else if(cmd.equals("shutdown")) {
      try  {
        QuickServer controlServer =
          (QuickServer) handler.getServer().getStoreObjects()[0];
        if(controlServer!=null && controlServer.isClosed()==false) {
          controlServer.stopServer();
        }
        if(handler.getServer()!=null && handler.getServer().isClosed()==false) {
          handler.getServer().stopServer();
        }

        QSAdminShell shell = QSAdminShell.getInstance(null, null);
        if(shell!=null) {
          try {
            shell.stopShell();
          } catch(Exception err) {
            logger.warning("Error stoping shell: "+err);
          }       
        }

        handler.sendClientMsg("+OK Done");
      } catch (AppException e) {
        handler.sendClientMsg("-ERR "+e);
      }
      return;
    } else if(cmd.equals("version")) {
      handler.sendClientMsg("+OK "+QuickServer.getVersion());
      return;
    } else if(cmd.equals("kill") || cmd.equals("exit")) /*v1.3,v1.3.2*/{
      StringBuilder errBuf = new StringBuilder();
      QuickServer controlServer =
        (QuickServer) handler.getServer().getStoreObjects()[0];
      int exitCode = 0;

      if(param.length!=0) {
        try {
          exitCode = Integer.parseInt(param[0]);
        } catch(Exception nfe) {/*ignore*/}       
      }

      try  {       
        if(controlServer!=null && controlServer.isClosed()==false) {
          try {
            controlServer.stopServer();
          } catch(AppException ae) {
            errBuf.append(ae.toString());
          }
        }
        if(handler.getServer()!=null  && handler.getServer().isClosed()==false) {
          try {
            handler.getServer().stopServer();
          } catch(AppException ae) {
            errBuf.append(ae.toString());
          }         
        }

        QSAdminShell shell = QSAdminShell.getInstance(null, null);
        if(shell!=null) {
          try {
            shell.stopShell();
          } catch(Exception err) {
            errBuf.append(err.toString());
          }       
        }

        if(errBuf.length()==0)
          handler.sendClientMsg("+OK Done");
        else
          handler.sendClientMsg("+OK Done, Errors: "+errBuf.toString());
      } catch (Exception e) {
        handler.sendClientMsg("-ERR Exception : "+e+"\r\n"+errBuf.toString());
        if(exitCode==0) exitCode = 1;
      } finally {
        try {
          if(controlServer!=null)
            controlServer.closeAllPools();
          if(handler.getServer()!=null)
            handler.getServer().closeAllPools();
        } catch(Exception er) {
          logger.warning("Error closing pools: "+er);
        }
View Full Code Here

Examples of org.quickserver.net.server.QuickServer

  private transient QuickServer myServer = null;
 
  public void start() throws UnknownHostException  {
    final String cmdHandle = org.ejbca.ui.tcp.CmpTcpCommandHandler.class.getName();

    myServer = new QuickServer();
    myServer.setClientAuthenticationHandler(null);
    myServer.setBindAddr(CmpConfiguration.getTCPBindAdress());
    myServer.setPort(CmpConfiguration.getTCPPortNumber());
    myServer.setName("CMP TCP Server v " + VER);
    if(QuickServer.getVersionNo() >= 1.2) {
View Full Code Here

Examples of org.quickserver.net.server.QuickServer

   * @throws UnknownHostException
   * @throws AppException
   *
   */
  private CmpTcpProxyServer(CmpProxyConfig config) throws UnknownHostException, AppException {
    final QuickServer myServer = new QuickServer();
    myServer.setClientAuthenticationHandler(null);
    if ( config.proxyBindAddress!=null ) {
      myServer.setBindAddr(config.proxyBindAddress);
    }
    myServer.setPort(config.proxyPort);
    final String cmdHandle;
    switch ( config.serverProtokoll ) {
    case TCP:
      cmdHandle = CmpTcpProxyCommandHandlerTcp.class.getName();
      break;
    case HTTP:
      cmdHandle = CmpTcpProxyCommandHandlerHttp.class.getName();
      break;
    default:
      log.fatal("No valid server protokoll.");
      return;
    }
    CmpTcpProxyCommandHandler.setConfig(config);
    myServer.setClientBinaryHandler(cmdHandle);
    myServer.setClientEventHandler(cmdHandle);
    myServer.getClientBinaryHandler();

    //reduce info to Console
    myServer.setConsoleLoggingToMicro();

    if ( config.quickConfigFile!=null && config.quickConfigFile.trim().length()>0 ) {
      Object _config[] = new Object[] {config.quickConfigFile};
      if ( !myServer.initService(_config) ) {
        System.out.println("Configuration from config file "+config.quickConfigFile+" failed!");
      }
    }
    myServer.startServer()
    //myServer.getQSAdminServer().setShellEnable(true);
    //myServer.startQSAdminServer();     
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.