Example usage for org.apache.wicket.util.collections ConcurrentHashSet remove

List of usage examples for org.apache.wicket.util.collections ConcurrentHashSet remove

Introduction

In this page you can find the example usage for org.apache.wicket.util.collections ConcurrentHashSet remove.

Prototype

@Override
public boolean remove(final Object o) 

Source Link

Usage

From source file:org.efaps.ui.wicket.ConnectionRegistry.java

License:Apache License

/**
 * @param _login        login of the user to be removed for the registry
 * @param _sessionID    id to be removed
 * @param _application  Application that contains the mapping
 *///  w  ww  .  j a  va2 s .  c om
protected void removeUser(final String _login, final String _sessionID, final Application _application) {
    if (_login != null) {
        ConnectionRegistry.LOG.debug("remove user: '{}', session: '{}'", _login, _sessionID);
        ConcurrentMap<String, ConcurrentHashSet<String>> user2session = _application
                .getMetaData(ConnectionRegistry.USER2SESSION);
        synchronized (ConnectionRegistry.USER2SESSION) {
            user2session = _application.getMetaData(ConnectionRegistry.USER2SESSION);
            if (user2session != null) {
                final ConcurrentHashSet<String> sessions = user2session.get(_login);
                sessions.remove(_sessionID);
                if (sessions.isEmpty()) {
                    user2session.remove(_login);
                }
            }
        }
        synchronized (ConnectionRegistry.KEEPALIVE) {
            final ConcurrentMap<String, Long> keepalive = _application
                    .getMetaData(ConnectionRegistry.KEEPALIVE);
            if (keepalive != null) {
                keepalive.remove(_sessionID);
            }
        }
        ConnectionRegistry.LOG.debug("Removed User '{}' for Session: {}", _login, _sessionID);
        registerLogout4History(_login, _sessionID);
    }
}