public Object handleCreateConnectionDelegate(Invocation inv) throws Throwable
{
CreateConnectionResult res = (CreateConnectionResult)inv.invokeNext();
ClientConnectionDelegate connectionDelegate = (ClientConnectionDelegate)res.getDelegate();
if (connectionDelegate != null && connectionDelegate.getState() == null)
{
// no state set yet, initialize and configure it
if(trace) { log.trace(connectionDelegate + " not configured, configuring ..."); }
int serverID = connectionDelegate.getServerID();
Version versionToUse = connectionDelegate.getVersionToUse();
JMSRemotingConnection remotingConnection = connectionDelegate.getRemotingConnection();
// install the consolidated remoting connection listener; it will be de-installed on
// connection closing by ConnectionAspect
ConsolidatedRemotingConnectionListener listener =
new ConsolidatedRemotingConnectionListener();
remotingConnection.addConnectionListener(listener);
if (versionToUse == null)
{
throw new IllegalStateException("Connection version is null");
}
// We have one message id generator per unique server
MessageIdGenerator idGenerator =
MessageIdGeneratorFactory.instance.checkOutGenerator(serverID);
ConnectionState connectionState =
new ConnectionState(serverID, connectionDelegate,
remotingConnection, versionToUse, idGenerator);
listener.setConnectionState(connectionState);
connectionDelegate.setState(connectionState);
}
return res;
}