List of usage examples for org.apache.wicket.util.collections ConcurrentHashSet isEmpty
@Override public boolean isEmpty()
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 *//*from w w w . j ava2s .com*/ 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); } }
From source file:org.efaps.ui.wicket.ConnectionRegistry.java
License:Apache License
/** * @param _login login of the user the session is wanted for * @return Connections for the user, empty list if not found *//*from w w w. jav a 2 s .c o m*/ public List<IWebSocketConnection> getConnections4User(final String _login) { final List<IWebSocketConnection> ret = new ArrayList<>(); final ConcurrentMap<String, ConcurrentHashSet<String>> user2session = Session.get().getApplication() .getMetaData(ConnectionRegistry.USER2SESSION); final ConcurrentMap<String, IKey> sessionId2pageId = Session.get().getApplication() .getMetaData(ConnectionRegistry.SESSION2KEY); final ConcurrentHashSet<String> sessionIds = user2session.get(_login); if (sessionIds != null && !sessionIds.isEmpty()) { final Iterator<String> iter = sessionIds.iterator(); while (iter.hasNext()) { final String sessionId = iter.next(); final IKey key = sessionId2pageId.get(sessionId); if (key != null) { final IWebSocketConnectionRegistry registry = WebSocketSettings.Holder .get(EFapsApplication.get()).getConnectionRegistry(); final IWebSocketConnection conn = registry.getConnection(EFapsApplication.get(), sessionId, key); if (conn != null) { ret.add(conn); } } } } return ret; }