/**
* @return new VMTransport
* @throws IOException
*/
public VMTransport connect() throws IOException {
TransportAcceptListener al;
synchronized (this) {
if (disposed) {
throw new IOException("Server has been disposed.");
}
al = acceptListener;
}
if (al == null) {
throw new IOException("Server TransportAcceptListener is null.");
}
connectionCount.incrementAndGet();
VMTransport client = new VMTransport(location) {
public void stop() throws Exception {
if (disposed) {
return;
}
super.stop();
if (connectionCount.decrementAndGet() == 0 && disposeOnDisconnect) {
VMTransportServer.this.stop();
}
};
};
VMTransport server = new VMTransport(location);
client.setPeer(server);
server.setPeer(client);
al.onAccept(configure(server));
return client;
}