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

Gavin King gavin.king at jboss.com
Fri Sep 29 18:48:50 EDT 2006


  User: gavin   
  Date: 06/09/29 18:48:50

  Modified:    src/main/org/jboss/seam/core     BusinessProcess.java
                        Events.java Manager.java Pageflow.java
  Log:
  JBSEAM-28 context events
  
  Revision  Changes    Path
  1.2       +112 -0    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.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- BusinessProcess.java	20 Jun 2006 04:11:02 -0000	1.1
  +++ BusinessProcess.java	29 Sep 2006 22:48:50 -0000	1.2
  @@ -4,6 +4,8 @@
   
   import java.io.Serializable;
   
  +import javax.faces.application.FacesMessage;
  +
   import org.jboss.seam.Component;
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.annotations.Intercept;
  @@ -70,6 +72,8 @@
         // need to set process variables before the signal
         Contexts.getBusinessProcessContext().flush();
         process.signal();
  +      
  +      Events.instance().raiseEvent("org.jboss.seam.createProcess." + processDefinitionName);
      }
   
      public void startTask()
  @@ -84,6 +88,8 @@
         {
            task.start();
         }
  +      
  +      Events.instance().raiseEvent("org.jboss.seam.startTask." + task.getTask().getName());
      }
   
      public void endTask(String transitionName)
  @@ -109,6 +115,112 @@
         }
         
         setTaskId(null);
  +      
  +      Events.instance().raiseEvent("org.jboss.seam.endTask." + task.getTask().getName());
  +   }
  +   
  +   public boolean initTask(Long taskId)
  +   {
  +      setTaskId(taskId);
  +      TaskInstance task = org.jboss.seam.core.TaskInstance.instance();
  +      if (task==null)
  +      {
  +         taskNotFound(taskId);
  +         return false;
  +      }
  +      else if ( task.hasEnded() )
  +      {
  +         taskEnded(taskId);
  +         return false;
  +      }
  +      else
  +      {
  +         setProcessId( task.getTaskMgmtInstance().getProcessInstance().getId() );
  +         Events.instance().raiseEvent("org.jboss.seam.initTask." + task.getTask().getName());
  +         return true;
  +      }
  +      
  +   }
  +   
  +   public boolean initProcess(Long processId)
  +   {
  +      setProcessId(processId);
  +      ProcessInstance process = org.jboss.seam.core.ProcessInstance.instance();
  +      if ( process==null )
  +      {
  +         processNotFound(processId);
  +         return false;
  +      }
  +      else if ( process.hasEnded() )
  +      {
  +         processEnded(processId);
  +         return false;
  +      }
  +      else
  +      {
  +         Events.instance().raiseEvent("org.jboss.seam.initProcess." + process.getProcessDefinition().getName());
  +         return true;
  +      }
  +   }
  +
  +   public boolean checkTask()
  +   {
  +      TaskInstance task = org.jboss.seam.core.TaskInstance.instance();
  +      Long taskId = getTaskId();
  +      if ( task==null )
  +      {
  +         taskNotFound(taskId);
  +         return false;
  +      }
  +      else if ( task.hasEnded() )
  +      {
  +         taskEnded(taskId);
  +         return false;
  +      }
  +      else
  +      {
  +         return true;
  +      }
  +   }
  +
  +   private void taskNotFound(Long taskId)
  +   {
  +      FacesMessages.instance().addFromResourceBundle(
  +            FacesMessage.SEVERITY_WARN, 
  +            "org.jboss.seam.TaskNotFound", 
  +            "Task #0 not found", 
  +            taskId
  +         );
  +   }
  +
  +   private void taskEnded(Long taskId)
  +   {
  +      FacesMessages.instance().addFromResourceBundle(
  +            FacesMessage.SEVERITY_WARN, 
  +            "org.jboss.seam.TaskEnded", 
  +            "Task #0 already ended", 
  +            taskId
  +         );
  +   }
  +
  +   private void processEnded(Long processId)
  +   {
  +      FacesMessages.instance().addFromResourceBundle(
  +            FacesMessage.SEVERITY_WARN, 
  +            "org.jboss.seam.ProcessEnded", 
  +            "Process #0 already ended", 
  +            processId
  +         );
  +   }
  +
  +   private void processNotFound(Long processId)
  +   {
  +      FacesMessages.instance().addFromResourceBundle(
  +            FacesMessage.SEVERITY_WARN, 
  +            "org.jboss.seam.ProcessNotFound", 
  +            "Process #0 not found", 
  +            processId
  +         );
      }
      
   }
  
  
  
  1.5       +6 -0      jboss-seam/src/main/org/jboss/seam/core/Events.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Events.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Events.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- Events.java	25 Jul 2006 20:15:18 -0000	1.4
  +++ Events.java	29 Sep 2006 22:48:50 -0000	1.5
  @@ -19,6 +19,7 @@
   import org.dom4j.io.SAXReader;
   import org.jboss.seam.Component;
   import org.jboss.seam.ScopeType;
  +import org.jboss.seam.Seam;
   import org.jboss.seam.annotations.Create;
   import org.jboss.seam.annotations.Intercept;
   import org.jboss.seam.annotations.Name;
  @@ -105,6 +106,11 @@
         }
      }
      
  +   public static boolean exists()
  +   {
  +      return Contexts.getApplicationContext().isSet( Seam.getComponentName(Events.class) );
  +   }
  +
      public static Events instance()
      {
         if ( !Contexts.isApplicationContextActive() )
  
  
  
  1.86      +3 -1      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.85
  retrieving revision 1.86
  diff -u -b -r1.85 -r1.86
  --- Manager.java	27 Sep 2006 23:14:41 -0000	1.85
  +++ Manager.java	29 Sep 2006 22:48:50 -0000	1.86
  @@ -44,7 +44,7 @@
    *
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.85 $
  + * @version $Revision: 1.86 $
    */
   @Scope(ScopeType.EVENT)
   @Name("org.jboss.seam.core.manager")
  @@ -714,6 +714,7 @@
         setLongRunningConversation(true);
         createConversationEntry().setInitiatorComponentName(initiator);
         Conversation.instance(); //force instantiation of the Conversation in the outer (non-nested) conversation
  +      Events.instance().raiseEvent("org.jboss.seam.beginConversation");
      }
   
      /**
  @@ -721,6 +722,7 @@
       */
      public void endConversation(boolean beforeRedirect)
      {
  +      Events.instance().raiseEvent("org.jboss.seam.endConversation");
         setLongRunningConversation(false);
         destroyBeforeRedirect = beforeRedirect;
      }
  
  
  
  1.30      +2 -0      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.29
  retrieving revision 1.30
  diff -u -b -r1.29 -r1.30
  --- Pageflow.java	13 Sep 2006 18:41:53 -0000	1.29
  +++ Pageflow.java	29 Sep 2006 22:48:50 -0000	1.30
  @@ -228,6 +228,8 @@
           //TODO: this is not actually completely true, what about <s:actionLink/>
       	  //pi.signal();
         //}
  +      
  +      Events.instance().raiseEvent("org.jboss.seam.beginPageflow." + pageflowDefinitionName);
      }
      
      public String getNoConversationViewId(String pageflowName, String pageflowNodeName)
  
  
  



More information about the jboss-cvs-commits mailing list