-
1. Re: Create Custom Implementation for Human Task WorkItemHandler, Which class I should extend?
tcharman Dec 3, 2012 5:08 AM (in response to thomas.setiabudi)Human tasks are added through the default.session.template property file that is baked into console server. You can override this using your own session.template file, which you need to put in an appropriate location (JBoss conf directory I think?).
Human tasks need the knowledge session injected, so they added this functionality. You can add your own human task implementations this way too.
The latest implementation to look at is
AsyncHornetQHTWorkItemHandler or AsyncMinaHTWorkItemHandler. They keep deprecating classes so it is hard to keep up. These use the AsyncGenericHTWorkItemHandler and AbstractHTWorkItemHandler in its type hierarchy. Once you get what they are doing, you can write a similar one that suits your needs.
-
2. Re: Create Custom Implementation for Human Task WorkItemHandler, Which class I should extend?
thomas.setiabudi Dec 3, 2012 5:19 AM (in response to tcharman)Hi Timothy Charman,
Thank you for your response, I still cannot find the session.template file, where it should be?
Regards,
Thomas Setiabudi
-
3. Re: Create Custom Implementation for Human Task WorkItemHandler, Which class I should extend?
tcharman Dec 3, 2012 5:24 AM (in response to thomas.setiabudi)1 of 1 people found this helpfuldefault.session.template is in console-server code in src/main/resources. It looks like this:
new SessionTemplate().{
businessKey = "jbpm/consolesession",
imported = false,
persistenceUnit = "org.jbpm.persistence.jpa",
properties = ["drools.processInstanceManagerFactory":"org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory",
"drools.processSignalManagerFactory" : "org.jbpm.persistence.processinstance.JPASignalManagerFactory"
],
workItemHandlers = ["Human Task" : "new org.jbpm.process.workitem.wsht.AsyncHornetQHTWorkItemHandler(\"jbpmConsoleHTHandler\", taskClient, ksession, org.jbpm.task.utils.OnErrorAction.LOG)",
"Service Task" : "new org.jbpm.process.workitem.bpmn2.ServiceTaskHandler(ksession)"],
eventListeners = ["new org.jbpm.process.audit.JPAWorkingMemoryDbLogger(ksession)",
"new org.jbpm.integration.console.listeners.TriggerRulesEventListener(ksession)" ]
};
You won't find a session.template unless you create one to override this.
The session template is loaded by the MVELSingleSessionManager. The code is like this:
InputStream templateFile = PropertyLoader.getStreamForConfigFile("/session.template", defaultSessionTemplate);
So it loads the property from the classpath - you just have to pick a place on the classpath .
We gave up with this approach as we have dozens of human type tasks and didn't want to configure them all here, and we wrote our own SessionManager, but it is up to you.
-
4. Re: Create Custom Implementation for Human Task WorkItemHandler, Which class I should extend?
thomas.setiabudi Dec 3, 2012 5:25 AM (in response to tcharman)Hi Timothy Charman,
I got the file
jbpm-installer\jboss-as-7.1.1.Final\standalone\deployments\jbpm-gwt-console-server.war\WEB-INF\classes\default.session.template
Going to try doing my custom implementation now.
Thank you very much
Regards,
Thomas Setiabudi
-
5. Re: Create Custom Implementation for Human Task WorkItemHandler, Which class I should extend?
thomas.setiabudi Dec 3, 2012 5:30 AM (in response to tcharman)By writing your own session manager it means you are creating a custom implementation of jbpm-console?
Regards,
Thomas Setiabudi
-
6. Re: Create Custom Implementation for Human Task WorkItemHandler, Which class I should extend?
tcharman Dec 3, 2012 5:33 AM (in response to thomas.setiabudi)1 of 1 people found this helpfulNo, just the session manager. There's a hook for contributing your own, see how the session manager instantiates a MVELSingleSessionManager if you don't give it one below.
We give it our own so we can add them programmatically rather than using the config file. Our session manager does what the MVEL one does but doesn't use a template, it adds the task handlers in code.
@SuppressWarnings("unchecked")
public static SessionManager newSessionManager(KnowledgeBase kbase) {
String sessionManager = System.getProperty("jbpm.session.manager");
if (sessionManager == null) {
return new MVELSingleSessionManager(kbase);
}
SessionManager sessionManagerInstance = null;
try {
// build session manager based on given class
Class<SessionManager> sessionManagerClass = (Class<SessionManager>) Class.forName(sessionManager);
Constructor<SessionManager> c = sessionManagerClass.getConstructor(KnowledgeBase.class);
sessionManagerInstance = c.newInstance(kbase);
} catch (Exception e) {
throw new RuntimeException("Cannot create SessionManager from class " + sessionManager, e);
}
return sessionManagerInstance;
}
-
7. Re: Create Custom Implementation for Human Task WorkItemHandler, Which class I should extend?
thomas.setiabudi Dec 3, 2012 5:40 AM (in response to tcharman)Thank you for sharing about the Custom Session Manager
After you build your own SessionManager, how do you tell JBPM-console to use your custom session manager?
-
8. Re: Create Custom Implementation for Human Task WorkItemHandler, Which class I should extend?
tcharman Dec 3, 2012 5:42 AM (in response to thomas.setiabudi)I use the hook in the SessionManager (which is really a session manager factory of sorts) code:
String sessionManager = System.getProperty("jbpm.session.manager");
So in the java arguments I do:
-Djbpm.session.manager=com.me.mySessionManager
-
9. Re: Create Custom Implementation for Human Task WorkItemHandler, Which class I should extend?
thomas.setiabudi Dec 3, 2012 5:45 AM (in response to tcharman)Awesome,
Thanks again Timothy Charman. I guess I will need that as my requirements keep growing.
Regards,
Thomas Setiabudi