public <T> Provider<T> scope(final Key<T> key, final Provider<T> unscoped) {
        return new Provider<T>() {
            public T get() {
                Subject subject = ThreadContext.getSubject();
                if (subject == null) {
                    throw new OutOfScopeException("There is no Shiro Session currently in scope.");
                }
                Session session = subject.getSession();
                T scoped = castSessionAttribute(session);
                if (scoped == null) {
                    scoped = unscoped.get();
                }
                return scoped;
            }

            @SuppressWarnings({"unchecked"})
            private T castSessionAttribute(Session session) {
                return (T) session.getAttribute(key);
            }

            @Override
            public String toString() {
                return unscoped.toString();
            }
        };
    }
Guice scope for Shiro sessions.  Not bound by default.
support/guice/src/main/java/org/apache/shiro/guice/ShiroSessionScope.java