public void register(T object) {

        // If already invalidated (or invalidation is in progress), avoid adding
        // the object unnecessarily - just cleanup now
        if (invalidated.get()) {
            cleanup(object);
            return;
        }

        // Store provided object
        objects.add(object);

        // If collection was invalidated while object was being added, recheck
        // the underlying collection and cleanup
        if (invalidated.get())
            cleanupAll();

    }
Registers the given object with this SharedObjectManager such that it is
cleaned up once the SharedObjectManager is invalidated. If the
SharedObjectManager has already been invalidated, the object will be
cleaned up immediately.

@param object
    The object to register with this SharedObjectManager.
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharing/SharedObjectManager.java