[jbpm-commits] JBoss JBPM SVN: r3142 - in jbpm3/trunk/modules: integration/jboss42/src/main/etc and 6 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Nov 28 06:05:17 EST 2008


Author: thomas.diesler at jboss.com
Date: 2008-11-28 06:05:17 -0500 (Fri, 28 Nov 2008)
New Revision: 3142

Added:
   jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ExecutionServiceImpl.java
   jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/IdentityServiceImpl.java
   jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/TaskServiceImpl.java
   jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/task/
   jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/task/TaskImpl.java
Modified:
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java
   jbpm3/trunk/modules/integration/jboss42/src/main/etc/jboss-beans.xml
   jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java
   jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java
   jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ProcessDefinitionServiceImpl.java
   jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ProcessServiceImpl.java
   jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml
Log:
Add task & identity service

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java	2008-11-28 11:04:14 UTC (rev 3141)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java	2008-11-28 11:05:17 UTC (rev 3142)
@@ -38,8 +38,8 @@
   protected Set taskInstances = null;
   protected SwimlaneInstance swimlaneInstance = null;
 
-  public static Set createPool(String[] actorIds, SwimlaneInstance swimlaneInstance, TaskInstance taskInstance) {
-    Set pooledActors = new HashSet();
+  public static Set<PooledActor> createPool(String[] actorIds, SwimlaneInstance swimlaneInstance, TaskInstance taskInstance) {
+    Set<PooledActor> pooledActors = new HashSet<PooledActor>();
     for (int i=0; i<actorIds.length; i++) {
       PooledActor pooledActor = new PooledActor(actorIds[i]);
       if (swimlaneInstance!=null) {

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java	2008-11-28 11:04:14 UTC (rev 3141)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java	2008-11-28 11:05:17 UTC (rev 3142)
@@ -38,7 +38,7 @@
   int version = 0;
   protected String name = null;
   protected String actorId = null;
-  protected Set pooledActors = null;
+  protected Set<PooledActor> pooledActors = null;
   protected Swimlane swimlane = null;
   protected TaskMgmtInstance taskMgmtInstance = null;
   
@@ -84,10 +84,10 @@
   public void setTaskMgmtInstance(TaskMgmtInstance taskMgmtInstance) {
     this.taskMgmtInstance = taskMgmtInstance;
   }
-  public Set getPooledActors() {
+  public Set<PooledActor> getPooledActors() {
     return pooledActors;
   }
-  public void setPooledActors(Set pooledActors) {
+  public void setPooledActors(Set<PooledActor> pooledActors) {
     this.pooledActors = pooledActors;
   }
 }

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java	2008-11-28 11:04:14 UTC (rev 3141)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java	2008-11-28 11:05:17 UTC (rev 3142)
@@ -51,11 +51,11 @@
 import org.jbpm.util.EqualsUtil;
 
 /**
- * is one task instance that can be assigned to an actor (read: put in 
- * someones task list) and that can trigger the coninuation of execution 
- * of the token upon completion.
+ * is one task instance that can be assigned to an actor (read: put in someones task list) and that can trigger the
+ * coninuation of execution of the token upon completion.
  */
-public class TaskInstance extends VariableContainer implements Assignable {
+public class TaskInstance extends VariableContainer implements Assignable
+{
 
   private static final long serialVersionUID = 1L;
 
@@ -79,24 +79,28 @@
   protected SwimlaneInstance swimlaneInstance = null;
   protected TaskMgmtInstance taskMgmtInstance = null;
   protected ProcessInstance processInstance = null;
-  protected Set pooledActors = null;
+  protected Set<PooledActor> pooledActors = null;
   protected List comments = null;
 
-  protected String previousActorId = null; // not persisted.  just extra information for listeners of the assign-event  
+  protected String previousActorId = null; // not persisted. just extra information for listeners of the assign-event
 
-  public TaskInstance() {
+  public TaskInstance()
+  {
   }
 
-  public TaskInstance(String taskName) {
+  public TaskInstance(String taskName)
+  {
     this.name = taskName;
   }
 
-  public TaskInstance(String taskName, String actorId) {
+  public TaskInstance(String taskName, String actorId)
+  {
     this.name = taskName;
     this.actorId = actorId;
   }
 
-  public void setTask(Task task) {
+  public void setTask(Task task)
+  {
     this.name = task.getName();
     this.description = task.getDescription();
     this.task = task;
@@ -104,117 +108,129 @@
     this.priority = task.getPriority();
     this.isSignalling = task.isSignalling();
   }
-  
-  void submitVariables() {
-    TaskController taskController = (task!=null ? task.getTaskController() : null);
-    // if there is a task controller, 
-    if (taskController!=null) {
+
+  void submitVariables()
+  {
+    TaskController taskController = (task != null ? task.getTaskController() : null);
+    // if there is a task controller,
+    if (taskController != null)
+    {
       // the task controller is responsible for copying variables back into the process
       taskController.submitParameters(this);
-      
-    // if there is no task controller
-    } else if ( (token!=null)
-                && (token.getProcessInstance()!=null)
-              ) {
-      // the default behaviour is that all task-local variables are flushed to the process 
-      if (variableInstances!=null) {
+
+      // if there is no task controller
+    }
+    else if ((token != null) && (token.getProcessInstance() != null))
+    {
+      // the default behaviour is that all task-local variables are flushed to the process
+      if (variableInstances != null)
+      {
         ContextInstance contextInstance = token.getProcessInstance().getContextInstance();
         Iterator iter = variableInstances.values().iterator();
-        while(iter.hasNext()) {
-          VariableInstance variableInstance = (VariableInstance) iter.next();
-          log.debug("flushing variable '"+variableInstance.getName()+"' from task '"+name+"' to process variables");
+        while (iter.hasNext())
+        {
+          VariableInstance variableInstance = (VariableInstance)iter.next();
+          log.debug("flushing variable '" + variableInstance.getName() + "' from task '" + name + "' to process variables");
           // This might be optimized, but this was the simplest way to make a clone of the variable instance.
           contextInstance.setVariable(variableInstance.getName(), variableInstance.getValue(), token);
         }
       }
     }
   }
-  void initializeVariables() {
-    TaskController taskController = (task!=null ? task.getTaskController() : null);
-    if (taskController!=null) {
+
+  void initializeVariables()
+  {
+    TaskController taskController = (task != null ? task.getTaskController() : null);
+    if (taskController != null)
+    {
       taskController.initializeVariables(this);
     }
   }
 
-  public void create() {
+  public void create()
+  {
     create(null);
   }
 
-  public void create(ExecutionContext executionContext) {
-    if (create!=null) {
-      throw new IllegalStateException("task instance '"+id+"' was already created");
+  public void create(ExecutionContext executionContext)
+  {
+    if (create != null)
+    {
+      throw new IllegalStateException("task instance '" + id + "' was already created");
     }
     create = Clock.getCurrentTime();
-    
+
     // if this task instance is associated with a task...
-    if ( (task!=null)
-         && (executionContext!=null)
-       ) {
+    if ((task != null) && (executionContext != null))
+    {
       // the TASK_CREATE event is fired
       executionContext.setTaskInstance(this);
       executionContext.setTask(task);
       task.fireEvent(Event.EVENTTYPE_TASK_CREATE, executionContext);
     }
-    
+
     // WARNING: The events create and assign are fired in the right order, but
     // the logs are still not ordered properly.
     // See also: TaskMgmtInstance.createTaskInstance
   }
 
-  public void assign(ExecutionContext executionContext) {
+  public void assign(ExecutionContext executionContext)
+  {
     TaskMgmtInstance taskMgmtInstance = executionContext.getTaskMgmtInstance();
-    
+
     Swimlane swimlane = task.getSwimlane();
     // if this task is in a swimlane
-    if (swimlane!=null) {
-      
+    if (swimlane != null)
+    {
+
       // if this is a task assignment for a start-state
-      if (isStartTaskInstance()) {
+      if (isStartTaskInstance())
+      {
         // initialize the swimlane
         swimlaneInstance = new SwimlaneInstance(swimlane);
         taskMgmtInstance.addSwimlaneInstance(swimlaneInstance);
         // with the current authenticated actor
         swimlaneInstance.setActorId(SecurityHelper.getAuthenticatedActorId());
-        
-      } else {
-        
+
+      }
+      else
+      {
+
         // lazy initialize the swimlane...
-        // get the swimlane instance (if there is any) 
+        // get the swimlane instance (if there is any)
         swimlaneInstance = taskMgmtInstance.getInitializedSwimlaneInstance(executionContext, swimlane);
-        
+
         // copy the swimlaneInstance assignment into the taskInstance assignment
         copySwimlaneInstanceAssignment(swimlaneInstance);
       }
 
-    } else { // this task is not in a swimlane
-      taskMgmtInstance.performAssignment(task.getAssignmentDelegation(), 
-                                         task.getActorIdExpression(),
-                                         task.getPooledActorsExpression(),
-                                         this, 
-                                         executionContext);
     }
-    
+    else
+    { // this task is not in a swimlane
+      taskMgmtInstance.performAssignment(task.getAssignmentDelegation(), task.getActorIdExpression(), task.getPooledActorsExpression(), this, executionContext);
+    }
+
     updatePooledActorsReferences(swimlaneInstance);
   }
 
-
-  public boolean isStartTaskInstance() {
+  public boolean isStartTaskInstance()
+  {
     boolean isStartTaskInstance = false;
-    if ( (taskMgmtInstance!=null)
-         && (taskMgmtInstance.getTaskMgmtDefinition()!=null)
-       ) {
-         isStartTaskInstance = ( (task!=null)
-                                 && (task.equals(taskMgmtInstance.getTaskMgmtDefinition().getStartTask()))
-                               );
+    if ((taskMgmtInstance != null) && (taskMgmtInstance.getTaskMgmtDefinition() != null))
+    {
+      isStartTaskInstance = ((task != null) && (task.equals(taskMgmtInstance.getTaskMgmtDefinition().getStartTask())));
     }
     return isStartTaskInstance;
   }
 
-  void updatePooledActorsReferences(SwimlaneInstance swimlaneInstance) {
-    if (pooledActors!=null) {
+  void updatePooledActorsReferences(SwimlaneInstance swimlaneInstance)
+  {
+    if (pooledActors != null)
+    {
       Iterator iter = pooledActors.iterator();
-      while (iter.hasNext()) {
-        PooledActor pooledActor = (PooledActor) iter.next();
+      while (iter.hasNext())
+      {
+        PooledActor pooledActor = (PooledActor)iter.next();
         pooledActor.setSwimlaneInstance(swimlaneInstance);
         pooledActor.addTaskInstance(this);
       }
@@ -222,58 +238,58 @@
   }
 
   /**
-   * copies the assignment (that includes both the swimlaneActorId and the set of pooledActors) of 
-   * the given swimlane into this taskInstance. 
+   * copies the assignment (that includes both the swimlaneActorId and the set of pooledActors) of the given swimlane
+   * into this taskInstance.
    */
-  public void copySwimlaneInstanceAssignment(SwimlaneInstance swimlaneInstance) {
+  public void copySwimlaneInstanceAssignment(SwimlaneInstance swimlaneInstance)
+  {
     setSwimlaneInstance(swimlaneInstance);
     setActorId(swimlaneInstance.getActorId());
     setPooledActors(swimlaneInstance.getPooledActors());
   }
 
   /**
-   * gets the pool of actors for this task instance.  If this task has a simlaneInstance 
-   * and no pooled actors, the pooled actors of the swimlane instance are returned.
+   * gets the pool of actors for this task instance. If this task has a simlaneInstance and no pooled actors, the pooled
+   * actors of the swimlane instance are returned.
    */
-  public Set getPooledActors() {
-    if ( (swimlaneInstance!=null)
-         && ( (pooledActors==null)
-              || (pooledActors.isEmpty())
-            )
-       ){
-      return swimlaneInstance.getPooledActors(); 
+  public Set<PooledActor> getPooledActors()
+  {
+    if ((swimlaneInstance != null) && ((pooledActors == null) || (pooledActors.isEmpty())))
+    {
+      return swimlaneInstance.getPooledActors();
     }
     return pooledActors;
   }
 
   /**
-   * (re)assign this task to the given actor.  If this task is related 
-   * to a swimlane instance, that swimlane instance will be updated as well.
+   * (re)assign this task to the given actor. If this task is related to a swimlane instance, that swimlane instance
+   * will be updated as well.
    */
-  public void setActorId(String actorId) {
+  public void setActorId(String actorId)
+  {
     setActorId(actorId, true);
   }
 
   /**
    * (re)assign this task to the given actor.
+   * 
    * @param actorId is reference to the person that is assigned to this task.
-   * @param overwriteSwimlane specifies if the related swimlane 
-   * should be overwritten with the given swimlaneActorId.
+   * @param overwriteSwimlane specifies if the related swimlane should be overwritten with the given swimlaneActorId.
    */
-  public void setActorId(String actorId, boolean overwriteSwimlane){
+  public void setActorId(String actorId, boolean overwriteSwimlane)
+  {
     // do the actual assignment
     this.previousActorId = this.actorId;
     this.actorId = actorId;
-    if ( (swimlaneInstance!=null)
-         && (overwriteSwimlane) ) {
-      log.debug("assigning task '"+name+"' to '"+actorId+"'");
+    if ((swimlaneInstance != null) && (overwriteSwimlane))
+    {
+      log.debug("assigning task '" + name + "' to '" + actorId + "'");
       swimlaneInstance.setActorId(actorId);
     }
-    
+
     // fire the event
-    if ( (task!=null)
-         && (token!=null) 
-       ) {
+    if ((task != null) && (token != null))
+    {
       ExecutionContext executionContext = new ExecutionContext(token);
       executionContext.setTask(task);
       executionContext.setTaskInstance(this);
@@ -283,32 +299,34 @@
       // See also: TaskMgmtInstance.createTaskInstance
       task.fireEvent(Event.EVENTTYPE_TASK_ASSIGN, executionContext);
     }
-    
+
     // add the log
-    if (token!=null) {
+    if (token != null)
+    {
       // log this assignment
       token.addLog(new TaskAssignLog(this, previousActorId, actorId));
     }
   }
 
   /** takes a set of String's as the actorIds */
-  public void setPooledActors(String[] actorIds) {
+  public void setPooledActors(String[] actorIds)
+  {
     this.pooledActors = PooledActor.createPool(actorIds, null, this);
   }
 
   /**
-   * can optionally be used to indicate that the actor is starting to 
-   * work on this task instance. 
+   * can optionally be used to indicate that the actor is starting to work on this task instance.
    */
-  public void start(){
-    if (start!=null) {
-      throw new IllegalStateException("task instance '"+id+"' is already started");
+  public void start()
+  {
+    if (start != null)
+    {
+      throw new IllegalStateException("task instance '" + id + "' is already started");
     }
-    
+
     start = Clock.getCurrentTime();
-    if ( (task!=null)
-         && (token!=null)
-       ) {
+    if ((task != null) && (token != null))
+    {
       ExecutionContext executionContext = new ExecutionContext(token);
       executionContext.setTask(task);
       executionContext.setTaskInstance(this);
@@ -317,176 +335,181 @@
   }
 
   /**
-   * convenience method that combines a {@link #setActorId(String)} and
-   * a {@link #start()}.
+   * convenience method that combines a {@link #setActorId(String)} and a {@link #start()}.
    */
-  public void start(String actorId){
+  public void start(String actorId)
+  {
     start(actorId, true);
   }
-  
+
   /**
-   * convenience method that combines a {@link #setActorId(String,boolean)} and
-   * a {@link #start()}.
+   * convenience method that combines a {@link #setActorId(String,boolean)} and a {@link #start()}.
    */
-  public void start(String actorId, boolean overwriteSwimlane){
+  public void start(String actorId, boolean overwriteSwimlane)
+  {
     setActorId(actorId, overwriteSwimlane);
     start();
   }
-  
+
   /**
    * overwrite start date
    */
-  public void setStart(Date date) {	
-	  start = null;
+  public void setStart(Date date)
+  {
+    start = null;
   }
-  
-  private void markAsCancelled() {
+
+  private void markAsCancelled()
+  {
     this.isCancelled = true;
     this.isOpen = false;
   }
 
   /**
-   * cancels this task.
-   * This task intance will be marked as cancelled and as ended.  But cancellation 
-   * doesn't influence singalling and continuation of process execution.
+   * cancels this task. This task intance will be marked as cancelled and as ended. But cancellation doesn't influence
+   * singalling and continuation of process execution.
    */
-  public void cancel() {
+  public void cancel()
+  {
     markAsCancelled();
     end();
   }
 
   /**
-   * cancels this task, takes the specified transition.
-   * This task intance will be marked as cancelled and as ended.  But cancellation 
-   * doesn't influence singalling and continuation of process execution.
+   * cancels this task, takes the specified transition. This task intance will be marked as cancelled and as ended. But
+   * cancellation doesn't influence singalling and continuation of process execution.
    */
-  public void cancel(Transition transition) {
+  public void cancel(Transition transition)
+  {
     markAsCancelled();
     end(transition);
   }
 
-  
   /**
-   * cancels this task, takes the specified transition.
-   * This task intance will be marked as cancelled and as ended.  But cancellation 
-   * doesn't influence singalling and continuation of process execution.
+   * cancels this task, takes the specified transition. This task intance will be marked as cancelled and as ended. But
+   * cancellation doesn't influence singalling and continuation of process execution.
    */
-  public void cancel(String transitionName) {
+  public void cancel(String transitionName)
+  {
     markAsCancelled();
     end(transitionName);
   }
-  
+
   /**
-   * marks this task as done.  If this task is related to a task node 
-   * this might trigger a signal on the token.
+   * marks this task as done. If this task is related to a task node this might trigger a signal on the token.
+   * 
    * @see #end(Transition)
    */
-  public void end() {
+  public void end()
+  {
     end((Transition)null);
   }
 
   /**
-   * marks this task as done and specifies the name of a transition  
-   * leaving the task-node for the case that the completion of this 
-   * task instances triggers a signal on the token.
-   * If this task leads to a signal on the token, the given transition 
-   * name will be used in the signal.
-   * If this task completion does not trigger execution to move on, 
+   * marks this task as done and specifies the name of a transition leaving the task-node for the case that the
+   * completion of this task instances triggers a signal on the token. If this task leads to a signal on the token, the
+   * given transition name will be used in the signal. If this task completion does not trigger execution to move on,
    * the transitionName is ignored.
    */
-  public void end(String transitionName) {
+  public void end(String transitionName)
+  {
     Transition leavingTransition = null;
-    
-    if (task!=null) {
+
+    if (task != null)
+    {
       Node node = task.getTaskNode();
-      if (node==null) {
-        node = (Node) task.getParent();
+      if (node == null)
+      {
+        node = (Node)task.getParent();
       }
 
-      if (node!=null) {
+      if (node != null)
+      {
         leavingTransition = node.getLeavingTransition(transitionName);
       }
     }
-    if (leavingTransition==null) {
-      throw new JbpmException("task node does not have leaving transition '"+transitionName+"'");
+    if (leavingTransition == null)
+    {
+      throw new JbpmException("task node does not have leaving transition '" + transitionName + "'");
     }
     end(leavingTransition);
   }
-  
+
   /**
-   * marks this task as done and specifies a transition  
-   * leaving the task-node for the case that the completion of this 
-   * task instances triggers a signal on the token.
-   * If this task leads to a signal on the token, the given transition 
-   * name will be used in the signal.
-   * If this task completion does not trigger execution to move on, 
-   * the transition is ignored.
+   * marks this task as done and specifies a transition leaving the task-node for the case that the completion of this
+   * task instances triggers a signal on the token. If this task leads to a signal on the token, the given transition
+   * name will be used in the signal. If this task completion does not trigger execution to move on, the transition is
+   * ignored.
    */
-  public void end(Transition transition) {
-    if (this.end!=null){
-      throw new IllegalStateException("task instance '"+id+"' is already ended");
+  public void end(Transition transition)
+  {
+    if (this.end != null)
+    {
+      throw new IllegalStateException("task instance '" + id + "' is already ended");
     }
-    if (this.isSuspended) {
-      throw new JbpmException("task instance '"+id+"' is suspended");
+    if (this.isSuspended)
+    {
+      throw new JbpmException("task instance '" + id + "' is suspended");
     }
-    
+
     // mark the end of this task instance
     this.end = Clock.getCurrentTime();
     this.isOpen = false;
 
     // fire the task instance end event
-    if ( (task!=null)
-         && (token!=null)
-       ) {
+    if ((task != null) && (token != null))
+    {
       ExecutionContext executionContext = new ExecutionContext(token);
       executionContext.setTask(task);
       executionContext.setTaskInstance(this);
       task.fireEvent(Event.EVENTTYPE_TASK_END, executionContext);
     }
-    
+
     // log this assignment
-    if (token!=null) {
+    if (token != null)
+    {
       token.addLog(new TaskEndLog(this));
     }
-    
+
     // submit the variables
     submitVariables();
-    
+
     // verify if the end of this task triggers continuation of execution
-    if (isSignalling) {
+    if (isSignalling)
+    {
       this.isSignalling = false;
-      
-      
-      
-      if ( this.isStartTaskInstance() // ending start tasks always leads to a signal
-           || ( (task!=null)
-                && (token!=null)
-                && (task.getTaskNode()!=null)
-                && (task.getTaskNode().completionTriggersSignal(this))
-              )
-         ) {
-        
-        if (transition==null) {
-          log.debug("completion of task '"+task.getName()+"' results in taking the default transition");
+
+      if (this.isStartTaskInstance() // ending start tasks always leads to a signal
+          || ((task != null) && (token != null) && (task.getTaskNode() != null) && (task.getTaskNode().completionTriggersSignal(this))))
+      {
+
+        if (transition == null)
+        {
+          log.debug("completion of task '" + task.getName() + "' results in taking the default transition");
           token.signal();
-        } else {
-          log.debug("completion of task '"+task.getName()+"' results in taking transition '"+transition+"'");
+        }
+        else
+        {
+          log.debug("completion of task '" + task.getName() + "' results in taking transition '" + transition + "'");
           token.signal(transition);
         }
       }
     }
   }
 
-  public boolean hasEnded() {
-    return (end!=null);
+  public boolean hasEnded()
+  {
+    return (end != null);
   }
 
   /**
    * suspends a process execution.
    */
-  public void suspend() {
-    if (!isOpen) {
-      throw new JbpmException("a task that is not open cannot be suspended: "+toString());
+  public void suspend()
+  {
+    if (!isOpen)
+    {
+      throw new JbpmException("a task that is not open cannot be suspended: " + toString());
     }
     isSuspended = true;
   }
@@ -494,193 +517,272 @@
   /**
    * resumes a process execution.
    */
-  public void resume() {
-    if (!isOpen) {
-      throw new JbpmException("a task that is not open cannot be resumed: "+toString());
+  public void resume()
+  {
+    if (!isOpen)
+    {
+      throw new JbpmException("a task that is not open cannot be resumed: " + toString());
     }
     isSuspended = false;
   }
-  
+
   // comments /////////////////////////////////////////////////////////////////
 
-  public void addComment(String message) {
+  public void addComment(String message)
+  {
     addComment(new Comment(message));
   }
 
-  public void addComment(Comment comment) {
-    if (comment!=null) {
-      if (comments==null) comments = new ArrayList();
+  public void addComment(Comment comment)
+  {
+    if (comment != null)
+    {
+      if (comments == null)
+        comments = new ArrayList();
       comments.add(comment);
       comment.setTaskInstance(this);
-      if (token!=null) {
+      if (token != null)
+      {
         comment.setToken(token);
         token.addComment(comment);
       }
     }
   }
-  
-  public List getComments() {
+
+  public List getComments()
+  {
     return comments;
   }
- 
+
   // task form ////////////////////////////////////////////////////////////////
-  
-  public boolean isLast() {
-    return ( (token!=null)
-             && (taskMgmtInstance!=null) 
-             && (! taskMgmtInstance.hasUnfinishedTasks(token))
-           );
+
+  public boolean isLast()
+  {
+    return ((token != null) && (taskMgmtInstance != null) && (!taskMgmtInstance.hasUnfinishedTasks(token)));
   }
-  
+
   /**
-   * is the list of transitions that can be used in the end method
-   * and it is null in case this is not the last task instance.
+   * is the list of transitions that can be used in the end method and it is null in case this is not the last task
+   * instance.
    */
-  public List getAvailableTransitions() {
+  public List getAvailableTransitions()
+  {
     List transitions = null;
-    if ( (! isLast())
-         && (token!=null)
-       ) {
+    if ((!isLast()) && (token != null))
+    {
       transitions = new ArrayList(token.getAvailableTransitions());
     }
     return transitions;
   }
-  
+
   // equals ///////////////////////////////////////////////////////////////////
   // hack to support comparing hibernate proxies against the real objects
   // since this always falls back to ==, we don't need to overwrite the hashcode
-  public boolean equals(Object o) {
+  public boolean equals(Object o)
+  {
     return EqualsUtil.equals(this, o);
   }
-  
-  public String toString() {
-    return "TaskInstance"+(name!=null ? "("+name+")" : "@"+Integer.toHexString(hashCode()));
+
+  public String toString()
+  {
+    return "TaskInstance" + (name != null ? "(" + name + ")" : "@" + Integer.toHexString(hashCode()));
   }
 
   // private //////////////////////////////////////////////////////////////////
 
   /** takes a set of {@link PooledActor}s */
-  public void setPooledActors(Set pooledActors) {
-    if (pooledActors!=null) {
+  public void setPooledActors(Set pooledActors)
+  {
+    if (pooledActors != null)
+    {
       this.pooledActors = new HashSet(pooledActors);
       Iterator iter = pooledActors.iterator();
-      while (iter.hasNext()) {
-        PooledActor pooledActor = (PooledActor) iter.next();
+      while (iter.hasNext())
+      {
+        PooledActor pooledActor = (PooledActor)iter.next();
         pooledActor.addTaskInstance(this);
       }
-    } else {
+    }
+    else
+    {
       this.pooledActors = null;
     }
   }
-  
+
   // protected ////////////////////////////////////////////////////////////////
 
-  protected VariableContainer getParentVariableContainer() {
+  protected VariableContainer getParentVariableContainer()
+  {
     ContextInstance contextInstance = getContextInstance();
-    return (contextInstance!=null ? contextInstance.getOrCreateTokenVariableMap(token) : null);
+    return (contextInstance != null ? contextInstance.getOrCreateTokenVariableMap(token) : null);
   }
 
   // getters and setters //////////////////////////////////////////////////////
-  
-  public String getActorId() {
+
+  public String getActorId()
+  {
     return actorId;
   }
-  public Date getDueDate() {
+
+  public Date getDueDate()
+  {
     return dueDate;
   }
-  public void setDueDate(Date dueDate) {
+
+  public void setDueDate(Date dueDate)
+  {
     this.dueDate = dueDate;
   }
-  public Date getEnd() {
+
+  public Date getEnd()
+  {
     return end;
   }
-  public void setEnd(Date end) {
+
+  public void setEnd(Date end)
+  {
     this.end = end;
   }
-  public void setCreate(Date create) {
+
+  public void setCreate(Date create)
+  {
     this.create = create;
   }
-  public long getId() {
+
+  public long getId()
+  {
     return id;
   }
-  public void setId(long id) {
+
+  public void setId(long id)
+  {
     this.id = id;
   }
-  public Date getStart() {
+
+  public Date getStart()
+  {
     return start;
   }
-  public TaskMgmtInstance getTaskMgmtInstance() {
+
+  public TaskMgmtInstance getTaskMgmtInstance()
+  {
     return taskMgmtInstance;
   }
-  public void setTaskMgmtInstance(TaskMgmtInstance taskMgmtInstance) {
+
+  public void setTaskMgmtInstance(TaskMgmtInstance taskMgmtInstance)
+  {
     this.taskMgmtInstance = taskMgmtInstance;
   }
-  public Token getToken() {
+
+  public Token getToken()
+  {
     return token;
   }
-  public void setToken(Token token) {
+
+  public void setToken(Token token)
+  {
     this.token = token;
   }
-  public void setSignalling(boolean isSignalling) {
+
+  public void setSignalling(boolean isSignalling)
+  {
     this.isSignalling = isSignalling;
   }
-  public boolean isSignalling() {
+
+  public boolean isSignalling()
+  {
     return isSignalling;
   }
-  public boolean isCancelled() {
+
+  public boolean isCancelled()
+  {
     return isCancelled;
   }
-  public String getName() {
+
+  public String getName()
+  {
     return name;
   }
-  public void setName(String name) {
+
+  public void setName(String name)
+  {
     this.name = name;
   }
-  public boolean isBlocking() {
+
+  public boolean isBlocking()
+  {
     return isBlocking;
   }
-  public void setBlocking(boolean isBlocking) {
+
+  public void setBlocking(boolean isBlocking)
+  {
     this.isBlocking = isBlocking;
   }
-  public Date getCreate() {
+
+  public Date getCreate()
+  {
     return create;
   }
-  public Task getTask() {
+
+  public Task getTask()
+  {
     return task;
   }
-  public SwimlaneInstance getSwimlaneInstance() {
+
+  public SwimlaneInstance getSwimlaneInstance()
+  {
     return swimlaneInstance;
   }
-  public void setSwimlaneInstance(SwimlaneInstance swimlaneInstance) {
+
+  public void setSwimlaneInstance(SwimlaneInstance swimlaneInstance)
+  {
     this.swimlaneInstance = swimlaneInstance;
   }
-  public String getPreviousActorId() {
+
+  public String getPreviousActorId()
+  {
     return previousActorId;
   }
-  public int getPriority() {
+
+  public int getPriority()
+  {
     return priority;
   }
-  public void setPriority(int priority) {
+
+  public void setPriority(int priority)
+  {
     this.priority = priority;
   }
-  public boolean isOpen() {
+
+  public boolean isOpen()
+  {
     return isOpen;
   }
-  public String getDescription() {
+
+  public String getDescription()
+  {
     return description;
   }
-  public void setDescription(String description) {
+
+  public void setDescription(String description)
+  {
     this.description = description;
   }
-  public boolean isSuspended() {
+
+  public boolean isSuspended()
+  {
     return isSuspended;
   }
-  public ProcessInstance getProcessInstance() {
+
+  public ProcessInstance getProcessInstance()
+  {
     return processInstance;
   }
-  public void setProcessInstance(ProcessInstance processInstance) {
+
+  public void setProcessInstance(ProcessInstance processInstance)
+  {
     this.processInstance = processInstance;
   }
-  
+
   private static final Log log = LogFactory.getLog(TaskInstance.class);
 }

Modified: jbpm3/trunk/modules/integration/jboss42/src/main/etc/jboss-beans.xml
===================================================================
--- jbpm3/trunk/modules/integration/jboss42/src/main/etc/jboss-beans.xml	2008-11-28 11:04:14 UTC (rev 3141)
+++ jbpm3/trunk/modules/integration/jboss42/src/main/etc/jboss-beans.xml	2008-11-28 11:05:17 UTC (rev 3142)
@@ -14,9 +14,12 @@
   <property name="services">
    <set elementClass="org.jboss.bpm.api.service.Service">
     <inject bean="BPMDialectHandlerService"/>
+    <inject bean="BPMExecutionService"/>
+    <inject bean="BPMIdentityService"/>
     <inject bean="BPMProcessBuilderService"/>
     <inject bean="BPMProcessDefinitionService"/>
     <inject bean="BPMProcessService"/>
+    <inject bean="BPMTaskService"/>
    </set>
   </property>
  </bean>
@@ -46,7 +49,10 @@
  <bean name="BPMDialectHandlerJPDL32" class="org.jbpm.integration.jpdl32.DialectHandlerImpl" />
 
  <!-- Other Services -->
+ <bean name="BPMExecutionService" class="org.jbpm.integration.service.ExecutionServiceImpl" />
+ <bean name="BPMIdentityService" class="org.jbpm.integration.service.IdentityServiceImpl" />
  <bean name="BPMProcessBuilderService" class="org.jbpm.integration.service.ProcessBuilderServiceImpl" />
  <bean name="BPMProcessDefinitionService" class="org.jbpm.integration.service.ProcessDefinitionServiceImpl" />
+ <bean name="BPMTaskService" class="org.jbpm.integration.service.TaskServiceImpl" />
 
 </deployment>

Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java	2008-11-28 11:04:14 UTC (rev 3141)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java	2008-11-28 11:05:17 UTC (rev 3142)
@@ -27,6 +27,7 @@
 
 import org.jboss.bpm.api.client.ProcessEngine;
 import org.jboss.bpm.api.service.Service;
+import org.jbpm.JbpmConfiguration;
 import org.jbpm.integration.service.MutableService;
 
 /**
@@ -37,6 +38,8 @@
  */
 public class ProcessEngineImpl extends ProcessEngine
 {
+  private JbpmConfiguration jbpmConfig;
+  
   public void setServices(Set<Service> services)
   {
     this.services = services;
@@ -51,4 +54,13 @@
       }
     }
   }
+
+  public JbpmConfiguration getJbpmConfiguration()
+  {
+    if (jbpmConfig == null)
+    {
+      jbpmConfig = JbpmConfiguration.getInstance();
+    }
+    return jbpmConfig;
+  }
 }

Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java	2008-11-28 11:04:14 UTC (rev 3141)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java	2008-11-28 11:05:17 UTC (rev 3142)
@@ -37,7 +37,6 @@
 import org.jboss.bpm.api.model.Process;
 import org.jboss.bpm.api.model.ProcessDefinition;
 import org.jboss.bpm.api.model.builder.ObjectNameFactory;
-import org.jbpm.JbpmConfiguration;
 import org.jbpm.graph.def.Transition;
 import org.jbpm.graph.node.EndState;
 import org.jbpm.graph.node.StartState;
@@ -56,7 +55,6 @@
   private org.jbpm.graph.def.ProcessDefinition oldProcDef;
   private ProcessEngine engine;
   private Map<String, Node> nodes = new LinkedHashMap<String, Node>();
-  private JbpmConfiguration jbpmConfigCache;
 
   public ProcessDefinitionImpl(ProcessEngine engine, String name)
   {
@@ -83,15 +81,6 @@
     return oldProcDef;
   }
 
-  public JbpmConfiguration getJbpmConfiguration()
-  {
-    if (jbpmConfigCache == null)
-    {
-      jbpmConfigCache = JbpmConfiguration.getInstance();
-    }
-    return jbpmConfigCache;
-  }
-
   public ProcessEngine getProcessEngine()
   {
     return engine;

Added: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ExecutionServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ExecutionServiceImpl.java	                        (rev 0)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ExecutionServiceImpl.java	2008-11-28 11:05:17 UTC (rev 3142)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.service;
+
+// $Id$
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.management.ObjectName;
+
+import org.jboss.bpm.api.client.ProcessEngine;
+import org.jboss.bpm.api.model.Process;
+import org.jboss.bpm.api.runtime.Token;
+import org.jboss.bpm.api.service.ExecutionService;
+import org.jboss.bpm.api.service.ProcessService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The ExecutionService manages Tokens
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 28-Nov-2008
+ */
+public class ExecutionServiceImpl extends ExecutionService implements MutableService
+{
+  // Provide logging
+  final Logger log = LoggerFactory.getLogger(ExecutionServiceImpl.class);
+
+  // @Override
+  public void setProcessEngine(ProcessEngine engine)
+  {
+    super.setProcessEngine(engine);
+  }
+
+  @Override
+  public Set<Token> getTokens()
+  {
+    Set<Token> tokens = new HashSet<Token>();
+    ProcessService procService = getProcessEngine().getService(ProcessService.class);
+    for (ObjectName procID : procService.getProcesses())
+    {
+      Process proc = procService.getProcess(procID);
+      for (Token aux : proc.getTokens())
+      {
+        tokens.add(aux);
+      }
+    }
+    return tokens;
+  }
+
+  @Override
+  public Token getToken(ObjectName tokenID)
+  {
+    Token token = null;
+    
+    // [TODO] is there a better way than iterating over all processes and tokens?
+    ProcessService procService = getProcessEngine().getService(ProcessService.class);
+    for (ObjectName procID : procService.getProcesses())
+    {
+      Process proc = procService.getProcess(procID);
+      for (Token aux : proc.getTokens())
+      {
+        if (aux.getKey().equals(tokenID))
+        {
+          token = aux;
+          break;
+        }
+      }
+    }
+    return token;
+  }
+}


Property changes on: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ExecutionServiceImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/IdentityServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/IdentityServiceImpl.java	                        (rev 0)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/IdentityServiceImpl.java	2008-11-28 11:05:17 UTC (rev 3142)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.service;
+
+// $Id$
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.bpm.api.NotImplementedException;
+import org.jboss.bpm.api.client.ProcessEngine;
+import org.jboss.bpm.api.service.IdentityService;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.identity.Group;
+import org.jbpm.identity.User;
+import org.jbpm.identity.hibernate.IdentitySession;
+import org.jbpm.integration.client.ProcessEngineImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The IdentityService manages identities
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 28-Nov-2008
+ */
+public class IdentityServiceImpl extends IdentityService implements MutableService
+{
+  // Provide logging
+  final Logger log = LoggerFactory.getLogger(IdentityServiceImpl.class);
+
+  // @Override
+  public void setProcessEngine(ProcessEngine engine)
+  {
+    super.setProcessEngine(engine);
+  }
+
+  @Override
+  public List<String> getActors()
+  {
+    List<String> actors = new ArrayList<String>();
+    
+    IdentitySession identSession = getIdentitySession();
+    try
+    {
+      actors.addAll(identSession.getUsers());
+    }
+    catch (RuntimeException rte)
+    {
+      throw rte;
+    }
+    finally
+    {
+      identSession.close();
+    }
+    
+    return actors;
+  }
+
+  @Override
+  public List<String> getActorsByGroup(String group)
+  {
+    List<String> actors = new ArrayList<String>();
+    
+    IdentitySession identSession = getIdentitySession();
+    try
+    {
+      Group identGroup = identSession.getGroupByName(group);
+      for (User user : (Set<User>)identGroup.getUsers())
+      {
+        actors.add(user.getName());
+      }
+    }
+    catch (RuntimeException rte)
+    {
+      throw rte;
+    }
+    finally
+    {
+      identSession.close();
+    }
+    
+    return actors;
+  }
+
+  @Override
+  public List<String> getGroups()
+  {
+    throw new NotImplementedException();
+  }
+
+  @Override
+  public List<String> getGroupsByActor(String actor)
+  {
+    List<String> groups = new ArrayList<String>();
+    
+    IdentitySession identSession = getIdentitySession();
+    try
+    {
+      User identUser = identSession.getUserByName(actor);
+      for (Group group : (Set<Group>)identUser.getGroupsForGroupType("organisation"))
+      {
+        groups.add(group.getName());
+      }
+    }
+    catch (RuntimeException rte)
+    {
+      throw rte;
+    }
+    finally
+    {
+      identSession.close();
+    }
+    
+    return groups;
+  }
+
+  private IdentitySession getIdentitySession()
+  {
+    ProcessEngineImpl engineImpl = (ProcessEngineImpl)getProcessEngine();
+    JbpmConfiguration jbpmConfig = engineImpl.getJbpmConfiguration();
+    JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
+    IdentitySession identSession = new IdentitySession(jbpmContext.getSession());
+    return identSession;
+  }
+}


Property changes on: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/IdentityServiceImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ProcessDefinitionServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ProcessDefinitionServiceImpl.java	2008-11-28 11:04:14 UTC (rev 3141)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ProcessDefinitionServiceImpl.java	2008-11-28 11:05:17 UTC (rev 3142)
@@ -36,6 +36,7 @@
 import org.jboss.bpm.api.service.ProcessService;
 import org.jbpm.JbpmConfiguration;
 import org.jbpm.JbpmContext;
+import org.jbpm.integration.client.ProcessEngineImpl;
 import org.jbpm.integration.model.ProcessDefinitionImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -77,14 +78,12 @@
 
     log.debug("registerProcessDefinition: " + procDef);
     
-    // Works with the default configuration
-    ProcessDefinitionImpl procDefImpl = (ProcessDefinitionImpl)procDef;
-    JbpmConfiguration jbpmConfig = procDefImpl.getJbpmConfiguration();
-    JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
+    JbpmContext jbpmContext = getJbpmContext();
 
     ObjectName procDefID;
     try
     {
+      ProcessDefinitionImpl procDefImpl = (ProcessDefinitionImpl)procDef;
       jbpmContext.deployProcessDefinition(procDefImpl.getOldProcessDefinition());
       
       procDefID = procDef.getKey();
@@ -117,11 +116,10 @@
         procService.unregisterProcess(procID);
 
       // Save the ProcessDefinition
-      ProcessDefinitionImpl procDefImpl = (ProcessDefinitionImpl)procDef;
-      JbpmConfiguration jbpmConfig = procDefImpl.getJbpmConfiguration();
-      JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
+      JbpmContext jbpmContext = getJbpmContext();
       try
       {
+        ProcessDefinitionImpl procDefImpl = (ProcessDefinitionImpl)procDef;
         long oldID = procDefImpl.getOldProcessDefinition().getId();
         jbpmContext.getGraphSession().deleteProcessDefinition(oldID);
         
@@ -140,4 +138,12 @@
     
     return removed;
   }
+
+  private JbpmContext getJbpmContext()
+  {
+    ProcessEngineImpl engineImpl = (ProcessEngineImpl)getProcessEngine();
+    JbpmConfiguration jbpmConfig = engineImpl.getJbpmConfiguration();
+    JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
+    return jbpmContext;
+  }
 }
\ No newline at end of file

Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ProcessServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ProcessServiceImpl.java	2008-11-28 11:04:14 UTC (rev 3141)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/ProcessServiceImpl.java	2008-11-28 11:05:17 UTC (rev 3142)
@@ -41,7 +41,7 @@
 import org.jboss.bpm.api.service.ProcessService;
 import org.jbpm.JbpmConfiguration;
 import org.jbpm.JbpmContext;
-import org.jbpm.integration.model.ProcessDefinitionImpl;
+import org.jbpm.integration.client.ProcessEngineImpl;
 import org.jbpm.integration.model.ProcessImpl;
 import org.jbpm.integration.runtime.NodeInterceptor;
 import org.slf4j.Logger;
@@ -134,6 +134,7 @@
     if (getProcess(procID) != null)
       throw new IllegalStateException("Process already registered: " + proc);
 
+    ProcessImpl procImpl = (ProcessImpl)proc;
     ProcessStatus procStatus = proc.getProcessStatus();
     ProcessDefinition procDef = proc.getProcessDefinition();
     ProcessEngine engine = getProcessEngine();
@@ -147,10 +148,7 @@
       procDefService.registerProcessDefinition(procDef);
 
     // Save the Process instance
-    ProcessDefinitionImpl procDefImpl = (ProcessDefinitionImpl)procDef;
-    JbpmConfiguration jbpmConfig = procDefImpl.getJbpmConfiguration();
-    JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
-    ProcessImpl procImpl = (ProcessImpl)proc;
+    JbpmContext jbpmContext = getJbpmContext();
     try
     {
       jbpmContext.save(procImpl.getOldProcessInstance());
@@ -184,12 +182,10 @@
       log.debug("unregisterProcess: " + proc);
       
       // Delete the Process instance
-      ProcessDefinitionImpl procDefImpl = (ProcessDefinitionImpl)proc.getProcessDefinition();
-      JbpmConfiguration jbpmConfig = procDefImpl.getJbpmConfiguration();
-      JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
-      ProcessImpl procImpl = (ProcessImpl)proc;
+      JbpmContext jbpmContext = getJbpmContext();
       try
       {
+        ProcessImpl procImpl = (ProcessImpl)proc;
         jbpmContext.getGraphSession().deleteProcessInstance(procImpl.getOldProcessInstance());
       }
       catch (RuntimeException rte)
@@ -224,4 +220,12 @@
     }
     return itor;
   }
+
+  private JbpmContext getJbpmContext()
+  {
+    ProcessEngineImpl engineImpl = (ProcessEngineImpl)getProcessEngine();
+    JbpmConfiguration jbpmConfig = engineImpl.getJbpmConfiguration();
+    JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
+    return jbpmContext;
+  }
 }
\ No newline at end of file

Added: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/TaskServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/TaskServiceImpl.java	                        (rev 0)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/TaskServiceImpl.java	2008-11-28 11:05:17 UTC (rev 3142)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.service;
+
+// $Id$
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jboss.bpm.api.client.ProcessEngine;
+import org.jboss.bpm.api.service.TaskService;
+import org.jboss.bpm.api.task.Task;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.integration.client.ProcessEngineImpl;
+import org.jbpm.integration.task.TaskImpl;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The TaskService manages Tasks.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 28-Nov-2008
+ */
+public class TaskServiceImpl extends TaskService implements MutableService
+{
+  // Provide logging
+  final Logger log = LoggerFactory.getLogger(TaskServiceImpl.class);
+
+  // @Override
+  public void setProcessEngine(ProcessEngine engine)
+  {
+    super.setProcessEngine(engine);
+  }
+
+  @Override
+  public Task getTask(ObjectName taskID)
+  {
+    Task task = null;
+    
+    JbpmContext jbpmContext = getJbpmContext();
+    try
+    {
+      TaskInstance oldTask = jbpmContext.getTaskInstance(adaptKey(taskID));
+      task = new TaskImpl(getProcessEngine(), oldTask);
+    }
+    catch (RuntimeException rte)
+    {
+      throw rte;
+    }
+    finally
+    {
+      jbpmContext.close();
+    }
+    
+    return task;
+  }
+
+  @Override
+  public List<Task> getTasksByActor(String actor)
+  {
+    List<Task> tasks = new ArrayList<Task>();
+    
+    JbpmContext jbpmContext = getJbpmContext();
+    try
+    {
+      for (TaskInstance oldTask : (List<TaskInstance>)jbpmContext.getTaskList(actor))
+      {
+        tasks.add(new TaskImpl(getProcessEngine(), oldTask));
+      }
+    }
+    catch (RuntimeException rte)
+    {
+      throw rte;
+    }
+    finally
+    {
+      jbpmContext.close();
+    }
+    
+    return tasks;
+  }
+
+  @Override
+  public void closeTask(ObjectName taskID, String signalName)
+  {
+    TaskImpl taskImpl = (TaskImpl)getTask(taskID);
+    TaskInstance taskInstance = taskImpl.getOldTask();
+    
+    if (signalName != null)
+      taskInstance.end(signalName);
+    else
+      taskInstance.end();
+  }
+
+  @Override
+  public void reassignTask(ObjectName taskID, String actor)
+  {
+    TaskImpl taskImpl = (TaskImpl)getTask(taskID);
+    TaskInstance taskInstance = taskImpl.getOldTask();
+    
+    if (taskInstance.getStart() != null)
+    {
+      log.warn("Force stop on task " + taskInstance.getId() + ". Will be restarted.");
+      taskInstance.setStart(null); // strange, but means isNotStarted()
+    }
+
+    taskInstance.start(actor, true);
+  }
+
+  private Long adaptKey(ObjectName key)
+  {
+    String id = key.getKeyProperty("id");
+    if (id == null)
+      throw new IllegalStateException("Cannot obtain id property from: " + key);
+
+    return new Long(id);
+  }
+  
+  private JbpmContext getJbpmContext()
+  {
+    ProcessEngineImpl engineImpl = (ProcessEngineImpl)getProcessEngine();
+    JbpmConfiguration jbpmConfig = engineImpl.getJbpmConfiguration();
+    JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
+    return jbpmContext;
+  }
+}


Property changes on: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/service/TaskServiceImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/task/TaskImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/task/TaskImpl.java	                        (rev 0)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/task/TaskImpl.java	2008-11-28 11:05:17 UTC (rev 3142)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.task;
+
+// $Id$
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.management.ObjectName;
+
+import org.jboss.bpm.api.client.ProcessEngine;
+import org.jboss.bpm.api.model.builder.ObjectNameFactory;
+import org.jboss.bpm.api.runtime.Token;
+import org.jboss.bpm.api.service.ExecutionService;
+import org.jboss.bpm.api.task.Task;
+import org.jbpm.integration.runtime.TokenImpl;
+import org.jbpm.taskmgmt.exe.PooledActor;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The TaskService manages Tasks.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 28-Nov-2008
+ */
+public class TaskImpl implements Task 
+{
+  // Provide logging
+  final Logger log = LoggerFactory.getLogger(TaskImpl.class);
+
+  private ProcessEngine engine;
+  private TaskInstance oldTask;
+  private Token token;
+  
+  public TaskImpl(ProcessEngine engine, TaskInstance oldTask)
+  {
+    this.engine = engine;
+    this.oldTask = oldTask;
+  }
+
+  public TaskInstance getOldTask()
+  {
+    return oldTask;
+  }
+
+  public ObjectName getKey()
+  {
+    return ObjectNameFactory.create("Task:id=" + oldTask.getId());
+  }
+
+  public String getActor()
+  {
+    return oldTask.getActorId();
+  }
+
+  public ObjectName getCorrelationKey()
+  {
+    if (token == null)
+    {
+      long tokenId = oldTask.getToken().getId();
+      ExecutionService exService = engine.getService(ExecutionService.class);
+      for (Token auxTok : exService.getTokens())
+      {
+        TokenImpl tokenImpl = (TokenImpl)auxTok;
+        if (tokenImpl.getOldToken().getId() == tokenId)
+        {
+          token = auxTok;
+          break;
+        }
+      }
+    }
+    
+    if (token == null)
+      throw new IllegalStateException("Cannot obtain associated token");
+    
+    return token.getKey();
+  }
+
+  public String getName()
+  {
+    return oldTask.getName();
+  }
+
+  public Set<String> getPooledActors()
+  {
+    Set<String> actors = new HashSet<String>();
+    for (PooledActor pa : oldTask.getPooledActors())
+    {
+      actors.add(pa.getActorId());
+    }
+    return actors;
+  }
+
+  public boolean isBlocking()
+  {
+    return oldTask.isBlocking();
+  }
+
+  public boolean isSignalling()
+  {
+    return oldTask.isSignalling();
+  }
+
+}


Property changes on: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/task/TaskImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml	2008-11-28 11:04:14 UTC (rev 3141)
+++ jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml	2008-11-28 11:05:17 UTC (rev 3142)
@@ -13,6 +13,7 @@
  <bean name="BPMProcessEngine" class="org.jbpm.integration.client.ProcessEngineImpl">
   <property name="services">
    <set elementClass="org.jboss.bpm.api.service.Service">
+    <inject bean="BPMIdentityService"/>
     <inject bean="BPMDialectHandlerService"/>
     <inject bean="BPMProcessBuilderService"/>
     <inject bean="BPMProcessDefinitionService"/>
@@ -46,6 +47,7 @@
  <bean name="BPMDialectHandlerJPDL32" class="org.jbpm.integration.jpdl32.DialectHandlerImpl" />
 
  <!-- Other Services -->
+ <bean name="BPMIdentityService" class="org.jbpm.integration.service.IdentityServiceImpl" />
  <bean name="BPMProcessBuilderService" class="org.jbpm.integration.service.ProcessBuilderServiceImpl" />
  <bean name="BPMProcessDefinitionService" class="org.jbpm.integration.service.ProcessDefinitionServiceImpl" />
 




More information about the jbpm-commits mailing list