Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jboss.weld.context.http;
 
 
 import  javax.servlet.http.HttpServletRequest;
 import  javax.servlet.http.HttpSession;
 
public class HttpSessionContextImpl extends AbstractBoundContext<HttpServletRequest> implements HttpSessionContext {
    // There is no need to store FQCN in a session key
    static final String NAMING_SCHEME_PREFIX = "WELD_S";
    static final String KEY_BEAN_ID_INDEX_HASH =  + "_HASH";
    private final NamingScheme namingScheme;
    private final String contextId;
    public HttpSessionContextImpl(String contextIdBeanIdentifierIndex index) {
        super(contextIdtrue);
        this. = contextId;
    }
    public boolean associate(HttpServletRequest request) {
        // At this point the bean store should never be set - see also HttpContextLifecycle.nestedInvocationGuard
        if (getBeanStore() != null) {
            ..beanStoreLeakDuringAssociation(this.getClass().getName(), request);
        }
        // We always associate a new bean store to avoid possible leaks (security threats)
        setBeanStore(new LazySessionBeanStore(request));
        checkBeanIdentifierIndexConsistency(request);
        return true;
    }
    public boolean destroy(HttpSession session) {
        if (getBeanStore() == null) {
            try {
                HttpConversationContext conversationContext = getConversationContext();
                setBeanStore(new EagerSessionBeanStore(session));
                activate();
                invalidate();
                conversationContext.destroy(session);
                deactivate();
                setBeanStore(null);
                return true;
            } finally {
                cleanup();
            }
        } else {
            // We are in a request, invalidate it
            invalidate();
            getConversationContext().destroy(session);
            return false;
        }
    }
    public Class<? extends AnnotationgetScope() {
        return SessionScoped.class;
    }
        return Container.instance().deploymentManager().instance().select(HttpConversationContext.class).get();
    }
    protected Conversation getConversation() {
        return Container.instance().deploymentManager().instance().select(Conversation.class).get();
    }
    private void checkBeanIdentifierIndexConsistency(HttpServletRequest request) {
        HttpSession session = request.getSession(false);
        if (session != null) {
            BeanIdentifierIndex index = getServiceRegistry().get(BeanIdentifierIndex.class);
            if (index != null && index.isBuilt()) {
                Object hash = session.getAttribute();
                if (hash != null) {
                    if (!index.getIndexHash().equals(hash)) {
                        throw ..beanIdentifierIndexInconsistencyDetected();
                    }
                } else {
                    session.setAttribute(index.getIndexHash());
                }
            }
        }
    }
New to GrepCode? Check out our FAQ X