[weld-commits] Weld SVN: r5726 - core/trunk/impl/src/main/java/org/jboss/weld/servlet.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Feb 4 11:58:35 EST 2010


Author: dallen6
Date: 2010-02-04 11:58:35 -0500 (Thu, 04 Feb 2010)
New Revision: 5726

Removed:
   core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpRequestSessionBeanStore.java
Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java
   core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruSessionBeanStore.java
Log:
WELD-403  Cleanup

Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java	2010-02-04 16:20:38 UTC (rev 5725)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java	2010-02-04 16:58:35 UTC (rev 5726)
@@ -34,6 +34,10 @@
    public ConversationBeanStore(HttpSession session, boolean sessionInvalidated, String cid)
    {
       this.namingScheme = new NamingScheme(ConversationContext.class.getName() + "[" + cid + "]", "#");
+      if (sessionInvalidated)
+      {
+         invalidate();
+      }
       attachToSession(session);
    }
 

Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruSessionBeanStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruSessionBeanStore.java	2010-02-04 16:20:38 UTC (rev 5725)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpPassThruSessionBeanStore.java	2010-02-04 16:58:35 UTC (rev 5726)
@@ -37,7 +37,7 @@
  * A BeanStore that maintains Contextuals in a hash map and writes them through
  * to a HttpSession. When this BeanStore is attached to a session, it will load
  * all the existing contextuals from the session within the naming scheme for
- * this BeanStore.  All read operations are directly against the local map.
+ * this BeanStore. All read operations are directly against the local map.
  * 
  * @author David Allen
  */
@@ -118,11 +118,21 @@
    protected void loadFromSession(HttpSession newSession)
    {
       log.trace("Loading bean store " + this + " map from session " + newSession.getId());
-      for (String id : this.getFilteredAttributeNames())
+      try
       {
-         delegateBeanStore.put(id, (ContextualInstance<?>) super.getAttribute(id));
-         log.trace("Added contextual " + super.getAttribute(id) + " under ID " + id);
+         for (String id : this.getFilteredAttributeNames())
+         {
+            delegateBeanStore.put(id, (ContextualInstance<?>) super.getAttribute(id));
+            log.trace("Added contextual " + super.getAttribute(id) + " under ID " + id);
+         }
       }
+      catch (IllegalStateException e)
+      {
+         // There's not a lot to do here if the session is invalidated while
+         // loading this map.  These beans will not be destroyed since the
+         // references are lost.
+         delegateBeanStore.clear();
+      }
    }
 
    @Override

Deleted: core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpRequestSessionBeanStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpRequestSessionBeanStore.java	2010-02-04 16:20:38 UTC (rev 5725)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpRequestSessionBeanStore.java	2010-02-04 16:58:35 UTC (rev 5726)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.weld.servlet;
-
-import java.util.Collections;
-import java.util.Enumeration;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.jboss.weld.context.SessionContext;
-import org.jboss.weld.context.beanstore.AbstractAttributeBackedBeanStore;
-import org.jboss.weld.context.beanstore.NamingScheme;
-
-/**
- * Abstracts the servlet API specific session context
- * as a BeanStore. Actual sessions are created lazily.
- * 
- * @author Gavin King
- */
-public class HttpRequestSessionBeanStore extends AbstractAttributeBackedBeanStore
-{
-   // The HTTP session context to use as backing map
-   private final HttpServletRequest request;
-   private static final NamingScheme NAMING_SCHEME = new NamingScheme(SessionContext.class.getName(), "#");
-
-   /**
-    * Constructor
-    * 
-    * @param session The HTTP session
-    */
-   public HttpRequestSessionBeanStore(HttpServletRequest request)
-   {
-      super();
-      this.request = request;
-   }
-
-   /**
-    * @see org.jboss.weld.context.beanstore.AbstractAttributeBackedBeanStore#getAttribute()
-    */
-   @Override
-   protected Object getAttribute(String key)
-   {
-      HttpSession session = request.getSession(false);
-      return session==null ? null : session.getAttribute( key );
-   }
-
-   /**
-    * @see org.jboss.weld.context.beanstore.AbstractAttributeBackedBeanStore#getAttributeNames()
-    */
-   @SuppressWarnings("unchecked")
-   @Override
-   protected Enumeration<String> getAttributeNames()
-   {
-      HttpSession session = request.getSession(false);
-      if (session != null)
-      {
-         return session.getAttributeNames();
-      }
-      else
-      {
-         return Collections.enumeration(Collections.EMPTY_LIST);
-      }
-   }
-
-   /**
-    * @see org.jboss.weld.context.beanstore.AbstractAttributeBackedBeanStore#removeAttributes()
-    */
-   @Override
-   protected void removeAttribute(String key)
-   {
-      HttpSession session = request.getSession(false);
-      if (session != null)
-      {
-         session.removeAttribute( key );
-      }
-   }
-
-   /**
-    * @see org.jboss.weld.context.beanstore.AbstractAttributeBackedBeanStore#setAttribute()
-    */
-   @Override
-   protected void setAttribute(String key, Object instance)
-   {
-      HttpSession session = request.getSession(true);
-      session.setAttribute(key, instance);
-   }
-
-   @Override
-   protected NamingScheme getNamingScheme()
-   {
-      return NAMING_SCHEME;
-   }
-
-}
\ No newline at end of file



More information about the weld-commits mailing list