Beispiel #1
0
 /**
  * Attach to a JVM that is already running at specified host.
  *
  * @throws DebuggerException when connection to Java VM is not established
  */
 private void connect() throws DebuggerException {
   final String connectorName = "com.sun.jdi.SocketAttach";
   AttachingConnector connector = connector(connectorName);
   if (connector == null) {
     throw new DebuggerException(
         String.format(
             "Unable connect to target Java VM. Requested connector '%s' not found. ",
             connectorName));
   }
   Map<String, Connector.Argument> arguments = connector.defaultArguments();
   arguments.get("hostname").setValue(host);
   ((Connector.IntegerArgument) arguments.get("port")).setValue(port);
   int attempt = 0;
   for (; ; ) {
     try {
       Thread.sleep(2000);
       vm = connector.attach(arguments);
       vm.suspend();
       break;
     } catch (UnknownHostException | IllegalConnectorArgumentsException e) {
       throw new DebuggerException(e.getMessage(), e);
     } catch (IOException e) {
       LOG.error(e.getMessage(), e);
       if (++attempt > 10) {
         throw new DebuggerException(e.getMessage(), e);
       }
       try {
         Thread.sleep(2000);
       } catch (InterruptedException ignored) {
       }
     } catch (InterruptedException ignored) {
     }
   }
   eventsCollector = new EventsCollector(vm.eventQueue(), this);
   LOG.debug("Connect {}:{}", host, port);
 }
 @Override
 public EventQueue eventQueue() {
   return virtualMachine.eventQueue();
 }
Beispiel #3
0
 public EventQueue eventQueue() {
   return myVirtualMachine.eventQueue();
 }