Package com.sun.jdi

Examples of com.sun.jdi.VirtualMachineManager


        throw new IllegalStateException(e);
      }
    }

    private AttachingConnector getConnector() {
      VirtualMachineManager vmManager = Bootstrap
          .virtualMachineManager();
      for (AttachingConnector connector : vmManager
          .attachingConnectors()) {
        if ("com.sun.jdi.SocketAttach".equals(connector
            .name())) {
          return (AttachingConnector) connector;
        }
View Full Code Here


    // either host,port will be set, or name
    private void connect(String host, String port, String name) throws Exception {
        // connect to JVM
        boolean useSocket = (port != null);

        VirtualMachineManager manager = Bootstrap.virtualMachineManager();
        List<AttachingConnector> connectors = manager.attachingConnectors();
        AttachingConnector connector = null;
//      System.err.println("Connectors available");
        for (int i = 0; i < connectors.size(); i++) {
            AttachingConnector tmp = connectors.get(i);
//          System.err.println("conn "+i+"  name="+tmp.name()+" transport="+tmp.transport().name()+
View Full Code Here

      attachButton = new JButton();
      attachButton.setText("Attach");
      attachButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
          boolean suspend = false;
          VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
          if (DebugTab.this.launchVM.isSelected()) {
            // Launch
            LaunchingConnector connector = vmm.defaultConnector();
            Map<String, Argument> args = connector.defaultArguments();
            //Project project = OpenProjects.getInstance().getCurrentProject();
            String mainClass = DebugTab.this.mainClassField.getText();
            args.get("options").setValue("-cp \"" + project.getFileSet().getClasspath(mainClass) + "\"" + DebugTab.this.classpathField.getText());
            args.get("suspend").setValue("true");
            suspend = DebugTab.this.suspend.isSelected();
            args.get("main").setValue(mainClass);
            try {
              DebugTab.this.vm = connector.launch(args);       
              StreamRedirector srErr = new StreamRedirector(vm.process().getErrorStream(), System.err);
              new Thread(srErr).start();
              StreamRedirector srOut = new StreamRedirector(vm.process().getInputStream(), System.out);
              new Thread(srOut).start();
            } catch (Exception ex) {
              SystemFacade.getInstance().handleException(ex);
              return;
            }
          } else {
            // Attach
            AttachingConnector connector = null;
            for (AttachingConnector ac : vmm.attachingConnectors()) {
              if (ac.transport().name().equals(DebugTab.this.methodCombo.getSelectedItem())) {
                connector = ac;
                break;
              }
            }
View Full Code Here

    }
    return null;
  }

  private static AttachingConnector getAttachingConnector() {
    VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
    List<AttachingConnector> connectors = vmm.attachingConnectors();
    AttachingConnector connector = null;
    for (AttachingConnector conn : connectors) {
      if (conn.name().equals("com.sun.jdi.SocketAttach"))
        connector = conn;
    }
View Full Code Here

    }
    return connector;
  }
 
  private static ListeningConnector getListeningConnector() {
    VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
    List<ListeningConnector> connectors = vmm.listeningConnectors();
    ListeningConnector connector = null;
    for (ListeningConnector conn : connectors) {
      if (conn.name().equals("com.sun.jdi.SocketListen"))
        connector = conn;
    }
View Full Code Here

    void log(String event) {
        trace.append(event).append('\n');
    }
   
    public void start() throws Exception {
        VirtualMachineManager vmm = com.sun.jdi.Bootstrap.virtualMachineManager();
        LaunchingConnector conn = vmm.defaultConnector();
        Map<String, Argument> defaultArguments = conn.defaultArguments();
        defaultArguments.get("main").setValue(mainClass);
        defaultArguments.get("options").setValue("-cp " + classPath);
        System.out.println(defaultArguments);
        vm = conn.launch(defaultArguments);
View Full Code Here

    inject(args[0], loader, stagerArgs);
  }
 
  public static void inject(String connector, final StagerHandler.Loader loader, String[] stagerArgs) throws Exception {
    final String stager = stagerArgs[0];
    final VirtualMachineManager vmm = com.sun.jdi.Bootstrap.virtualMachineManager();
    VirtualMachine vm = null;
    boolean disableSecurityManager = false;
    if (connector.endsWith("!")) {
      disableSecurityManager = true;
      connector = connector.substring(0, connector.length()-1);
    }
    final int pos = connector.lastIndexOf(':');
    if (pos == -1) {
      final int port = Integer.parseInt(connector);
      for (int i = 0; i < vmm.listeningConnectors().size(); i++) {
        final ListeningConnector lc = (ListeningConnector) vmm.listeningConnectors().get(i);
        if (lc.name().equals("com.sun.jdi.SocketListen")) {
          final Map connectorArgs = lc.defaultArguments();
          ((Argument) connectorArgs.get("port")).setValue("" + port);
          lc.startListening(connectorArgs);
          vm = lc.accept(connectorArgs);
          lc.stopListening(connectorArgs);
        }
      }
    } else {
      final int port = Integer.parseInt(connector.substring(pos + 1));
      for (int i = 0; i < vmm.attachingConnectors().size(); i++) {
        final AttachingConnector ac = (AttachingConnector) vmm.attachingConnectors().get(i);
        if (ac.name().equals("com.sun.jdi.SocketAttach")) {
          final Map connectorArgs = ac.defaultArguments();
          ((Argument) connectorArgs.get("hostname")).setValue(connector.substring(0, pos));
          ((Argument) connectorArgs.get("port")).setValue("" + port);
          vm = ac.attach(connectorArgs);
View Full Code Here

   * @since 2.1
   */
  public static int[] getJDIVersion() {
    if (fJDIVersion == null) {
      fJDIVersion = new int[2];
      VirtualMachineManager mgr = Bootstrap.virtualMachineManager();
      fJDIVersion[0] = mgr.majorInterfaceVersion();
      fJDIVersion[1] = mgr.minorInterfaceVersion();
    }
    return fJDIVersion;
  }
View Full Code Here

    public void close() throws IOException {
        disconnect();
    }

    private VirtualMachine connect(int port) throws IOException {
        VirtualMachineManager manager = Bootstrap.virtualMachineManager();

        // Find appropiate connector
        List<AttachingConnector> connectors = manager.attachingConnectors();
        AttachingConnector chosenConnector = null;
        for (AttachingConnector c : connectors) {
            if (c.transport().name().equals(TRANSPORT_NAME)) {
                chosenConnector = c;
                break;
View Full Code Here

TOP

Related Classes of com.sun.jdi.VirtualMachineManager

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.