You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2003/10/02 17:27:42 UTC

cvs commit: cocoon-lenya/src/java/org/apache/lenya/workflow WorkflowInstance.java Transition.java

andreas     2003/10/02 08:27:42

  Modified:    src/java/org/apache/lenya/cms/workflow WorkflowFactory.java
               src/java/org/apache/lenya/workflow/impl TransitionImpl.java
                        WorkflowInstanceImpl.java WorkflowBuilder.java
               src/java/org/apache/lenya/workflow WorkflowInstance.java
                        Transition.java
  Added:       src/java/org/apache/lenya/cms/workflow
                        WorkflowDocumentSet.java
               src/java/org/apache/lenya/workflow/impl
                        SynchronizedWorkflowInstances.java
  Log:
  added synchronization layer to workflow
  
  Revision  Changes    Path
  1.24      +21 -1     cocoon-lenya/src/java/org/apache/lenya/cms/workflow/WorkflowFactory.java
  
  Index: WorkflowFactory.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/workflow/WorkflowFactory.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- WorkflowFactory.java	9 Sep 2003 10:29:14 -0000	1.23
  +++ WorkflowFactory.java	2 Oct 2003 15:27:41 -0000	1.24
  @@ -66,10 +66,13 @@
   import org.apache.lenya.cms.ac2.Identity;
   import org.apache.lenya.cms.ac2.PolicyAuthorizer;
   import org.apache.lenya.cms.publication.Document;
  +import org.apache.lenya.cms.publication.DocumentException;
  +import org.apache.lenya.cms.publication.LanguageVersions;
   import org.apache.lenya.cms.publication.Publication;
   import org.apache.lenya.workflow.*;
   import org.apache.lenya.workflow.Workflow;
   import org.apache.lenya.workflow.impl.History;
  +import org.apache.lenya.workflow.impl.SynchronizedWorkflowInstances;
   import org.apache.lenya.workflow.impl.WorkflowBuilder;
   
   import java.io.File;
  @@ -106,6 +109,23 @@
           assert document != null;
   
           return new CMSHistory(document).getInstance();
  +    }
  +
  +    /**
  +     * Creates a new synchronized workflow instances object..
  +     * @param document The document to create the instances for.
  +     * @return A synchronized workflow instances object.
  +     * @throws WorkflowException when something went wrong.
  +     */
  +    public SynchronizedWorkflowInstances buildSynchronizedInstance(Document document) throws WorkflowException {
  +        assert document != null;
  +        LanguageVersions versions;
  +        try {
  +            versions = new LanguageVersions(document);
  +        } catch (DocumentException e) {
  +            throw new WorkflowException(e);
  +        }
  +        return new WorkflowDocumentSet(versions, document);
       }
   
       /**
  
  
  
  1.1                  cocoon-lenya/src/java/org/apache/lenya/cms/workflow/WorkflowDocumentSet.java
  
  Index: WorkflowDocumentSet.java
  ===================================================================
  /*
  $Id: WorkflowDocumentSet.java,v 1.1 2003/10/02 15:27:41 andreas Exp $
  <License>
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Lenya" and  "Apache Software Foundation"  must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
   ware Foundation, please see <http://www.apache.org/>.
  
   Lenya includes software developed by the Apache Software Foundation, W3C,
   DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
  </License>
  */
  package org.apache.lenya.cms.workflow;
  
  import org.apache.lenya.cms.publication.Document;
  import org.apache.lenya.cms.publication.DocumentSet;
  import org.apache.lenya.workflow.WorkflowException;
  import org.apache.lenya.workflow.WorkflowInstance;
  import org.apache.lenya.workflow.impl.SynchronizedWorkflowInstances;
  
  /**
   * @author <a href="mailto:andreas@apache.org">Andreas Hartmann</a>
   */
  public class WorkflowDocumentSet extends SynchronizedWorkflowInstances {
  
      public WorkflowDocumentSet(DocumentSet documentSet, Document mainDocument) throws WorkflowException {
          Document[] documents = documentSet.getDocuments();
          WorkflowInstance[] instances = new WorkflowInstance[documents.length];
          WorkflowFactory factory = WorkflowFactory.newInstance();
          for (int i = 0; i < documents.length; i++) {
              instances[i] = factory.buildInstance(documents[i]);
          }
          setInstances(instances);
          setMainInstance(factory.buildInstance(mainDocument));
      }
  
  }
  
  
  
  1.8       +19 -1     cocoon-lenya/src/java/org/apache/lenya/workflow/impl/TransitionImpl.java
  
  Index: TransitionImpl.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/workflow/impl/TransitionImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TransitionImpl.java	8 Sep 2003 19:29:54 -0000	1.7
  +++ TransitionImpl.java	2 Oct 2003 15:27:42 -0000	1.8
  @@ -90,6 +90,7 @@
       }
   
       private List actions = new ArrayList();
  +    private boolean isSynchronized = false;
   
       /**
        * DOCUMENT ME!
  @@ -230,4 +231,21 @@
   
           return string;
       }
  +
  +    /**
  +     * Returns if this transition is synchronized.
  +     * @return A boolean value.
  +     */
  +    public boolean isSynchronized() {
  +        return isSynchronized;
  +    }
  +
  +    /**
  +     * Sets if this transition is synchronized.
  +     * @param isSynchronized A boolean value.
  +     */
  +    protected void setSynchronized(boolean isSynchronized) {
  +        this.isSynchronized = isSynchronized;
  +    }
  +
   }
  
  
  
  1.10      +37 -6     cocoon-lenya/src/java/org/apache/lenya/workflow/impl/WorkflowInstanceImpl.java
  
  Index: WorkflowInstanceImpl.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/workflow/impl/WorkflowInstanceImpl.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- WorkflowInstanceImpl.java	8 Sep 2003 19:29:54 -0000	1.9
  +++ WorkflowInstanceImpl.java	2 Oct 2003 15:27:42 -0000	1.10
  @@ -157,18 +157,40 @@
                   "' cannot be invoked in the situation '" + situation + "'.");
           }
   
  +        fire(getNextTransition(event));
  +
  +        for (Iterator iter = listeners.iterator(); iter.hasNext();) {
  +            WorkflowListener listener = (WorkflowListener) iter.next();
  +            listener.transitionFired(this, situation, event);
  +        }
  +    }
  +
  +    /**
  +     * Returns the transition that would fire for a given event.
  +     * @param event The event.
  +     * @return A transition.
  +     * @throws WorkflowException if no single transition would fire.
  +     */
  +    protected TransitionImpl getNextTransition(Event event) throws WorkflowException {
  +        TransitionImpl nextTransition = null;
           Transition[] transitions = getWorkflow().getLeavingTransitions(getCurrentState());
   
           for (int i = 0; i < transitions.length; i++) {
               if (transitions[i].getEvent().equals(event)) {
  -                fire((TransitionImpl) transitions[i]);
  +                
  +                if (nextTransition != null) {
  +                    throw new WorkflowException("More than one transition found for event [" + event + "]!");
  +                }
  +                
  +                nextTransition = (TransitionImpl) transitions[i];
               }
           }
  -
  -        for (Iterator iter = listeners.iterator(); iter.hasNext();) {
  -            WorkflowListener listener = (WorkflowListener) iter.next();
  -            listener.transitionFired(this, situation, event);
  +        
  +        if (nextTransition == null) {
  +            throw new WorkflowException("No transition found for event [" + event + "]!");
           }
  +        
  +        return nextTransition;
       }
   
       /**
  @@ -316,4 +338,13 @@
       public void removeWorkflowListener(WorkflowListener listener) {
           listeners.remove(listener);
       }
  +
  +    /**
  +     * @see org.apache.lenya.workflow.WorkflowInstance#isSynchronized(org.apache.lenya.workflow.Situation, org.apache.lenya.workflow.Event)
  +     */
  +    public boolean isSynchronized(Event event) throws WorkflowException {
  +        Transition nextTransition = getNextTransition(event);
  +        return nextTransition.isSynchronized();
  +    }
  +
   }
  
  
  
  1.11      +39 -29    cocoon-lenya/src/java/org/apache/lenya/workflow/impl/WorkflowBuilder.java
  
  Index: WorkflowBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/workflow/impl/WorkflowBuilder.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- WorkflowBuilder.java	8 Sep 2003 19:29:54 -0000	1.10
  +++ WorkflowBuilder.java	2 Oct 2003 15:27:42 -0000	1.11
  @@ -77,15 +77,14 @@
   
   import javax.xml.parsers.ParserConfigurationException;
   
  -
   /**
    *
    * @author  andreas
    */
   public class WorkflowBuilder {
  -    
  +
       private static final Category log = Category.getInstance(WorkflowBuilder.class);
  -    
  +
       /**
        * Ctor.
        */
  @@ -101,8 +100,7 @@
        *
        * @throws WorkflowException DOCUMENT ME!
        */
  -    public static WorkflowImpl buildWorkflow(File file)
  -        throws WorkflowException {
  +    public static WorkflowImpl buildWorkflow(File file) throws WorkflowException {
           WorkflowImpl workflow;
   
           try {
  @@ -153,7 +151,8 @@
           WorkflowImpl workflow = new WorkflowImpl(initialState);
   
           // load variables
  -        NodeList variableElements = root.getElementsByTagNameNS(Workflow.NAMESPACE, VARIABLE_ELEMENT);
  +        NodeList variableElements =
  +            root.getElementsByTagNameNS(Workflow.NAMESPACE, VARIABLE_ELEMENT);
   
           for (int i = 0; i < variableElements.getLength(); i++) {
               Element element = (Element) variableElements.item(i);
  @@ -173,12 +172,12 @@
           }
   
           // load transitions
  -        NodeList transitionElements = root.getElementsByTagNameNS(Workflow.NAMESPACE,
  -                TRANSITION_ELEMENT);
  +        NodeList transitionElements =
  +            root.getElementsByTagNameNS(Workflow.NAMESPACE, TRANSITION_ELEMENT);
   
           for (int i = 0; i < transitionElements.getLength(); i++) {
  -            TransitionImpl transition = buildTransition((Element) transitionElements.item(i),
  -                    states, events, variables);
  +            TransitionImpl transition =
  +                buildTransition((Element) transitionElements.item(i), states, events, variables);
               workflow.addTransition(transition);
           }
   
  @@ -195,8 +194,8 @@
   
           String initialAttribute = element.getAttribute(INITIAL_ATTRIBUTE);
   
  -        return (initialAttribute != null) &&
  -        (initialAttribute.equals("yes") || initialAttribute.equals("true"));
  +        return (initialAttribute != null)
  +            && (initialAttribute.equals("yes") || initialAttribute.equals("true"));
       }
   
       protected static final String STATE_ELEMENT = "state";
  @@ -214,6 +213,7 @@
       protected static final String VARIABLE_ATTRIBUTE = "variable";
       protected static final String VALUE_ATTRIBUTE = "value";
       protected static final String NAME_ATTRIBUTE = "name";
  +    protected static final String SYNCHRONIZED_ATTRIBUTE = "synchronized";
   
       /**
        * Builds a state from an XML element.
  @@ -238,13 +238,17 @@
        * @return A transition.
        * @throws WorkflowException when something went wrong.
        */
  -    protected static TransitionImpl buildTransition(Element element, Map states, Map events,
  -        Map variables) throws WorkflowException {
  -            
  +    protected static TransitionImpl buildTransition(
  +        Element element,
  +        Map states,
  +        Map events,
  +        Map variables)
  +        throws WorkflowException {
  +
           if (log.isDebugEnabled()) {
               log.debug("Building transition");
           }
  -            
  +
           assert element.getLocalName().equals(TRANSITION_ELEMENT);
   
           String sourceId = element.getAttribute(SOURCE_ATTRIBUTE);
  @@ -262,8 +266,8 @@
           TransitionImpl transition = new TransitionImpl(source, destination);
   
           // set event
  -        Element eventElement = (Element) element.getElementsByTagNameNS(Workflow.NAMESPACE,
  -                EVENT_ELEMENT).item(0);
  +        Element eventElement =
  +            (Element) element.getElementsByTagNameNS(Workflow.NAMESPACE, EVENT_ELEMENT).item(0);
           String id = eventElement.getAttribute(ID_ATTRIBUTE);
           assert id != null;
   
  @@ -275,10 +279,10 @@
           if (log.isDebugEnabled()) {
               log.debug("    Event: [" + event + "]");
           }
  -            
  +
           // load conditions
  -        NodeList conditionElements = element.getElementsByTagNameNS(Workflow.NAMESPACE,
  -                CONDITION_ELEMENT);
  +        NodeList conditionElements =
  +            element.getElementsByTagNameNS(Workflow.NAMESPACE, CONDITION_ELEMENT);
   
           for (int i = 0; i < conditionElements.getLength(); i++) {
               Condition condition = buildCondition((Element) conditionElements.item(i));
  @@ -286,23 +290,30 @@
           }
   
           // load assignments
  -        NodeList assignmentElements = element.getElementsByTagNameNS(Workflow.NAMESPACE,
  -                ASSIGNMENT_ELEMENT);
  +        NodeList assignmentElements =
  +            element.getElementsByTagNameNS(Workflow.NAMESPACE, ASSIGNMENT_ELEMENT);
   
           for (int i = 0; i < assignmentElements.getLength(); i++) {
  -            BooleanVariableAssignmentImpl action = buildAssignment(variables,
  -                    (Element) assignmentElements.item(i));
  +            BooleanVariableAssignmentImpl action =
  +                buildAssignment(variables, (Element) assignmentElements.item(i));
               transition.addAction(action);
           }
   
           // load actions
  -        NodeList actionElements = element.getElementsByTagNameNS(Workflow.NAMESPACE, ACTION_ELEMENT);
  +        NodeList actionElements =
  +            element.getElementsByTagNameNS(Workflow.NAMESPACE, ACTION_ELEMENT);
   
           for (int i = 0; i < actionElements.getLength(); i++) {
               Action action = buildAction((Element) actionElements.item(i));
               transition.addAction(action);
           }
   
  +        // set synchronization
  +        if (element.hasAttribute(SYNCHRONIZED_ATTRIBUTE)) {
  +            Boolean isSynchronized = Boolean.valueOf(element.getAttribute(SYNCHRONIZED_ATTRIBUTE));
  +            transition.setSynchronized(isSynchronized.booleanValue());
  +        }
  +
           return transition;
       }
   
  @@ -326,8 +337,7 @@
        * @return A condition.
        * @throws WorkflowException when something went wrong.
        */
  -    protected static Condition buildCondition(Element element)
  -        throws WorkflowException {
  +    protected static Condition buildCondition(Element element) throws WorkflowException {
           String className = element.getAttribute(CLASS_ATTRIBUTE);
           String expression = DocumentHelper.getSimpleElementText(element);
           Condition condition = ConditionFactory.createCondition(className, expression);
  
  
  
  1.1                  cocoon-lenya/src/java/org/apache/lenya/workflow/impl/SynchronizedWorkflowInstances.java
  
  Index: SynchronizedWorkflowInstances.java
  ===================================================================
  /*
  $Id: SynchronizedWorkflowInstances.java,v 1.1 2003/10/02 15:27:42 andreas Exp $
  <License>
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Lenya" and  "Apache Software Foundation"  must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
   ware Foundation, please see <http://www.apache.org/>.
  
   Lenya includes software developed by the Apache Software Foundation, W3C,
   DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
  </License>
  */
  package org.apache.lenya.workflow.impl;
  
  import java.util.Arrays;
  import java.util.HashSet;
  import java.util.Set;
  
  import org.apache.lenya.workflow.Event;
  import org.apache.lenya.workflow.Situation;
  import org.apache.lenya.workflow.State;
  import org.apache.lenya.workflow.WorkflowException;
  import org.apache.lenya.workflow.WorkflowInstance;
  import org.apache.log4j.Category;
  
  /**
   * An object of this class encapsulates a set of synchronized
   * workflow instances.
   * @author <a href="mailto:andreas@apache.org">Andreas Hartmann</a>
   */
  public class SynchronizedWorkflowInstances {
  
      private static final Category log = Category.getInstance(SynchronizedWorkflowInstances.class);
  
      /**
       * Ctor.
       */
      public SynchronizedWorkflowInstances() {
      }
  
      /**
       * Ctor.
       * @param instances The set of workflow instances to synchronize.
       * @param mainInstance The main workflow instance to invoke for non-synchronized transitions.
       */
      public SynchronizedWorkflowInstances(
          WorkflowInstance[] instances,
          WorkflowInstance mainInstance) {
          setInstances(instances);
          setMainInstance(mainInstance);
      }
  
      /**
       * Sets the main workflow instance.
       * @param mainInstance The main workflow instance to invoke for non-synchronized transitions.
       */
      public void setMainInstance(WorkflowInstance mainInstance) {
          this.mainInstance = mainInstance;
      }
  
      private WorkflowInstance[] instances;
      private WorkflowInstance mainInstance;
  
      public void setInstances(WorkflowInstance[] instances) {
          this.instances = instances;
      }
  
      public WorkflowInstance[] getInstances() {
          return instances;
      }
  
      /**
       * Returns all executable events.
       * @see org.apache.lenya.workflow.WorkflowInstance#getExecutableEvents(org.apache.lenya.workflow.Situation)
       */
      public Event[] getExecutableEvents(Situation situation) throws WorkflowException {
          if (log.isDebugEnabled()) {
              log.debug("Resolving executable events");
          }
  
          WorkflowInstance[] instances = getInstances();
          if (instances.length == 0) {
              throw new WorkflowException("The set must contain at least one workflow instance!");
          }
  
          Event[] events = mainInstance.getExecutableEvents(situation);
          Set executableEvents = new HashSet(Arrays.asList(events));
  
          for (int i = 0; i < events.length; i++) {
              Event event = events[i];
              if (mainInstance.isSynchronized(event)) {
  
                  boolean canFire = true;
                  if (log.isDebugEnabled()) {
                      log.debug("    Transition for event [" + event + "] is synchronized.");
                  }
  
                  boolean sameState = true;
                  State currentState = mainInstance.getCurrentState();
                  int j = 0;
                  while (j < instances.length && sameState) {
                      sameState = instances[j].getCurrentState().equals(currentState);
                      j++;
                  }
                  if (log.isDebugEnabled()) {
                      log.debug("    All instances are in the same state: [" + sameState + "]");
                  }
  
                  if (sameState) {
                      for (int k = 0; k < instances.length; k++) {
                          WorkflowInstanceImpl instance = (WorkflowInstanceImpl) instances[k];
                          if (instance != mainInstance && !instance.getNextTransition(event).canFire(situation, instance)) {
                              canFire = false;
                              if (log.isDebugEnabled()) {
                                  log.debug("    Workflow instance [" + instance + "] can not fire.");
                              }
                          }
                      }
                  } else {
                      canFire = false;
                  }
  
                  if (!canFire) {
                      executableEvents.remove(event);
                      if (log.isDebugEnabled()) {
                          log.debug("    Event [" + event + "] can not fire - removing from executable events.");
                      }
                  }
              }
          }
  
          if (log.isDebugEnabled()) {
              log.debug("    Resolving executable events completed.");
          }
  
          return (Event[]) executableEvents.toArray(new Event[executableEvents.size()]);
      }
  
      /**
       * Invokes an event on all documents.
       * @see org.apache.lenya.workflow.WorkflowInstance#invoke(org.apache.lenya.workflow.Situation, org.apache.lenya.workflow.Event)
       */
      public void invoke(Situation situation, Event event) throws WorkflowException {
          
          if (mainInstance.isSynchronized(event)) {
              for (int i = 0; i < instances.length; i++) {
                  instances[i].invoke(situation, event);
              }
          }
          else {
              mainInstance.invoke(situation, event);
          }
      }
  
  }
  
  
  
  1.8       +8 -2      cocoon-lenya/src/java/org/apache/lenya/workflow/WorkflowInstance.java
  
  Index: WorkflowInstance.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/workflow/WorkflowInstance.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- WorkflowInstance.java	2 Sep 2003 13:17:22 -0000	1.7
  +++ WorkflowInstance.java	2 Oct 2003 15:27:42 -0000	1.8
  @@ -55,7 +55,6 @@
   */
   package org.apache.lenya.workflow;
   
  -
   /**
    *
    * @author  andreas
  @@ -110,4 +109,11 @@
        * @param listener The listener to remove.
        */
       void removeWorkflowListener(WorkflowListener listener);
  +
  +    /**
  +     * Returns if the transition for a certain event is synchronized.
  +     * @param event An event.
  +     * @return A boolean value.
  +     */
  +    boolean isSynchronized(Event event) throws WorkflowException;
   }
  
  
  
  1.7       +7 -1      cocoon-lenya/src/java/org/apache/lenya/workflow/Transition.java
  
  Index: Transition.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/workflow/Transition.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Transition.java	2 Sep 2003 13:17:22 -0000	1.6
  +++ Transition.java	2 Oct 2003 15:27:42 -0000	1.7
  @@ -86,4 +86,10 @@
        * @throws WorkflowException when an error occurs.
        */
       boolean canFire(Situation situation, WorkflowInstance instance) throws WorkflowException;
  +    
  +    /**
  +     * Returns if this transition is synchronized.
  +     * @return A boolean value.
  +     */
  +    boolean isSynchronized();
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org