* Returns a ServerSession from the pool, creating a new pool for the given
* session manager if necessary.
* @see #createObjectPool
*/
public ServerSession getServerSession(ListenerSessionManager sessionManager) throws JMSException {
ObjectPool pool = null;
synchronized (this.serverSessionPools) {
pool = (ObjectPool) this.serverSessionPools.get(sessionManager);
if (pool == null) {
if (logger.isInfoEnabled()) {
logger.info("Creating Commons ServerSession pool for: " + sessionManager);
}
pool = createObjectPool(sessionManager);
this.serverSessionPools.put(sessionManager, pool);
}
}
try {
return (ServerSession) pool.borrowObject();
}
catch (Exception ex) {
JMSException jmsEx = new JMSException("Failed to borrow ServerSession from pool");
jmsEx.setLinkedException(ex);
throw jmsEx;