[jboss-cvs] jboss-seam/src/main/org/jboss/seam/contexts ...

Gavin King gavin.king at jboss.com
Tue Dec 12 23:54:19 EST 2006


  User: gavin   
  Date: 06/12/12 23:54:19

  Modified:    src/main/org/jboss/seam/contexts    WebSessionContext.java
                        ServerConversationContext.java Lifecycle.java
  Log:
  maintain referential integrity for entity beans in conversation context
  
  Revision  Changes    Path
  1.27      +4 -2      jboss-seam/src/main/org/jboss/seam/contexts/WebSessionContext.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WebSessionContext.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/contexts/WebSessionContext.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -b -r1.26 -r1.27
  --- WebSessionContext.java	25 Nov 2006 02:56:06 -0000	1.26
  +++ WebSessionContext.java	13 Dec 2006 04:54:19 -0000	1.27
  @@ -16,7 +16,7 @@
   /**
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.26 $
  + * @version $Revision: 1.27 $
    */
   public class WebSessionContext implements Context 
   {
  @@ -93,7 +93,9 @@
         for ( String name: getNames() )
         {
            Object attribute = session.getAttribute(name);
  -         if ( attribute!=null && Lifecycle.isAttributeDirty(attribute) )
  +         boolean dirty = attribute!=null && 
  +               ( Lifecycle.isAttributeDirty(attribute) || Seam.isEntityClass( attribute.getClass() ) );
  +         if ( dirty )
            {
               session.setAttribute(name, attribute);
            }
  
  
  
  1.18      +42 -13    jboss-seam/src/main/org/jboss/seam/contexts/ServerConversationContext.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ServerConversationContext.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/contexts/ServerConversationContext.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- ServerConversationContext.java	25 Nov 2006 02:56:06 -0000	1.17
  +++ ServerConversationContext.java	13 Dec 2006 04:54:19 -0000	1.18
  @@ -26,7 +26,7 @@
    * 
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.17 $
  + * @version $Revision: 1.18 $
    */
   public class ServerConversationContext implements Context {
   
  @@ -84,12 +84,22 @@
   	public Object get(String name) 
      {
         Object result = additions.get(name);
  -      if (result!=null) return result;
  -      if ( removals.contains(name) ) return null;
  +      if (result!=null)
  +      {
  +         return unwrapEntityBean(result);
  +      }
  +      else
  +      {
  +         if ( removals.contains(name) ) 
  +         {
  +            return null;
  +         }
  +         else
  +         {
         List<String> stack = getIdStack();
         if (stack==null)
         {
  -         return session.getAttribute( getKey(name) );
  +               return unwrapEntityBean( session.getAttribute( getKey(name) ) );
         }
         else
         {
  @@ -99,11 +109,26 @@
               result = session.getAttribute( getKey(name, id) );
               boolean found = result!=null && 
                     ( i==0 || !result.getClass().isAnnotationPresent(PerNestedConversation.class) );
  -            if (found) return result;
  +                  if (found) return unwrapEntityBean(result);
            }
            return null;
         }
   	}
  +      }
  +	}
  +
  +   private Object unwrapEntityBean(Object result)
  +   {
  +      if (result==null) return null;
  +      if ( result instanceof EntityBean )
  +      {
  +         return ( (EntityBean) result ).getInstance();
  +      }
  +      else
  +      {
  +         return result;
  +      }
  +   }
   
      public void set(String name, Object value) 
      {
  @@ -116,6 +141,10 @@
         else
         {
            removals.remove(name);
  +         if ( Seam.isEntityClass( value.getClass() ) )
  +         {
  +            value = new EntityBean(value);
  +         }
            additions.put(name, value);
         }
         if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.postSetVariable." + name);
  
  
  
  1.70      +3 -4      jboss-seam/src/main/org/jboss/seam/contexts/Lifecycle.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Lifecycle.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/contexts/Lifecycle.java,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -b -r1.69 -r1.70
  --- Lifecycle.java	3 Dec 2006 07:01:47 -0000	1.69
  +++ Lifecycle.java	13 Dec 2006 04:54:19 -0000	1.70
  @@ -7,9 +7,9 @@
   package org.jboss.seam.contexts;
   
   import java.util.Set;
  +
   import javax.faces.context.ExternalContext;
   import javax.faces.event.PhaseId;
  -import javax.persistence.Entity;
   import javax.servlet.ServletContext;
   import javax.servlet.ServletRequest;
   import javax.servlet.http.HttpServletRequest;
  @@ -31,7 +31,7 @@
   /**
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.69 $
  + * @version $Revision: 1.70 $
    */
   public class Lifecycle
   {
  @@ -447,8 +447,7 @@
   
      public static boolean isAttributeDirty(Object attribute)
      {
  -      return ( attribute instanceof Mutable && ( (Mutable) attribute ).clearDirty() ) || 
  -            attribute.getClass().isAnnotationPresent(Entity.class);
  +      return attribute instanceof Mutable && ( (Mutable) attribute ).clearDirty();
      }
   
   }
  
  
  



More information about the jboss-cvs-commits mailing list