Package com.sun.jdi.connect

Examples of com.sun.jdi.connect.AttachingConnector


       
        IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
        subMonitor.beginTask(LaunchingMessages.SocketAttachConnector_Connecting____1, 2);
        subMonitor.subTask(LaunchingMessages.SocketAttachConnector_Configuring_connection____1);
       
        AttachingConnector connector= getAttachingConnector();
        String portNumberString = arguments.get("port"); //$NON-NLS-1$
        if (portNumberString == null) {
            abort(LaunchingMessages.SocketAttachConnector_Port_unspecified_for_remote_connection__2, null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_PORT);
        }
        String host = arguments.get("hostname"); //$NON-NLS-1$
        if (host == null) {
            abort(LaunchingMessages.SocketAttachConnector_Hostname_unspecified_for_remote_connection__4, null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_HOSTNAME);
        }
        Map<String, Connector.Argument> map= connector.defaultArguments();
       
        Connector.Argument param= map.get("hostname"); //$NON-NLS-1$
        param.setValue(host);
        param= map.get("port"); //$NON-NLS-1$
        param.setValue(portNumberString);
       
        String timeoutString = arguments.get("timeout"); //$NON-NLS-1$
        if (timeoutString != null) {
            param= map.get("timeout"); //$NON-NLS-1$
            param.setValue(timeoutString);
        }
       
        ILaunchConfiguration configuration = launch.getLaunchConfiguration();
        boolean allowTerminate = false;
        if (configuration != null) {
            allowTerminate = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, false);
        }
        subMonitor.worked(1);
        subMonitor.subTask(LaunchingMessages.SocketAttachConnector_Establishing_connection____2);
        try {
            VirtualMachine vm = connector.attach(map);
            String vmLabel = constructVMLabel(vm, host, portNumberString, configuration);
            IDebugTarget debugTarget= DroolsDebugModel.newDebugTarget(launch, vm, vmLabel, null, allowTerminate, true);
            launch.addDebugTarget(debugTarget);
            subMonitor.worked(1);
            subMonitor.done();
View Full Code Here


     * Call this with the localhost port to connect to.
     */
    public VirtualMachine connect(int port)
        throws IOException {
      String strPort = Integer.toString(port);
      AttachingConnector connector = getConnector();
      try {
        VirtualMachine vm = connect(connector, strPort);
        return vm;
      } catch (IllegalConnectorArgumentsException e) {
        throw new IllegalStateException(e);
View Full Code Here

        // 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()+
//          " description="+tmp.description());
            if (!useSocket && tmp.transport().name().equals("dt_shmem")) {
                connector = tmp;
                break;
            }
            if (useSocket && tmp.transport().name().equals("dt_socket")) {
                connector = tmp;
                break;
            }
        }
        if (connector == null) {
View Full Code Here

              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

    }
    return null;
  }

  public VirtualMachine attachToVm(String port) {
    AttachingConnector connector = getAttachingConnector();
    if (connector == null) return null;
    Map<String, Connector.Argument> args = connector.defaultArguments();
    Connector.Argument portArg = args.get("port");
    Connector.Argument hostArg = args.get("hostname");
    try {
      portArg.setValue(port);
      hostArg.setValue("127.0.0.1");
      VirtualMachine vm = connector.attach(args);
      return vm;
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
View Full Code Here

  }

  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;
    }
    return connector;
View Full Code Here

        if ("dt_socket".equals(transport))
            name = "com.sun.jdi.SocketAttach";
        else if ("dt_shmem".equals(transport))
            name = "com.sun.jdi.SharedMemoryAttach";

        AttachingConnector connector = null;
        for (Iterator i = Bootstrap.virtualMachineManager().attachingConnectors().iterator(); i.hasNext();) {
            AttachingConnector aConnector = (AttachingConnector) i.next();
            if (aConnector.name().equals(name)) {
                connector = aConnector;
                break;
            }
        }
        if (connector == null)
View Full Code Here

        // find ProcessAttachingConnector

        List<AttachingConnector> l =
            Bootstrap.virtualMachineManager().attachingConnectors();
        AttachingConnector ac = null;
        for (AttachingConnector c: l) {
            if (c.name().equals("com.sun.jdi.ProcessAttach")) {
                ac = c;
                break;
            }
        }
        if (ac == null) {
            throw new RuntimeException("Unable to locate ProcessAttachingConnector");
        }

        Map<String,Connector.Argument> args = ac.defaultArguments();
        Connector.StringArgument arg = (Connector.StringArgument)args.get("pid");
        arg.setValue(pid);

        System.out.println("Debugger is attaching to: " + pid + " ...");

        VirtualMachine vm = ac.attach(args);

        System.out.println("Attached! Now listing threads ...");

        // list all threads
View Full Code Here

            name = "com.sun.jdi.SharedMemoryAttach";

        }

        AttachingConnector connector = null;

        for (Iterator i = Bootstrap.virtualMachineManager().attachingConnectors().iterator(); i.hasNext();) {

            AttachingConnector aConnector = (AttachingConnector) i.next();

            if (aConnector.name().equals(name)) {

                connector = aConnector;

                break;
View Full Code Here

        if ("dt_socket".equals(transport)) {
            name = "com.sun.jdi.SocketAttach";
        } else if ("dt_shmem".equals(transport)) {
            name = "com.sun.jdi.SharedMemoryAttach";
        }
        AttachingConnector connector = null;
        for (Iterator i = Bootstrap.virtualMachineManager().attachingConnectors().iterator(); i.hasNext();) {
            AttachingConnector aConnector = (AttachingConnector) i.next();
            if (aConnector.name().equals(name)) {
                connector = aConnector;
                break;
            }
        }
        if (connector == null) {
View Full Code Here

TOP

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

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.