Author: sb
Date: Mon Feb 11 12:53:55 2008
New Revision: 7338

Log:
- Initial work on the plugin system.

Added:
    trunk/Workflow/src/execution/plugin/
    trunk/Workflow/src/execution/plugin/execution_listener.php   (with props)
    trunk/Workflow/src/interfaces/execution_plugin.php
Modified:
    trunk/Workflow/ChangeLog
    trunk/Workflow/design/class_diagram.png
    trunk/Workflow/src/interfaces/execution.php
    trunk/Workflow/src/workflow_autoload.php

Modified: trunk/Workflow/ChangeLog
==============================================================================
--- trunk/Workflow/ChangeLog [iso-8859-1] (original)
+++ trunk/Workflow/ChangeLog [iso-8859-1] Mon Feb 11 12:53:55 2008
@@ -2,6 +2,9 @@
 
 - Implemented issue #12404: Separate file i/o from XML processing in
   ezcWorkflowDefinitionStorageXml.
+
+- Implemented a plugin system that allows plugin developers to hook into
+  various extension points in the workflow execution engine.
 
 - The visualization visitor can now highlight a set of nodes.
 

Modified: trunk/Workflow/design/class_diagram.png
==============================================================================
Binary files - no diff available.

Added: trunk/Workflow/src/execution/plugin/execution_listener.php
==============================================================================
--- trunk/Workflow/src/execution/plugin/execution_listener.php (added)
+++ trunk/Workflow/src/execution/plugin/execution_listener.php [iso-8859-1] Mon 
Feb 11 12:53:55 2008
@@ -1,0 +1,327 @@
+<?php
+/**
+ * File containing the ezcWorkflowExecutionListenerPlugin interface.
+ *
+ * @package Workflow
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Execution plugin that notifies ezcWorkflowExecutionListener objects.
+ *
+ * @package Workflow
+ * @version //autogen//
+ */
+class ezcWorkflowExecutionListenerPlugin extends ezcWorkflowExecutionPlugin
+{
+    /**
+     * Listeners.
+     *
+     * @var array
+     */
+    protected $listeners = array();
+
+    /**
+     * Adds a listener.
+     *
+     * @param ezcWorkflowExecutionListener $listener
+     * @return bool true when the listener was added, false otherwise.
+     */
+    public function addListener( ezcWorkflowExecutionListener $listener )
+    {
+        if ( ezcWorkflowUtil::findObject( $this->listeners, $listener ) !== 
false )
+        {
+            return false;
+        }
+
+        $this->listeners[] = $listener;
+
+        return true;
+    }
+
+    /**
+     * Removes a listener.
+     *
+     * @param ezcWorkflowExecutionListener $listener
+     * @return bool true when the listener was removed, false otherwise.
+     */
+    public function removeListener( ezcWorkflowExecutionListener $listener )
+    {
+        $index = ezcWorkflowUtil::findObject( $this->listeners, $listener );
+
+        if ( $index === false )
+        {
+            return false;
+        }
+
+        unset( $this->listeners[$index] );
+
+        return true;
+    }
+
+    /**
+     * Notify listeners.
+     *
+     * @param string $message
+     * @param int    $type
+     */
+    protected function notifyListeners( $message, $type = 
ezcWorkflowExecutionListener::INFO )
+    {
+        foreach ( $this->listeners as $listener )
+        {
+            $listener->notify( $message, $type );
+        }
+    }
+
+    /**
+     * Called after an execution has been started.
+     *
+     * @param ezcWorkflowExecution $execution
+     */
+    public function afterExecutionStarted( ezcWorkflowExecution $execution )
+    {
+        $this->notifyListeners(
+          sprintf(
+            'Started execution #%d of workflow "%s" (version %d).',
+
+            $execution->getId(),
+            $execution->workflow->name,
+            $execution->workflow->version
+          )
+        );
+    }
+
+    /**
+     * Called after an execution has been suspended.
+     *
+     * @param ezcWorkflowExecution $execution
+     */
+    public function afterExecutionSuspended( ezcWorkflowExecution $execution )
+    {
+        $this->notifyListeners(
+          sprintf(
+            'Suspended execution #%d of workflow "%s" (version %d).',
+
+            $execution->getId(),
+            $execution->workflow->name,
+            $execution->workflow->version
+          )
+        );
+    }
+
+    /**
+     * Called after an execution has been resumed.
+     *
+     * @param ezcWorkflowExecution $execution
+     */
+    public function afterExecutionResumed( ezcWorkflowExecution $execution )
+    {
+        $this->notifyListeners(
+          sprintf(
+            'Resumed execution #%d of workflow "%s" (version %d).',
+
+            $execution->getId(),
+            $execution->workflow->name,
+            $execution->workflow->version
+          )
+        );
+    }
+
+    /**
+     * Called after an execution has been cancelled.
+     *
+     * @param ezcWorkflowExecution $execution
+     */
+    public function afterExecutionCancelled( ezcWorkflowExecution $execution )
+    {
+        $this->notifyListeners(
+          sprintf(
+            'Cancelled execution #%d of workflow "%s" (version %d).',
+
+            $execution->getId(),
+            $execution->workflow->name,
+            $execution->workflow->version
+          )
+        );
+    }
+
+    /**
+     * Called after an execution has successfully ended.
+     *
+     * @param ezcWorkflowExecution $execution
+     */
+    public function afterExecutionEnded( ezcWorkflowExecution $execution )
+    {
+        $this->notifyListeners(
+          sprintf(
+            'Ended execution #%d of workflow "%s" (version %d).',
+
+            $execution->getId(),
+            $execution->workflow->name,
+            $execution->workflow->version
+          )
+        );
+    }
+
+    /**
+     * Called after a node has been activated.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param ezcWorkflowNode      $node
+     */
+    public function afterNodeActivated( ezcWorkflowExecution $execution, 
ezcWorkflowNode $node )
+    {
+        $this->notifyListeners(
+          sprintf(
+            'Activated node #%d(%s) for instance #%d of workflow "%s" (version 
%d).',
+
+            $node->getId(),
+            get_class( $node ),
+            $execution->getId(),
+            $execution->workflow->name,
+            $execution->workflow->version
+          ),
+          ezcWorkflowExecutionListener::DEBUG
+        );
+    }
+
+    /**
+     * Called after a node has been executed.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param ezcWorkflowNode      $node
+     */
+    public function afterNodeExecuted( ezcWorkflowExecution $execution, 
ezcWorkflowNode $node )
+    {
+        $this->notifyListeners(
+          sprintf(
+            'Executed node #%d(%s) for instance #%d of workflow "%s" (version 
%d).',
+
+            $node->getId(),
+            get_class( $node ),
+            $execution->getId(),
+            $execution->workflow->name,
+            $execution->workflow->version
+          ),
+          ezcWorkflowExecutionListener::DEBUG
+        );
+    }
+
+    /**
+     * Called after a service object has been rolled back.
+     *
+     * @param ezcWorkflowExecution                 $execution
+     * @param ezcWorkflowNode                      $node
+     * @param ezcWorkflowRollbackableServiceObject $serviceObject
+     * @param bool                                 $success
+     */
+    public function afterRolledBackServiceObject( ezcWorkflowExecution 
$execution, ezcWorkflowNode $node, ezcWorkflowRollbackableServiceObject 
$serviceObject, $success )
+    {
+        $this->notifyListeners(
+          sprintf(
+            '%s back service object "%s" of node #%d for instance #%d of 
workflow "%s" (version %d).',
+
+            $success ? 'Rolled' : 'Could not roll',
+            get_class( $serviceObject ),
+            $node->getId(),
+            $execution->getId(),
+            $execution->workflow->name,
+            $execution->workflow->version
+          ),
+          ezcWorkflowExecutionListener::DEBUG
+        );
+    }
+
+    /**
+     * Called after a new thread has been started.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param int                  $threadId
+     * @param int                  $parentId
+     * @param int                  $numSiblings
+     */
+    public function afterThreadStarted( ezcWorkflowExecution $execution, 
$threadId, $parentId, $numSiblings )
+    {
+        $this->notifyListeners(
+          sprintf(
+            'Started thread #%d (%s%d sibling(s)) for execution #%d of 
workflow "%s" (version %d).',
+
+            $threadId,
+            $parentId != null ? 'parent: ' . $parentId . ', ' : '',
+            $numSiblings,
+            $execution->getId(),
+            $execution->workflow->name,
+            $execution->workflow->version
+          ),
+          ezcWorkflowExecutionListener::DEBUG
+        );
+    }
+
+    /**
+     * Called after a thread has ended.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param int                  $threadId
+     */
+    public function afterThreadEnded( ezcWorkflowExecution $execution, 
$threadId )
+    {
+        $this->notifyListeners(
+          sprintf(
+            'Ended thread #%d for execution #%d of workflow "%s" (version 
%d).',
+
+            $threadId,
+            $execution->getId(),
+            $execution->workflow->name,
+            $execution->workflow->version
+          ),
+          ezcWorkflowExecutionListener::DEBUG
+        );
+    }
+
+    /**
+     * Called after a variable has been set.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param string               $variableName
+     * @param mixed                $value
+     */
+    public function afterVariableSet( ezcWorkflowExecution $execution, 
$variableName, $value )
+    {
+        $this->notifyListeners(
+          sprintf(
+            'Set variable "%s" to "%s" for execution #%d of workflow "%s" 
(version %d).',
+
+            $variableName,
+            ezcWorkflowUtil::variableToString( $value ),
+            $execution->getId(),
+            $execution->workflow->name,
+            $execution->workflow->version
+          ),
+          ezcWorkflowExecutionListener::DEBUG
+        );
+    }
+
+    /**
+     * Called after a variable has been unset.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param string               $variableName
+     */
+    public function afterVariableUnset( ezcWorkflowExecution $execution, 
$variableName )
+    {
+        $this->notifyListeners(
+          sprintf(
+            'Unset variable "%s" for execution #%d of workflow "%s" (version 
%d).',
+
+            $variableName,
+            $execution->getId(),
+            $execution->workflow->name,
+            $execution->workflow->version
+          ),
+          ezcWorkflowExecutionListener::DEBUG
+        );
+    }
+}
+?>

Propchange: trunk/Workflow/src/execution/plugin/execution_listener.php
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/Workflow/src/execution/plugin/execution_listener.php
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: trunk/Workflow/src/interfaces/execution.php
==============================================================================
--- trunk/Workflow/src/interfaces/execution.php [iso-8859-1] (original)
+++ trunk/Workflow/src/interfaces/execution.php [iso-8859-1] Mon Feb 11 
12:53:55 2008
@@ -111,11 +111,9 @@
     protected $suspended;
 
     /**
-     * Listeners attached to this execution.
-     *
      * @var array
      */
-    protected $listeners = array();
+    protected $plugins = array();
 
     /**
      * @var array
@@ -242,15 +240,10 @@
         $this->doStart( $parentId );
         $this->loadFromVariableHandlers();
 
-        $this->notifyListeners(
-          sprintf(
-            'Started execution #%d of workflow "%s" (version %d).',
-
-            $this->id,
-            $this->workflow->name,
-            $this->workflow->version
-          )
-        );
+        foreach ( $this->plugins as $plugin )
+        {
+            $plugin->afterExecutionStarted( $this );
+        }
 
         // Start workflow execution by activating the start node.
         $this->workflow->startNode->activate( $this );
@@ -300,15 +293,10 @@
         $this->doSuspend();
         $this->saveToVariableHandlers();
 
-        $this->notifyListeners(
-          sprintf(
-            'Suspended execution #%d of workflow "%s" (version %d).',
-
-            $this->id,
-            $this->workflow->name,
-            $this->workflow->version
-          )
-        );
+        foreach ( $this->plugins as $plugin )
+        {
+            $plugin->afterExecutionSuspended( $this );
+        }
     }
 
     /**
@@ -364,15 +352,10 @@
             throw new ezcWorkflowInvalidInputException( $errors );
         }
 
-        $this->notifyListeners(
-          sprintf(
-            'Resumed execution #%d of workflow "%s" (version %d).',
-
-            $this->id,
-            $this->workflow->name,
-            $this->workflow->version
-          )
-        );
+        foreach ( $this->plugins as $plugin )
+        {
+            $plugin->afterExecutionResumed( $this );
+        }
 
         $this->execute();
 
@@ -401,20 +384,10 @@
         {
             $result = $object['object']->rollback( $this );
 
-            $this->notifyListeners(
-              sprintf(
-                '%s back service object "%s" of node #%d for instance #%d ' .
-                'of workflow "%s" (version %d).',
-
-                $result ? 'Rolled' : 'Could not roll',
-                get_class( $object['object'] ),
-                $object['node']->getId(),
-                $this->id,
-                $this->workflow->name,
-                $this->workflow->version
-              ),
-              ezcWorkflowExecutionListener::DEBUG
-            );
+            foreach ( $this->plugins as $plugin )
+            {
+                $plugin->afterRolledBackServiceObject( $this, $object['node'], 
$object['object'], $result );
+            }
         }
 
         $this->end( $node );
@@ -437,35 +410,27 @@
         $this->doEnd();
         $this->saveToVariableHandlers();
 
-        $this->notifyListeners(
-          sprintf(
-            'Executed node #%d(%s) for instance #%d ' .
-            'of workflow "%s" (version %d).',
-
-            $node->getId(),
-            get_class( $node ),
-            $this->id,
-            $this->workflow->name,
-            $this->workflow->version
-          ),
-          ezcWorkflowExecutionListener::DEBUG
-        );
-
-        if ( !$this->cancelled )
+        foreach ( $this->plugins as $plugin )
+        {
+            $plugin->afterNodeExecuted( $this, $node );
+        }
+
+        if ( $this->cancelled )
+        {
+            foreach ( $this->plugins as $plugin )
+            {
+                $plugin->afterExecutionCancelled( $this );
+            }
+        }
+        else
         {
             $this->endThread( $node->getThreadId() );
-        }
-
-        $this->notifyListeners(
-          sprintf(
-            '%s execution #%d of workflow "%s" (version %d).',
-
-            $this->cancelled ? 'Cancelled' : 'Ended',
-            $this->id,
-            $this->workflow->name,
-            $this->workflow->version
-          )
-        );
+
+            foreach ( $this->plugins as $plugin )
+            {
+                $plugin->afterExecutionEnded( $this );
+            }
+        }
     }
 
     /**
@@ -508,23 +473,13 @@
                         unset( $this->activatedNodes[$key] );
                         $this->numActivatedNodes--;
 
-                        // Notify workflow listeners about the node that has
-                        // been executed.
+                        // Notify plugins that the node has been executed.
                         if ( !$this->hasEnded() )
                         {
-                            $this->notifyListeners(
-                              sprintf(
-                                'Executed node #%d(%s) for instance #%d ' .
-                                'of workflow "%s" (version %d).',
-
-                                $node->getId(),
-                                get_class( $node ),
-                                $this->id,
-                                $this->workflow->name,
-                                $this->workflow->version
-                              ),
-                              ezcWorkflowExecutionListener::DEBUG
-                            );
+                            foreach ( $this->plugins as $plugin )
+                            {
+                                $plugin->afterNodeExecuted( $this, $node );
+                            }
                         }
 
                         // Toggle flag (see above).
@@ -550,11 +505,11 @@
      * See [EMAIL PROTECTED] ezcWorkflowNode::isExecutable()}.
      *
      * @param ezcWorkflowNode $node
-     * @param bool $notifyListeners
+     * @param bool            $notifyPlugins
      * @return bool
      * @ignore
      */
-    public function activate( ezcWorkflowNode $node, $notifyListeners = true )
+    public function activate( ezcWorkflowNode $node, $notifyPlugins = true )
     {
         // Only activate the node when
         //  - the execution of the workflow has not been cancelled,
@@ -567,33 +522,43 @@
             return false;
         }
 
-        // Add node to list of activated nodes.
-        $this->activatedNodes[] = $node;
-        $this->numActivatedNodes++;
-
-        if ( $node instanceof ezcWorkflowNodeEnd )
-        {
-            $this->numActivatedEndNodes++;
-        }
-
-        if ( $notifyListeners )
-        {
-            $this->notifyListeners(
-              sprintf(
-                'Activated node #%d(%s) for instance #%d ' .
-                'of workflow "%s" (version %d).',
-
-                $node->getId(),
-                get_class( $node ),
-                $this->id,
-                $this->workflow->name,
-                $this->workflow->version
-              ),
-              ezcWorkflowExecutionListener::DEBUG
-            );
-        }
-
-        return true;
+        $activateNode = true;
+
+        foreach ( $this->plugins as $plugin )
+        {
+            $activateNode = $plugin->beforeNodeActivated( $this, $node );
+
+            if ( !$activateNode )
+            {
+                break;
+            }
+        }
+
+        if ( $activateNode )
+        {
+            // Add node to list of activated nodes.
+            $this->activatedNodes[] = $node;
+            $this->numActivatedNodes++;
+
+            if ( $node instanceof ezcWorkflowNodeEnd )
+            {
+                $this->numActivatedEndNodes++;
+            }
+
+            if ( $notifyPlugins )
+            {
+                foreach ( $this->plugins as $plugin )
+                {
+                    $plugin->afterNodeActivated( $this, $node );
+                }
+            }
+
+            return true;
+        }
+        else
+        {
+            return false;
+        }
     }
 
     /**
@@ -657,19 +622,10 @@
               'numSiblings' => $numSiblings
             );
 
-            $this->notifyListeners(
-              sprintf(
-                'Started thread #%d (%s%d sibling(s)) for execution #%d of 
workflow "%s" (version %d).',
-
-                $this->nextThreadId,
-                $parentId != null ? 'parent: ' . $parentId . ', ' : '',
-                $numSiblings,
-                $this->id,
-                $this->workflow->name,
-                $this->workflow->version
-              ),
-              ezcWorkflowExecutionListener::DEBUG
-            );
+            foreach ( $this->plugins as $plugin )
+            {
+                $plugin->afterThreadStarted( $this, $this->nextThreadId, 
$parentId, $numSiblings );
+            }
 
             return $this->nextThreadId++;
         }
@@ -689,17 +645,10 @@
         {
             unset( $this->threads[$threadId] );
 
-            $this->notifyListeners(
-              sprintf(
-                'Ended thread #%d for execution #%d of workflow "%s" (version 
%d).',
-
-                $threadId,
-                $this->id,
-                $this->workflow->name,
-                $this->workflow->version
-              ),
-              ezcWorkflowExecutionListener::DEBUG
-            );
+            foreach ( $this->plugins as $plugin )
+            {
+                $plugin->afterThreadEnded( $this, $threadId );
+            }
         }
         else
         {
@@ -740,9 +689,9 @@
             $execution = new ezcWorkflowExecutionNonInteractive;
         }
 
-        foreach ( $this->listeners as $listener )
-        {
-            $execution->addListener( $listener );
+        foreach ( $this->plugins as $plugin )
+        {
+            $execution->addPlugin( $plugin );
         }
 
         return $execution;
@@ -787,6 +736,50 @@
     }
 
     /**
+     * Adds a plugin to this execution.
+     *
+     * @param ezcWorkflowExecutionPlugin $plugin
+     * @return bool true when the plugin was added, false otherwise.
+     */
+    public function addPlugin( ezcWorkflowExecutionPlugin $plugin )
+    {
+        $pluginClass = get_class( $plugin );
+
+        if ( !isset( $this->plugins[$pluginClass] ) )
+        {
+            $this->plugins[$pluginClass] = $plugin;
+
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    /**
+     * Removes a plugin from this execution.
+     *
+     * @param ezcWorkflowExecutionPlugin $plugin
+     * @return bool true when the plugin was removed, false otherwise.
+     */
+    public function removePlugin( ezcWorkflowExecutionPlugin $plugin )
+    {
+        $pluginClass = get_class( $plugin );
+
+        if ( isset( $this->plugins[$pluginClass] ) )
+        {
+            unset( $this->plugins[$pluginClass] );
+
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    /**
      * Adds a listener to this execution.
      *
      * @param ezcWorkflowExecutionListener $listener
@@ -794,14 +787,12 @@
      */
     public function addListener( ezcWorkflowExecutionListener $listener )
     {
-        if ( ezcWorkflowUtil::findObject( $this->listeners, $listener ) !== 
false )
-        {
-            return false;
-        }
-
-        $this->listeners[] = $listener;
-
-        return true;
+        if ( !isset( $this->plugins['ezcWorkflowExecutionListenerPlugin'] ) )
+        {
+            $this->addPlugin( new ezcWorkflowExecutionListenerPlugin );
+        }
+
+        return 
$this->plugins['ezcWorkflowExecutionListenerPlugin']->addListener( $listener );
     }
 
     /**
@@ -812,30 +803,12 @@
      */
     public function removeListener( ezcWorkflowExecutionListener $listener )
     {
-        $index = ezcWorkflowUtil::findObject( $this->listeners, $listener );
-
-        if ( $index === false )
-        {
-            return false;
-        }
-
-        unset( $this->listeners[$index] );
-
-        return true;
-    }
-
-    /**
-     * Notify listeners.
-     *
-     * @param string  $message
-     * @param int $type
-     */
-    protected function notifyListeners( $message, $type = 
ezcWorkflowExecutionListener::INFO )
-    {
-        foreach ( $this->listeners as $listener )
-        {
-            $listener->notify( $message, $type );
-        }
+        if ( isset( $this->plugins['ezcWorkflowExecutionListenerPlugin'] ) )
+        {
+            return 
$this->plugins['ezcWorkflowExecutionListenerPlugin']->removeListener( $listener 
);
+        }
+
+        return false;
     }
 
     /**
@@ -898,26 +871,26 @@
     /**
      * Sets a variable.
      *
-     * @param string $variableName
-     * @param mixed $value
+     * @param  string $variableName
+     * @param  mixed  $value
+     * @return mixed the value that the variable has been set to
      * @ignore
      */
     public function setVariable( $variableName, $value )
     {
+        foreach ( $this->plugins as $plugin )
+        {
+            $value = $plugin->beforeVariableSet( $this, $variableName, $value 
);
+        }
+
         $this->variables[$variableName] = $value;
 
-        $this->notifyListeners(
-          sprintf(
-            'Set variable "%s" to "%s" for execution #%d of workflow "%s" 
(version %d).',
-
-            $variableName,
-            ezcWorkflowUtil::variableToString( $value ),
-            $this->id,
-            $this->workflow->name,
-            $this->workflow->version
-          ),
-          ezcWorkflowExecutionListener::DEBUG
-        );
+        foreach ( $this->plugins as $plugin )
+        {
+            $plugin->afterVariableSet( $this, $variableName, $value );
+        }
+
+        return $value;
     }
 
     /**
@@ -939,27 +912,38 @@
     /**
      * Unsets a variable.
      *
-     * @param string $variableName
+     * @param  string $variableName
+     * @return true, when the variable has been unset, false otherwise
      * @ignore
      */
     public function unsetVariable( $variableName )
     {
         if ( array_key_exists( $variableName, $this->variables ) )
         {
-            unset( $this->variables[$variableName] );
-
-            $this->notifyListeners(
-              sprintf(
-                'Unset variable "%s" for execution #%d of workflow "%s" 
(version %d).',
-
-                $variableName,
-                $this->id,
-                $this->workflow->name,
-                $this->workflow->version
-              ),
-              ezcWorkflowExecutionListener::DEBUG
-            );
-        }
+            $unsetVariable = true;
+
+            foreach ( $this->plugins as $plugin )
+            {
+                $unsetVariable = $plugin->beforeVariableUnset( $this, 
$variableName );
+
+                if ( !$unsetVariable )
+                {
+                    break;
+                }
+            }
+
+            if ( $unsetVariable )
+            {
+                unset( $this->variables[$variableName] );
+
+                foreach ( $this->plugins as $plugin )
+                {
+                    $plugin->afterVariableUnset( $this, $variableName );
+                }
+            }
+        }
+
+        return $unsetVariable;
     }
 
     /**

Added: trunk/Workflow/src/interfaces/execution_plugin.php
==============================================================================
--- trunk/Workflow/src/interfaces/execution_plugin.php (added)
+++ trunk/Workflow/src/interfaces/execution_plugin.php [iso-8859-1] Mon Feb 11 
12:53:55 2008
@@ -1,0 +1,200 @@
+<?php
+/**
+ * File containing the ezcWorkflowExecutionPlugin class.
+ *
+ * @package Workflow
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Abstract base class for workflow execution engine plugins.
+ *
+ * @package Workflow
+ * @version //autogen//
+ */
+abstract class ezcWorkflowExecutionPlugin
+{
+    /**
+     * Called after an execution has been started.
+     *
+     * @param ezcWorkflowExecution $execution
+     */
+    public function afterExecutionStarted( ezcWorkflowExecution $execution )
+    {
+    // @codeCoverageIgnoreStart
+    }
+    // @codeCoverageIgnoreEnd
+
+    /**
+     * Called after an execution has been suspended.
+     *
+     * @param ezcWorkflowExecution $execution
+     */
+    public function afterExecutionSuspended( ezcWorkflowExecution $execution )
+    {
+    // @codeCoverageIgnoreStart
+    }
+    // @codeCoverageIgnoreEnd
+
+    /**
+     * Called after an execution has been resumed.
+     *
+     * @param ezcWorkflowExecution $execution
+     */
+    public function afterExecutionResumed( ezcWorkflowExecution $execution )
+    {
+    // @codeCoverageIgnoreStart
+    }
+    // @codeCoverageIgnoreEnd
+
+    /**
+     * Called after an execution has been cancelled.
+     *
+     * @param ezcWorkflowExecution $execution
+     */
+    public function afterExecutionCancelled( ezcWorkflowExecution $execution )
+    {
+    // @codeCoverageIgnoreStart
+    }
+    // @codeCoverageIgnoreEnd
+
+    /**
+     * Called after an execution has successfully ended.
+     *
+     * @param ezcWorkflowExecution $execution
+     */
+    public function afterExecutionEnded( ezcWorkflowExecution $execution )
+    {
+    // @codeCoverageIgnoreStart
+    }
+    // @codeCoverageIgnoreEnd
+
+    /**
+     * Called before a node is activated.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param ezcWorkflowNode      $node
+     * @return bool true, when the node should be activated, false otherwise
+     */
+    public function beforeNodeActivated( ezcWorkflowExecution $execution, 
ezcWorkflowNode $node )
+    {
+        return true;
+    }
+
+    /**
+     * Called after a node has been activated.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param ezcWorkflowNode      $node
+     */
+    public function afterNodeActivated( ezcWorkflowExecution $execution, 
ezcWorkflowNode $node )
+    {
+    // @codeCoverageIgnoreStart
+    }
+    // @codeCoverageIgnoreEnd
+
+    /**
+     * Called after a node has been executed.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param ezcWorkflowNode      $node
+     */
+    public function afterNodeExecuted( ezcWorkflowExecution $execution, 
ezcWorkflowNode $node )
+    {
+    // @codeCoverageIgnoreStart
+    }
+    // @codeCoverageIgnoreEnd
+
+    /**
+     * Called after a service object has been rolled back.
+     *
+     * @param ezcWorkflowExecution                 $execution
+     * @param ezcWorkflowNode                      $node
+     * @param ezcWorkflowRollbackableServiceObject $serviceObject
+     * @param bool                                 $success
+     */
+    public function afterRolledBackServiceObject( ezcWorkflowExecution 
$execution, ezcWorkflowNode $node, ezcWorkflowRollbackableServiceObject 
$serviceObject, $success )
+    {
+    // @codeCoverageIgnoreStart
+    }
+    // @codeCoverageIgnoreEnd
+
+    /**
+     * Called after a new thread has been started.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param int                  $threadId
+     * @param int                  $parentId
+     * @param int                  $numSiblings
+     */
+    public function afterThreadStarted( ezcWorkflowExecution $execution, 
$threadId, $parentId, $numSiblings )
+    {
+    // @codeCoverageIgnoreStart
+    }
+    // @codeCoverageIgnoreEnd
+
+    /**
+     * Called after a thread has ended.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param int                  $threadId
+     */
+    public function afterThreadEnded( ezcWorkflowExecution $execution, 
$threadId )
+    {
+    // @codeCoverageIgnoreStart
+    }
+    // @codeCoverageIgnoreEnd
+
+    /**
+     * Called before a variable is set.
+     *
+     * @param  ezcWorkflowExecution $execution
+     * @param  string               $variableName
+     * @param  mixed                $value
+     * @return mixed the value the variable should be set to
+     */
+    public function beforeVariableSet( ezcWorkflowExecution $execution, 
$variableName, $value )
+    {
+        return $value;
+    }
+
+    /**
+     * Called after a variable has been set.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param string               $variableName
+     * @param mixed                $value
+     */
+    public function afterVariableSet( ezcWorkflowExecution $execution, 
$variableName, $value )
+    {
+    // @codeCoverageIgnoreStart
+    }
+    // @codeCoverageIgnoreEnd
+
+    /**
+     * Called before a variable is unset.
+     *
+     * @param  ezcWorkflowExecution $execution
+     * @param  string               $variableName
+     * @return bool true, when the variable should be unset, false otherwise
+     */
+    public function beforeVariableUnset( ezcWorkflowExecution $execution, 
$variableName )
+    {
+        return true;
+    }
+
+    /**
+     * Called after a variable has been unset.
+     *
+     * @param ezcWorkflowExecution $execution
+     * @param string               $variableName
+     */
+    public function afterVariableUnset( ezcWorkflowExecution $execution, 
$variableName )
+    {
+    // @codeCoverageIgnoreStart
+    }
+    // @codeCoverageIgnoreEnd
+}
+?>

Modified: trunk/Workflow/src/workflow_autoload.php
==============================================================================
--- trunk/Workflow/src/workflow_autoload.php [iso-8859-1] (original)
+++ trunk/Workflow/src/workflow_autoload.php [iso-8859-1] Mon Feb 11 12:53:55 
2008
@@ -25,6 +25,7 @@
     'ezcWorkflowConditionType'                 => 
'Workflow/interfaces/condition_type.php',
     'ezcWorkflowDefinitionStorage'             => 
'Workflow/interfaces/definition_storage.php',
     'ezcWorkflowExecution'                     => 
'Workflow/interfaces/execution.php',
+    'ezcWorkflowExecutionPlugin'               => 
'Workflow/interfaces/execution_plugin.php',
     'ezcWorkflowNodeArithmeticBase'            => 
'Workflow/interfaces/node_arithmetic_base.php',
     'ezcWorkflowNodeConditionalBranch'         => 
'Workflow/interfaces/node_conditional_branch.php',
     'ezcWorkflowNodeEnd'                       => 'Workflow/nodes/end.php',
@@ -55,6 +56,7 @@
     'ezcWorkflowConditionXor'                  => 
'Workflow/conditions/xor.php',
     'ezcWorkflowDefinitionStorageXml'          => 
'Workflow/definition_storage/xml.php',
     'ezcWorkflowExecutionListener'             => 
'Workflow/interfaces/execution_listener.php',
+    'ezcWorkflowExecutionListenerPlugin'       => 
'Workflow/execution/plugin/execution_listener.php',
     'ezcWorkflowExecutionNonInteractive'       => 
'Workflow/execution/non_interactive.php',
     'ezcWorkflowNodeAction'                    => 'Workflow/nodes/action.php',
     'ezcWorkflowNodeCancel'                    => 'Workflow/nodes/cancel.php',


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to