* in the data service if: the AppListener.loggedIn callback
* either threw a non-retryable exception or returned a
* null listener, or the application removed the
* ClientSessionListener object from the data service.
*/
ClientSessionListener listener = null;
try {
ManagedObject obj = null;
try {
obj = dataService.getServiceBinding(listenerKey);
} catch (ObjectNotFoundException ignore) {
// listener already removed
}
dataService.removeServiceBinding(listenerKey);
if (obj instanceof ListenerWrapper) {
dataService.removeObject(obj);
listener = ((ListenerWrapper) obj).get();
} else {
listener = (ClientSessionListener) obj;
}
} catch (NameNotBoundException e) {
logger.logThrow(
Level.FINE, e,
"removing ClientSessionListener for session:{0} throws",
this);
}
/*
* Remove event queue and associated binding.
*/
try {
ManagedObject eventQueue =
dataService.getServiceBinding(eventQueueKey);
dataService.removeServiceBinding(eventQueueKey);
dataService.removeObject(eventQueue);
} catch (NameNotBoundException e) {
logger.logThrow(
Level.FINE, e,
"removing EventQueue for session:{0} throws",
this);
}
/*
* Invoke listener's 'disconnected' callback if 'notify'
* is true and a listener exists for this client session. If the
* 'disconnected' callback throws a non-retryable exception,
* schedule a task to remove this session and its associated
* bindings without invoking the listener, and rethrow the
* exception so that the currently executing transaction aborts.
*/
if (notify && listener != null) {
try {
listener.disconnected(graceful);
} catch (RuntimeException e) {
if (!isRetryableException(e)) {
logger.logThrow(
Level.WARNING, e,
"invoking disconnected callback on listener:{0} " +