Package org.apache.webbeans.context

Examples of org.apache.webbeans.context.SessionContext


    protected void storeBeansInFailOverBag(FailOverBag bag, HttpSession session)
    {
        // store the session context
        SessionContextManager sessionManager =
                ((WebContextsService) webBeansContext.getContextsService()).getSessionContextManager();
        SessionContext sessionContext = sessionManager.getSessionContextWithSessionId(session.getId());
        bag.put(ATTRIBUTE_SESSION_CONTEXT, sessionContext);

        // store all conversation contexts
        ConversationManager conversationManager = webBeansContext.getConversationManager();
        bag.put(ATTRIBUTE_CONVERSATION_CONTEXT_MAP, conversationManager.getConversationMapWithSessionId(session.getId()));
View Full Code Here


    protected void restoreBeansFromFailOverBag(FailOverBag bag, HttpSession session)
    {
        try
        {
            // restore session context
            SessionContext sessionContext = (SessionContext) bag.get(ATTRIBUTE_SESSION_CONTEXT);

            if (sessionContext != null)
            {
                SessionContextManager sessionManager =
                        ((WebContextsService) webBeansContext.getContextsService()).getSessionContextManager();

                sessionManager.addNewSessionContext(session.getId(), sessionContext);
                sessionContext.setActive(true);
            }

            // restore conversation contexts
            Map<Conversation, ConversationContext> conversationContextMap =
                    (Map<Conversation, ConversationContext>) bag.get(ATTRIBUTE_CONVERSATION_CONTEXT_MAP);
View Full Code Here

     * Creates the session context at the session start.
     * @param session http session object
     */
    private void initSessionContext(HttpSession session)
    {
        SessionContext currentSessionContext;

        if (session == null)
        {
            // no session -> create a dummy SessionContext
            // this is handy if you create asynchronous tasks or
            // batches which use a 'admin' user.
            currentSessionContext = new SessionContext();
        }
        else
        {
            String sessionId = session.getId();

            //Current context
            currentSessionContext = sessionCtxManager.getSessionContextWithSessionId(sessionId);

            //No current context
            if (currentSessionContext == null)
            {
                currentSessionContext = new SessionContext();
                sessionCtxManager.addNewSessionContext(sessionId, currentSessionContext);
            }
        }

        //Activate
        currentSessionContext.setActive(true);

        //Set thread local
        sessionContexts.set(currentSessionContext);
    }
View Full Code Here

    private void destroySessionContext(HttpSession session)
    {
        if (session != null)
        {
            //Get current session context
            SessionContext context = sessionContexts.get();

            if (context == null)
            {
                initSessionContext(session);
                context = sessionContexts.get();
            }

            //Destroy context
            if (context != null)
            {
                context.destroy();
            }

            //Clear thread locals
            sessionContexts.set(null);
            sessionContexts.remove();
View Full Code Here

     * Get current session ctx.
     * @return session context
     */
    private  SessionContext getSessionContext()
    {
        SessionContext context = sessionContexts.get();
        if (null == context)
        {
            lazyStartSessionContext();
            context = sessionContexts.get();
        }
View Full Code Here

     * Destroy session context with given id.
     * @param sessionId session id
     */
    public void destroySessionContextWithSessionId(String sessionId)
    {
        SessionContext sessionContext = this.sessionContexts.remove(sessionId);
        if(sessionContext != null)
        {
            sessionContext.destroy();
        }
    }
View Full Code Here

    }

   
    private void startSessionContext(Object instance)
    {
        SessionContext ctx = new SessionContext();
        ctx.setActive(true);
       
        sessionContext.set(ctx);
    }
View Full Code Here

     * Creates the session context at the session start.
     * @param session http session object
     */
    private void initSessionContext(HttpSession session)
    {
        SessionContext currentSessionContext;

        if (session == null)
        {
            // no session -> create a dummy SessionContext
            // this is handy if you create asynchronous tasks or
            // batches which use a 'admin' user.
            currentSessionContext = new SessionContext();
        }
        else
        {
            String sessionId = session.getId();

            //Current context
            currentSessionContext = sessionCtxManager.getSessionContextWithSessionId(sessionId);

            //No current context
            if (currentSessionContext == null)
            {
                currentSessionContext = new SessionContext();
                sessionCtxManager.addNewSessionContext(sessionId, currentSessionContext);
            }
        }

        //Activate
        currentSessionContext.setActive(true);

        //Set thread local
        sessionContexts.set(currentSessionContext);
    }
View Full Code Here

    private void destroySessionContext(HttpSession session)
    {
        if (session != null)
        {
            //Get current session context
            SessionContext context = sessionContexts.get();

            //Destroy context
            if (context != null)
            {
                context.destroy();
            }

            //Clear thread locals
            sessionContexts.set(null);
            sessionContexts.remove();
View Full Code Here

     * Get current session ctx.
     * @return session context
     */
    private  SessionContext getSessionContext()
    {
        SessionContext context = sessionContexts.get();
        if (null == context)
        {
            lazyStartSessionContext();
            context = sessionContexts.get();
        }
View Full Code Here

TOP

Related Classes of org.apache.webbeans.context.SessionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.