private boolean add(DefaultHttpSession httpSession) {
HttpResourceAddress serverAddress = (HttpResourceAddress)httpSession.getRemoteAddress();
IoSession transportSession = httpSession.getParent();
ServerConnections serverConnections = connections.get();
boolean cached = serverConnections.add(serverAddress, transportSession);
if (cached) {
if (logger.isDebugEnabled()) {
int cachedConnections = serverConnections.cachedConnections(serverAddress);
logger.debug(String.format("Caching persistent connection: server = %s session = %s pool = %d",
serverAddress.getResource(), transportSession, cachedConnections));
}
return true;
} else {
if (logger.isDebugEnabled()) {
int cachedConnections = serverConnections.cachedConnections(serverAddress);
logger.debug(String.format("NOT caching persistent connection: server = %s session = %s pool = %d",
serverAddress.getResource(), transportSession, cachedConnections));
}
}
return false;
}