[jbpm-commits] JBoss JBPM SVN: r3479 - in jbpm3/trunk/modules: core/src/main/java/org/jbpm/graph/def and 8 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Dec 20 07:55:34 EST 2008


Author: thomas.diesler at jboss.com
Date: 2008-12-20 07:55:32 -0500 (Sat, 20 Dec 2008)
New Revision: 3479

Added:
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/signal/
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/signal/EventService.java
   jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/EventServiceFactory.java
   jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/SignalBuilderServiceImpl.java
   jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/SignalServiceImpl.java
Modified:
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/ExecutionContext.java
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/Service.java
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/Services.java
   jbpm3/trunk/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
   jbpm3/trunk/modules/integration/.classpath
   jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/model/ExclusiveGatewayImpl.java
   jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/model/ProcessInstanceImpl.java
   jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/ContextServiceImpl.java
   jbpm3/trunk/modules/integration/src/main/resources/bpm-spec-jbpm3-beans.xml
Log:
Add bpm-spec signal support

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java	2008-12-20 12:06:16 UTC (rev 3478)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java	2008-12-20 12:55:32 UTC (rev 3479)
@@ -39,11 +39,13 @@
 import org.jbpm.instantiation.UserCodeInterceptorConfig;
 import org.jbpm.job.ExecuteActionJob;
 import org.jbpm.msg.MessageService;
+import org.jbpm.signal.EventService;
+import org.jbpm.svc.Service;
 import org.jbpm.svc.Services;
 import org.jbpm.util.EqualsUtil;
 
-public abstract class GraphElement implements Identifiable, Serializable {
-  
+public abstract class GraphElement implements Identifiable, Serializable
+{
   private static final long serialVersionUID = 1L;
 
   long id = 0;
@@ -53,67 +55,82 @@
   protected Map events = null;
   protected List exceptionHandlers = null;
 
-  public GraphElement() {
+  public GraphElement()
+  {
   }
-  
-  public GraphElement( String name ) {
-    setName( name );
+
+  public GraphElement(String name)
+  {
+    setName(name);
   }
 
   // events ///////////////////////////////////////////////////////////////////
 
   /**
-   * indicative set of event types supported by this graph element.
-   * this is currently only used by the process designer to know which 
-   * event types to show on a given graph element.  in process definitions 
-   * and at runtime, there are no contstraints on the event-types.
+   * indicative set of event types supported by this graph element. this is currently only used by the process designer
+   * to know which event types to show on a given graph element. in process definitions and at runtime, there are no
+   * contstraints on the event-types.
    */
   public abstract String[] getSupportedEventTypes();
 
   /**
    * gets the events, keyd by eventType (java.lang.String).
    */
-  public Map getEvents() {
+  public Map getEvents()
+  {
     return events;
   }
 
-  public boolean hasEvents() {
-    return ( (events!=null)
-             && (events.size()>0) );
+  public boolean hasEvents()
+  {
+    return ((events != null) && (events.size() > 0));
   }
 
-  public Event getEvent(String eventType) {
+  public Event getEvent(String eventType)
+  {
     Event event = null;
-    if (events!=null) {
-      event = (Event) events.get(eventType);
+    if (events != null)
+    {
+      event = (Event)events.get(eventType);
     }
     return event;
   }
-  
-  public boolean hasEvent(String eventType) {
+
+  public boolean hasEvent(String eventType)
+  {
     boolean hasEvent = false;
-    if (events!=null) {
+    if (events != null)
+    {
       hasEvent = events.containsKey(eventType);
     }
     return hasEvent;
   }
-  
-  public Event addEvent(Event event) {
-    if (event == null) throw new IllegalArgumentException("can't add a null event to a graph element");
-    if (event.getEventType() == null) throw new IllegalArgumentException("can't add an event without an eventType to a graph element");
-    if (events == null) events = new HashMap();
+
+  public Event addEvent(Event event)
+  {
+    if (event == null)
+      throw new IllegalArgumentException("can't add a null event to a graph element");
+    if (event.getEventType() == null)
+      throw new IllegalArgumentException("can't add an event without an eventType to a graph element");
+    if (events == null)
+      events = new HashMap();
     events.put(event.getEventType(), event);
     event.graphElement = this;
     return event;
   }
-  
-  public Event removeEvent(Event event) {
+
+  public Event removeEvent(Event event)
+  {
     Event removedEvent = null;
-    if (event == null) throw new IllegalArgumentException("can't remove a null event from a graph element");
-    if (event.getEventType() == null) throw new IllegalArgumentException("can't remove an event without an eventType from a graph element");
-    if (events != null) {
-      removedEvent = (Event) events.remove(event.getEventType());
-      if (removedEvent!=null) {
+    if (event == null)
+      throw new IllegalArgumentException("can't remove a null event from a graph element");
+    if (event.getEventType() == null)
+      throw new IllegalArgumentException("can't remove an event without an eventType from a graph element");
+    if (events != null)
+    {
+      removedEvent = (Event)events.remove(event.getEventType());
+      if (removedEvent != null)
+      {
         event.graphElement = null;
       }
     }
@@ -125,98 +142,130 @@
   /**
    * is the list of exception handlers associated to this graph element.
    */
-  public List getExceptionHandlers() {
+  public List getExceptionHandlers()
+  {
     return exceptionHandlers;
   }
-  
-  public ExceptionHandler addExceptionHandler(ExceptionHandler exceptionHandler) {
-    if (exceptionHandler == null) throw new IllegalArgumentException("can't add a null exceptionHandler to a graph element");
-    if (exceptionHandlers == null) exceptionHandlers = new ArrayList();
+
+  public ExceptionHandler addExceptionHandler(ExceptionHandler exceptionHandler)
+  {
+    if (exceptionHandler == null)
+      throw new IllegalArgumentException("can't add a null exceptionHandler to a graph element");
+    if (exceptionHandlers == null)
+      exceptionHandlers = new ArrayList();
     exceptionHandlers.add(exceptionHandler);
     exceptionHandler.graphElement = this;
     return exceptionHandler;
   }
-  
-  public void removeExceptionHandler(ExceptionHandler exceptionHandler) {
-    if (exceptionHandler == null) throw new IllegalArgumentException("can't remove a null exceptionHandler from an graph element");
-    if (exceptionHandlers != null) {
-      if (exceptionHandlers.remove(exceptionHandler)) {
+
+  public void removeExceptionHandler(ExceptionHandler exceptionHandler)
+  {
+    if (exceptionHandler == null)
+      throw new IllegalArgumentException("can't remove a null exceptionHandler from an graph element");
+    if (exceptionHandlers != null)
+    {
+      if (exceptionHandlers.remove(exceptionHandler))
+      {
         exceptionHandler.graphElement = null;
       }
     }
   }
 
-  public void reorderExceptionHandler(int oldIndex, int newIndex) {
-    if ( (exceptionHandlers!=null)
-         && (Math.min(oldIndex, newIndex)>=0)
-         && (Math.max(oldIndex, newIndex)<exceptionHandlers.size()) ) {
+  public void reorderExceptionHandler(int oldIndex, int newIndex)
+  {
+    if ((exceptionHandlers != null) && (Math.min(oldIndex, newIndex) >= 0) && (Math.max(oldIndex, newIndex) < exceptionHandlers.size()))
+    {
       Object o = exceptionHandlers.remove(oldIndex);
       exceptionHandlers.add(newIndex, o);
-    } else {
-      throw new IndexOutOfBoundsException("couldn't reorder element from index '"+oldIndex+"' to index '"+newIndex+"' in exceptionHandler-list '"+exceptionHandlers+"'");
     }
+    else
+    {
+      throw new IndexOutOfBoundsException("couldn't reorder element from index '" + oldIndex + "' to index '" + newIndex + "' in exceptionHandler-list '"
+          + exceptionHandlers + "'");
+    }
   }
 
   // event handling ///////////////////////////////////////////////////////////
 
-  public void fireEvent(String eventType, ExecutionContext executionContext) {
-    log.debug( "event '"+eventType+"' on '"+this+"' for '"+executionContext.getToken()+"'" );
-    try {
+  public void fireEvent(String eventType, ExecutionContext executionContext)
+  {
+    log.debug("event '" + eventType + "' on '" + this + "' for '" + executionContext.getToken() + "'");
+    try
+    {
       executionContext.setEventSource(this);
+      
+      Services services = executionContext.getJbpmContext().getServices();
+      EventService evService = (EventService)services.getService(EventService.SERVICE_NAME);
+      if (evService != null)
+      {
+        evService.fireEvent(eventType, this, executionContext);
+      }
+      
       fireAndPropagateEvent(eventType, executionContext);
-    } finally {
+    }
+    finally
+    {
       executionContext.setEventSource(null);
     }
   }
 
-  public void fireAndPropagateEvent(String eventType, ExecutionContext executionContext) {
+  public void fireAndPropagateEvent(String eventType, ExecutionContext executionContext)
+  {
     // calculate if the event was fired on this element or if it was a propagated event
     boolean isPropagated = !(this.equals(executionContext.getEventSource()));
-    
-    // execute static actions 
+
+    // execute static actions
     Event event = getEvent(eventType);
-    if (event!=null) {
+    if (event != null)
+    {
       // update the context
       executionContext.setEvent(event);
       // execute the static actions specified in the process definition
       executeActions(event.getActions(), executionContext, isPropagated);
     }
-    
+
     // execute the runtime actions
     List runtimeActions = getRuntimeActionsForEvent(executionContext, eventType);
     executeActions(runtimeActions, executionContext, isPropagated);
 
     // remove the event from the context
     executionContext.setEvent(null);
-    
+
     // propagate the event to the parent element
     GraphElement parent = getParent();
-    if (parent!=null) {
+    if (parent != null)
+    {
       parent.fireAndPropagateEvent(eventType, executionContext);
     }
   }
 
-  void executeActions(List actions, ExecutionContext executionContext, boolean isPropagated) {
-    if (actions!=null) {
+  void executeActions(List actions, ExecutionContext executionContext, boolean isPropagated)
+  {
+    if (actions != null)
+    {
       Iterator iter = actions.iterator();
-      while (iter.hasNext()) {
-        Action action = (Action) iter.next();
-        if ( action.acceptsPropagatedEvents()
-             || (!isPropagated)
-           ) {
-          if (action.isAsync()) {
+      while (iter.hasNext())
+      {
+        Action action = (Action)iter.next();
+        if (action.acceptsPropagatedEvents() || (!isPropagated))
+        {
+          if (action.isAsync())
+          {
             ExecuteActionJob job = createAsyncActionExecutionJob(executionContext.getToken(), action);
-            MessageService messageService = (MessageService) Services.getCurrentService(Services.SERVICENAME_MESSAGE);
+            MessageService messageService = (MessageService)Services.getCurrentService(Services.SERVICENAME_MESSAGE);
             messageService.send(job);
-          } else {
+          }
+          else
+          {
             executeAction(action, executionContext);
           }
         }
       }
     }
   }
-  
-  protected ExecuteActionJob createAsyncActionExecutionJob(Token token, Action action) {
+
+  protected ExecuteActionJob createAsyncActionExecutionJob(Token token, Action action)
+  {
     ExecuteActionJob job = new ExecuteActionJob(token);
     job.setAction(action);
     job.setDueDate(new Date());
@@ -224,85 +273,106 @@
     return job;
   }
 
-  public void executeAction(Action action, ExecutionContext executionContext) {
+  public void executeAction(Action action, ExecutionContext executionContext)
+  {
     Token token = executionContext.getToken();
 
     // create action log
     ActionLog actionLog = new ActionLog(action);
     token.startCompositeLog(actionLog);
 
-    // if this is an action being executed in an event, 
-    // the token needs to be locked.  if this is an action 
-    // being executed as the node behaviour or if the token 
+    // if this is an action being executed in an event,
+    // the token needs to be locked. if this is an action
+    // being executed as the node behaviour or if the token
     // is already locked, the token doesn't need to be locked.
-    boolean actionMustBeLocked = (executionContext.getEvent()!=null)
-                                 && (!token.isLocked());
+    boolean actionMustBeLocked = (executionContext.getEvent() != null) && (!token.isLocked());
 
-    try {
+    try
+    {
       // update the execution context
       executionContext.setAction(action);
 
       // execute the action
-      log.debug("executing action '"+action+"'");
-      String lockOwnerId = "token["+token.getId()+"]"; 
-      try {
-        if (actionMustBeLocked) {
+      log.debug("executing action '" + action + "'");
+      String lockOwnerId = "token[" + token.getId() + "]";
+      try
+      {
+        if (actionMustBeLocked)
+        {
           token.lock(lockOwnerId);
         }
-        
-        if (UserCodeInterceptorConfig.userCodeInterceptor!=null) {
+
+        if (UserCodeInterceptorConfig.userCodeInterceptor != null)
+        {
           UserCodeInterceptorConfig.userCodeInterceptor.executeAction(action, executionContext);
-        } else {
+        }
+        else
+        {
           action.execute(executionContext);
         }
 
-      } finally {
-        if (actionMustBeLocked) {
+      }
+      finally
+      {
+        if (actionMustBeLocked)
+        {
           token.unlock(lockOwnerId);
         }
       }
-   
-    } catch (Exception exception) {
+
+    }
+    catch (Exception exception)
+    {
       // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
-      log.error("action threw exception: "+exception.getMessage(), exception);
-      
-      // log the action exception 
+      log.error("action threw exception: " + exception.getMessage(), exception);
+
+      // log the action exception
       actionLog.setException(exception);
 
       // If an exception is already set we are in an action of an exception handler
       // in this case don't give the exception to the handlers but throw it to the client
       // see https://jira.jboss.org/jira/browse/JBPM-1887
-      if (executionContext.getException()==null) {
+      if (executionContext.getException() == null)
+      {
         // if an exception handler is available
         raiseException(exception, executionContext);
       }
-      else {
-          // if there is no parent we need to throw an action exception to the client
-          if (exception instanceof JbpmException) {
-            throw (JbpmException) exception;
-          } else {
-            throw new DelegationException(exception, executionContext);
-          }
-      }       
-    } finally {
+      else
+      {
+        // if there is no parent we need to throw an action exception to the client
+        if (exception instanceof JbpmException)
+        {
+          throw (JbpmException)exception;
+        }
+        else
+        {
+          throw new DelegationException(exception, executionContext);
+        }
+      }
+    }
+    finally
+    {
       executionContext.setAction(null);
       token.endCompositeLog();
     }
   }
 
-  List getRuntimeActionsForEvent(ExecutionContext executionContext, String eventType) {
+  List getRuntimeActionsForEvent(ExecutionContext executionContext, String eventType)
+  {
     List runtimeActionsForEvent = null;
     List runtimeActions = executionContext.getProcessInstance().getRuntimeActions();
-    if (runtimeActions!=null) {
+    if (runtimeActions != null)
+    {
       Iterator iter = runtimeActions.iterator();
-      while (iter.hasNext()) {
-        RuntimeAction runtimeAction = (RuntimeAction) iter.next();
+      while (iter.hasNext())
+      {
+        RuntimeAction runtimeAction = (RuntimeAction)iter.next();
         // if the runtime-action action is registered on this element and this eventType
-        if ( (this.equals(runtimeAction.getGraphElement()))
-             && (eventType.equals(runtimeAction.getEventType()))
-           ) {
-          // ... add its action to the list of runtime actions 
-          if (runtimeActionsForEvent==null) runtimeActionsForEvent = new ArrayList();
+        if ((this.equals(runtimeAction.getGraphElement())) && (eventType.equals(runtimeAction.getEventType())))
+        {
+          // ... add its action to the list of runtime actions
+          if (runtimeActionsForEvent == null)
+            runtimeActionsForEvent = new ArrayList();
           runtimeActionsForEvent.add(runtimeAction.getAction());
         }
       }
@@ -310,117 +380,118 @@
     return runtimeActionsForEvent;
   }
 
-/*    
-      // the next instruction merges the actions specified in the process definition with the runtime actions
-      List actions = event.collectActions(executionContext);
-      
-      // loop over all actions of this event
-      Iterator iter = actions.iterator();
-      while (iter.hasNext()) {
-        Action action = (Action) iter.next();
-        executionContext.setAction(action);
-        
-        if ( (!isPropagated)
-             || (action.acceptsPropagatedEvents() ) ) {
-      
-          // create action log
-          ActionLog actionLog = new ActionLog(action);
-          executionContext.getToken().startCompositeLog(actionLog);
-      
-          try {
-            // execute the action
-            action.execute(executionContext);
-      
-          } catch (Exception exception) {
-            // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
-            Event.log.error("action threw exception: "+exception.getMessage(), exception);
-            
-            // log the action exception 
-            actionLog.setException(exception);
-      
-            // if an exception handler is available
-            event.graphElement.raiseException(exception, executionContext);
-          } finally {
-            executionContext.getToken().endCompositeLog();
-          }
-        }
-      }
-    }
-*/
+  /*
+   * // the next instruction merges the actions specified in the process definition with the runtime actions List
+   * actions = event.collectActions(executionContext);
+   * 
+   * // loop over all actions of this event Iterator iter = actions.iterator(); while (iter.hasNext()) { Action action =
+   * (Action) iter.next(); executionContext.setAction(action);
+   * 
+   * if ( (!isPropagated) || (action.acceptsPropagatedEvents() ) ) {
+   * 
+   * // create action log ActionLog actionLog = new ActionLog(action);
+   * executionContext.getToken().startCompositeLog(actionLog);
+   * 
+   * try { // execute the action action.execute(executionContext);
+   * 
+   * } catch (Exception exception) { // NOTE that Error's are not caught because that might halt the JVM and mask the
+   * original Error. Event.log.error("action threw exception: "+exception.getMessage(), exception);
+   * 
+   * // log the action exception actionLog.setException(exception);
+   * 
+   * // if an exception handler is available event.graphElement.raiseException(exception, executionContext); } finally {
+   * executionContext.getToken().endCompositeLog(); } } } }
+   */
 
   /**
-   * throws an ActionException if no applicable exception handler is found.
-   * An ExceptionHandler is searched for in this graph element and then recursively up the 
-   * parent hierarchy.  
-   * If an exception handler is found, it is applied.  If the exception handler does not 
-   * throw an exception, the exception is considered handled.  Otherwise the search for 
-   * an applicable exception handler continues where it left of with the newly thrown 
-   * exception.
+   * throws an ActionException if no applicable exception handler is found. An ExceptionHandler is searched for in this
+   * graph element and then recursively up the parent hierarchy. If an exception handler is found, it is applied. If the
+   * exception handler does not throw an exception, the exception is considered handled. Otherwise the search for an
+   * applicable exception handler continues where it left of with the newly thrown exception.
    */
-  public void raiseException(Throwable exception, ExecutionContext executionContext) throws DelegationException {
+  public void raiseException(Throwable exception, ExecutionContext executionContext) throws DelegationException
+  {
     boolean isHandled = false;
-    if (exceptionHandlers!=null) {
-      try {
+    if (exceptionHandlers != null)
+    {
+      try
+      {
         ExceptionHandler exceptionHandler = findExceptionHandler(exception);
-        if (exceptionHandler!=null) {
+        if (exceptionHandler != null)
+        {
           executionContext.setException(exception);
           exceptionHandler.handleException(this, executionContext);
           isHandled = true;
         }
-      } catch (Exception e) {
+      }
+      catch (Exception e)
+      {
         // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
         exception = e;
       }
     }
 
-    if (!isHandled) {
+    if (!isHandled)
+    {
       GraphElement parent = getParent();
       // if this graph element has a parent
-      if ( (parent!=null)
-           && (parent!=this) ){
+      if ((parent != null) && (parent != this))
+      {
         // action to the parent
         parent.raiseException(exception, executionContext);
-      } else {
+      }
+      else
+      {
         // rollback the actions
         // rollbackActions(executionContext);
-        
+
         // if there is no parent we need to throw an action exception to the client
-        if (exception instanceof JbpmException) {
-          throw (JbpmException) exception;
-        } else {
+        if (exception instanceof JbpmException)
+        {
+          throw (JbpmException)exception;
+        }
+        else
+        {
           throw new DelegationException(exception, executionContext);
         }
       }
     }
   }
 
-  protected ExceptionHandler findExceptionHandler(Throwable exception) {
+  protected ExceptionHandler findExceptionHandler(Throwable exception)
+  {
     ExceptionHandler exceptionHandler = null;
-    
-    if (exceptionHandlers!=null) {
+
+    if (exceptionHandlers != null)
+    {
       Iterator iter = exceptionHandlers.iterator();
-      while (iter.hasNext() && (exceptionHandler==null)) {
-        ExceptionHandler candidate = (ExceptionHandler) iter.next();
-        if (candidate.matches(exception)) {
+      while (iter.hasNext() && (exceptionHandler == null))
+      {
+        ExceptionHandler candidate = (ExceptionHandler)iter.next();
+        if (candidate.matches(exception))
+        {
           exceptionHandler = candidate;
         }
       }
     }
-    
+
     return exceptionHandler;
   }
 
-  public GraphElement getParent() {
+  public GraphElement getParent()
+  {
     return processDefinition;
   }
 
   /**
    * @return all the parents of this graph element ordered by age.
    */
-  public List getParents() {
+  public List getParents()
+  {
     List parents = new ArrayList();
-    GraphElement parent = getParent(); 
-    if (parent!=null) {
+    GraphElement parent = getParent();
+    if (parent != null)
+    {
       parent.addParentChain(parents);
     }
     return parents;
@@ -429,62 +500,83 @@
   /**
    * @return this graph element plus all the parents ordered by age.
    */
-  public List getParentChain() {
+  public List getParentChain()
+  {
     List parents = new ArrayList();
     this.addParentChain(parents);
     return parents;
   }
 
-  void addParentChain(List parentChain) {
+  void addParentChain(List parentChain)
+  {
     parentChain.add(this);
     GraphElement parent = getParent();
-    if (parent!=null) {
+    if (parent != null)
+    {
       parent.addParentChain(parentChain);
     }
   }
-  
-  public String toString() {
-    String className = getClass().getName(); 
-    className = className.substring(className.lastIndexOf('.')+1);
-    if (name!=null) {
-      className = className+"("+name+")";
-    } else {
-      className = className+"("+Integer.toHexString(System.identityHashCode(this))+")";
+
+  public String toString()
+  {
+    String className = getClass().getName();
+    className = className.substring(className.lastIndexOf('.') + 1);
+    if (name != null)
+    {
+      className = className + "(" + name + ")";
     }
+    else
+    {
+      className = className + "(" + Integer.toHexString(System.identityHashCode(this)) + ")";
+    }
     return className;
   }
 
   // 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);
   }
-  
+
   // getters and setters //////////////////////////////////////////////////////
-  
-  public long getId() {
+
+  public long getId()
+  {
     return id;
   }
-  public String getName() {
+
+  public String getName()
+  {
     return name;
   }
-  public void setName( String name ) {
+
+  public void setName(String name)
+  {
     this.name = name;
   }
-  public String getDescription() {
+
+  public String getDescription()
+  {
     return description;
   }
-  public void setDescription(String description) {
+
+  public void setDescription(String description)
+  {
     this.description = description;
   }
-  public ProcessDefinition getProcessDefinition() {
+
+  public ProcessDefinition getProcessDefinition()
+  {
     return processDefinition;
   }
-  public void setProcessDefinition(ProcessDefinition processDefinition) {
+
+  public void setProcessDefinition(ProcessDefinition processDefinition)
+  {
     this.processDefinition = processDefinition;
   }
-  
+
   // logger ///////////////////////////////////////////////////////////////////
   private static final Log log = LogFactory.getLog(GraphElement.class);
 }

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/ExecutionContext.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/ExecutionContext.java	2008-12-20 12:06:16 UTC (rev 3478)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/ExecutionContext.java	2008-12-20 12:55:32 UTC (rev 3479)
@@ -39,11 +39,12 @@
 import org.jbpm.taskmgmt.exe.TaskInstance;
 import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
 
-public class ExecutionContext {
-  
+public class ExecutionContext
+{
+
   protected Token token = null;
   protected Event event = null;
-  protected GraphElement eventSource = null; 
+  protected GraphElement eventSource = null;
   protected Action action = null;
   protected Throwable exception = null;
   protected Transition transition = null;
@@ -53,38 +54,46 @@
   protected TaskInstance taskInstance = null;
   protected ProcessInstance subProcessInstance = null;
 
-  public ExecutionContext( Token token ) {
+  public ExecutionContext(Token token)
+  {
     this.token = token;
   }
 
-  public ExecutionContext(ExecutionContext other) {
+  public ExecutionContext(ExecutionContext other)
+  {
     this.token = other.token;
     this.event = other.event;
     this.action = other.action;
   }
 
-  public Node getNode() {
+  public Node getNode()
+  {
     return token.getNode();
   }
 
-  public ProcessDefinition getProcessDefinition() {
+  public ProcessDefinition getProcessDefinition()
+  {
     ProcessInstance processInstance = getProcessInstance();
-    return ( processInstance!=null ? processInstance.getProcessDefinition() : null );
+    return (processInstance != null ? processInstance.getProcessDefinition() : null);
   }
 
-  public void setAction(Action action) {
+  public void setAction(Action action)
+  {
     this.action = action;
-    if (action!=null) {
+    if (action != null)
+    {
       this.event = action.getEvent();
     }
   }
-  
-  public ProcessInstance getProcessInstance() {
+
+  public ProcessInstance getProcessInstance()
+  {
     return token.getProcessInstance();
   }
-  
-  public String toString() {
-    return "ExecutionContext["+ token + "]";
+
+  public String toString()
+  {
+    return "ExecutionContext[" + token + "]";
   }
 
   // convenience methods //////////////////////////////////////////////////////
@@ -92,160 +101,224 @@
   /**
    * set a process variable.
    */
-  public void setVariable(String name, Object value) {
-    if (taskInstance!=null) {
+  public void setVariable(String name, Object value)
+  {
+    if (taskInstance != null)
+    {
       taskInstance.setVariable(name, value);
-    } else {
+    }
+    else
+    {
       getContextInstance().setVariable(name, value, token);
     }
   }
-  
+
   /**
    * get a process variable.
    */
-  public Object getVariable(String name) {
-    if (taskInstance!=null) {
+  public Object getVariable(String name)
+  {
+    if (taskInstance != null)
+    {
       return taskInstance.getVariable(name);
-    } else {
+    }
+    else
+    {
       return getContextInstance().getVariable(name, token);
     }
   }
-  
+
   /**
-   * leave this node over the default transition.  This method is only available
-   * on node actions.  Not on actions that are executed on events.  Actions on 
-   * events cannot change the flow of execution.
+   * leave this node over the default transition. This method is only available on node actions. Not on actions that are
+   * executed on events. Actions on events cannot change the flow of execution.
    */
-  public void leaveNode() {
+  public void leaveNode()
+  {
     getNode().leave(this);
   }
+
   /**
-   * leave this node over the given transition.  This method is only available
-   * on node actions.  Not on actions that are executed on events.  Actions on 
-   * events cannot change the flow of execution.
+   * leave this node over the given transition. This method is only available on node actions. Not on actions that are
+   * executed on events. Actions on events cannot change the flow of execution.
    */
-  public void leaveNode(String transitionName) {
+  public void leaveNode(String transitionName)
+  {
     getNode().leave(this, transitionName);
   }
+
   /**
-   * leave this node over the given transition.  This method is only available
-   * on node actions.  Not on actions that are executed on events.  Actions on 
-   * events cannot change the flow of execution.
+   * leave this node over the given transition. This method is only available on node actions. Not on actions that are
+   * executed on events. Actions on events cannot change the flow of execution.
    */
-  public void leaveNode(Transition transition) {
+  public void leaveNode(Transition transition)
+  {
     getNode().leave(this, transition);
   }
-  
-  public ModuleDefinition getDefinition(Class clazz) {
+
+  public ModuleDefinition getDefinition(Class clazz)
+  {
     return getProcessDefinition().getDefinition(clazz);
   }
 
-  public ModuleInstance getInstance(Class clazz) {
-    ProcessInstance processInstance = (token!=null ? token.getProcessInstance() : null);
-    return (processInstance!=null ? processInstance.getInstance(clazz): null);
+  public ModuleInstance getInstance(Class clazz)
+  {
+    ProcessInstance processInstance = (token != null ? token.getProcessInstance() : null);
+    return (processInstance != null ? processInstance.getInstance(clazz) : null);
   }
-  
-  public ContextInstance getContextInstance() {
-    return (ContextInstance) getInstance(ContextInstance.class);
+
+  public ContextInstance getContextInstance()
+  {
+    return (ContextInstance)getInstance(ContextInstance.class);
   }
 
-  public TaskMgmtInstance getTaskMgmtInstance() {
-    return (TaskMgmtInstance) getInstance(TaskMgmtInstance.class);
+  public TaskMgmtInstance getTaskMgmtInstance()
+  {
+    return (TaskMgmtInstance)getInstance(TaskMgmtInstance.class);
   }
 
-  public JbpmContext getJbpmContext() {
+  public JbpmContext getJbpmContext()
+  {
     return JbpmContext.getCurrentJbpmContext();
   }
 
   // getters and setters //////////////////////////////////////////////////////
-  
-  public void setTaskInstance(TaskInstance taskInstance) {
+
+  public void setTaskInstance(TaskInstance taskInstance)
+  {
     this.taskInstance = taskInstance;
-    this.task = (taskInstance!=null ? taskInstance.getTask() : null);
+    this.task = (taskInstance != null ? taskInstance.getTask() : null);
   }
 
-  public Token getToken() {
+  public Token getToken()
+  {
     return token;
   }
-  public Action getAction() {
+
+  public Action getAction()
+  {
     return action;
   }
-  public Event getEvent() {
+
+  public Event getEvent()
+  {
     return event;
   }
-  public void setEvent(Event event) {
+
+  public void setEvent(Event event)
+  {
     this.event = event;
   }
-  public Throwable getException() {
+
+  public Throwable getException()
+  {
     return exception;
   }
-  public void setException(Throwable exception) {
+
+  public void setException(Throwable exception)
+  {
     this.exception = exception;
   }
-  public Transition getTransition() {
+
+  public Transition getTransition()
+  {
     return transition;
   }
-  public void setTransition(Transition transition) {
+
+  public void setTransition(Transition transition)
+  {
     this.transition = transition;
   }
-  public Node getTransitionSource() {
+
+  public Node getTransitionSource()
+  {
     return transitionSource;
   }
-  public void setTransitionSource(Node transitionSource) {
+
+  public void setTransitionSource(Node transitionSource)
+  {
     this.transitionSource = transitionSource;
   }
-  public GraphElement getEventSource() {
+
+  public GraphElement getEventSource()
+  {
     return eventSource;
   }
-  public void setEventSource(GraphElement eventSource) {
+
+  public void setEventSource(GraphElement eventSource)
+  {
     this.eventSource = eventSource;
   }
-  public Task getTask() {
+
+  public Task getTask()
+  {
     return task;
   }
-  public void setTask(Task task) {
+
+  public void setTask(Task task)
+  {
     this.task = task;
   }
-  public TaskInstance getTaskInstance() {
+
+  public TaskInstance getTaskInstance()
+  {
     return taskInstance;
   }
-  public ProcessInstance getSubProcessInstance() {
+
+  public ProcessInstance getSubProcessInstance()
+  {
     return subProcessInstance;
   }
-  public void setSubProcessInstance(ProcessInstance subProcessInstance) {
+
+  public void setSubProcessInstance(ProcessInstance subProcessInstance)
+  {
     this.subProcessInstance = subProcessInstance;
   }
-  public Timer getTimer() {
+
+  public Timer getTimer()
+  {
     return timer;
   }
-  public void setTimer(Timer timer) {
+
+  public void setTimer(Timer timer)
+  {
     this.timer = timer;
   }
 
   // thread local execution context
-  
+
   static ThreadLocal threadLocalContextStack = new ThreadLocal();
-  static Stack getContextStack() {
-    Stack stack = (Stack) threadLocalContextStack.get();
-    if (stack==null) {
+
+  static Stack getContextStack()
+  {
+    Stack stack = (Stack)threadLocalContextStack.get();
+    if (stack == null)
+    {
       stack = new Stack();
       threadLocalContextStack.set(stack);
     }
     return stack;
   }
-  public static void pushCurrentContext(ExecutionContext executionContext) {
+
+  public static void pushCurrentContext(ExecutionContext executionContext)
+  {
     getContextStack().push(executionContext);
   }
-  public static void popCurrentContext(ExecutionContext executionContext) {
-    if (getContextStack().pop()!=executionContext) {
+
+  public static void popCurrentContext(ExecutionContext executionContext)
+  {
+    if (getContextStack().pop() != executionContext)
+    {
       throw new JbpmException("current execution context mismatch.  make sure that every pushed context gets popped");
     }
   }
-  public static ExecutionContext currentExecutionContext() {
+
+  public static ExecutionContext currentExecutionContext()
+  {
     ExecutionContext executionContext = null;
     Stack stack = getContextStack();
-    if (! stack.isEmpty()) {
-      executionContext = (ExecutionContext) stack.peek();
+    if (!stack.isEmpty())
+    {
+      executionContext = (ExecutionContext)stack.peek();
     }
     return executionContext;
   }

Added: jbpm3/trunk/modules/core/src/main/java/org/jbpm/signal/EventService.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/signal/EventService.java	                        (rev 0)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/signal/EventService.java	2008-12-20 12:55:32 UTC (rev 3479)
@@ -0,0 +1,18 @@
+package org.jbpm.signal;
+
+import org.jbpm.graph.def.GraphElement;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.svc.Service;
+
+/**
+ * An extension to the jBPM event architecture 
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 20-Dec-2008
+ */
+public interface EventService extends Service
+{
+  static String SERVICE_NAME = "event";
+
+  void fireEvent(String eventType, GraphElement graphElement, ExecutionContext executionContext);
+}


Property changes on: jbpm3/trunk/modules/core/src/main/java/org/jbpm/signal/EventService.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/Service.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/Service.java	2008-12-20 12:06:16 UTC (rev 3478)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/Service.java	2008-12-20 12:55:32 UTC (rev 3479)
@@ -23,7 +23,7 @@
 
 import java.io.Serializable;
 
-public interface Service extends Serializable  {
-  
+public interface Service extends Serializable
+{
   void close();
 }

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/Services.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/Services.java	2008-12-20 12:06:16 UTC (rev 3478)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/svc/Services.java	2008-12-20 12:55:32 UTC (rev 3479)
@@ -50,233 +50,307 @@
 import org.jbpm.svc.save.SaveOperation;
 import org.jbpm.tx.TxService;
 
-public class Services implements Serializable {
-
+public class Services implements Serializable
+{
   private static final long serialVersionUID = 1L;
 
-  public static final String SERVICENAME_AUTHENTICATION  = "authentication";
-  public static final String SERVICENAME_AUTHORIZATION   = "authorization";
-  public static final String SERVICENAME_TX              = "tx";
-  public static final String SERVICENAME_LOGGING         = "logging";
-  public static final String SERVICENAME_MESSAGE         = "message";
-  public static final String SERVICENAME_PERSISTENCE     = "persistence";
-  public static final String SERVICENAME_SCHEDULER       = "scheduler";
-  public static final String SERVICENAME_JCR             = "jcr";
+  public static final String SERVICENAME_AUTHENTICATION = "authentication";
+  public static final String SERVICENAME_AUTHORIZATION = "authorization";
+  public static final String SERVICENAME_TX = "tx";
+  public static final String SERVICENAME_LOGGING = "logging";
+  public static final String SERVICENAME_MESSAGE = "message";
+  public static final String SERVICENAME_PERSISTENCE = "persistence";
+  public static final String SERVICENAME_SCHEDULER = "scheduler";
+  public static final String SERVICENAME_JCR = "jcr";
   public static final String SERVICENAME_ADDRESSRESOLVER = "addressresolver";
 
   static final List defaultSaveOperations = createDefaultSaveOperations();
 
-  private static List createDefaultSaveOperations() {
+  private static List createDefaultSaveOperations()
+  {
     SaveOperation[] operations = new SaveOperation[4];
     operations[0] = new CheckUnpersistableVariablesOperation();
     // first we save the runtime data (process instance)
     operations[1] = new HibernateSaveOperation();
-    // then we insert the logs cause the logs can have references 
+    // then we insert the logs cause the logs can have references
     // to the runtime data
     operations[2] = new SaveLogsOperation();
     operations[3] = new CascadeSaveOperation();
     return Arrays.asList(operations);
   }
 
-  Map serviceFactories = null;
-  Map services = null;
+  Map<String, ServiceFactory> serviceFactories;
+  Map<String, Service> services;
   List serviceNames = null;
   List saveOperations = null;
-  
-  public static Service getCurrentService(String name) {
-    return getCurrentService(name, true); 
+
+  public static Service getCurrentService(String name)
+  {
+    return getCurrentService(name, true);
   }
-  
-  public static Service getCurrentService(String name, boolean isRequired) {
+
+  public static Service getCurrentService(String name, boolean isRequired)
+  {
     Service service = null;
     JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
-    if (jbpmContext!=null) {
+    if (jbpmContext != null)
+    {
       service = jbpmContext.getServices().getService(name);
     }
-    if (isRequired && (service==null)) {
-      throw new JbpmServiceException("service '"+name+"' unavailable");
+    if (isRequired && (service == null))
+    {
+      throw new JbpmServiceException("service '" + name + "' unavailable");
     }
     return service;
   }
 
-  public Services(Map serviceFactories) {
+  public Services(Map serviceFactories)
+  {
     this(serviceFactories, new ArrayList(serviceFactories.keySet()), null);
   }
 
-  public Services(Map serviceFactories, List serviceNames, List saveOperations) {
+  public Services(Map serviceFactories, List serviceNames, List saveOperations)
+  {
     this.serviceFactories = serviceFactories;
     this.serviceNames = serviceNames;
     this.saveOperations = saveOperations != null ? saveOperations : defaultSaveOperations;
   }
 
-  public void setSaveOperations(List saveOperations) {
-    if (saveOperations == null) {
+  public void setSaveOperations(List saveOperations)
+  {
+    if (saveOperations == null)
+    {
       throw new IllegalArgumentException("saveOperations cannot be null");
     }
     this.saveOperations = saveOperations;
   }
 
-  public void addSaveOperation(SaveOperation saveOperation) {
-    if (saveOperation == null) {
+  public void addSaveOperation(SaveOperation saveOperation)
+  {
+    if (saveOperation == null)
+    {
       throw new IllegalArgumentException("saveOperation cannot be null");
     }
-    if (saveOperations == defaultSaveOperations) {
+    if (saveOperations == defaultSaveOperations)
+    {
       saveOperations = new ArrayList(defaultSaveOperations);
     }
     saveOperations.add(saveOperation);
   }
 
-  public Map getServiceFactories() {
-    if (serviceFactories==null) {
-      serviceFactories = new HashMap();
+  public Map<String, ServiceFactory> getServiceFactories()
+  {
+    if (serviceFactories == null)
+    {
+      serviceFactories = new HashMap<String, ServiceFactory>();
     }
     return serviceFactories;
   }
 
-  public ServiceFactory getServiceFactory(String name) {
-    return (ServiceFactory) getServiceFactories().get(name);
+  public ServiceFactory getServiceFactory(String name)
+  {
+    return getServiceFactories().get(name);
   }
-  
-  public boolean hasService(String name) {
+
+  public boolean hasService(String name)
+  {
     boolean hasService = false;
-    if (services!=null) {
+    if (services != null)
+    {
       hasService = services.containsKey(name);
     }
     return hasService;
   }
 
-  public Service getService(String name) {
-    if (services==null) {
-      services = new HashMap();
+  public Service getService(String name)
+  {
+    if (services == null)
+    {
+      services = new HashMap<String, Service>();
     }
-    Service service = (Service) services.get(name);
-    if (service==null) {
+    Service service = services.get(name);
+    if (service == null)
+    {
       ServiceFactory serviceFactory = getServiceFactory(name);
-      if (serviceFactory!=null) {
+      if (serviceFactory != null)
+      {
         service = serviceFactory.openService();
         services.put(name, service);
       }
     }
     return service;
   }
-  
-  public void save(ProcessInstance processInstance, JbpmContext jbpmContext) {
+
+  public void save(ProcessInstance processInstance, JbpmContext jbpmContext)
+  {
     Iterator iter = saveOperations.iterator();
-    
-    if (log.isDebugEnabled()) {
-      if (saveOperations==defaultSaveOperations) {
+
+    if (log.isDebugEnabled())
+    {
+      if (saveOperations == defaultSaveOperations)
+      {
         log.debug("executing default save operations");
-      } else {
+      }
+      else
+      {
         log.debug("executing custom save operations");
       }
     }
-    
-    while (iter.hasNext()) {
-      SaveOperation saveOperation = (SaveOperation) iter.next();
+
+    while (iter.hasNext())
+    {
+      SaveOperation saveOperation = (SaveOperation)iter.next();
       saveOperation.save(processInstance, jbpmContext);
     }
   }
 
   // services /////////////////////////////////////////////////////////////////
-  
-  public AuthenticationService getAuthenticationService() {
-    return (AuthenticationService) getService(SERVICENAME_AUTHENTICATION);
+
+  public AuthenticationService getAuthenticationService()
+  {
+    return (AuthenticationService)getService(SERVICENAME_AUTHENTICATION);
   }
-  public AuthorizationService getAuthorizationService() {
-    return (AuthorizationService) getService(SERVICENAME_AUTHORIZATION);
+
+  public AuthorizationService getAuthorizationService()
+  {
+    return (AuthorizationService)getService(SERVICENAME_AUTHORIZATION);
   }
-  public LoggingService getLoggingService() {
-    return (LoggingService) getService(SERVICENAME_LOGGING);
+
+  public LoggingService getLoggingService()
+  {
+    return (LoggingService)getService(SERVICENAME_LOGGING);
   }
-  public MessageService getMessageService() {
-    return (MessageService) getService(SERVICENAME_MESSAGE);
+
+  public MessageService getMessageService()
+  {
+    return (MessageService)getService(SERVICENAME_MESSAGE);
   }
-  public PersistenceService getPersistenceService() {
-    return (PersistenceService) getService(SERVICENAME_PERSISTENCE);
+
+  public PersistenceService getPersistenceService()
+  {
+    return (PersistenceService)getService(SERVICENAME_PERSISTENCE);
   }
-  public SchedulerService getSchedulerService() {
-    return (SchedulerService) getService(SERVICENAME_SCHEDULER);
+
+  public SchedulerService getSchedulerService()
+  {
+    return (SchedulerService)getService(SERVICENAME_SCHEDULER);
   }
-  public TxService getTxService() {
-    return (TxService) getService(SERVICENAME_TX);
+
+  public TxService getTxService()
+  {
+    return (TxService)getService(SERVICENAME_TX);
   }
 
-  public void setAuthenticationService(AuthenticationService authenticationService) {
+  public void setAuthenticationService(AuthenticationService authenticationService)
+  {
     services.put(SERVICENAME_AUTHENTICATION, authenticationService);
   }
-  public void setAuthorizationService(AuthorizationService authorizationService) {
+
+  public void setAuthorizationService(AuthorizationService authorizationService)
+  {
     services.put(SERVICENAME_AUTHORIZATION, authorizationService);
   }
-  public void setLoggingService(LoggingService loggingService) {
+
+  public void setLoggingService(LoggingService loggingService)
+  {
     services.put(SERVICENAME_LOGGING, loggingService);
   }
-  public void setMessageService(MessageService messageService) {
+
+  public void setMessageService(MessageService messageService)
+  {
     services.put(SERVICENAME_MESSAGE, messageService);
   }
-  public void setPersistenceService(PersistenceService persistenceService) {
+
+  public void setPersistenceService(PersistenceService persistenceService)
+  {
     services.put(SERVICENAME_PERSISTENCE, persistenceService);
   }
-  public void setSchedulerService(SchedulerService schedulerService) {
+
+  public void setSchedulerService(SchedulerService schedulerService)
+  {
     services.put(SERVICENAME_SCHEDULER, schedulerService);
   }
-  public void setTxService(TxService txService) {
+
+  public void setTxService(TxService txService)
+  {
     services.put(SERVICENAME_TX, txService);
   }
 
-  public void close() {
-    if (services!=null) {
+  public void close()
+  {
+    if (services != null)
+    {
       Exception firstException = null;
       Iterator iter = serviceNames.iterator();
-      while (iter.hasNext()) {
-        String serviceName = (String) iter.next();
-        Service service = (Service) services.get(serviceName);
-        if (service!=null) {
-          try {
-            log.debug("closing service '"+serviceName+"': "+service);
+      while (iter.hasNext())
+      {
+        String serviceName = (String)iter.next();
+        Service service = (Service)services.get(serviceName);
+        if (service != null)
+        {
+          try
+          {
+            log.debug("closing service '" + serviceName + "': " + service);
             service.close();
-          } catch (JbpmPersistenceException e) {
+          }
+          catch (JbpmPersistenceException e)
+          {
             // if this is a stale state exception, the jbpm configuration has control over the logging
-            if (isCausedByStaleState(e)) {
-              log.info("problem closing service '"+serviceName+"': optimistic locking failed");
-              StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("problem closing service '"+serviceName+"': optimistic locking failed", e);
-            } else {
-              log.error("problem closing service '"+serviceName+"'", e);
+            if (isCausedByStaleState(e))
+            {
+              log.info("problem closing service '" + serviceName + "': optimistic locking failed");
+              StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("problem closing service '" + serviceName + "': optimistic locking failed", e);
             }
-            if (firstException==null) {
+            else
+            {
+              log.error("problem closing service '" + serviceName + "'", e);
+            }
+            if (firstException == null)
+            {
               firstException = e;
             }
-          } catch (Exception e) {
+          }
+          catch (Exception e)
+          {
             // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
-            log.error("problem closing service '"+serviceName+"'", e);
-            if (firstException==null) {
+            log.error("problem closing service '" + serviceName + "'", e);
+            if (firstException == null)
+            {
               firstException = e;
             }
           }
         }
       }
-      if (firstException != null) {
-        if (firstException instanceof JbpmException) {
-          throw (JbpmException) firstException;
+      if (firstException != null)
+      {
+        if (firstException instanceof JbpmException)
+        {
+          throw (JbpmException)firstException;
         }
         throw new JbpmException("problem closing services", firstException);
       }
     }
   }
 
-  public static boolean isCausedByStaleState(JbpmPersistenceException persistenceException) {
-    for (Throwable cause = persistenceException.getCause(); cause != null; cause = cause.getCause()) {
+  public static boolean isCausedByStaleState(JbpmPersistenceException persistenceException)
+  {
+    for (Throwable cause = persistenceException.getCause(); cause != null; cause = cause.getCause())
+    {
       if (cause instanceof StaleStateException)
         return true;
     }
     return false;
   }
 
-  public static void assignId(Object object) {
+  public static void assignId(Object object)
+  {
     JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
-    if (jbpmContext!=null) {
+    if (jbpmContext != null)
+    {
       // give this process instance an id
       Services services = jbpmContext.getServices();
-      if (services.hasService(Services.SERVICENAME_PERSISTENCE)) {
+      if (services.hasService(Services.SERVICENAME_PERSISTENCE))
+      {
         PersistenceService persistenceService = services.getPersistenceService();
         persistenceService.assignId(object);
       }

Modified: jbpm3/trunk/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml	2008-12-20 12:06:16 UTC (rev 3478)
+++ jbpm3/trunk/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml	2008-12-20 12:55:32 UTC (rev 3479)
@@ -9,12 +9,12 @@
   -->
   
   <jbpm-context>
+    <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
+    <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
+    <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
     <service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" />
+    <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
     <service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
-    <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
-    <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
-    <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
-    <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
   </jbpm-context>
 
   <!-- configuration property used by persistence service impl org.jbpm.persistence.db.DbPersistenceServiceFactory -->

Modified: jbpm3/trunk/modules/integration/.classpath
===================================================================
--- jbpm3/trunk/modules/integration/.classpath	2008-12-20 12:06:16 UTC (rev 3478)
+++ jbpm3/trunk/modules/integration/.classpath	2008-12-20 12:55:32 UTC (rev 3479)
@@ -2,9 +2,6 @@
 <classpath>
 	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
 	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
-	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
-	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
-	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/cts/resources"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
 	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
 	<classpathentry kind="output" path="target/classes"/>

Modified: jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/model/ExclusiveGatewayImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/model/ExclusiveGatewayImpl.java	2008-12-20 12:06:16 UTC (rev 3478)
+++ jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/model/ExclusiveGatewayImpl.java	2008-12-20 12:55:32 UTC (rev 3479)
@@ -34,7 +34,6 @@
 import org.jbpm.graph.exe.ExecutionContext;
 import org.jbpm.graph.node.Decision;
 import org.jbpm.graph.node.DecisionHandler;
-import org.jbpm.instantiation.Delegation;
 import org.jbpm.integration.spec.runtime.ExpressionEvaluator;
 import org.jbpm.integration.spec.runtime.TokenImpl;
 
@@ -51,8 +50,8 @@
   public ExclusiveGatewayImpl(ProcessEngine engine, ProcessDefinition procDef, Node oldDecision)
   {
     super(engine, procDef, Decision.class, oldDecision);
-    ExclusiveGatewayDecisionHandler decisionHandler = new ExclusiveGatewayDecisionHandler();
-    getDelegate().setDecisionDelegation(new Delegation(decisionHandler));
+    //ExclusiveGatewayDecisionHandler decisionHandler = new ExclusiveGatewayDecisionHandler();
+    //getDelegate().setDecisionDelegation(new Delegation(decisionHandler));
   }
 
   // @Override

Modified: jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/model/ProcessInstanceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/model/ProcessInstanceImpl.java	2008-12-20 12:06:16 UTC (rev 3478)
+++ jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/model/ProcessInstanceImpl.java	2008-12-20 12:55:32 UTC (rev 3479)
@@ -21,7 +21,8 @@
  */
 package org.jbpm.integration.spec.model;
 
-// $Idimport java.util.Date;
+// $Id$
+
 import java.util.Date;
 import java.util.HashSet;
 import java.util.List;

Modified: jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/ContextServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/ContextServiceImpl.java	2008-12-20 12:06:16 UTC (rev 3478)
+++ jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/ContextServiceImpl.java	2008-12-20 12:55:32 UTC (rev 3479)
@@ -23,12 +23,17 @@
 
 // $Id$
 
+import java.util.Map;
+
 import org.jboss.bpm.api.runtime.BasicAttachments;
 import org.jboss.bpm.api.runtime.Context;
 import org.jboss.bpm.api.service.AbstractService;
 import org.jboss.bpm.api.service.ContextService;
 import org.jboss.bpm.api.service.ProcessEngine;
 import org.jbpm.JbpmContext;
+import org.jbpm.signal.EventService;
+import org.jbpm.svc.ServiceFactory;
+import org.jbpm.svc.Services;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -82,6 +87,15 @@
     {
       this.jbpmContext = jbpmContext;
       addAttachment(JbpmContext.class, jbpmContext);
+      
+      // Add the event service
+      Services services = jbpmContext.getServices();
+      ServiceFactory serviceFactory = services.getServiceFactory(EventService.SERVICE_NAME);
+      if (serviceFactory == null)
+      {
+        Map<String, ServiceFactory> factories = services.getServiceFactories();
+        factories.put(EventService.SERVICE_NAME, new EventServiceFactory(getProcessEngine()));
+      }
     }
 
     public void close()

Added: jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/EventServiceFactory.java
===================================================================
--- jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/EventServiceFactory.java	                        (rev 0)
+++ jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/EventServiceFactory.java	2008-12-20 12:55:32 UTC (rev 3479)
@@ -0,0 +1,147 @@
+package org.jbpm.integration.spec.service;
+
+import javax.management.ObjectName;
+
+import org.jboss.bpm.api.model.Node;
+import org.jboss.bpm.api.model.ProcessDefinition;
+import org.jboss.bpm.api.model.Signal;
+import org.jboss.bpm.api.model.Signal.SignalType;
+import org.jboss.bpm.api.model.builder.SignalBuilder;
+import org.jboss.bpm.api.service.ProcessDefinitionService;
+import org.jboss.bpm.api.service.ProcessEngine;
+import org.jboss.bpm.api.service.SignalBuilderService;
+import org.jboss.bpm.api.service.SignalService;
+import org.jbpm.graph.def.Event;
+import org.jbpm.graph.def.GraphElement;
+import org.jbpm.graph.def.Node.NodeType;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.integration.spec.model.ProcessDefinitionImpl;
+import org.jbpm.signal.EventService;
+import org.jbpm.svc.Service;
+import org.jbpm.svc.ServiceFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EventServiceFactory implements ServiceFactory
+{
+  // provide logging
+  final static Logger log = LoggerFactory.getLogger(EventServiceFactory.class);
+
+  private static final long serialVersionUID = 1L;
+
+  private ProcessEngine engine;
+
+  public EventServiceFactory(ProcessEngine engine)
+  {
+    this.engine = engine;
+  }
+
+  public Service openService()
+  {
+    return new EventServiceImpl();
+  }
+
+  public void close()
+  {
+  }
+
+  class EventServiceImpl implements EventService
+  {
+    private static final long serialVersionUID = 1L;
+
+    public void fireEvent(String eventType, GraphElement graphElement, ExecutionContext executionContext)
+    {
+      SignalBuilderService sigBuilderService = engine.getService(SignalBuilderService.class);
+      SignalService sigService = engine.getService(SignalService.class);
+
+      if (sigBuilderService != null && sigService != null)
+      {
+        SignalBuilder sigBuilder = sigBuilderService.getSignalBuilder();
+
+        SignalType sigType = getSignalType(eventType, graphElement);
+        ObjectName fromRef = getFromRef(graphElement);
+        if (sigType != null && fromRef != null)
+        {
+          Signal signal = sigBuilder.newSignal(sigType, fromRef, null);
+          sigService.throwSignal(signal);
+        }
+        else
+        {
+          log.debug("Cannot map to signal: [" + eventType + "," + graphElement + "]");
+        }
+      }
+    }
+
+    private ObjectName getFromRef(GraphElement graphElement)
+    {
+      ObjectName fromRef = null;
+      
+      ProcessDefinitionService pdService = engine.getService(ProcessDefinitionService.class);
+      org.jbpm.graph.def.ProcessDefinition oldProcDef = graphElement.getProcessDefinition();
+      ObjectName pdKey = ProcessDefinitionImpl.getKey(oldProcDef);
+      ProcessDefinition procDef = pdService.getProcessDefinition(pdKey);
+      
+      if (graphElement instanceof org.jbpm.graph.def.ProcessDefinition)
+      {
+        fromRef = pdKey;
+      }
+      else if (graphElement instanceof org.jbpm.graph.def.Node)
+      {
+        org.jbpm.graph.def.Node oldNode = (org.jbpm.graph.def.Node)graphElement;
+        Node node = procDef.getNode(oldNode.getNameExt());
+        fromRef = node.getKey();
+      }
+      
+      return fromRef;
+    }
+
+    private SignalType getSignalType(String eventType, GraphElement graphElement)
+    {
+      NodeType nodeType = null;
+      if (graphElement instanceof org.jbpm.graph.def.Node)
+      {
+        org.jbpm.graph.def.Node oldNode = (org.jbpm.graph.def.Node)graphElement;
+        nodeType = oldNode.getNodeType();
+      }
+
+      SignalType sigType = null;
+      if (Event.EVENTTYPE_PROCESS_START.equals(eventType))
+      {
+        sigType = SignalType.SYSTEM_PROCESS_ENTER;
+      }
+      else if (Event.EVENTTYPE_PROCESS_END.equals(eventType))
+      {
+        sigType = SignalType.SYSTEM_PROCESS_EXIT;
+      }
+      else if (Event.EVENTTYPE_BEFORE_SIGNAL.equals(eventType) && nodeType == NodeType.StartState)
+      {
+        sigType = SignalType.SYSTEM_START_EVENT_ENTER;
+      }
+      else if (Event.EVENTTYPE_NODE_LEAVE.equals(eventType) && nodeType == NodeType.StartState)
+      {
+        sigType = SignalType.SYSTEM_START_EVENT_EXIT;
+      }
+      else if (Event.EVENTTYPE_NODE_ENTER.equals(eventType) && nodeType == NodeType.EndState)
+      {
+        sigType = SignalType.SYSTEM_END_EVENT_ENTER;
+      }
+      else if (Event.EVENTTYPE_NODE_LEAVE.equals(eventType) && nodeType == NodeType.EndState)
+      {
+        sigType = SignalType.SYSTEM_END_EVENT_EXIT;
+      }
+      else if (Event.EVENTTYPE_NODE_ENTER.equals(eventType) && nodeType == NodeType.State)
+      {
+        sigType = SignalType.SYSTEM_TASK_ENTER;
+      }
+      else if (Event.EVENTTYPE_NODE_LEAVE.equals(eventType) && nodeType == NodeType.State)
+      {
+        sigType = SignalType.SYSTEM_TASK_EXIT;
+      }
+      return sigType;
+    }
+
+    public void close()
+    {
+    }
+  }
+}


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

Added: jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/SignalBuilderServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/SignalBuilderServiceImpl.java	                        (rev 0)
+++ jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/SignalBuilderServiceImpl.java	2008-12-20 12:55:32 UTC (rev 3479)
@@ -0,0 +1,95 @@
+/*
+ * 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.spec.service;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.jboss.bpm.api.model.Signal;
+import org.jboss.bpm.api.model.Signal.SignalType;
+import org.jboss.bpm.api.model.builder.SignalBuilder;
+import org.jboss.bpm.api.service.ProcessEngine;
+import org.jboss.bpm.api.service.SignalBuilderService;
+
+/**
+ * The SignalBuilder can be used to build a {@link Signal} dynamically.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public class SignalBuilderServiceImpl extends SignalBuilderService implements MutableService
+{
+  public void setProcessEngine(ProcessEngine engine)
+  {
+    super.setProcessEngine(engine);
+  }
+
+  @Override
+  public SignalBuilder getSignalBuilder()
+  {
+    SignalBuilder sigBuilder = new SignalBuilder()
+    {
+      public Signal newSignal(SignalType sigType, ObjectName fromRef, String message)
+      {
+        return new SignalImpl(sigType, fromRef, message);
+      }
+    };
+    return sigBuilder;
+  }
+  
+  class SignalImpl implements Signal
+  {
+    private static final long serialVersionUID = 1L;
+    
+    private ObjectName fromRef;
+    private SignalType sigType;
+    private String message;
+    
+    public SignalImpl(SignalType sigType, ObjectName fromRef, String message)
+    {
+      this.sigType = sigType;
+      this.fromRef = fromRef;
+      this.message = message;
+    }
+
+    public SignalType getSignalType()
+    {
+      return sigType;
+    }
+    
+    public ObjectName getFromRef()
+    {
+      return fromRef;
+    }
+
+    public String getMessage()
+    {
+      return message;
+    }
+
+    public String toString()
+    {
+      return "[" + sigType + ",from=" + fromRef + ",msg=" + message + "]";
+    }
+  }
+}
\ No newline at end of file


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

Added: jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/SignalServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/SignalServiceImpl.java	                        (rev 0)
+++ jbpm3/trunk/modules/integration/src/main/java/org/jbpm/integration/spec/service/SignalServiceImpl.java	2008-12-20 12:55:32 UTC (rev 3479)
@@ -0,0 +1,44 @@
+/*
+ * 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.spec.service;
+
+// $Id$
+
+import org.jboss.bpm.api.model.Signal;
+import org.jboss.bpm.api.model.SignalListener;
+import org.jboss.bpm.api.service.ProcessEngine;
+import org.jboss.bpm.api.service.SignalService;
+
+/**
+ * A {@link Signal} is like an undirected flare shot up
+ * into the air. A component can register a {@link SignalListener} with the SignalService.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public class SignalServiceImpl extends SignalService implements MutableService
+{
+  public void setProcessEngine(ProcessEngine engine)
+  {
+    super.setProcessEngine(engine);
+  }
+}
\ No newline at end of file


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

Modified: jbpm3/trunk/modules/integration/src/main/resources/bpm-spec-jbpm3-beans.xml
===================================================================
--- jbpm3/trunk/modules/integration/src/main/resources/bpm-spec-jbpm3-beans.xml	2008-12-20 12:06:16 UTC (rev 3478)
+++ jbpm3/trunk/modules/integration/src/main/resources/bpm-spec-jbpm3-beans.xml	2008-12-20 12:55:32 UTC (rev 3479)
@@ -19,6 +19,8 @@
     <inject bean="BPMIdentityService"/>
     <inject bean="BPMProcessDefinitionService"/>
     <inject bean="BPMProcessInstanceService"/>
+    <inject bean="BPMSignalBuilderService"/>
+    <inject bean="BPMSignalService"/>
     <inject bean="BPMTaskInstanceService"/>
     <inject bean="BPMTokenService"/>
    </set>
@@ -41,6 +43,8 @@
  <bean name="BPMIdentityService" class="org.jbpm.integration.spec.service.IdentityServiceImpl" />
  <bean name="BPMProcessDefinitionService" class="org.jbpm.integration.spec.service.ProcessDefinitionServiceImpl" />
  <bean name="BPMProcessInstanceService" class="org.jbpm.integration.spec.service.ProcessInstanceServiceImpl"/>
+ <bean name="BPMSignalBuilderService" class="org.jbpm.integration.spec.service.SignalBuilderServiceImpl" />
+ <bean name="BPMSignalService" class="org.jbpm.integration.spec.service.SignalServiceImpl" />
  <bean name="BPMTaskInstanceService" class="org.jbpm.integration.spec.service.TaskInstanceServiceImpl" />
  <bean name="BPMTokenService" class="org.jbpm.integration.spec.service.TokenServiceImpl" />
 




More information about the jbpm-commits mailing list