/** @see nyla.solutions.global.patterns.command.Command#execute(java.lang.Object) */
  public Integer execute(Environment env) {

    try {
      if (env.getArgs().length != 2) {
        System.err.println(" Required httpPort and handleName arguments");
        return -1;
      }

      int httpPort = Integer.parseInt(env.getArgs()[0]);
      Server server = new Server(httpPort);

      String handlerName = env.getArgs()[1];

      Handler handler = ServiceFactory.getInstance().create(handlerName);

      server.setHandler(handler);

      server.start();
      server.join();

    } catch (InterruptedException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return 0;
  }
示例#2
0
  /**
   * @return instance of the FormBeanRemote
   * @throws Exception
   */
  private FormService getFormService() throws Exception {
    if (this.service == null)
      this.service = (FormService) ServiceFactory.getInstance().create(FormService.class);

    return service;
  } // --------------------------------------------