com.sun.jdi.connect.ListeningConnector Java Examples

The following examples show how to use com.sun.jdi.connect.ListeningConnector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AcceptTimeout.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #2
Source File: AcceptTimeout.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #3
Source File: AcceptTimeout.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #4
Source File: AcceptTimeout.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #5
Source File: AcceptTimeout.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #6
Source File: AcceptTimeout.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #7
Source File: AcceptTimeout.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #8
Source File: AcceptTimeout.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #9
Source File: AcceptTimeout.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #10
Source File: AcceptTimeout.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #11
Source File: AcceptTimeout.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #12
Source File: JPDADebugger.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * This utility method helps to start a new JPDA debugger session.
 * Its implementation use {@link ListeningDICookie} and
 * {@link org.netbeans.api.debugger.DebuggerManager#getDebuggerManager}.
 * It's identical to {@link #startListening(com.sun.jdi.connect.ListeningConnector, java.util.Map, java.lang.Object[])},
 * but returns the started engines.
 *
 * @param connector The listening connector
 * @param args The arguments
 * @param services The additional services, which are added to the debugger session lookup.<br/>
 * See {@link #listen(com.sun.jdi.connect.ListeningConnector, java.util.Map, java.lang.Object[])} for a more detailed description of this argument.
 * @return A non-empty array of started engines (since 2.26)
 * @throws DebuggerStartException when {@link org.netbeans.api.debugger.DebuggerManager#startDebugging}
 * returns an empty array
 * @since 2.26
 */
public static DebuggerEngine[] startListeningAndGetEngines (
    ListeningConnector        connector,
    Map<String, ? extends Argument>  args,
    Object[]                  services
) throws DebuggerStartException {
    Object[] s = new Object [services.length + 1];
    System.arraycopy (services, 0, s, 1, services.length);
    s [0] = ListeningDICookie.create (
        connector,
        args
    );
    DebuggerEngine[] es = DebuggerManager.getDebuggerManager ().
        startDebugging (
            DebuggerInfo.create (
                ListeningDICookie.ID,
                s
            )
        );
    if (es.length == 0) {
        throw new DebuggerStartException(
                NbBundle.getMessage(JPDADebugger.class, "MSG_NO_DEBUGGER"));
    }
    return es;
}
 
Example #13
Source File: AcceptTimeout.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #14
Source File: AcceptTimeout.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
 
Example #15
Source File: ListeningDICookie.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Map<String, ? extends Argument> getArgs (
    ListeningConnector listeningConnector,
    String name
) {
    Map<String, ? extends Argument> args = listeningConnector.defaultArguments ();
    args.get ("name").setValue (name);
    return args;
}
 
Example #16
Source File: ListeningDICookie.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Map<String, ? extends Argument> getArgs (
    ListeningConnector listeningConnector,
    int portNumber
) {
    Map<String, ? extends Argument> args = listeningConnector.defaultArguments ();
    args.get ("port").setValue (portNumber > 0 ? "" + portNumber : "");
    return args;
}
 
Example #17
Source File: JPDAStart.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Searching for a connector in given collection.
 * @param name - name of the connector
 * @param connectors
 * @return the connector or null
 */
private static ListeningConnector findConnector(String name, final Collection<ListeningConnector> connectors) {
    assert name != null;
    for (ListeningConnector c : connectors) {
        if (name.equals(c.name())) {
            return c;
        }
    }
    return null;
}
 
Example #18
Source File: ListeningDICookie.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static ListeningConnector findListeningConnector (String s) {
    Iterator iter = Bootstrap.virtualMachineManager ().
        listeningConnectors ().iterator ();
    while (iter.hasNext ()) {
        ListeningConnector ac = (ListeningConnector) iter.next ();
        if (ac.transport() != null && ac.transport ().name ().toLowerCase ().indexOf (s) > -1)
            return ac;
    }
    return null;
}
 
Example #19
Source File: ListeningDICookie.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of ListeningDICookie for given parameters.
 *
 * @param listeningConnector a instance of ListeningConnector
 * @param args arguments to be used
 * @return a new instance of ListeningDICookie for given parameters
 */
public static ListeningDICookie create (
    ListeningConnector listeningConnector,
    Map<String, ? extends Argument> args
) {
    return new ListeningDICookie (
        listeningConnector,
        args
    );
}
 
Example #20
Source File: ListeningDICookie.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private ListeningDICookie (
    ListeningConnector listeningConnector,
    Map<String, ? extends Argument> args
) {
    this.listeningConnector = listeningConnector;
    this.args = args;
}
 
Example #21
Source File: JPDADebugger.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * This utility method helps to start a new JPDA debugger session. 
 * Its implementation use {@link ListeningDICookie} and 
 * {@link org.netbeans.api.debugger.DebuggerManager#getDebuggerManager}.
 *
 * @param connector The listening connector
 * @param args The arguments
 * @param services The additional services, which are added to the debugger session lookup.<br/>
 * It is expected, that one element in the services array is a {@link Map} with following setup properties:<br/>
 * <lu>
 * <li><code>name</code> with the value being the session name as String,</li>
 * <li><code>sourcepath</code> with the {@link ClassPath} value containing class path of sources used by debugger,</li>
 * <li><code>jdksources</code> with the {@link ClassPath} value containing class path of platform sources,</li>
 * <li><code>listeningCP</code> optional String representation of source class path which is in compile-on-save mode, which we listen on for artifacts changes,</li>
 * <li><code>baseDir</code> with the debugging project's base directory as {@link File}.</li>
 * </lu>
 */
public static JPDADebugger listen (
    ListeningConnector        connector,
    Map<String, ? extends Argument>  args,
    Object[]                  services
) throws DebuggerStartException {
    Object[] s = new Object [services.length + 1];
    System.arraycopy (services, 0, s, 1, services.length);
    s [0] = ListeningDICookie.create (
        connector,
        args
    );
    DebuggerEngine[] es = DebuggerManager.getDebuggerManager ().
        startDebugging (
            DebuggerInfo.create (
                ListeningDICookie.ID,
                s
            )
        );
    int i, k = es.length;
    for (i = 0; i < k; i++) {
        JPDADebugger d = es[i].lookupFirst(null, JPDADebugger.class);
        if (d == null) {
            continue;
        }
        d.waitRunning ();
        return d;
    }
    throw new DebuggerStartException(
            NbBundle.getMessage(JPDADebugger.class, "MSG_NO_DEBUGGER"));
}
 
Example #22
Source File: StandardScriptVMRunner.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private 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;
}
 
Example #23
Source File: JPDADebugger.java    From netbeans with Apache License 2.0 3 votes vote down vote up
/**
 * This utility method helps to start a new JPDA debugger session. 
 * Its implementation use {@link ListeningDICookie} and 
 * {@link org.netbeans.api.debugger.DebuggerManager#getDebuggerManager}.
 *
 * @param connector The listening connector
 * @param args The arguments
 * @param services The additional services, which are added to the debugger session lookup.<br/>
 * See {@link #listen(com.sun.jdi.connect.ListeningConnector, java.util.Map, java.lang.Object[])} for a more detailed description of this argument.
 * @throws DebuggerStartException when {@link org.netbeans.api.debugger.DebuggerManager#startDebugging}
 * returns an empty array
 */
public static void startListening (
    ListeningConnector        connector,
    Map<String, ? extends Argument>  args,
    Object[]                  services
) throws DebuggerStartException {
    startListeningAndGetEngines(connector, args, services);
}
 
Example #24
Source File: StandardScriptVMRunner.java    From birt with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Constructs a runnable to connect to a VM via the given connector with
 * the given connection arguments.
 * 
 * @param connector
 * @param map
 */
public ConnectRunnable( ListeningConnector connector, Map map )
{
	fConnector = connector;
	fConnectionMap = map;
}
 
Example #25
Source File: ListeningDICookie.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Returns instance of ListeningConnector.
 *
 * @return instance of ListeningConnector
 */
public ListeningConnector getListeningConnector () {
    return listeningConnector;
}