当前位置: 首页>>代码示例>>Java>>正文


Java Connection类代码示例

本文整理汇总了Java中com.sun.jdi.connect.spi.Connection的典型用法代码示例。如果您正苦于以下问题:Java Connection类的具体用法?Java Connection怎么用?Java Connection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Connection类属于com.sun.jdi.connect.spi包,在下文中一共展示了Connection类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createVirtualMachine

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
public synchronized VirtualMachine createVirtualMachine(
                                    Connection connection,
                                    Process process) throws IOException {

    if (!connection.isOpen()) {
        throw new IllegalStateException("connection is not open");
    }

    VirtualMachine vm;
    try {
        vm = new VirtualMachineImpl(this, connection, process,
                                               ++vmSequenceNumber);
    } catch (VMDisconnectedException e) {
        throw new IOException(e.getMessage());
    }
    targets.add(vm);
    return vm;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:VirtualMachineManagerImpl.java

示例2: accept

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
@Override
public Connection accept(ListenKey listenKey, long attachTimeout, long handshakeTimeout) throws IOException {
	if (attachTimeout > 0) {
		if (attachTimeout > Integer.MAX_VALUE) {
			attachTimeout = Integer.MAX_VALUE; // approx 25 days!
		}
		fServerSocket.setSoTimeout((int) attachTimeout);
	}
	Socket socket;
	try {
		socket = fServerSocket.accept();
	} catch (SocketTimeoutException e) {
		throw new TransportTimeoutException();
	}
	InputStream input = socket.getInputStream();
	OutputStream output = socket.getOutputStream();
	performHandshake(input, output, handshakeTimeout);
	return new SocketConnection(socket, input, output);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:20,代码来源:SocketTransportService.java

示例3: TargetVM

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
TargetVM(VirtualMachineImpl vm, Connection connection) {
    this.vm = vm;
    this.connection = connection;
    this.readerThread = new Thread(vm.threadGroupForJDI(),
                                   this, "JDI Target VM Interface");
    this.readerThread.setDaemon(true);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:TargetVM.java

示例4: launch

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:35,代码来源:SimpleLaunchingConnector.java

示例5: attach

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
/**
 * Attach to a target VM using the specified address and Connector arguments.
 */
public VirtualMachine attach(String address, Map<String, ? extends Connector.Argument> args)
    throws IOException, IllegalConnectorArgumentsException
{
    String ts  = argument(ARG_TIMEOUT, args).value();
    int timeout = 0;
    if (ts.length() > 0) {
        timeout = Integer.decode(ts).intValue();
    }
    Connection connection = transportService.attach(address, timeout, 0);
    return Bootstrap.virtualMachineManager().createVirtualMachine(connection);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:GenericAttachingConnector.java

示例6: attach

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
@Override
public Connection attach(String address, long attachTimeout, long handshakeTimeout) throws IOException {
	String[] strings = address.split(":"); //$NON-NLS-1$
	String host = "localhost"; //$NON-NLS-1$
	int port = 0;
	if (strings.length == 2) {
		host = strings[0];
		port = Integer.parseInt(strings[1]);
	} else {
		port = Integer.parseInt(strings[0]);
	}

	return attach(host, port, attachTimeout, handshakeTimeout);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:15,代码来源:SocketTransportService.java

示例7: VirtualMachineImpl

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
VirtualMachineImpl(VirtualMachineManager manager,
                   Connection connection, Process process,
                   int sequenceNumber) {
    super(null);  // Can't use super(this)
    vm = this;

    this.vmManager = (VirtualMachineManagerImpl)manager;
    this.process = process;
    this.sequenceNumber = sequenceNumber;

    /* Create ThreadGroup to be used by all threads servicing
     * this VM.
     */
    threadGroupForJDI = new ThreadGroup(vmManager.mainGroupForJDI(),
                                        "JDI [" +
                                        this.hashCode() + "]");

    /*
     * Set up a thread to communicate with the target VM over
     * the specified transport.
     */
    target = new TargetVM(this, connection);

    /*
     * Set up a thread to handle events processed internally
     * the JDI implementation.
     */
    EventQueueImpl internalEventQueue = new EventQueueImpl(this, target);
    new InternalEventHandler(this, internalEventQueue);
    /*
     * Initialize client access to event setting and handling
     */
    eventQueue = new EventQueueImpl(this, target);
    eventRequestManager = new EventRequestManagerImpl(this);

    target.start();

    /*
     * Many ids are variably sized, depending on target VM.
     * Find out the sizes right away.
     */
    JDWP.VirtualMachine.IDSizes idSizes;
    try {
        idSizes = JDWP.VirtualMachine.IDSizes.process(vm);
    } catch (JDWPException exc) {
        throw exc.toJDIException();
    }
    sizeofFieldRef  = idSizes.fieldIDSize;
    sizeofMethodRef = idSizes.methodIDSize;
    sizeofObjectRef = idSizes.objectIDSize;
    sizeofClassRef = idSizes.referenceTypeIDSize;
    sizeofFrameRef  = idSizes.frameIDSize;

    /**
     * Set up requests needed by internal event handler.
     * Make sure they are distinguished by creating them with
     * an internal event request manager.
     *
     * Warning: create events only with SUSPEND_NONE policy.
     * In the current implementation other policies will not
     * be handled correctly when the event comes in. (notfiySuspend()
     * will not be properly called, and if the event is combined
     * with external events in the same set, suspend policy is not
     * correctly determined for the internal vs. external event sets)
     */
    internalEventRequestManager = new EventRequestManagerImpl(this);
    EventRequest er = internalEventRequestManager.createClassPrepareRequest();
    er.setSuspendPolicy(EventRequest.SUSPEND_NONE);
    er.enable();
    er = internalEventRequestManager.createClassUnloadRequest();
    er.setSuspendPolicy(EventRequest.SUSPEND_NONE);
    er.enable();

    /*
     * Tell other threads, notably TargetVM, that initialization
     * is complete.
     */
    notifyInitCompletion();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:80,代码来源:VirtualMachineImpl.java

示例8: accept

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
/**
 * Accept a connection from a debuggee and handshake with it.
 */
public Connection accept(ListenKey listener, long acceptTimeout, long handshakeTimeout) throws IOException {
    if (acceptTimeout < 0 || handshakeTimeout < 0) {
        throw new IllegalArgumentException("timeout is negative");
    }
    if (!(listener instanceof SocketListenKey)) {
        throw new IllegalArgumentException("Invalid listener");
    }
    ServerSocket ss;

    // obtain the ServerSocket from the listener - if the
    // socket is closed it means the listener is invalid
    synchronized (listener) {
        ss = ((SocketListenKey)listener).socket();
        if (ss.isClosed()) {
           throw new IllegalArgumentException("Invalid listener");
        }
    }

    // from here onwards it's possible that the ServerSocket
    // may be closed by a call to stopListening - that's okay
    // because the ServerSocket methods will throw an
    // IOException indicating the socket is closed.
    //
    // Additionally, it's possible that another thread calls accept
    // with a different accept timeout - that creates a same race
    // condition between setting the timeout and calling accept.
    // As it is such an unlikely scenario (requires both threads
    // to be using the same listener we've chosen to ignore the issue).

    ss.setSoTimeout((int)acceptTimeout);
    Socket s;
    try {
        s = ss.accept();
    } catch (SocketTimeoutException x) {
        throw new TransportTimeoutException("timeout waiting for connection");
    }

    // handshake here
    handshake(s, handshakeTimeout);

    return new SocketConnection(s);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:46,代码来源:SocketTransportService.java

示例9: connection

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
Connection connection() {
    return connection;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:AbstractLauncher.java

示例10: notifyOfConnection

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
synchronized void notifyOfConnection(Connection connection) {
    this.connection = connection;
    notify();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:AbstractLauncher.java

示例11: VirtualMachineImpl

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
VirtualMachineImpl(VirtualMachineManager manager,
                   Connection connection, Process process,
                   int sequenceNumber) {
    super(null);  // Can't use super(this)
    vm = this;

    this.vmManager = (VirtualMachineManagerImpl)manager;
    this.process = process;
    this.sequenceNumber = sequenceNumber;

    /* Create ThreadGroup to be used by all threads servicing
     * this VM.
     */
    threadGroupForJDI = new ThreadGroup(vmManager.mainGroupForJDI(),
                                        "JDI [" +
                                        this.hashCode() + "]");

    /*
     * Set up a thread to communicate with the target VM over
     * the specified transport.
     */
    target = new TargetVM(this, connection);

    /*
     * Set up a thread to handle events processed internally
     * the JDI implementation.
     */
    EventQueueImpl internalEventQueue = new EventQueueImpl(this, target);
    new InternalEventHandler(this, internalEventQueue);
    /*
     * Initialize client access to event setting and handling
     */
    eventQueue = new EventQueueImpl(this, target);
    eventRequestManager = new EventRequestManagerImpl(this);

    target.start();

    /*
     * Many ids are variably sized, depending on target VM.
     * Find out the sizes right away.
     */
    JDWP.VirtualMachine.IDSizes idSizes;
    try {
        idSizes = JDWP.VirtualMachine.IDSizes.process(vm);
    } catch (JDWPException exc) {
        throw exc.toJDIException();
    }
    sizeofFieldRef  = idSizes.fieldIDSize;
    sizeofMethodRef = idSizes.methodIDSize;
    sizeofObjectRef = idSizes.objectIDSize;
    sizeofClassRef = idSizes.referenceTypeIDSize;
    sizeofFrameRef  = idSizes.frameIDSize;
    sizeofModuleRef = idSizes.objectIDSize;

    /**
     * Set up requests needed by internal event handler.
     * Make sure they are distinguished by creating them with
     * an internal event request manager.
     *
     * Warning: create events only with SUSPEND_NONE policy.
     * In the current implementation other policies will not
     * be handled correctly when the event comes in. (notfiySuspend()
     * will not be properly called, and if the event is combined
     * with external events in the same set, suspend policy is not
     * correctly determined for the internal vs. external event sets)
     */
    internalEventRequestManager = new EventRequestManagerImpl(this);
    EventRequest er = internalEventRequestManager.createClassPrepareRequest();
    er.setSuspendPolicy(EventRequest.SUSPEND_NONE);
    er.enable();
    er = internalEventRequestManager.createClassUnloadRequest();
    er.setSuspendPolicy(EventRequest.SUSPEND_NONE);
    er.enable();

    /*
     * Tell other threads, notably TargetVM, that initialization
     * is complete.
     */
    notifyInitCompletion();
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:81,代码来源:VirtualMachineImpl.java

示例12: attach

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
public Connection attach(String hostname, int port, long attachTimeout, long handshakeTimeout) throws IOException {
	return service.attach(hostname, port, attachTimeout, handshakeTimeout);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:4,代码来源:SocketTransportImpl.java

示例13: accept

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
public Connection accept(long attachTimeout, long handshakeTimeout) throws IOException {
	return service.accept(fListenKey, attachTimeout, handshakeTimeout);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:4,代码来源:SocketTransportImpl.java

示例14: createVirtualMachine

import com.sun.jdi.connect.spi.Connection; //导入依赖的package包/类
public VirtualMachine createVirtualMachine(Connection connection, 
        Process process) throws IOException {
    VirtualMachineManager pvmm = Bootstrap.virtualMachineManager();
    return F3Wrapper.wrap(pvmm.createVirtualMachine(connection, process));
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:6,代码来源:F3Bootstrap.java


注:本文中的com.sun.jdi.connect.spi.Connection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。