if (logger.isInfoEnabled()) {
logger.info(String.format("Connected %s", association));
}
if (association.getIpChannelType() == IpChannelType.TCP) {
AssocChangeEvent ace = AssocChangeEvent.COMM_UP;
AssociationChangeNotification2 acn = new AssociationChangeNotification2(ace);
association.associationHandler.handleNotification(acn, association);
}
break;
}
}
}
if (provisioned)
break;
}// for (SocketAddress sockAdd : socAddresses)
if (!provisioned && srv.isAcceptAnonymousConnections() && this.management.getServerListener() != null) {
// the server accepts anonymous connections
// checking for limit of concurrent connections
if (srvv.getMaxConcurrentConnectionsCount() > 0 && srvv.anonymAssociations.size() >= srvv.getMaxConcurrentConnectionsCount()) {
logger.warn(String.format("Incoming anonymous connection is rejected because of too many active connections to Server=%s", srv));
try {
socketChannel.close();
} catch (Exception ee) {
}
return;
}
provisioned = true;
AssociationImpl anonymAssociation = new AssociationImpl(firstInetAddress.getHostAddress(), firstPort, srv.getName(),
srv.getIpChannelType(), srvv);
anonymAssociation.setManagement(this.management);
anonymAssociation.setSocketChannel(socketChannel);
// Accept the connection and make it
// non-blocking
socketChannel.configureBlocking(false);
try {
this.management.getServerListener().onNewRemoteConnection(srv, anonymAssociation);
} catch (Throwable e) {
logger.warn(String.format("Exception when invoking ServerListener.onNewRemoteConnection() Ass=%s", anonymAssociation), e);
try {
socketChannel.close();
} catch (Exception ee) {
}
return;
}
if (!anonymAssociation.isStarted()) {
// connection is rejected
logger.info(String.format("Rejected anonymous %s", anonymAssociation));
try {
socketChannel.close();
} catch (Exception ee) {
}
return;
}
// Register the new SocketChannel with our Selector,
// indicating we'd like to be notified when there's data
// waiting to be read
SelectionKey key1 = socketChannel.register(this.selector, SelectionKey.OP_READ);
key1.attach(anonymAssociation);
if (logger.isInfoEnabled()) {
logger.info(String.format("Accepted anonymous %s", anonymAssociation));
}
if (anonymAssociation.getIpChannelType() == IpChannelType.TCP) {
AssocChangeEvent ace = AssocChangeEvent.COMM_UP;
AssociationChangeNotification2 acn = new AssociationChangeNotification2(ace);
anonymAssociation.associationHandler.handleNotification(acn, anonymAssociation);
}
}
}