??????δ???????????????????????У?????????????????usedPooled++????????
??????????JBoss Remoting????????createClientSocket???д??????jboss remoting??????д???????????????????????????????????п???????????????????£???????д?????????????????????????????????????????????е??????????????????????л????????
?????????????????????pooled=createClientSocket(socket?? address.timeout?? metadata);???д???????????try...catch???????????????????usedPooled--??????createSocket???????????
??????JBoss Remoting 2.4?У?jboss???????usedPooled???long?????usedPoolLock????????????????????????????????????????????Semphore????????????EDG???????????java 5?????????jboss remoting 2.4?е???δ????????????
boolean timedout = !semaphore.attempt(timeToWait);
if (trace) log.trace(this + " obtained semaphore: " + semaphore.permits());
if (timedout)
{
throw new IllegalStateException("Timeout waiting for a free socket");
}
SocketWrapper pooled = null;
if (tryPool)
{
synchronized (pool)
{
// if connection within pool?? use it
if (pool.size() > 0)
{
pooled = getPooledConnection();
if (trace) log.trace(this + " reusing pooled connection: " + pooled);
}
}
}
else
{
if (trace) log.trace(this + " avoiding connection pool?? creating new socket");
}
if (pooled == null)
{
//Need to create a new one
Socket socket = null;
if (trace) { log.trace(this + " creating socket "); }
// timeAllowed < 0 indicates no per invocation timeout has been set.
int timeRemaining = -1;
if (0 <= timeAllowed)
{
timeRemaining = (int) (timeAllowed - (System.currentTimeMillis() - start));
}
socket = createSocket(address.address?? address.port?? timeRemaining);
if (trace) log.trace(this + " created socket: " + socket);
socket.setTcpNoDelay(address.enableTcpNoDelay);
Map metadata = getLocator().getParameters();
if (metadata == null)
{
metadata = new HashMap(2);
}
else
{
metadata = new HashMap(metadata);
}
metadata.put(SocketWrapper.MARSHALLER?? marshaller);
metadata.put(SocketWrapper.UNMARSHALLER?? unmarshaller);
if (timeAllowed > 0)
{
timeRemaining = (int) (timeAllowed - (System.currentTimeMillis() - start));
if (timeRemaining <= 0)
throw new IllegalStateException("Timeout creating a new socket");
metadata.put(SocketWrapper.TEMP_TIMEOUT?? new Integer(timeRemaining));
}
pooled = createClientSocket(socket?? address.timeout?? metadata);
}
return pooled;