if (disconnectTimeout > 0)
metadata.put(ServerInvoker.TIMEOUT, Integer.toString(disconnectTimeout));
try
{
invoke(new InternalInvocation(InternalInvocation.REMOVELISTENER, null), metadata);
}
catch (Exception e)
{
log.debug("unable to remove remote callback handler", e);
}
}
// clean up callback poller if one exists
CallbackPoller callbackPoller = (CallbackPoller) callbackPollers.remove(callbackHandler);
if (callbackPoller != null)
{
callbackPoller.stop();
}
listeners.remove(callbackHandler);
}
else
{
// have a push callback handler
List holderList = invoker.getClientLocators(sessionId, callbackHandler);
if(holderList != null && holderList.size() > 0)
{
for(int x = 0; x < holderList.size(); x++)
{
AbstractInvoker.CallbackLocatorHolder holder =
(AbstractInvoker.CallbackLocatorHolder)holderList.get(x);
listenerId = holder.getListenerId();
InvokerLocator locator = holder.getLocator();
Map metadata = new HashMap();
metadata.put(LISTENER_ID_KEY, listenerId);
// If disconnectTimeout == 0, skip network i/o.
if (disconnectTimeout != 0)
{
if (disconnectTimeout > 0)
metadata.put(ServerInvoker.TIMEOUT, Integer.toString(disconnectTimeout));
try
{
// now call target server to remove listener
InternalInvocation ii =
new InternalInvocation(InternalInvocation.REMOVELISTENER, null);
invoke(ii, metadata);
}
catch (Exception e)
{
log.debug("unable to remove remote callback handler", e);
}
}
// call to callback server to remove listener
Client client = new Client(locator, subsystem);
client.setSessionId(getSessionId());
client.connect();
InternalInvocation ii =
new InternalInvocation(InternalInvocation.REMOVECLIENTLISTENER,
new Object[]{callbackHandler});
client.invoke(ii, metadata);
client.disconnect();
}