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

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

Introduction

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

Prototype

@Override
public boolean add(final E o) 

Source Link

Usage

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

License:Apache License

/**
 * @param _sessionID session to marked as invalid
 *///from   www  .j  a va 2 s .  c  o m
public void markSessionAsInvalid(final String _sessionID) {
    ConcurrentHashSet<String> invalidated = Session.get().getApplication()
            .getMetaData(ConnectionRegistry.INVALIDATED);

    if (invalidated == null) {
        synchronized (ConnectionRegistry.INVALIDATED) {
            invalidated = Session.get().getApplication().getMetaData(ConnectionRegistry.INVALIDATED);
            if (invalidated == null) {
                invalidated = new ConcurrentHashSet<>();
                Session.get().getApplication().setMetaData(ConnectionRegistry.INVALIDATED, invalidated);
            }
        }
    }
    invalidated.add(_sessionID);
    ConnectionRegistry.LOG.debug("Marked Session: {} as invalid", _sessionID);
}

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

License:Apache License

/**
 * @param _userName login of the user/*from  www .ja  v  a2s .  c  om*/
 * @param _sessionID    SessionId assigned
 */
protected void setUser(final String _userName, final String _sessionID) {
    ConnectionRegistry.LOG.debug("register user: '{}', session: '{}'", _userName, _sessionID);
    ConcurrentMap<String, ConcurrentHashSet<String>> user2session = Session.get().getApplication()
            .getMetaData(ConnectionRegistry.USER2SESSION);

    if (user2session == null) {

        synchronized (ConnectionRegistry.USER2SESSION) {
            user2session = Session.get().getApplication().getMetaData(ConnectionRegistry.USER2SESSION);
            if (user2session == null) {
                user2session = Generics.<String, ConcurrentHashSet<String>>newConcurrentHashMap();
                Session.get().getApplication().setMetaData(ConnectionRegistry.USER2SESSION, user2session);
            }
        }
    }
    ConcurrentHashSet<String> sessions = user2session.get(_userName);
    if (sessions == null) {
        synchronized (ConnectionRegistry.USER2SESSION) {
            sessions = user2session.get(_userName);
            if (sessions == null) {
                sessions = new ConcurrentHashSet<>();
                user2session.put(_userName, sessions);
            }
        }
    }
    sessions.add(_sessionID);
    ConnectionRegistry.LOG.debug("Added User '{}' for Session: {}", _userName, _sessionID);
    registerLogin4History(_userName, _sessionID);
}