Пример #1
0
 @Override
 public void start(ThreadExitListener listener) throws ShellInvocationException {
   try {
     Link cl = Link.newLink(Isolate.currentIsolate(), isolate);
     sl = isolate.newStatusLink();
     isolate.start(cl);
     ObjectLinkMessage msg = ObjectLinkMessage.newMessage(this.cr);
     cl.send(msg);
   } catch (Exception ex) {
     throw new ShellInvocationException("Error starting isolate", ex);
   }
 }
Пример #2
0
  @Override
  public void execute() throws NameNotFoundException, IsolateStartupException, ShellException {
    final PrintWriter out = getOutput().getPrintWriter();
    final ShellManager sm = InitialNaming.lookup(ShellManager.NAME);
    final ConsoleManager conMgr = sm.getCurrentShell().getConsole().getManager();

    boolean listConsoles = FLAG_LIST.isSet();
    boolean newConsole = FLAG_NEW.isSet();
    boolean isolateNewConsole = FLAG_ISOLATED.isSet();
    boolean test = FLAG_TEST.isSet();

    if (listConsoles) {
      conMgr.printConsoles(out);
    } else if (newConsole) {
      if (isolateNewConsole) {
        try {
          Isolate newIsolate =
              new Isolate(ConsoleCommand.IsolatedConsole.class.getName(), new String[0]);
          newIsolate.start();
          out.println("Started new isolated console");
        } catch (IsolateStartupException ex) {
          out.println("Failed to start new isolated console");
          throw ex;
        }
      } else {
        createConsoleWithShell(conMgr, out);
      }
    } else if (test) {
      out.println("test RawTextConsole");
      final TextConsole console =
          (TextConsole)
              conMgr.createConsole(
                  null,
                  ConsoleManager.CreateOptions.TEXT
                      | ConsoleManager.CreateOptions.NO_LINE_EDITTING);
      conMgr.registerConsole(console);
      conMgr.focus(console);
      console.clear();
    }
  }
 /**
  * The entry point that used to run the 'application' when the isolate is started. The actual
  * command is then passed to us in a Link message in the form of a CommandRunner object.
  *
  * @param args
  */
 public static void main(String[] args) {
   Link cl = Isolate.getLinks()[0];
   CommandRunner cr;
   try {
     ObjectLinkMessage message = (ObjectLinkMessage) cl.receive();
     cr = (CommandRunner) message.extract();
     Map<String, String> env = cr.getEnv();
     int envSize = (env == null) ? 0 : env.size();
     byte[][] binEnv = new byte[envSize * 2][];
     if (envSize > 0) {
       int i = 0;
       for (Map.Entry<String, String> entry : env.entrySet()) {
         binEnv[i++] = entry.getKey().getBytes();
         binEnv[i++] = entry.getValue().getBytes();
       }
     }
     NativeProcessEnvironment.setIsolateInitialEnv(binEnv);
   } catch (Exception e) {
     Unsafe.debugStackTrace(e.getMessage(), e);
     return;
   }
   cr.run();
 }
Пример #4
0
 @Override
 public void stop(ThreadDeath threadDeath) {
   isolate.halt(-1);
 }
Пример #5
0
 @Override
 public boolean isAlive() {
   final IsolateStatus.State state = isolate.getState();
   return IsolateStatus.State.STARTED.equals(state);
 }