Package org.crsh.shell

Examples of org.crsh.shell.ShellResponse


      exitMsg = e.getMessage();
      exitStatus = ERROR;
    }
    finally {
      // get command output
      ShellResponse response = context.getResponse();
      if (response instanceof ShellResponse.Ok) {
        // Ok
      }
      else {
        String errorMsg;

        // Set the exit status to Error
        exitStatus = ERROR;

        if (response != null) {
          errorMsg = "Error during command execution : " + response.getMessage();
        }
        else {
          errorMsg = "Error during command execution";
        }
        err.println(errorMsg);
View Full Code Here


    ServerAutomaton server = new ServerAutomaton(serverOOS, serverOIS);

    ShellProcess process = server.createProcess("hello");
    BaseProcessContext context = BaseProcessContext.create(process);
    context.execute();
    ShellResponse response = context.getResponse();
    assertInstance(ShellResponse.Close.class, response);

    //
    assertJoin(t);
  }
View Full Code Here

    final AtomicReference<Throwable> error = new AtomicReference<Throwable>();
    Thread u = new Thread() {
      @Override
      public void run() {
        context.execute();
        ShellResponse response = context.getResponse();
        assertInstance(ShellResponse.Cancelled.class, response);
      }
    };
    u.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
      public void uncaughtException(Thread t, Throwable e) {
View Full Code Here

  }

  public void process(String request, ShellProcessContext processContext) throws IOException {
    this.processContext = processContext;
    try {
      ShellResponse resp = execute(request);
      processContext.end(resp);
    } finally {
      this.processContext = null;
    }
  }
View Full Code Here

  public ShellProcess createProcess(String request) {
    log.log(Level.FINE, "Invoking request " + request);
    String trimmedRequest = request.trim();
    final StringBuilder msg = new StringBuilder();
    final ShellResponse response;
    if ("bye".equals(trimmedRequest) || "exit".equals(trimmedRequest)) {
      response = ShellResponse.close();
    } else {
      ReplResponse r = repl.eval(this, request);
      if (r instanceof ReplResponse.Response) {
View Full Code Here

  }

  public void execute(ShellProcessContext processContext) {
    ClassLoader previous = crash.setCRaSHLoader();
    try {
      ShellResponse resp;
      thread = Thread.currentThread();

      //
      String userName = crash.user != null ? crash.user.getName() : "unauthenticated";
      CRaSHSession.accessLog.log(Level.FINE, "User " + userName + " executes " + request);
View Full Code Here

    } else {
      throw new IllegalStateException();
    }

    //
    ShellResponse response = null;
    try {
      out.writeObject(new ClientMessage.Execute(processContext.getWidth(), processContext.getHeight(), process.line));
      out.flush();

      //
View Full Code Here

    Callable<AsyncProcess> task = new Callable<AsyncProcess>() {
      public AsyncProcess call() throws Exception {
        try {
          // Cancelled -> Cancelled
          // Queued -> Evaluating
          ShellResponse response;
          synchronized (lock) {
            switch (status) {
              case CANCELED:
                // Do nothing it was canceled in the mean time
                response = ShellResponse.cancelled();
View Full Code Here

TOP

Related Classes of org.crsh.shell.ShellResponse

Copyright © 2018 www.massapicom. 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.