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

Gavin King gavin.king at jboss.com
Tue Jun 19 00:21:45 EDT 2007


  User: gavin   
  Date: 07/06/19 00:21:45

  Modified:    src/main/org/jboss/seam/core    FacesPage.java Jbpm.java
                        Pageflow.java
  Log:
  JBSEAM-157, pageflow composition, finally
  
  Revision  Changes    Path
  1.11      +1 -1      jboss-seam/src/main/org/jboss/seam/core/FacesPage.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FacesPage.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/FacesPage.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- FacesPage.java	10 Jun 2007 20:18:17 -0000	1.10
  +++ FacesPage.java	19 Jun 2007 04:21:45 -0000	1.11
  @@ -67,7 +67,7 @@
            Pageflow pageflow = Pageflow.instance();
            if ( pageflow.isInProcess() /*&& !pageflow.getProcessInstance().hasEnded()*/ && Manager.instance().isLongRunningConversation() )
            {
  -            pageflowName = pageflow.getProcessInstance().getProcessDefinition().getName();
  +            pageflowName = pageflow.getSubProcessInstance().getProcessDefinition().getName();
               pageflowNodeName = pageflow.getNode().getName();
               pageflowCounter = pageflow.getPageflowCounter();
            }
  
  
  
  1.46      +16 -0     jboss-seam/src/main/org/jboss/seam/core/Jbpm.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Jbpm.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Jbpm.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -b -r1.45 -r1.46
  --- Jbpm.java	18 Jun 2007 17:27:22 -0000	1.45
  +++ Jbpm.java	19 Jun 2007 04:21:45 -0000	1.46
  @@ -12,6 +12,7 @@
   
   import javax.naming.NamingException;
   
  +import org.dom4j.Element;
   import org.hibernate.HibernateException;
   import org.hibernate.cfg.Environment;
   import org.hibernate.lob.ReaderInputStream;
  @@ -35,6 +36,9 @@
   import org.jbpm.JbpmConfiguration;
   import org.jbpm.JbpmContext;
   import org.jbpm.graph.def.ProcessDefinition;
  +import org.jbpm.graph.node.DbSubProcessResolver;
  +import org.jbpm.graph.node.ProcessState;
  +import org.jbpm.graph.node.SubProcessResolver;
   import org.jbpm.instantiation.UserCodeInterceptorConfig;
   import org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator;
   import org.jbpm.persistence.db.DbPersistenceServiceFactory;
  @@ -67,6 +71,7 @@
      public void startup() throws Exception
      {
         log.trace( "Starting jBPM" );
  +      ProcessState.setDefaultSubProcessResolver( new SeamSubProcessResolver() );
         installProcessDefinitions();
         installPageflowDefinitions();
         JbpmExpressionEvaluator.setVariableResolver( new SeamVariableResolver() );
  @@ -286,4 +291,15 @@
         this.jbpmConfigurationJndiName = jbpmConfigurationJndiName;
      }
      
  +   private static final DbSubProcessResolver DB_SUB_PROCESS_RESOLVER = new DbSubProcessResolver();
  +   class SeamSubProcessResolver implements SubProcessResolver
  +   {
  +      public ProcessDefinition findSubProcess(Element element)
  +      {
  +         String subProcessName = element.attributeValue("name");
  +         ProcessDefinition pageflow = pageflowProcessDefinitions.get(subProcessName);
  +         return pageflow==null ? DB_SUB_PROCESS_RESOLVER.findSubProcess(element) : pageflow;
  +      }
  +   }
  +   
   }
  
  
  
  1.52      +45 -13    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.51
  retrieving revision 1.52
  diff -u -b -r1.51 -r1.52
  --- Pageflow.java	18 Jun 2007 17:27:22 -0000	1.51
  +++ Pageflow.java	19 Jun 2007 04:21:45 -0000	1.52
  @@ -30,7 +30,6 @@
   import org.jbpm.graph.def.ProcessDefinition;
   import org.jbpm.graph.exe.ExecutionContext;
   import org.jbpm.graph.exe.ProcessInstance;
  -import org.jbpm.graph.exe.Token;
   
   /**
    * A Seam component that manages the current
  @@ -99,7 +98,7 @@
            String pageflowName = page.getPageflowName();
            String pageflowNodeName = page.getPageflowNodeName();
            boolean canReposition = getPage().isBackEnabled() && 
  -               processInstance.getProcessDefinition().getName().equals(pageflowName) && //probably not necessary
  +               getSubProcessInstance().getProcessDefinition().getName().equals(pageflowName) && //probably not necessary
                  pageflowNodeName!=null; //probably not necessary
            if (canReposition)
            {
  @@ -151,8 +150,7 @@
      public Node getNode() 
      {
         if (processInstance==null) return null;
  -      Token pageFlowToken = processInstance.getRootToken();
  -      Node node = pageFlowToken.getNode();
  +      Node node = getSubProcessInstance().getRootToken().getNode();
         if (node==null) 
         {
            throw new IllegalStateException("pageflow has not yet started");
  @@ -160,6 +158,24 @@
         return node;
      }
      
  +   public ProcessInstance getSubProcessInstance()
  +   {
  +      return getSubProcess(processInstance);
  +   }
  +   
  +   private static ProcessInstance getSubProcess(ProcessInstance processInstance)
  +   {
  +      ProcessInstance subProcess = processInstance.getRootToken().getSubProcessInstance();
  +      if (subProcess!=null)
  +      {
  +         return getSubProcess(subProcess);
  +      }
  +      else
  +      {
  +         return processInstance;
  +      }
  +   }
  +   
      /**
       * Reposition the pageflow at the named node.
       * 
  @@ -171,15 +187,16 @@
         {
            throw new IllegalStateException("no pageflow in progress");
         }
  -      Node node = processInstance.getProcessDefinition().getNode(nodeName);
  +      ProcessInstance subProcess = getSubProcessInstance();
  +      Node node = subProcess.getProcessDefinition().getNode(nodeName);
         if (node==null)
         {
            throw new IllegalArgumentException(
                  "no node named: " + nodeName + 
  -               " for pageflow: " + processInstance.getProcessDefinition().getName()
  +               " for pageflow: " + subProcess.getProcessDefinition().getName()
               );
         }
  -      processInstance.getRootToken().setNode(node);
  +      subProcess.getRootToken().setNode(node);
         setDirty();
      }
      
  @@ -282,7 +299,9 @@
       * Given the JSF action outcome, perform navigation according
       * to the current pageflow.
       */
  -   public void navigate(FacesContext context, String outcome) {
  +   public void navigate(FacesContext context, String outcome) 
  +   {
  +      ProcessInstance subProcess = getSubProcessInstance();
         if ( isNullOutcome(outcome) )
         {
            //if it has a default transition defined, trigger it,
  @@ -291,20 +310,28 @@
            {
               //we don't use jBPM's default transition,
               //instead we use the "anonymous" transition
  -            PageflowHelper.signal(processInstance, null);
  +            PageflowHelper.signal(subProcess, null);
               navigate(context);
            }
         }
         else
         {
            //trigger the named transition
  -         PageflowHelper.signal(processInstance, outcome);
  +         PageflowHelper.signal(subProcess, outcome);
            navigate(context);
         }
         
  +      raiseEndEventIfNecessary();
  +   }
  +
  +   protected void raiseEndEventIfNecessary()
  +   {
         if ( processInstance.hasEnded() )
         {
  -         Events.instance().raiseEvent("org.jboss.seam.endPageflow." + processInstance.getProcessDefinition().getName());
  +         Events.instance().raiseEvent(
  +                  "org.jboss.seam.endPageflow." + 
  +                  processInstance.getProcessDefinition().getName()
  +               );
         }
      }
   
  @@ -359,12 +386,17 @@
         
         setDirty();
         
  -      Events.instance().raiseEvent("org.jboss.seam.beginPageflow." + pageflowDefinitionName);
  +      raiseBeginEvent(pageflowDefinitionName);
         
         storePageflowToViewRootIfNecessary();
   
      }
   
  +   protected void raiseBeginEvent(String pageflowDefinitionName)
  +   {
  +      Events.instance().raiseEvent("org.jboss.seam.beginPageflow." + pageflowDefinitionName);
  +   }
  +
      private void storePageflowToViewRootIfNecessary()
      {
         FacesContext facesContext = FacesContext.getCurrentInstance();
  
  
  



More information about the jboss-cvs-commits mailing list