use of com.swiftmq.swiftlet.net.event.ConnectionListener in project swiftmq-ce by iitsoftware.
the class IntraVMScheduler method connectListener.
public synchronized void connectListener(String swiftletName, IntraVMConnection clientConnection) throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$net", toString() + "/connectListener: swiftletName=" + swiftletName + ", clientConnection=" + clientConnection);
IntraVMListenerMetaData metaData = (IntraVMListenerMetaData) listeners.get(swiftletName);
if (metaData == null)
throw new Exception("No intra-VM listener found for Swiftlet '" + swiftletName + "'");
IntraVMServerEndpointImpl connection = new IntraVMServerEndpointImpl(ctx, clientConnection);
try {
ConnectionListener connectionListener = metaData.getConnectionListener();
connection.setConnectionListener(connectionListener);
connection.setMetaData(metaData);
connectionListener.connected(connection);
ctx.networkSwiftlet.getConnectionManager().addConnection(connection);
} catch (ConnectionVetoException cve) {
connection.close();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$net", toString() + "/ConnectionVetoException: " + cve.getMessage());
ctx.logSwiftlet.logError("sys$net", toString() + "/ConnectionVetoException: " + cve.getMessage());
throw new Exception(cve.getMessage());
}
ctx.logSwiftlet.logInformation("sys$net", toString() + "/connection accepted: " + connection);
}
use of com.swiftmq.swiftlet.net.event.ConnectionListener in project swiftmq-ce by iitsoftware.
the class NettyOutboundConnectionHandler method activate.
private void activate() throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$net", toString() + "/activate");
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$net", toString() + "/registerConnection");
ConnectionListener connectionListener = metaData.getConnectionListener();
connection.setConnectionListener(connectionListener);
connection.setMetaData(metaData);
connectionListener.connected(connection);
ctx.networkSwiftlet.getConnectionManager().addConnection(connection);
ctx.logSwiftlet.logInformation(super.toString(), "connection created: " + connection.toString());
inputHandler = metaData.createProtocolInputHandler();
connection.setProtocolInputHandler(inputHandler);
inputHandler.setChunkListener(this);
inputHandler.createInputBuffer(metaData.getInputBufferSize(), metaData.getInputExtendSize());
inboundHandler = connection.getInboundHandler();
countableInput = (Countable) connection.getInputStream();
activated = true;
}
use of com.swiftmq.swiftlet.net.event.ConnectionListener in project swiftmq-ce by iitsoftware.
the class NettyTCPListener method setupConnection.
private NettyConnection setupConnection(SocketChannel ch) throws Exception {
if (ctx.networkSwiftlet.isDnsResolve() && !getMetaData().isConnectionAllowed(ch.remoteAddress().getHostName())) {
String msg = "connection NOT allowed, REJECTED: " + ch.remoteAddress().getHostName();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$net", toString() + "/" + msg);
ctx.logSwiftlet.logError(toString(), msg);
throw new Exception(msg);
}
NettyConnection connection = new NettyConnection(ctx, ch, ctx.networkSwiftlet.isDnsResolve());
ConnectionListener connectionListener = getMetaData().getConnectionListener();
connection.setConnectionListener(connectionListener);
connection.setMetaData(getMetaData());
connectionListener.connected(connection);
ctx.networkSwiftlet.getConnectionManager().addConnection(connection);
ctx.logSwiftlet.logInformation(super.toString(), "connection accepted: " + connection.toString());
return connection;
}
Aggregations