Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jbpm.process.workitem.handler;
 
 import java.util.Map;
 
public class JavaHandlerWorkItemHandler implements WorkItemHandler {
		this. = ksession;
	}
	@SuppressWarnings("unchecked")
	public void executeWorkItem(WorkItem workItemWorkItemManager manager) {
		String className = (StringworkItem.getParameter("Class");
		try {
			Class<JavaHandlerc = (Class<JavaHandler>) Class.forName(className);
			JavaHandler handler = c.newInstance();
			kcontext.setProcessInstance(processInstance);
			WorkItemNodeInstance nodeInstance = findNodeInstance(workItem.getId(), processInstance);
			kcontext.setNodeInstance(nodeInstance);
			Map<StringObjectresults = handler.execute(kcontext);
            manager.completeWorkItem(workItem.getId(), results);
    		return;
        } catch (ClassNotFoundException e) {
            ..println(e);
        } catch (InstantiationException e) {
            ..println(e);
        } catch (IllegalAccessException e) {
            ..println(e);
        }
        manager.abortWorkItem(workItem.getId());
	}
	private WorkItemNodeInstance findNodeInstance(long workItemIdNodeInstanceContainer container) {
		for (NodeInstance nodeInstancecontainer.getNodeInstances()) {
			if (nodeInstance instanceof WorkItemNodeInstance) {
				WorkItemNodeInstance workItemNodeInstance = (WorkItemNodeInstancenodeInstance;
				if (workItemNodeInstance.getWorkItem().getId() == workItemId) {
					return workItemNodeInstance;
				}
			}
			if (nodeInstance instanceof NodeInstanceContainer) {
				WorkItemNodeInstance result = findNodeInstance(workItemId, ((NodeInstanceContainernodeInstance));
				if (result != null) {
					return result;
				}
			}
		}
		return null;
	}
	public void abortWorkItem(WorkItem arg0WorkItemManager arg1) {
		// Do nothing
	}
New to GrepCode? Check out our FAQ X