[jboss-user] [JBoss jBPM] - Re: Communication between JBoss jBPM application and a web a

dleerob do-not-reply at jboss.com
Tue Oct 23 04:00:00 EDT 2007


All the code you require is in the jbpm-console web application source code. That's probably where most people will learn how to interact with the Jbpm lilbraries.

For example, here is a method in one of my action classes, which shows how I start a process in my own web application:



public ActionForward startProcess(ActionMapping mapping, ActionForm form,
  | 			HttpServletRequest request,
  | 			HttpServletResponse response)
  | 	throws Exception {
  | 		if (log.isDebugEnabled()) {
  | 			log.debug("Entering 'startProcess' method");
  | 		}
  | 		User currentUser = getUser(request);
  | 		String processDefinitionIdStr = request.getParameter("processDefinitionId");
  | 		long processDefinitionId = Long.parseLong(processDefinitionIdStr);
  | 		jbpmContext.setActorId(currentUser.getUsername());
  | 		GraphSession graphSession = jbpmContext.getGraphSession();
  | 		ProcessDefinition processDefinition = graphSession.getProcessDefinition(processDefinitionId);
  | 		ProcessInstance processInstance = processDefinition.createProcessInstance();
  | 		// Signal the root token based on the following criteria:
  | 		// 1. If there is no start task, and
  | 		// 2. If the root token is still at the start state, and
  | 		// 3. If the start state has a default leaving transition, then
  | 		// signal the token along the default transition.
  | 		TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance();
  | 		//set the current user as the initiator
  | 		processInstance.getContextInstance().setVariable("sys_initiator", currentUser.getUsername());
  | 		TaskInstance startTaskInstance = taskMgmtInstance.createStartTaskInstance();
  | 		if (startTaskInstance == null) {
  | 			// There is no start task
  | 			Node initialNode = processDefinition.getStartState();
  | 			Token rootToken = processInstance.getRootToken();
  | 			Node rootTokenNode = rootToken.getNode();
  | 			if (initialNode.getId() == rootTokenNode.getId()) {
  | 				// The root token is still at the start node
  | 				Transition defaultLeavingTransition = initialNode.getDefaultLeavingTransition();
  | 				if (defaultLeavingTransition != null) {
  | 					// There's a default transition
  | 					rootToken.signal(defaultLeavingTransition);
  | 					System.out.println("Signalled Root Token");
  | 				}
  | 			}
  | 		}
  | 		System.out.println("Started");
  | 		if (processInstance.hasEnded()) {
  | 			System.out.println("Finished");
  | 		}
  | 		// Nothing else saves the process, so we must
  | 		jbpmContext.save(processInstance);
  | 
  | 		return mapping.findForward("myTasks");
  | 	}

And guess what, if I remember correctly, that was taken almost exactly as it from the jbpm-console webapp source code. So take a look there if you need help.

Good luck!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4097720#4097720

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4097720



More information about the jboss-user mailing list