Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- adding listeners improvements

  • Loading branch information...
commit 281ea433bb8022ef939b213a8e9c3d4f70202290 1 parent 6107afc
@Salaboy Salaboy authored
Showing with 254 additions and 68 deletions.
  1. +19 −3 jbpm-human-task/jbpm-human-task-core-cdi/pom.xml
  2. +3 −1 jbpm-human-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/TaskEvent.java
  3. +8 −9 jbpm-human-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/commands/AddTaskCommand.java
  4. +21 −0 jbpm-human-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/events/AfterTaskAddedEvent.java
  5. +21 −0 jbpm-human-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/events/BeforeTaskAddedEvent.java
  6. +8 −0 jbpm-human-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/impl/factories/TaskFactory.java
  7. +22 −0 ...n-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/lifecycle/listeners/DeadlinesEventListener.java
  8. +30 −10 ...-human-task-core-cdi/src/main/java/org/jbpm/task/lifecycle/listeners/DefaultTaskLifeCycleEventListener.java
  9. +56 −0 ...bpm-human-task-core-cdi/src/main/java/org/jbpm/task/lifecycle/listeners/InternalDeadlinesEventListener.java
  10. +29 −9 ...human-task-core-cdi/src/main/java/org/jbpm/task/lifecycle/listeners/InternalTaskLifeCycleEventListener.java
  11. +29 −6 ...jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/lifecycle/listeners/JPATaskLifeCycleEventListener.java
  12. +5 −0 ...sk/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/lifecycle/listeners/TaskLifeCycleEventListener.java
  13. +3 −30 jbpm-human-task/jbpm-human-task-core-cdi/src/test/filtered-resources/META-INF/persistence.xml
View
22 jbpm-human-task/jbpm-human-task-core-cdi/pom.xml
@@ -88,8 +88,8 @@
</dependency>
<dependency>
- <groupId>org.jboss.arquillian.junit</groupId>
- <artifactId>arquillian-junit-container</artifactId>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
@@ -123,8 +123,24 @@
<filtering>true</filtering>
</testResource>
</testResources>
-
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
<plugins>
+
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
View
4 jbpm-human-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/TaskEvent.java
@@ -17,7 +17,9 @@
@Entity
public class TaskEvent implements Serializable {
- public enum TaskEventType{STARTED, ACTIVATED, COMPLETED, CLAIMED, SKIPPED, SUSPENDED};
+ public enum TaskEventType{STARTED, ACTIVATED, COMPLETED,
+ STOPPED, EXITED, FAILED, ADDED,
+ CLAIMED, SKIPPED, SUSPENDED};
@Id
@GeneratedValue
private long id;
View
17 jbpm-human-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/commands/AddTaskCommand.java
@@ -15,20 +15,15 @@
*/
package org.jbpm.task.commands;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
+import javax.enterprise.util.AnnotationLiteral;
import org.drools.command.Context;
import org.jboss.seam.transaction.Transactional;
import org.jbpm.task.Content;
import org.jbpm.task.ContentData;
-import org.jbpm.task.Group;
-import org.jbpm.task.OrganizationalEntity;
-import org.jbpm.task.PeopleAssignments;
-import org.jbpm.task.Status;
import org.jbpm.task.Task;
-import org.jbpm.task.TaskData;
-import org.jbpm.task.User;
+import org.jbpm.task.events.AfterTaskAddedEvent;
+import org.jbpm.task.events.BeforeTaskAddedEvent;
import org.jbpm.task.utils.ContentMarshallerHelper;
/**
@@ -55,7 +50,10 @@ public AddTaskCommand(Task task, ContentData data) {
}
public Long execute(Context cntxt) {
+
TaskContext context = (TaskContext) cntxt;
+ context.getTaskEvents().select(new AnnotationLiteral<BeforeTaskAddedEvent>() {
+ }).fire(task);
if (params != null) {
ContentData contentData = ContentMarshallerHelper.marshal(params, null);
Content content = new Content(contentData.getContent());
@@ -69,7 +67,8 @@ public Long execute(Context cntxt) {
}
context.getEm().persist(task);
-
+ context.getTaskEvents().select(new AnnotationLiteral<AfterTaskAddedEvent>() {
+ }).fire(task);
return (Long) task.getId();
}
View
21 jbpm-human-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/events/AfterTaskAddedEvent.java
@@ -0,0 +1,21 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.jbpm.task.events;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+
+@Qualifier
+
+@Target({ElementType.FIELD, ElementType.PARAMETER})
+
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AfterTaskAddedEvent {}
+
View
21 jbpm-human-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/events/BeforeTaskAddedEvent.java
@@ -0,0 +1,21 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.jbpm.task.events;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+
+@Qualifier
+
+@Target({ElementType.FIELD, ElementType.PARAMETER})
+
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface BeforeTaskAddedEvent {}
+
View
8 jbpm-human-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/impl/factories/TaskFactory.java
@@ -132,6 +132,14 @@ public static Task evalTask(Reader reader, Map<String, Object> vars, boolean ini
return task;
}
+ public static Task evalTask(String taskString, Map<String, Object> vars, boolean initialize) {
+ Task task = (Task) MVELUtils.eval(taskString, vars);
+ if (initialize) {
+ initializeTask(task);
+ }
+ return task;
+ }
+
public static Task evalTask(Reader reader) {
return evalTask(reader, null);
}
View
22 ...ask/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/lifecycle/listeners/DeadlinesEventListener.java
@@ -0,0 +1,22 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.jbpm.task.lifecycle.listeners;
+
+import org.jbpm.task.Task;
+
+/**
+ *
+ */
+
+public interface DeadlinesEventListener {
+ public void afterTaskAddedEvent(Task ti);
+ public void afterTaskStartedEvent(Task ti);
+ public void afterTaskSkippedEvent(Task ti);
+ public void afterTaskStoppedEvent(Task ti);
+ public void afterTaskCompletedEvent(Task ti);
+ public void afterTaskFailedEvent(Task ti);
+ public void afterTaskExitedEvent(Task ti);
+
+}
View
40 ...man-task-core-cdi/src/main/java/org/jbpm/task/lifecycle/listeners/DefaultTaskLifeCycleEventListener.java
@@ -9,11 +9,15 @@
import javax.enterprise.inject.Alternative;
import javax.inject.Singleton;
import org.jbpm.task.Task;
-import org.jbpm.task.events.BeforeTaskActivatedEvent;
-import org.jbpm.task.events.BeforeTaskClaimedEvent;
-import org.jbpm.task.events.BeforeTaskSkippedEvent;
-import org.jbpm.task.events.BeforeTaskStartedEvent;
-import org.jbpm.task.events.BeforeTaskStoppedEvent;
+import org.jbpm.task.events.AfterTaskActivatedEvent;
+import org.jbpm.task.events.AfterTaskAddedEvent;
+import org.jbpm.task.events.AfterTaskClaimedEvent;
+import org.jbpm.task.events.AfterTaskCompletedEvent;
+import org.jbpm.task.events.AfterTaskExitedEvent;
+import org.jbpm.task.events.AfterTaskFailedEvent;
+import org.jbpm.task.events.AfterTaskSkippedEvent;
+import org.jbpm.task.events.AfterTaskStartedEvent;
+import org.jbpm.task.events.AfterTaskStoppedEvent;
/**
@@ -27,23 +31,39 @@ public DefaultTaskLifeCycleEventListener() {
}
- public void afterTaskStartedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @BeforeTaskStartedEvent Task ti) {
+ public void afterTaskStartedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskStartedEvent Task ti) {
}
- public void afterTaskActivatedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @BeforeTaskActivatedEvent Task ti) {
+ public void afterTaskActivatedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskActivatedEvent Task ti) {
}
- public void afterTaskClaimedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @BeforeTaskClaimedEvent Task ti) {
+ public void afterTaskClaimedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskClaimedEvent Task ti) {
}
- public void afterTaskSkippedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @BeforeTaskSkippedEvent Task ti) {
+ public void afterTaskSkippedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskSkippedEvent Task ti) {
}
- public void afterTaskStoppedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @BeforeTaskStoppedEvent Task ti) {
+ public void afterTaskStoppedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskStoppedEvent Task ti) {
+
+ }
+
+ public void afterTaskCompletedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskCompletedEvent Task ti) {
+
+ }
+
+ public void afterTaskFailedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskFailedEvent Task ti) {
+
+ }
+
+ public void afterTaskAddedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskAddedEvent Task ti) {
+
+ }
+
+ public void afterTaskExitedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskExitedEvent Task ti) {
}
View
56 ...-human-task-core-cdi/src/main/java/org/jbpm/task/lifecycle/listeners/InternalDeadlinesEventListener.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2012 JBoss by Red Hat.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jbpm.task.lifecycle.listeners;
+
+import org.jbpm.task.Task;
+import org.jbpm.task.annotations.Internal;
+
+/**
+ *
+
+ */
+@Internal
+public class InternalDeadlinesEventListener implements DeadlinesEventListener{
+
+ public void afterTaskAddedEvent(Task ti) {
+
+ }
+
+ public void afterTaskStartedEvent(Task ti) {
+
+ }
+
+ public void afterTaskSkippedEvent(Task ti) {
+
+ }
+
+ public void afterTaskStoppedEvent(Task ti) {
+
+ }
+
+ public void afterTaskCompletedEvent(Task ti) {
+
+ }
+
+ public void afterTaskFailedEvent(Task ti) {
+
+ }
+
+ public void afterTaskExitedEvent(Task ti) {
+
+ }
+
+}
View
38 ...an-task-core-cdi/src/main/java/org/jbpm/task/lifecycle/listeners/InternalTaskLifeCycleEventListener.java
@@ -8,10 +8,14 @@
import javax.enterprise.event.Reception;
import org.jbpm.task.Task;
import org.jbpm.task.annotations.Internal;
-import org.jbpm.task.events.BeforeTaskActivatedEvent;
-import org.jbpm.task.events.BeforeTaskClaimedEvent;
-import org.jbpm.task.events.BeforeTaskSkippedEvent;
-import org.jbpm.task.events.BeforeTaskStartedEvent;
+import org.jbpm.task.events.AfterTaskActivatedEvent;
+import org.jbpm.task.events.AfterTaskAddedEvent;
+import org.jbpm.task.events.AfterTaskClaimedEvent;
+import org.jbpm.task.events.AfterTaskCompletedEvent;
+import org.jbpm.task.events.AfterTaskFailedEvent;
+import org.jbpm.task.events.AfterTaskSkippedEvent;
+import org.jbpm.task.events.AfterTaskStartedEvent;
+import org.jbpm.task.events.AfterTaskStoppedEvent;
/**
@@ -23,22 +27,38 @@
public InternalTaskLifeCycleEventListener() {
}
- public void afterTaskStartedEvent(@Observes(notifyObserver= Reception.ALWAYS) @BeforeTaskStartedEvent Task ti) {
+ public void afterTaskStartedEvent(@Observes(notifyObserver= Reception.ALWAYS) @AfterTaskStartedEvent Task ti) {
}
- public void afterTaskActivatedEvent(@Observes(notifyObserver= Reception.ALWAYS) @BeforeTaskActivatedEvent Task ti) {
+ public void afterTaskActivatedEvent(@Observes(notifyObserver= Reception.ALWAYS) @AfterTaskActivatedEvent Task ti) {
}
- public void afterTaskClaimedEvent(@Observes(notifyObserver= Reception.ALWAYS) @BeforeTaskClaimedEvent Task ti) {
+ public void afterTaskClaimedEvent(@Observes(notifyObserver= Reception.ALWAYS) @AfterTaskClaimedEvent Task ti) {
}
- public void afterTaskSkippedEvent(@Observes(notifyObserver= Reception.ALWAYS) @BeforeTaskSkippedEvent Task ti) {
+ public void afterTaskSkippedEvent(@Observes(notifyObserver= Reception.ALWAYS) @AfterTaskSkippedEvent Task ti) {
}
- public void afterTaskStoppedEvent(Task ti) {
+ public void afterTaskStoppedEvent(@Observes(notifyObserver= Reception.ALWAYS) @AfterTaskStoppedEvent Task ti) {
+
+ }
+
+ public void afterTaskCompletedEvent(@Observes(notifyObserver= Reception.ALWAYS) @AfterTaskCompletedEvent Task ti) {
+
+ }
+
+ public void afterTaskFailedEvent(@Observes(notifyObserver= Reception.ALWAYS) @AfterTaskFailedEvent Task ti) {
+
+ }
+
+ public void afterTaskAddedEvent(@Observes(notifyObserver= Reception.ALWAYS) @AfterTaskAddedEvent Task ti) {
+
+ }
+
+ public void afterTaskExitedEvent(Task ti) {
}
View
35 ...m-human-task-core-cdi/src/main/java/org/jbpm/task/lifecycle/listeners/JPATaskLifeCycleEventListener.java
@@ -13,7 +13,14 @@
import org.jboss.seam.transaction.Transactional;
import org.jbpm.task.Task;
import org.jbpm.task.TaskEvent;
-import org.jbpm.task.events.BeforeTaskStartedEvent;
+import org.jbpm.task.events.AfterTaskActivatedEvent;
+import org.jbpm.task.events.AfterTaskAddedEvent;
+import org.jbpm.task.events.AfterTaskClaimedEvent;
+import org.jbpm.task.events.AfterTaskCompletedEvent;
+import org.jbpm.task.events.AfterTaskExitedEvent;
+import org.jbpm.task.events.AfterTaskFailedEvent;
+import org.jbpm.task.events.AfterTaskStartedEvent;
+import org.jbpm.task.events.AfterTaskStoppedEvent;
/**
*
@@ -29,15 +36,15 @@ public JPATaskLifeCycleEventListener() {
}
@Transactional
- public void afterTaskStartedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @BeforeTaskStartedEvent Task ti) {
+ public void afterTaskStartedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskStartedEvent Task ti) {
em.persist(new TaskEvent(ti.getId(), TaskEvent.TaskEventType.STARTED, ti.getTaskData().getActualOwner()));
}
- public void afterTaskActivatedEvent(Task ti) {
+ public void afterTaskActivatedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskActivatedEvent Task ti) {
em.persist(new TaskEvent(ti.getId(), TaskEvent.TaskEventType.ACTIVATED, ti.getTaskData().getActualOwner()));
}
- public void afterTaskClaimedEvent(Task ti) {
+ public void afterTaskClaimedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskClaimedEvent Task ti) {
em.persist(new TaskEvent(ti.getId(), TaskEvent.TaskEventType.CLAIMED, ti.getTaskData().getActualOwner()));
}
@@ -45,8 +52,24 @@ public void afterTaskSkippedEvent(Task ti) {
em.persist(new TaskEvent(ti.getId(), TaskEvent.TaskEventType.SKIPPED, ti.getTaskData().getActualOwner()));
}
- public void afterTaskStoppedEvent(Task ti) {
- throw new UnsupportedOperationException("Not supported yet.");
+ public void afterTaskStoppedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskStoppedEvent Task ti ) {
+ em.persist(new TaskEvent(ti.getId(), TaskEvent.TaskEventType.STOPPED, ti.getTaskData().getActualOwner()));
+ }
+
+ public void afterTaskCompletedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskCompletedEvent Task ti) {
+ em.persist(new TaskEvent(ti.getId(), TaskEvent.TaskEventType.COMPLETED, ti.getTaskData().getActualOwner()));
+ }
+
+ public void afterTaskFailedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskFailedEvent Task ti) {
+ em.persist(new TaskEvent(ti.getId(), TaskEvent.TaskEventType.FAILED, ti.getTaskData().getActualOwner()));
+ }
+
+ public void afterTaskAddedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskAddedEvent Task ti) {
+ em.persist(new TaskEvent(ti.getId(), TaskEvent.TaskEventType.ADDED, ti.getTaskData().getActualOwner()));
+ }
+
+ public void afterTaskExitedEvent(@Observes(notifyObserver= Reception.IF_EXISTS) @AfterTaskExitedEvent Task ti) {
+ em.persist(new TaskEvent(ti.getId(), TaskEvent.TaskEventType.EXITED, ti.getTaskData().getActualOwner()));
}
}
View
5 ...jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/lifecycle/listeners/TaskLifeCycleEventListener.java
@@ -18,4 +18,9 @@
public void afterTaskSkippedEvent(Task ti);
public void afterTaskStartedEvent(Task ti);
public void afterTaskStoppedEvent(Task ti);
+ public void afterTaskCompletedEvent(Task ti);
+ public void afterTaskFailedEvent(Task ti);
+ public void afterTaskAddedEvent(Task ti);
+ public void afterTaskExitedEvent(Task ti);
+
}
View
33 jbpm-human-task/jbpm-human-task-core-cdi/src/test/filtered-resources/META-INF/persistence.xml
@@ -37,18 +37,9 @@
<!-- Event Classes -->
<class>org.jbpm.task.TaskEvent</class>
- <!--class>org.jbpm.task.event.entity.TaskUserEvent</class-->
- <!-- Specific Event Classes -->
- <!--class>org.jbpm.task.event.entity.TaskClaimedEvent</class>
- <class>org.jbpm.task.event.entity.TaskCompletedEvent</class>
- <class>org.jbpm.task.event.entity.TaskCreatedEvent</class>
- <class>org.jbpm.task.event.entity.TaskFailedEvent</class>
- <class>org.jbpm.task.event.entity.TaskForwardedEvent</class>
- <class>org.jbpm.task.event.entity.TaskReleasedEvent</class>
- <class>org.jbpm.task.event.entity.TaskSkippedEvent</class>
- <class>org.jbpm.task.event.entity.TaskStartedEvent</class>
- <class>org.jbpm.task.event.entity.TaskStoppedEvent</class-->
+
+
<properties>
<property name="hibernate.dialect" value="${maven.hibernate.dialect}" />
@@ -69,24 +60,6 @@
</properties>
</persistence-unit>
- <persistence-unit name="org.jbpm.persistence.example">
- <provider>org.hibernate.ejb.HibernatePersistence</provider>
- <class>org.jbpm.task.service.persistence.variable.MyEntity</class>
- <properties>
- <property name="hibernate.dialect" value="${maven.hibernate.dialect}" />
- <property name="hibernate.connection.driver_class" value="${maven.jdbc.driver.class}" />
- <property name="hibernate.connection.url" value="${maven.jdbc.url}" />
- <property name="hibernate.connection.username" value="${maven.jdbc.username}" />
- <property name="hibernate.connection.password" value="${maven.jdbc.password}" />
-
- <property name="hibernate.max_fetch_depth" value="3" />
- <property name="hibernate.hbm2ddl.auto" value="create-drop" />
- <property name="hibernate.show_sql" value="false" />
-
- <!-- needed for JTA testing
- <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />
- -->
- </properties>
- </persistence-unit>
+
</persistence>
Please sign in to comment.
Something went wrong with that request. Please try again.