boolean shouldLease = false;
long leasePeriod = -1;
if(invocation != null && invocation instanceof InvocationRequest)
{
InvocationRequest request = (InvocationRequest)invocation;
Object payload = request.getParameter();
// although a bit of a hack, this will determin if first time ping called by client.
if(payload != null && payload instanceof String && "$PING$".equalsIgnoreCase((String)payload) && request.getReturnPayload() != null)
{
try
{
// now know is a ping request, so convert to be a HEAD method call
conn.setDoOutput(false);
conn.setDoInput(true);
conn.setRequestMethod("HEAD");
// set the remoting version
conn.setRequestProperty(HTTPMetadataConstants.REMOTING_VERSION_HEADER, new Integer(Version.getDefaultVersion()).toString());
// set the user agent
conn.setRequestProperty(HTTPMetadataConstants.REMOTING_USER_AGENT, "JBossRemoting - " + Version.VERSION);
conn.setRequestProperty(HTTPMetadataConstants.REMOTING_LEASE_QUERY, "true");
conn.setRequestProperty("sessionId", request.getSessionId());
conn.connect();
//InputStream is = (conn.getResponseCode() < 400) ? conn.getInputStream() : conn.getErrorStream();
Map headers = conn.getHeaderFields();