Package org.crsh.util

Examples of org.crsh.util.CloseableList


    this.term = term;
    this.shell = shell;
    this.queue = new LinkedList<TermEvent>();
    this.lock = new Object();
    this.status = Status.AVAILABLE;
    this.listeners = new CloseableList();
    this.waitingEvent = false;
    this.lineVisitor = new MultiLineVisitor();
    this.lineBuffer = new LineParser(lineVisitor);
  }
View Full Code Here


    log.log(Level.INFO, "conf mounts: " + confBuilder.toString());
    log.log(Level.INFO, "cmd mounts: " + cmdBuilder.toString());


    //
    CloseableList closeable = new CloseableList();
    Shell shell;
    if (pids != null && pids.size() > 0) {

      //
      if (interactive && pids.size() > 1) {
        throw new Exception("Cannot attach to more than one JVM in interactive mode");
      }

      // Compute classpath
      String classpath = System.getProperty("java.class.path");
      String sep = System.getProperty("path.separator");
      StringBuilder buffer = new StringBuilder();
      for (String path : classpath.split(Pattern.quote(sep))) {
        File file = new File(path);
        if (file.exists()) {
          if (buffer.length() > 0) {
            buffer.append(' ');
          }
          buffer.append(file.getCanonicalPath());
        }
      }

      // Create manifest
      Manifest manifest = new Manifest();
      Attributes attributes = manifest.getMainAttributes();
      attributes.putValue("Agent-Class", Agent.class.getName());
      attributes.put(Attributes.Name.MANIFEST_VERSION, "1.0");
      attributes.put(Attributes.Name.CLASS_PATH, buffer.toString());

      // Create jar file
      File agentFile = File.createTempFile("agent", ".jar");
      agentFile.deleteOnExit();
      JarOutputStream out = new JarOutputStream(new FileOutputStream(agentFile), manifest);
      out.close();
      log.log(Level.INFO, "Created agent jar " + agentFile.getCanonicalPath());

      // Build the options
      StringBuilder sb = new StringBuilder();

      // Path configuration
      sb.append("--cmd ");
      Delimiter.EMPTY.escape(toString(cmdBuilder), sb);
      sb.append(' ');
      sb.append("--conf ");
      Delimiter.EMPTY.escape(toString(confBuilder), sb);
      sb.append(' ');

      // Propagate canonical config
      if (properties != null) {
        for (String property : properties) {
          sb.append("--property ");
          Delimiter.EMPTY.escape(property, sb);
          sb.append(' ');
        }
      }

      //
      if (interactive) {
        RemoteServer server = new RemoteServer(0);
        int port = server.bind();
        log.log(Level.INFO, "Callback server set on port " + port);
        sb.append(port);
        String options = sb.toString();
        Integer pid = pids.get(0);
        final VirtualMachine vm = VirtualMachine.attach("" + pid);
        log.log(Level.INFO, "Loading agent with command " + options + " as agent " + agentFile.getCanonicalPath());
        vm.loadAgent(agentFile.getCanonicalPath(), options);
        server.accept();
        shell = server.getShell();
        closeable.add(new Closeable() {
          public void close() throws IOException {
            vm.detach();
          }
        });
      } else {
View Full Code Here

  /** . */
  long last;

  public ClientAutomaton(ObjectOutputStream out, ObjectInputStream in, Shell shell) {
    CloseableList listeners = new CloseableList();
    listeners.add(in);
    listeners.add(out);

    //
    this.in = in;
    this.out = out;
    this.shell = shell;
View Full Code Here

  /** . */
  final CloseableList listeners;

  public ServerAutomaton(ObjectOutputStream out, ObjectInputStream in) {
    CloseableList listeners = new CloseableList();
    listeners.add(in);
    listeners.add(out);

    //
    this.in = in;
    this.out = out;
    this.listeners = listeners;
View Full Code Here

TOP

Related Classes of org.crsh.util.CloseableList

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.