Community

JBPM-2537

reply from Michael Wohlfart in jBPM Development - View the full discussion

Hi Guys,

 

I also stumbled across the jbpm.task.lifecycle.xml file and tried to find out what it was doing, this is what i managed to figure out so far:

The content of the file is read in org.jbpm.pvm.internal.task.LifeCycle.java, it is parsed and seems to implement a kind of min-process / state machine for the task status. You can call LifeCycle.fireLifeCycleEvent(String eventName, TaskImpl task)and it changes the state of the task according to the transitions defined in jbpm.task.lifecycle.xml.

 

protected static void fireLifeCycleEvent(String eventName, TaskImpl task) {

    // reading the state machine
    ExecutionImpl lifeCycleExecution = new ExecutionImpl();
    ProcessDefinitionImpl lifeCycleProcess = getLifeCycle(task);
    lifeCycleExecution.setProcessDefinition(lifeCycleProcess);

    // setting up the current state:
    String state = task.getState();
    Activity activity = lifeCycleProcess.getActivity(state);
    lifeCycleExecution.setActivity((ActivityImpl) activity);

    // performing a transition
    lifeCycleExecution.signal(eventName);

    // transfering the new state to the task
    task.setState(lifeCycleExecution.getActivity().getName());
}

 

I think this is great stuff, unfortunatly I couldn't find any place in the code where LifeCycle.fireLifeCycleEvent(String eventName,  TaskImpl task)is called, but to me it seems a nice idea to have the task status and transitions configurable in a single file like this.

Reply to this message by going to Community

Start a new discussion in jBPM Development at Community