Package com.sun.jdi.connect

Examples of com.sun.jdi.connect.LaunchingConnector


        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;
              }
            }
            if (connector == null) {
              SystemFacade.getInstance().setStatus("Attaching connector (" + DebugTab.this.methodCombo.getSelectedItem() + ") not available.");
              return;
            }
            Map<String, Argument> args = connector.defaultArguments();
            args.get("timeout").setValue("30000");
            String hostname = DebugTab.this.hostField.getText();
            if (connector.transport().name().equals("dt_socket")) {
              if (hostname.length() == 0) {
                args.get("hostname").setValue("127.0.0.1");
              } else {
                args.get("hostname").setValue(hostname);
              }
              args.get("port").setValue(DebugTab.this.portField.getText());
            } else {
              args.get("name").setValue(hostname);
            }

            try {
              DebugTab.this.vm = connector.attach(args);
              DebugTab.this.vm.suspend();
            } catch (Exception ex) {
              SystemFacade.getInstance().handleException(ex);
              return;
            }
View Full Code Here


    static private VirtualMachine getVM(OutputListener diagnostics,
                                        String userVMArgs,
                                        String cmdLine) {
        VirtualMachineManager manager = Bootstrap.virtualMachineManager();
        LaunchingConnector connector = manager.defaultConnector();
        Map<String, Connector.Argument> arguments = connector.defaultArguments();
        arguments.get("options").setValue(userVMArgs);
        arguments.get("main").setValue(cmdLine);
        return generalGetVM(diagnostics, connector, arguments);
    }
View Full Code Here

    return null;
  }

  public VirtualMachine launch2(String mainClass, String classPathXml,
      List<String> opts,List<String> args) {
    LaunchingConnector launchingConnector = Bootstrap
        .virtualMachineManager().defaultConnector();

    Map<String, Connector.Argument> defaultArguments = launchingConnector
        .defaultArguments();

    Connector.Argument mainArg = defaultArguments.get("main");
    StringBuilder mainSb = new StringBuilder(mainClass);
   
    if (args != null & args.size() > 0 ) {
      mainSb.append(" ");
      for (String arg : args) {
        mainSb.append(arg).append(" ");
      }
    }
    mainArg.setValue(mainSb.toString());

    Connector.Argument suspendArg = defaultArguments.get("suspend");
    suspendArg.setValue("true");

    Connector.Argument optionArg = (Connector.Argument) defaultArguments
        .get("options");
   
    StringBuilder optionSb = new StringBuilder();
    String projectRoot = new File(classPathXml).getParent();
    String user_dir = "-Duser.dir=" + projectRoot ;
   
    String cp = "-Djava.class.path=" + getClassPath(classPathXml);
    optionSb.append(user_dir).append(" ");
    optionSb.append(cp).append(" ");
    if (opts != null) {
      for (String opt : opts) {
        optionSb.append(opt).append(" ");
      }
    }
    optionArg.setValue(optionSb.toString());
   

    try {
      VirtualMachine vm = launchingConnector.launch(defaultArguments);
      return vm;
    } catch (IOException e) {
      e.printStackTrace();
    } catch (IllegalConnectorArgumentsException e) {
      e.printStackTrace();
View Full Code Here

    static private VirtualMachine getVM(OutputListener diagnostics,
                                        String userVMArgs,
                                        String cmdLine) {
        VirtualMachineManager manager = Bootstrap.virtualMachineManager();
        LaunchingConnector connector = manager.defaultConnector();
        Map<String, Connector.Argument> arguments = connector.defaultArguments();
        arguments.get("options").setValue(userVMArgs);
        arguments.get("main").setValue(cmdLine);
        return generalGetVM(diagnostics, connector, arguments);
    }
View Full Code Here

      optionsArg.setValue(ARGUMENTS);
      return arguments;
  }

static VirtualMachine launchTarget(String mainArgs) {
    LaunchingConnector connector = findLaunchingConnector();
    Map  arguments = connectorArguments(connector, mainArgs);
    try {
        return (VirtualMachine) connector.launch(arguments);
    } catch (IOException exc) {
        throw new Error("Unable to launch target VM: " + exc);
    } catch (IllegalConnectorArgumentsException exc) {
        throw new Error("Internal error: " + exc);
    } catch (VMStartException exc) {
View Full Code Here

        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);
        err = vm.process().getErrorStream();
        out = vm.process().getInputStream();
        eq = vm.eventQueue();
        rm = vm.eventRequestManager();
        outer: while (true) {
View Full Code Here

    static private VirtualMachine getVM(OutputListener diagnostics,
                                        String userVMArgs,
                                        String cmdLine) {
        VirtualMachineManager manager = Bootstrap.virtualMachineManager();
        LaunchingConnector connector = manager.defaultConnector();
        Map<String, Connector.Argument> arguments = connector.defaultArguments();
        arguments.get("options").setValue(userVMArgs);
        arguments.get("main").setValue(cmdLine);
        return generalGetVM(diagnostics, connector, arguments);
    }
View Full Code Here

    @Override
    public void launchJVM(String[] programArguments) {
       
        String parameters = buildTODParameters();
        String jarFile = new File(this.getTODSession().getMainClassLocation(), this.getTODSession().getJar()).getAbsolutePath();
        LaunchingConnector defaultConnector = Bootstrap.virtualMachineManager().defaultConnector();
        Map arguments = defaultConnector.defaultArguments();
        //temporary hack for windows 7, 64-bit, possibly others?
        //String os = System.getProperty("os.name");
        //String arch = System.getProperty("sun.arch.data.model");
      
       
        // if(os.compareTo("Windows 7") == 0 &&
       //    arch.contains("64")
       // ) {
       
       
        Connector.Argument home = (Connector.Argument) arguments.get("home");
        home.setValue("\"" + home.value() + "");
        Connector.Argument java = (Connector.Argument) arguments.get("vmexec");
        java.setValue(java.value() + "\"");
       // }
       
        Connector.Argument mainArg = (Connector.Argument)arguments.get("main");
        mainArg.setValue("-jar \"" + jarFile + "\"");
        Connector.Argument optionsArg = (Connector.Argument)arguments.get("options");
        optionsArg.setValue(parameters);
        logger.log(Level.INFO, "JVM Args: {0}", parameters);
        //System.out.println("JVM Args: " + parameters);
        try {
            this.vm = defaultConnector.launch(arguments);
        } catch (IOException ex) {
            logger.log(Level.SEVERE, ex.getMessage());
            return;
        } catch (IllegalConnectorArgumentsException ex) {
            logger.log(Level.SEVERE, ex.getMessage());
View Full Code Here

TOP

Related Classes of com.sun.jdi.connect.LaunchingConnector

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.