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

Gavin King gavin.king at jboss.com
Tue Oct 10 15:37:38 EDT 2006


  User: gavin   
  Date: 06/10/10 15:37:38

  Modified:    src/main/org/jboss/seam/core               Actor.java
                        BusinessProcess.java Init.java LocaleSelector.java
                        ManagedHibernateSession.java
                        ManagedJbpmContext.java
                        ManagedPersistenceContext.java Manager.java
                        Pageflow.java Redirect.java TouchedContexts.java
                        Transition.java
  Added:       src/main/org/jboss/seam/core              
                        AbstractMutable.java Mutable.java
  Log:
  removed @Mutable, use Mutable interface instead
  
  Revision  Changes    Path
  1.7       +4 -3      jboss-seam/src/main/org/jboss/seam/core/Actor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Actor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Actor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- Actor.java	17 Jun 2006 01:35:11 -0000	1.6
  +++ Actor.java	10 Oct 2006 19:37:37 -0000	1.7
  @@ -9,7 +9,6 @@
   import org.jboss.seam.Component;
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.annotations.Intercept;
  -import org.jboss.seam.annotations.Mutable;
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.contexts.Contexts;
  @@ -23,13 +22,14 @@
   @Name("actor")
   @Scope(ScopeType.SESSION)
   @Intercept(NEVER)
  - at Mutable
  -public class Actor implements Serializable 
  +public class Actor extends AbstractMutable implements Serializable
   {
      
      private String id;
      private Set<String> groupActorIds = new HashSet<String>();
   
  +   //TODO: dirtyness for groupActorIds
  +
      public String getId() 
      {
         return id;
  @@ -37,6 +37,7 @@
   
      public void setId(String id) 
      {
  +      setDirty(this.id, id);
         this.id = id;
      }
      
  
  
  
  1.5       +3 -1      jboss-seam/src/main/org/jboss/seam/core/BusinessProcess.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BusinessProcess.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/BusinessProcess.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- BusinessProcess.java	3 Oct 2006 23:15:58 -0000	1.4
  +++ BusinessProcess.java	10 Oct 2006 19:37:37 -0000	1.5
  @@ -26,7 +26,7 @@
   @Scope(ScopeType.CONVERSATION)
   @Name("businessProcess")
   @Intercept(NEVER)
  -public class BusinessProcess implements Serializable {
  +public class BusinessProcess extends AbstractMutable implements Serializable {
      
      private Long processId;
      private Long taskId;
  @@ -55,6 +55,7 @@
      }
   
      public void setProcessId(Long processId) {
  +      setDirty(this.processId, processId);
         this.processId = processId;
      }
   
  @@ -63,6 +64,7 @@
      }
   
      public void setTaskId(Long taskId) {
  +      setDirty(this.taskId, taskId);
         this.taskId = taskId;
      }
   
  
  
  
  1.26      +1 -7      jboss-seam/src/main/org/jboss/seam/core/Init.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Init.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Init.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -b -r1.25 -r1.26
  --- Init.java	8 Oct 2006 14:01:53 -0000	1.25
  +++ Init.java	10 Oct 2006 19:37:37 -0000	1.26
  @@ -1,4 +1,4 @@
  -//$Id: Init.java,v 1.25 2006/10/08 14:01:53 gavin Exp $
  +//$Id: Init.java,v 1.26 2006/10/10 19:37:37 gavin Exp $
   package org.jboss.seam.core;
   
   
  @@ -35,7 +35,6 @@
      private String jndiPattern;
      private boolean debug;
      private boolean myFacesLifecycleBug;
  -   private List<String> mutableComponentNames = new ArrayList<String>();
      
      private Map<String, List<ObserverMethod>> observers = new HashMap<String, List<ObserverMethod>>();
      private Map<String, FactoryMethod> factories = new HashMap<String, FactoryMethod>();
  @@ -213,9 +212,4 @@
         this.jbpmInstalled = jbpmInstalled;
      }
   
  -   public List<String> getMutableComponentNames()
  -   {
  -      return mutableComponentNames;
  -   }
  -
   }
  
  
  
  1.11      +5 -3      jboss-seam/src/main/org/jboss/seam/core/LocaleSelector.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LocaleSelector.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/LocaleSelector.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- LocaleSelector.java	22 Jun 2006 09:46:01 -0000	1.10
  +++ LocaleSelector.java	10 Oct 2006 19:37:37 -0000	1.11
  @@ -21,7 +21,6 @@
   import org.jboss.seam.Seam;
   import org.jboss.seam.annotations.Create;
   import org.jboss.seam.annotations.Intercept;
  -import org.jboss.seam.annotations.Mutable;
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.contexts.Contexts;
  @@ -36,8 +35,7 @@
   @Scope(ScopeType.SESSION)
   @Name("localeSelector")
   @Intercept(NEVER)
  - at Mutable
  -public class LocaleSelector implements Serializable 
  +public class LocaleSelector extends AbstractMutable implements Serializable
   {
   
      private String language;
  @@ -164,6 +162,7 @@
      }
   
      public void setCountry(String country) {
  +      setDirty(this.country, country);
         this.country = country;
      }
   
  @@ -173,6 +172,7 @@
      }
   
      public void setLanguage(String language) {
  +      setDirty(this.language, language);
         this.language = language;
      }
   
  @@ -182,6 +182,7 @@
      }
   
      public void setVariant(String variant) {
  +      setDirty(this.variant, variant);
         this.variant = variant;
      }
   
  @@ -192,6 +193,7 @@
   
      public void setCookieEnabled(boolean cookieEnabled)
      {
  +      setDirty(this.cookieEnabled, cookieEnabled);
         this.cookieEnabled = cookieEnabled;
      }
      
  
  
  
  1.20      +8 -5      jboss-seam/src/main/org/jboss/seam/core/ManagedHibernateSession.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ManagedHibernateSession.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ManagedHibernateSession.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -b -r1.19 -r1.20
  --- ManagedHibernateSession.java	26 Sep 2006 00:29:52 -0000	1.19
  +++ ManagedHibernateSession.java	10 Oct 2006 19:37:37 -0000	1.20
  @@ -1,4 +1,4 @@
  -//$Id: ManagedHibernateSession.java,v 1.19 2006/09/26 00:29:52 gavin Exp $
  +//$Id: ManagedHibernateSession.java,v 1.20 2006/10/10 19:37:37 gavin Exp $
   package org.jboss.seam.core;
   
   import static org.jboss.seam.InterceptionType.NEVER;
  @@ -19,7 +19,6 @@
   import org.jboss.seam.annotations.Create;
   import org.jboss.seam.annotations.Destroy;
   import org.jboss.seam.annotations.Intercept;
  -import org.jboss.seam.annotations.Mutable;
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.annotations.Unwrap;
   import org.jboss.seam.util.Naming;
  @@ -33,8 +32,7 @@
    */
   @Scope(ScopeType.CONVERSATION)
   @Intercept(NEVER)
  - at Mutable
  -public class ManagedHibernateSession implements Serializable, HttpSessionActivationListener
  +public class ManagedHibernateSession implements Serializable, HttpSessionActivationListener, Mutable
   {
      
      /** The serialVersionUID */
  @@ -46,6 +44,11 @@
      private String sessionFactoryJndiName;
      private String componentName;
      
  +   public boolean clearDirty()
  +   {
  +      return true;
  +   }
  +
      @Create
      public void create(Component component)
      {
  @@ -56,7 +59,7 @@
         }
         createSession();
         
  -      TouchedContexts.instance().add(componentName);
  +      TouchedContexts.instance().touch(componentName);
         
         if ( log.isDebugEnabled() )
         {
  
  
  
  1.13      +2 -1      jboss-seam/src/main/org/jboss/seam/core/ManagedJbpmContext.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ManagedJbpmContext.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ManagedJbpmContext.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- ManagedJbpmContext.java	10 Oct 2006 18:12:31 -0000	1.12
  +++ ManagedJbpmContext.java	10 Oct 2006 19:37:37 -0000	1.13
  @@ -33,7 +33,7 @@
    * Manages a reference to a JbpmSession.
    *
    * @author <a href="mailto:steve at hibernate.org">Steve Ebersole </a>
  - * @version $Revision: 1.12 $
  + * @version $Revision: 1.13 $
    */
   @Scope(ScopeType.EVENT)
   @Name("jbpmContext")
  @@ -86,6 +86,7 @@
         {
            jbpmContext.save(processInstance);
         }
  +      log.debug( "flushing business process context" );
         Contexts.getBusinessProcessContext().flush();
         jbpmContext.getSession().flush();
      }
  
  
  
  1.20      +8 -5      jboss-seam/src/main/org/jboss/seam/core/ManagedPersistenceContext.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ManagedPersistenceContext.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ManagedPersistenceContext.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -b -r1.19 -r1.20
  --- ManagedPersistenceContext.java	26 Sep 2006 00:29:52 -0000	1.19
  +++ ManagedPersistenceContext.java	10 Oct 2006 19:37:37 -0000	1.20
  @@ -1,4 +1,4 @@
  -//$Id: ManagedPersistenceContext.java,v 1.19 2006/09/26 00:29:52 gavin Exp $
  +//$Id: ManagedPersistenceContext.java,v 1.20 2006/10/10 19:37:37 gavin Exp $
   package org.jboss.seam.core;
   
   import static org.jboss.seam.InterceptionType.NEVER;
  @@ -20,7 +20,6 @@
   import org.jboss.seam.annotations.Create;
   import org.jboss.seam.annotations.Destroy;
   import org.jboss.seam.annotations.Intercept;
  -import org.jboss.seam.annotations.Mutable;
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.annotations.Unwrap;
   import org.jboss.seam.util.Naming;
  @@ -36,8 +35,7 @@
    */
   @Scope(ScopeType.CONVERSATION)
   @Intercept(NEVER)
  - at Mutable
  -public class ManagedPersistenceContext implements Serializable, HttpSessionActivationListener
  +public class ManagedPersistenceContext implements Serializable, HttpSessionActivationListener, Mutable
   {
   
      private static final Log log = LogFactory.getLog(ManagedPersistenceContext.class);
  @@ -46,6 +44,11 @@
      private String persistenceUnitJndiName;
      private String componentName;
      
  +   public boolean clearDirty()
  +   {
  +      return true;
  +   }
  +
      @Create
      public void create(Component component)
      {
  @@ -57,7 +60,7 @@
         
         createEntityManager();
         
  -      TouchedContexts.instance().add(componentName);
  +      TouchedContexts.instance().touch(componentName);
         
         if ( log.isDebugEnabled() )
         {
  
  
  
  1.89      +1 -14     jboss-seam/src/main/org/jboss/seam/core/Manager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Manager.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Manager.java,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -b -r1.88 -r1.89
  --- Manager.java	8 Oct 2006 21:32:27 -0000	1.88
  +++ Manager.java	10 Oct 2006 19:37:37 -0000	1.89
  @@ -44,7 +44,7 @@
    *
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.88 $
  + * @version $Revision: 1.89 $
    */
   @Scope(ScopeType.EVENT)
   @Name("org.jboss.seam.core.manager")
  @@ -367,18 +367,6 @@
         dirty();
      }
      
  -   private void forceMutableComponentReplication()
  -   {
  -      for (String name: Init.instance().getMutableComponentNames())
  -      {
  -         Object object = Contexts.getSessionContext().get(name);
  -         if (object!=null)
  -         {
  -            Contexts.getSessionContext().set(name, object);
  -         }
  -      }
  -   }
  -   
      /**
       * Flush the server-side conversation context to the session and
       * write the conversation id and pageflow info to the response
  @@ -392,7 +380,6 @@
            touchConversationStack();
            if ( !Seam.isSessionInvalid() ) 
            {
  -            forceMutableComponentReplication();
               storeLongRunningConversation(response);
            }
         }
  
  
  
  1.32      +7 -4      jboss-seam/src/main/org/jboss/seam/core/Pageflow.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Pageflow.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Pageflow.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -b -r1.31 -r1.32
  --- Pageflow.java	3 Oct 2006 22:21:39 -0000	1.31
  +++ Pageflow.java	10 Oct 2006 19:37:38 -0000	1.32
  @@ -13,7 +13,6 @@
   import org.jboss.seam.Component;
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.annotations.Intercept;
  -import org.jboss.seam.annotations.Mutable;
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.contexts.Contexts;
  @@ -33,8 +32,7 @@
   @Scope(ScopeType.CONVERSATION)
   @Name("pageflow")
   @Intercept(NEVER)
  - at Mutable
  -public class Pageflow implements Serializable
  +public class Pageflow extends AbstractMutable implements Serializable
   {
      
      private static final Log log = LogFactory.getLog(Pageflow.class);
  @@ -54,6 +52,7 @@
   
      public void setProcessInstance(ProcessInstance processInstance) {
         this.processInstance = processInstance;
  +      setDirty();
      }
      
      public static Pageflow instance()
  @@ -142,6 +141,7 @@
               );
         }
         processInstance.getRootToken().setNode(node);
  +      setDirty();
      }
      
      public Page getPage() 
  @@ -169,6 +169,7 @@
         }
   
         counter++;
  +      setDirty();
      }
   
      public boolean hasDefaultTransition()
  @@ -234,6 +235,8 @@
       	  //pi.signal();
         //}
         
  +      setDirty();
  +      
         Events.instance().raiseEvent("org.jboss.seam.beginPageflow." + pageflowDefinitionName);
      }
      
  
  
  
  1.6       +5 -2      jboss-seam/src/main/org/jboss/seam/core/Redirect.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Redirect.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Redirect.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- Redirect.java	25 Jul 2006 04:40:43 -0000	1.5
  +++ Redirect.java	10 Oct 2006 19:37:38 -0000	1.6
  @@ -23,7 +23,7 @@
   @Name("redirect")
   @Intercept(InterceptionType.NEVER)
   @Scope(ScopeType.CONVERSATION)
  -public class Redirect implements Serializable
  +public class Redirect extends AbstractMutable implements Serializable
   {
      private String viewId;
      private Map<String, Object> parameters = new HashMap<String, Object>();
  @@ -44,6 +44,7 @@
       */
      public void setViewId(String viewId)
      {
  +      setDirty(this.viewId, viewId);
         this.viewId = viewId;
      }
      
  @@ -62,7 +63,8 @@
       */
      public void setParameter(String name, Object value)
      {
  -      parameters.put(name, value);
  +      Object old = parameters.put(name, value);
  +      setDirty(old, value);
      }
      
      /**
  @@ -76,6 +78,7 @@
         FacesContext context = FacesContext.getCurrentInstance();
         parameters.putAll( context.getExternalContext().getRequestParameterMap() );
         viewId = context.getViewRoot().getViewId();
  +      setDirty();
      }
      
      /**
  
  
  
  1.3       +11 -8     jboss-seam/src/main/org/jboss/seam/core/TouchedContexts.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TouchedContexts.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/TouchedContexts.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- TouchedContexts.java	26 Sep 2006 14:48:46 -0000	1.2
  +++ TouchedContexts.java	10 Oct 2006 19:37:38 -0000	1.3
  @@ -2,37 +2,40 @@
   
   import static org.jboss.seam.InterceptionType.NEVER;
   
  +import java.io.Serializable;
  +import java.util.Collections;
   import java.util.HashSet;
   import java.util.Set;
   
   import org.jboss.seam.Component;
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.annotations.Intercept;
  -import org.jboss.seam.annotations.Mutable;
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
  -import org.jboss.seam.annotations.Unwrap;
   import org.jboss.seam.contexts.Contexts;
   
   @Name("org.jboss.seam.core.touchedContexts")
   @Scope(ScopeType.CONVERSATION)
   @Intercept(NEVER)
  - at Mutable
  -public class TouchedContexts
  +public class TouchedContexts extends AbstractMutable implements Serializable
   {
      private Set<String> set = new HashSet<String>();
      
  -   @Unwrap
      public Set<String> getTouchedContexts()
      {
  -      return set;
  +      return Collections.unmodifiableSet(set);
      }
      
  -   public static Set<String> instance()
  +   public void touch(String context)
  +   {
  +      if ( set.add(context) ) setDirty();
  +   }
  +   
  +   public static TouchedContexts instance()
      {
         if ( Contexts.isConversationContextActive() )
         {
  -         return (Set<String>) Component.getInstance(TouchedContexts.class);
  +         return (TouchedContexts) Component.getInstance(TouchedContexts.class);
         }
         else
         {
  
  
  
  1.4       +5 -3      jboss-seam/src/main/org/jboss/seam/core/Transition.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Transition.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Transition.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- Transition.java	30 Dec 2005 00:49:38 -0000	1.3
  +++ Transition.java	10 Oct 2006 19:37:38 -0000	1.4
  @@ -20,7 +20,8 @@
   @Name("transition")
   @Scope(ScopeType.CONVERSATION)
   @Intercept(NEVER)
  -public class Transition implements Serializable {
  +public class Transition extends AbstractMutable implements Serializable {
  +   
      private String name;
   
      public String getName() 
  @@ -31,9 +32,10 @@
      /**
       * Set the jBPM transition name
       */
  -   public void setName(String id) 
  +   public void setName(String name) 
      {
  -      this.name = id;
  +      setDirty(this.name, name);
  +      this.name = name;
      }
      
      public static Transition instance()
  
  
  
  1.1      date: 2006/10/10 19:37:37;  author: gavin;  state: Exp;jboss-seam/src/main/org/jboss/seam/core/AbstractMutable.java
  
  Index: AbstractMutable.java
  ===================================================================
  package org.jboss.seam.core;
  
  /**
   * Base helper implementation of Mutable
   * 
   * @author Gavin King
   *
   */
  public abstract class AbstractMutable implements Mutable
  {
     private transient boolean dirty;
  
     public boolean clearDirty()
     {
        boolean result = dirty;
        dirty = false;
        return result;
     }
     
     /**
      * Set the dirty flag if the value has changed.
      * Call whenever a subclass attribute is updated.
      * 
      * @param oldValue the old value of an attribute
      * @param newValue the new value of an attribute
      */
     protected <T> void setDirty(T oldValue, T newValue)
     {
        dirty = dirty || (
              oldValue!=newValue && (
                    oldValue==null || 
                    !oldValue.equals(newValue) 
                 )
           );
     }
     
     /**
      * Set the dirty flag.
      */
     protected void setDirty()
     {
        dirty = true;
     }
  
  }
  
  
  
  1.1      date: 2006/10/10 19:37:38;  author: gavin;  state: Exp;jboss-seam/src/main/org/jboss/seam/core/Mutable.java
  
  Index: Mutable.java
  ===================================================================
  package org.jboss.seam.core;
  
  import java.io.Serializable;
  
  /**
   * Must be implemented by any SESSION or CONVERSATION scoped
   * mutable JavaBean component that will be used in a clustered
   * environment. If this interface is not implemented correctly,
   * changes may not be replicated across the cluster (depending
   * upon the servlet engine implementation).
   * 
   * @author Gavin King
   *
   */
  public interface Mutable extends Serializable
  {
     /**
      * Get and clear the dirty flag.
      * 
      * @return true if the instance is dirty and requires replication
      */
     public boolean clearDirty();
  }
  
  
  



More information about the jboss-cvs-commits mailing list