René Zoller [
https://community.jboss.org/people/rzoller] created the discussion
"Extending jbpm-human-task-war by custom EventListner but they don't get
fired"
To view the discussion, visit:
https://community.jboss.org/message/808596#808596
--------------------------------------------------------------
Hello all,
I'm trying to extend the jbpm-human-task-war by implementing an own
HumanTaskServiceServlet and a custom EventListner. My EventListner looks like this:
public class MyTaskEventListner implements TaskEventListener {
private static final Logger logger = LoggerFactory
.getLogger(SiebelTaskEventListner.class);
@Override
public void taskCreated(TaskUserEvent event) {
// TODO Call Siebel to add Task;
logger.info("Task created!");
}
@Override
public void taskClaimed(TaskUserEvent event) {
// Nothing to do here
}
@Override
public void taskStarted(TaskUserEvent event) {
// TODO Call Desktop Connector to open dialogue;
logger.info("Task Started!");
}
@Override
public void taskStopped(TaskUserEvent event) {
// TODO Call Siebel to make the activity editable;
logger.info("Task stoped!.");
}
@Override
public void taskReleased(TaskUserEvent event) {
// Nothing to do here
}
@Override
public void taskCompleted(TaskUserEvent event) {
// TODO Call Siebel to close activity and make it editable again;
logger.info("Task completed! I have to inform Siebel.");
}
@Override
public void taskFailed(TaskUserEvent event) {
logger.info("Task failed!");
}
@Override
public void taskSkipped(TaskUserEvent event) {
// Nothing to do here
}
@Override
public void taskForwarded(TaskUserEvent event) {
// Nothing to do here
}
}
I'm adding the EventListner with
public class HumanTaskServiceServlet extends HttpServlet {
private static final long serialVersionUID = 5L;
private TaskServer server = null;
private Thread thread = null;
public void init() throws ServletException {
EntityManagerFactory emf = Persistence
.createEntityManagerFactory(getConfigParameter(
"task.persistence.unit", "org.jbpm.task"));
String escalationHandlerClass = getConfigParameter(
"escalated.deadline.handler.class",
DefaultEscalatedDeadlineHandler.class.getName());
TaskService taskService = null;
try {
EscalatedDeadlineHandler handler = getInstance(escalationHandlerClass);
if (handler instanceof DefaultEscalatedDeadlineHandler) {
UserInfo userInfo = null;
try {
String userInfoClass = getConfigParameter(
"user.info.class", null);
userInfo = getInstance(userInfoClass);
} catch (IllegalArgumentException e) {
Properties registryProps = new Properties();
registryProps.load(this.getClass().getResourceAsStream(
"/userinfo.properties"));
// userInfo = new DefaultUserInfo(registryProps);
}
((DefaultEscalatedDeadlineHandler) handler)
.setUserInfo(userInfo);
}
taskService = new TaskService(emf,
SystemEventListenerFactory.getSystemEventListener(),
handler);
} catch (Exception e) {
taskService = new TaskService(emf,
SystemEventListenerFactory.getSystemEventListener());
}
String usersConfig = getConfigParameter("load.users", "");
String groupsConfig = getConfigParameter("load.groups", "");
Map<String, User> users = new HashMap<String, User>();
Map<String, Group> groups = new HashMap<String, Group>();
try {
if (usersConfig != null && usersConfig.length() > 0) {
if (usersConfig.endsWith(".mvel")) {
Map vars = new HashMap();
Reader reader = new InputStreamReader(
getConfigFileStream(usersConfig));
users = (Map<String, User>) TaskService.eval(reader, vars);
} else if (usersConfig.endsWith(".properties")) {
Properties props = new Properties();
props.load(getConfigFileStream(usersConfig));
Enumeration<?> ids = props.propertyNames();
while (ids.hasMoreElements()) {
Object idObject = ids.nextElement();
if (idObject instanceof String) {
String id = (String) idObject;
users.put(id, new User(id));
}
}
}
}
} catch (Exception e) {
System.err.println("Problem loading users from specified file: "
+ usersConfig + " error message: " + e);
}
try {
if (groupsConfig != null && groupsConfig.length() > 0) {
if (groupsConfig.endsWith(".mvel")) {
Map vars = new HashMap();
Reader reader = new InputStreamReader(
getConfigFileStream(groupsConfig));
groups = (Map<String, Group>) TaskService
.eval(reader, vars);
} else if (groupsConfig.endsWith(".properties")) {
Properties props = new Properties();
props.load(getConfigFileStream(groupsConfig));
Enumeration<?> ids = props.propertyNames();
while (ids.hasMoreElements()) {
Object idObject = ids.nextElement();
if (idObject instanceof String) {
String id = (String) idObject;
groups.put(id, new Group(id));
}
}
}
}
} catch (Exception e) {
System.err.println("Problem loading groups from specified file: "
+ groupsConfig + " error message: " + e);
}
taskService.addUsersAndGroups(users, groups);
// Add our own Siebel TaskListener
taskService.addEventListener(new SiebelTaskEventListner());
int port = Integer.parseInt(getConfigParameter("hornetq.port",
"5153"));
String host = getConfigParameter("hornetq.host",
"localhost");
server = new HornetQTaskServer(taskService, host, port);
thread = new Thread(server);
thread.start();
System.out.println("HornetQ Task service started correctly !");
System.out.println("HornetQ Task service running (host " + host
+ " port " + port + ") ...");
UserGroupCallbackManager manager = UserGroupCallbackManager
.getInstance();
if (!manager.existsCallback()) {
String callbackClass = getConfigParameter(
"user.group.callback.class", "");
UserGroupCallback userGroupCallback = getInstance(callbackClass);
manager.setCallback(userGroupCallback);
}
System.out.println("Task service startup completed successfully !");
}
...
}
But when I'm starting a Task in jbpm-console non of the methods is executed. How can I
assign/ how do I correctly implement a EventListner for User Tasks?
Thank you!
René
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/808596#808596]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]