Package com.sun.jdi.connect

Examples of com.sun.jdi.connect.ListeningConnector


        }

        subMonitor.worked(1);
        subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Starting_virtual_machine____4);

        ListeningConnector connector= getConnector();
        if (connector == null) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_find_an_appropriate_debug_connector_2, null, IJavaLaunchConfigurationConstants.ERR_CONNECTOR_NOT_AVAILABLE);
        }
        Map map= connector.defaultArguments();

        specifyArguments(map, port);
        Process p= null;
        try {
            try {
                // check for cancellation
                if (monitor.isCanceled()) {
                    return;
                }

                connector.startListening(map);

                File workingDir = getWorkingDir(config);
                p = exec(cmdLine, workingDir, envp);
                if (p == null) {
                    return;
                }

                // check for cancellation
                if (monitor.isCanceled()) {
                    p.destroy();
                    return;
                }
                java.util.Date date= new java.util.Date();
                Timestamp ts = new Timestamp(date.getTime());
                String format= LaunchingMessages.StandardVMRunner__0____1___2;
            String label = NLS.bind(format, new String[] { cmdLine[0], ts.toString() });
                IProcess process= newProcess(launch, p, label, getDefaultProcessMap());
                process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLineInternal(cmdLine));
                subMonitor.worked(1);
                subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Establishing_debug_connection____5);
                boolean retry= false;
                do  {
                    try {

                        ConnectRunnable runnable = new ConnectRunnable(connector, map);
                        Thread connectThread = new Thread(runnable, "Listening Connector"); //$NON-NLS-1$
                        connectThread.setDaemon(true);
                        connectThread.start();
                        while (connectThread.isAlive()) {
                            if (monitor.isCanceled()) {
                                connector.stopListening(map);
                                p.destroy();
                                return;
                            }
                            try {
                                p.exitValue();
                                // process has terminated - stop waiting for a connection
                                try {
                                    connector.stopListening(map);
                                } catch (IOException e) {
                                    // expected
                                }
                                checkErrorMessage(process);
                            } catch (IllegalThreadStateException e) {
                                // expected while process is alive
                            }
                            try {
                                Thread.sleep(100);
                            } catch (InterruptedException e) {
                            }
                        }

                        Exception ex = runnable.getException();
                        if (ex instanceof IllegalConnectorArgumentsException)                         {
                            throw (IllegalConnectorArgumentsException)ex;
                        }
                        if (ex instanceof InterruptedIOException) {
                            throw (InterruptedIOException)ex;
                        }
                        if (ex instanceof IOException) {
                            throw (IOException)ex;
                        }

                        VirtualMachine vm= runnable.getVirtualMachine();
                        if (vm != null) {
                            DroolsDebugModel.newDebugTarget(launch, vm, renderDebugTarget(config.getClassToLaunch(), port), process, true, false, config.isResumeOnStartup());
                            subMonitor.worked(1);
                            subMonitor.done();
                        }
                        return;
                    } catch (InterruptedIOException e) {
                        checkErrorMessage(process);

                        // timeout, consult status handler if there is one
                        IStatus status = new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), IJavaLaunchConfigurationConstants.ERR_VM_CONNECT_TIMEOUT, "", e); //$NON-NLS-1$
                        IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);

                        retry= false;
                        if (handler == null) {
                            // if there is no handler, throw the exception
                            throw new CoreException(status);
                        }
                        Object result = handler.handleStatus(status, this);
                        if (result instanceof Boolean) {
                            retry = ((Boolean)result).booleanValue();
                        }
                    }
                } while (retry);
            } finally {
                connector.stopListening(map);
            }
        } catch (IOException e) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_connect_to_VM_4, e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED);
        } catch (IllegalConnectorArgumentsException e) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_connect_to_VM_5, e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED);
View Full Code Here


    }

    protected ListeningConnector getConnector() {
        List connectors= Bootstrap.virtualMachineManager().listeningConnectors();
        for (int i= 0; i < connectors.size(); i++) {
            ListeningConnector c= (ListeningConnector) connectors.get(i);
            if ("com.sun.jdi.SocketListen".equals(c.name())) //$NON-NLS-1$
                return c;
        }
        return null;
    }
View Full Code Here

        }

        subMonitor.worked(1);
        subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Starting_virtual_machine____4);

        ListeningConnector connector= getConnector();
        if (connector == null) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_find_an_appropriate_debug_connector_2, null, IJavaLaunchConfigurationConstants.ERR_CONNECTOR_NOT_AVAILABLE);
        }
        Map<String, Argument> map= connector.defaultArguments();

        specifyArguments(map, port);
        Process p= null;
        try {
            try {
                // check for cancellation
                if (monitor.isCanceled()) {
                    return;
                }

                connector.startListening(map);

                File workingDir = getWorkingDir(config);
                p = exec(cmdLine, workingDir, envp);
                if (p == null) {
                    return;
                }

                // check for cancellation
                if (monitor.isCanceled()) {
                    p.destroy();
                    return;
                }
                java.util.Date date= new java.util.Date();
                Timestamp ts = new Timestamp(date.getTime());
                String format= LaunchingMessages.StandardVMRunner__0____1___2;
            String label = NLS.bind(format, new String[] { cmdLine[0], ts.toString() });
                IProcess process= newProcess(launch, p, label, getDefaultProcessMap());
                process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLineInternal(cmdLine));
                subMonitor.worked(1);
                subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Establishing_debug_connection____5);
                boolean retry= false;
                do  {
                    try {

                        ConnectRunnable runnable = new ConnectRunnable(connector, map);
                        Thread connectThread = new Thread(runnable, "Listening Connector"); //$NON-NLS-1$
                        connectThread.setDaemon(true);
                        connectThread.start();
                        while (connectThread.isAlive()) {
                            if (monitor.isCanceled()) {
                                connector.stopListening(map);
                                p.destroy();
                                return;
                            }
                            try {
                                p.exitValue();
                                // process has terminated - stop waiting for a connection
                                try {
                                    connector.stopListening(map);
                                } catch (IOException e) {
                                    // expected
                                }
                                checkErrorMessage(process);
                            } catch (IllegalThreadStateException e) {
                                // expected while process is alive
                            }
                            try {
                                Thread.sleep(100);
                            } catch (InterruptedException e) {
                            }
                        }

                        Exception ex = runnable.getException();
                        if (ex instanceof IllegalConnectorArgumentsException)                         {
                            throw (IllegalConnectorArgumentsException)ex;
                        }
                        if (ex instanceof InterruptedIOException) {
                            throw (InterruptedIOException)ex;
                        }
                        if (ex instanceof IOException) {
                            throw (IOException)ex;
                        }

                        VirtualMachine vm= runnable.getVirtualMachine();
                        if (vm != null) {
                            DroolsDebugModel.newDebugTarget(launch, vm, renderDebugTarget(config.getClassToLaunch(), port), process, true, false, config.isResumeOnStartup());
                            subMonitor.worked(1);
                            subMonitor.done();
                        }
                        return;
                    } catch (InterruptedIOException e) {
                        checkErrorMessage(process);

                        // timeout, consult status handler if there is one
                        IStatus status = new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), IJavaLaunchConfigurationConstants.ERR_VM_CONNECT_TIMEOUT, "", e); //$NON-NLS-1$
                        IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);

                        retry= false;
                        if (handler == null) {
                            // if there is no handler, throw the exception
                            throw new CoreException(status);
                        }
                        Object result = handler.handleStatus(status, this);
                        if (result instanceof Boolean) {
                            retry = ((Boolean)result).booleanValue();
                        }
                    }
                } while (retry);
            } finally {
                connector.stopListening(map);
            }
        } catch (IOException e) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_connect_to_VM_4, e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED);
        } catch (IllegalConnectorArgumentsException e) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_connect_to_VM_5, e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED);
View Full Code Here

    }

    protected ListeningConnector getConnector() {
        List<ListeningConnector> connectors= Bootstrap.virtualMachineManager().listeningConnectors();
        for (int i= 0; i < connectors.size(); i++) {
            ListeningConnector c= connectors.get(i);
            if ("com.sun.jdi.SocketListen".equals(c.name())) //$NON-NLS-1$
                return c;
        }
        return null;
    }
View Full Code Here

      process = Runtime.getRuntime().exec(cmd.toString(),null,workingDir);
    } catch (Exception err) {
      err.printStackTrace();
    }
   
    ListeningConnector connector = getListeningConnector();
    Map<String, Connector.Argument> connectArgs = connector.defaultArguments();
    Connector.Argument portArg = connectArgs.get("port");
    Connector.Argument hostArg = connectArgs.get("localAddress");
    portArg.setValue(port);
    hostArg.setValue("localhost");
    try {
      vm = connector.accept(connectArgs);
      startProcess();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "";
View Full Code Here

      process = Runtime.getRuntime().exec(cmd.toString(),null,workingDir);
    } catch (Exception err) {
      err.printStackTrace();
    }
   
    ListeningConnector connector = getListeningConnector();
    Map<String, Connector.Argument> connectArgs = connector.defaultArguments();
    Connector.Argument portArg = connectArgs.get("port");
    Connector.Argument hostArg = connectArgs.get("localAddress");
    portArg.setValue(port);
    hostArg.setValue("localhost");
    try {
      return connector.accept(connectArgs);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
View Full Code Here

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

        }

        subMonitor.worked(1);
        subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Starting_virtual_machine____4);

        ListeningConnector connector= getConnector();
        if (connector == null) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_find_an_appropriate_debug_connector_2, null, IJavaLaunchConfigurationConstants.ERR_CONNECTOR_NOT_AVAILABLE);
        }
        Map map= connector.defaultArguments();

        specifyArguments(map, port);
        Process p= null;
        try {
            try {
                // check for cancellation
                if (monitor.isCanceled()) {
                    return;
                }

                connector.startListening(map);

                File workingDir = getWorkingDir(config);
                p = exec(cmdLine, workingDir, envp);
                if (p == null) {
                    return;
                }

                // check for cancellation
                if (monitor.isCanceled()) {
                    p.destroy();
                    return;
                }

                IProcess process= newProcess(launch, p, renderProcessLabel(cmdLine), getDefaultProcessMap());
                process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLineInternal(cmdLine));
                subMonitor.worked(1);
                subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Establishing_debug_connection____5);
                boolean retry= false;
                do  {
                    try {

                        ConnectRunnable runnable = new ConnectRunnable(connector, map);
                        Thread connectThread = new Thread(runnable, "Listening Connector"); //$NON-NLS-1$
                        connectThread.setDaemon(true);
                        connectThread.start();
                        while (connectThread.isAlive()) {
                            if (monitor.isCanceled()) {
                                connector.stopListening(map);
                                p.destroy();
                                return;
                            }
                            try {
                                p.exitValue();
                                // process has terminated - stop waiting for a connection
                                try {
                                    connector.stopListening(map);
                                } catch (IOException e) {
                                    // expected
                                }
                                checkErrorMessage(process);
                            } catch (IllegalThreadStateException e) {
                                // expected while process is alive
                            }
                            try {
                                Thread.sleep(100);
                            } catch (InterruptedException e) {
                            }
                        }

                        Exception ex = runnable.getException();
                        if (ex instanceof IllegalConnectorArgumentsException)                         {
                            throw (IllegalConnectorArgumentsException)ex;
                        }
                        if (ex instanceof InterruptedIOException) {
                            throw (InterruptedIOException)ex;
                        }
                        if (ex instanceof IOException) {
                            throw (IOException)ex;
                        }

                        VirtualMachine vm= runnable.getVirtualMachine();
                        if (vm != null) {
                            DroolsDebugModel.newDebugTarget(launch, vm, renderDebugTarget(config.getClassToLaunch(), port), process, true, false, config.isResumeOnStartup());
                            subMonitor.worked(1);
                            subMonitor.done();
                        }
                        return;
                    } catch (InterruptedIOException e) {
                        checkErrorMessage(process);

                        // timeout, consult status handler if there is one
                        IStatus status = new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), IJavaLaunchConfigurationConstants.ERR_VM_CONNECT_TIMEOUT, "", e); //$NON-NLS-1$
                        IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);

                        retry= false;
                        if (handler == null) {
                            // if there is no handler, throw the exception
                            throw new CoreException(status);
                        }
                        Object result = handler.handleStatus(status, this);
                        if (result instanceof Boolean) {
                            retry = ((Boolean)result).booleanValue();
                        }
                    }
                } while (retry);
            } finally {
                connector.stopListening(map);
            }
        } catch (IOException e) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_connect_to_VM_4, e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED);
        } catch (IllegalConnectorArgumentsException e) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_connect_to_VM_5, e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED);
View Full Code Here

    }

    protected ListeningConnector getConnector() {
        List connectors= Bootstrap.virtualMachineManager().listeningConnectors();
        for (int i= 0; i < connectors.size(); i++) {
            ListeningConnector c= (ListeningConnector) connectors.get(i);
            if ("com.sun.jdi.SocketListen".equals(c.name())) //$NON-NLS-1$
                return c;
        }
        return null;
    }
View Full Code Here

        }

        subMonitor.worked(1);
        subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Starting_virtual_machine____4);

        ListeningConnector connector= getConnector();
        if (connector == null) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_find_an_appropriate_debug_connector_2, null, IJavaLaunchConfigurationConstants.ERR_CONNECTOR_NOT_AVAILABLE);
        }
        Map map= connector.defaultArguments();

        specifyArguments(map, port);
        Process p= null;
        try {
            try {
                // check for cancellation
                if (monitor.isCanceled()) {
                    return;
                }

                connector.startListening(map);

                File workingDir = getWorkingDir(config);
                p = exec(cmdLine, workingDir, envp);
                if (p == null) {
                    return;
                }

                // check for cancellation
                if (monitor.isCanceled()) {
                    p.destroy();
                    return;
                }
                java.util.Date date= new java.util.Date();
                Timestamp ts = new Timestamp(date.getTime());
                IProcess process= newProcess(launch, p, renderProcessLabel(cmdLine), getDefaultProcessMap());
                process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLineInternal(cmdLine));
                subMonitor.worked(1);
                subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Establishing_debug_connection____5);
                boolean retry= false;
                do  {
                    try {

                        ConnectRunnable runnable = new ConnectRunnable(connector, map);
                        Thread connectThread = new Thread(runnable, "Listening Connector"); //$NON-NLS-1$
                        connectThread.setDaemon(true);
                        connectThread.start();
                        while (connectThread.isAlive()) {
                            if (monitor.isCanceled()) {
                                connector.stopListening(map);
                                p.destroy();
                                return;
                            }
                            try {
                                p.exitValue();
                                // process has terminated - stop waiting for a connection
                                try {
                                    connector.stopListening(map);
                                } catch (IOException e) {
                                    // expected
                                }
                                checkErrorMessage(process);
                            } catch (IllegalThreadStateException e) {
                                // expected while process is alive
                            }
                            try {
                                Thread.sleep(100);
                            } catch (InterruptedException e) {
                            }
                        }

                        Exception ex = runnable.getException();
                        if (ex instanceof IllegalConnectorArgumentsException)                         {
                            throw (IllegalConnectorArgumentsException)ex;
                        }
                        if (ex instanceof InterruptedIOException) {
                            throw (InterruptedIOException)ex;
                        }
                        if (ex instanceof IOException) {
                            throw (IOException)ex;
                        }

                        VirtualMachine vm= runnable.getVirtualMachine();
                        if (vm != null) {
                            DroolsDebugModel.newDebugTarget(launch, vm, renderDebugTarget(config.getClassToLaunch(), port), process, true, false, config.isResumeOnStartup());
                            subMonitor.worked(1);
                            subMonitor.done();
                        }
                        return;
                    } catch (InterruptedIOException e) {
                        checkErrorMessage(process);

                        // timeout, consult status handler if there is one
                        IStatus status = new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), IJavaLaunchConfigurationConstants.ERR_VM_CONNECT_TIMEOUT, "", e); //$NON-NLS-1$
                        IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);

                        retry= false;
                        if (handler == null) {
                            // if there is no handler, throw the exception
                            throw new CoreException(status);
                        }
                        Object result = handler.handleStatus(status, this);
                        if (result instanceof Boolean) {
                            retry = ((Boolean)result).booleanValue();
                        }
                    }
                } while (retry);
            } finally {
                connector.stopListening(map);
            }
        } catch (IOException e) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_connect_to_VM_4, e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED);
        } catch (IllegalConnectorArgumentsException e) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_connect_to_VM_5, e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED);
View Full Code Here

TOP

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

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.