Ejemplo n.º 1
0
  private int info(String name) {

    ShellObject obj = env.get(name);
    if (obj == null) {
      println("flush: env object" + name + " not found");
      return ShellApp.appMiscError;
    }

    Object adv = obj.getObject();
    if (adv instanceof Advertisement) {
      long life = discovery.getAdvLifeTime((Advertisement) adv);
      long exp = discovery.getAdvExpirationTime((Advertisement) adv);
      println(
          "Expires on            : "
              + new Date(life + System.currentTimeMillis())
              + "\nExpires for others in : "
              + exp
              + " ms");
    } else {
      shortHelp();
    }
    return ShellApp.appNoError;
  }
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  public int startApp(String[] appArgs) {

    this.appArgs = appArgs;

    try {
      cons =
          new EndpointRemoteShellConsole(this, this, localAddress, remoteAddress, server.endpoint);
    } catch (IOException failed) {
      return ShellApp.appMiscError;
    }

    ShellEnv env = new ShellEnv();

    setEnv(env);

    env.add("console", new ShellObject<ShellConsole>("console", cons));
    env.add("stdgroup", new ShellObject<PeerGroup>("Default Group", getGroup()));

    // Create the default InputPipe
    inputPipe = new ShellInputPipe(getGroup(), cons);
    outputPipe = new ShellOutputPipe(getGroup(), cons);

    setInputPipe(inputPipe);
    setOutputPipe(outputPipe);

    setInputConsPipe(inputPipe);
    setOutputConsPipe(outputPipe);

    env.add("stdin", new ShellObject<InputPipe>("stdin", inputPipe));
    env.add("stdout", new ShellObject<OutputPipe>("stdout", outputPipe));
    env.add("consin", new ShellObject<InputPipe>("consin", inputPipe));
    env.add("consout", new ShellObject<OutputPipe>("consout", outputPipe));

    timerTask =
        new TimerTask() {

          @Override
          public void run() {
            long currentTime = System.currentTimeMillis();

            if ((currentTime - lastActivity) > rshd.INACTIVITY_TIMEOUT) {
              consprintln(" ");
              consoleMessage("Inactivity timeout, your session has automatically shutdown.");
              stopApp();
            }
          }
        };

    try {
      server.timer.schedule(timerTask, rshd.INACTIVITY_TIMEOUT, rshd.INACTIVITY_TIMEOUT);
    } catch (Exception ez1) {
      printStackTrace("Cannot set inactivity timer: ", ez1);
    }

    Thread t = new Thread(getGroup().getHomeThreadGroup(), this, "Remote Shell Session");
    t.setDaemon(true); // FIXME 20040421 jice  Questionable
    t.start();

    // As far as the invoker is concerned, we're finished here.
    return ShellApp.appSpawned;
  }