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

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

Introduction

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

Prototype

@Override
public Iterator<E> iterator() 

Source Link

Usage

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 ww.j ava 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;
}