View Full Version : Spring jBPM - Task Assignment
msegvich
Sep 20th, 2005, 05:02 PM
Has anyone gotten task assignment to work with spring-jbpm? When I call my task assignment handler a record shows up in the database. However the only data it has is the id and name. There's nothing for actor id or create date. When I don't use spring jBPM these get populated with my same assignment handler. If anyone can point out what I'm doing wrong, I'd appreciate it.
Here's my handler:
public class TestTaskAssignmentHandler implements AssignmentHandler {
private static final long serialVersionUID = 1L;
public void assign(Assignable assignable, ExecutionContext executionContext)
{
assignable.setActorId("test");
}
}
And here's my process:
<?xml version="1.0" encoding="UTF-8"?>
<process-definition
xmlns="http://jbpm.org/3/jpdl"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jbpm.org/3/jpdl http://jbpm.org/xsd/jpdl-3.0.xsd"
name="test task">
<start-state name="start">
<transition name="begin" to="task"></transition>
</start-state>
<task-node name="task">
<task name="test">
<assignment
class="com.receller.bpm.TestTaskAssignmentHandler" />
</task>
<transition name="task" to="end"/>
</task-node>
<end-state name="end"></end-state>
</process-definition>
Costin Leau
Sep 21st, 2005, 06:38 AM
AFAIK, rob has done an update to jBPM to spring modules about 2 days ago. Have you got the latest version? maybe it will help you with this problem.
Costin Leau
Sep 21st, 2005, 06:40 AM
From: dev@springmodules.dev.java.net
The code for the JBPM integration is now in the main Spring CVS in
spring-projects/spring-jbpm. You should be able to configure the standard OSIV
filter in Spring and then use the supplier JBPM classes you have JBPM use the
Spring-supplied session.
Be aware that this code is uber-early access and is basically a dump of my
current prototype. I am on vacation next week for two weeks and full development
will start on this again when I return.
Rob
msegvich
Sep 21st, 2005, 02:17 PM
Thanks for letting me know about the new release. I'll take a look.
On a related note, I would like to access my Spring beans from within my jBPM AssignmentHandler and custom Actions. I'm trying to figure out how I can get a handle to Spring's ApplicationContext. My first guess is that I can somehow get this through jBPM's ExecutionContext, but I'm not sure how. Maybe the new release documents this too, but I thought I'd throw it out there in case someone else has figure this out.
Matt
msegvich
Sep 22nd, 2005, 11:22 AM
1. After getting the latest code from CVS, I still have the same problem as before with not all the data getting populated in the jbpm_taskinstance table when my AssignmentHandler is called through spring-jbpm.
2. Figured out how to pass around the spring ApplicationContext. It always helps to read the docs :D. For those that are interested, you just need to pass it into the ContextInstance setTransientVariable method. I created my own version of signal() that looks like this:
public void signal(long processId, ApplicationContext ctx)
{
JbpmSession jbpmSession = sessionFactory.openJbpmSession();
jbpmSession.beginTransaction();
ProcessInstance process = jbpmSession.getGraphSession()
.loadProcessInstance(processId);
ContextInstance context = process.getContextInstance();
context.setTransientVariable("springCtx", ctx);
jbpmSession.getGraphSession().saveProcessInstance( process);
process.signal();
jbpmSession.getGraphSession().saveProcessInstance( process);
jbpmSession.commitTransaction();
jbpmSession.close();
}
I can then retrieve this from the EnvironmentContext in any of my custom jbpm handlers or actions.
The signal method seemed to make the most sense, at least so far for me. I would think this would be a common situation for users of Spring and jBPM. Are there any plans to put something like this into spring-jbpm?
Costin Leau
Sep 22nd, 2005, 04:48 PM
AFAIK Rob who's the maintainer, is on vacation. However you are free to submit code to the project :) or at least raise an issue on jira to make sure this topic is not forgotten.
robododge
Oct 2nd, 2005, 11:43 PM
Costin,
I've been using spring-jbpm since Sep 15th and I haven't seen any new code checked in since then. I have a few suggestions for the current code. One suggestion is regarding access to the ApplicationContext inside of an AssignmentHandler or ActionHander. I would like to access my Spring beans from within my jBPM AssignmentHandler and custom Actions I came up with a proxy technique that gets you around this. And, yes I'd be glad to help with anything.
Costin Leau
Oct 3rd, 2005, 02:15 AM
Steve please create issues on SM JIRA and if possible attach your code as patches as well.
robododge
Oct 3rd, 2005, 09:50 AM
On the topic of ApplicationContext, Matt already created a feature request, it's just in the wrong place.
http://opensource2.atlassian.com/projects/spring/browse/SPR-1320
I posted a bug regarding jBPM DB Transaction Management.
http://opensource2.atlassian.com/projects/spring/browse/MOD-52
anagha
Oct 14th, 2005, 09:06 AM
Matt,
I would like to know more about "signal" method implementation you suggested.
First, To call this "signal" method of bean "A" I need to invoke "getBean("A")" explicitly.
This call should be placed in the "Task Handler"? Or where?
Second, in the method itself you referred application context and process ID as arguments . What is this processId?
The name of the method has to be "signal"? Is it connected to ProcessInstance.signal()?
It would be helpful if you explained this with an example.
Thanks,
Anagha
Costin Leau
Jan 27th, 2006, 02:31 PM
Steve, see this thread (http://forum.springframework.org/showthread.php?t=21833) (in case you have missed my 'spam'). I've addressed both issues.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.