[JBoss jBPM] - cannot be cast to org.jbpm.graph.def.ActionHandler
by AJanz
i got a simple class implementing the actionhandler.
but when i try to execute it i got
WaitAndSignal cannot be cast to org.jbpm.graph.def.ActionHandler
code is
|
| import org.jbpm.graph.def.ActionHandler;
| import org.jbpm.graph.exe.ExecutionContext;
|
|
| public class WaitAndSignal implements ActionHandler{
|
| private final static long serialVersionUID=1l;
|
| public void execute(ExecutionContext executionContext) throws Exception {
| // TODO Auto-generated method stub
| try {
| System.out.println("Begin WaitAndSignal");
| long dauer = System.currentTimeMillis()% 100000;
| Thread.sleep(dauer);
| executionContext.getProcessInstance().signal();
| System.out.println("pid is = " +executionContext.getProcessInstance().getId() );
| }
| catch(Exception e ) {
| e.printStackTrace();
| }
| System.out.println("end WaitAndSignal");
|
| }
|
| int wait =100;
|
| public int getWait() {
| return wait;
| }
|
| public void setWait(int wait) {
| this.wait = wait;
| }
|
| }
|
the processdefinition is
| <?xml version="1.0" encoding="UTF-8"?>
|
| <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="autokette">
|
|
| <start-state name="start-state1">
| <transition to="node1"></transition>
| <event type="node-enter">
| <action name="weiter" class="mypackage.WaitAndSignal" ></action>
| </event>
| </start-state>
|
|
| <node name="node1">
| <transition to="node2"></transition>
| <event type="node-enter">
| <action name="weiter" class="mypackage.WaitAndSignal" ></action>
| </event>
|
| </node>
|
| <node name="node2">
| <transition to="node3"></transition>
| <event type="node-enter">
| <action name="weiter" class="mypackage.WaitAndSignal" ></action>
| </event>
|
| </node>
|
| <node name="node3">
| <transition to="end-state1">
| </transition>
| <event type="node-enter">
| <action name="weiter" class="mypackage.WaitAndSignal" ></action>
| </event>
|
| </node>
|
|
| <end-state name="end-state1"></end-state>
|
|
| </process-definition>
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4170796#4170796
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4170796
16 years, 3 months
[JBoss jBPM] - Re: Terminated or deleted process instance?
by lblaauw
Sure,
I dont claim this to be perfect but hey it works, so here is the code for the handler:
| public class VerwijderProcessInstanceHandler extends JbpmHandlerProxy{
| private static final long serialVersionUID = -6125309218094541298L;
| /** Logger available to subclasses */
| protected final Log logger = LogFactory.getLog(getClass());
|
| @SuppressWarnings("unchecked")
| @Override
| public void execute(ExecutionContext executionContext) throws Exception {
| try {
| logger.debug("executing VerwijderProcessInstanceHandler...");
| ProcessInstance pi = executionContext.getProcessInstance();
| logger.debug("ProcessInstance is null? " + (pi==null));
| List<Token> allTokens = pi.findAllTokens();
| logger.debug("allTokens of processInstance: " + allTokens.size());
|
| //clear taskinstances from comments
| Collection<TaskInstance> taskInstances = pi.getTaskMgmtInstance().getTaskInstances();
| for(TaskInstance ti : taskInstances){
| ti.getComments().clear();
| executionContext.getJbpmContext().save(ti);
| }
|
| //clear tokens from comments..
| if(allTokens.size() > 0){
| for(Token t : allTokens){
| //get all comments per token...
| if(!t.getComments().isEmpty()){
| logger.debug("cleared comments before deleting? " + t.getComments().isEmpty());
|
| for(Object o : t.getComments()){
| Comment c = (Comment)o;
| c.setTaskInstance(null);
| }
|
| //clearing comments on taskinsantce manually... pfff
| t.getComments().clear();
| }
|
| executionContext.getJbpmContext().save(t);
| logger.debug("t.getComments().size(): " + t.getComments().size());
| }
| }
|
| //saving without comments and taskinstances within comments...
| executionContext.getJbpmContext().save(pi);
|
| executionContext.getJbpmContext().getGraphSession().deleteProcessInstance(pi, true, true);
| } catch (Exception e){
| //Exception upon deleting processinstance..
| e.printStackTrace();
| logger.error(e.getMessage());
| }
| }
| }
|
Basically I have this handler configured in a Spring application context and then use the spring-jbpm integrationproxy. So I call this handler from within my jBPM process on the action like so:
| <end-state name="end-bevestigRelatieVerzoek">
| <event type="node-enter">
| <action name="verwijderProcessInstanceAction" class='org.springmodules.workflow.jbpm31.JbpmHandlerProxy' config-type="bean">
| <targetBean>VerwijderProcessInstanceHandler</targetBean>
| </action>
| </event>
| </end-state>
|
Allthough I strongly agree with you that I expect the jBPM (engine) to cleant up all process data after a processinstance finishes and I consider it to be a bug that it doesnt ! Coming from working for years with commercial workflow engine products the default behaviour I have allways encountered is to purge all data from the BPM database upon completion. This ensures a lean and mean processing database necesary for speedy processing with large numbers of processinstances or cases. If you then need historical data you as a developer store that in a seperate database....
But maybe some of the core jBPM folks in here could comment on this ?
Greetings and now off to my weekend,
Leo
"twiceknightly" wrote : "lblaauw" wrote : Hey,
| |
| | I just wrote a handler to get rid of all the process instance data including the cascades.
|
| Care to share what you did? I'm sure a fair few people would appreciate it. It seems an big ommission if the one "out of the box" doesn't clean up properly
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4170764#4170764
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4170764
16 years, 3 months