JBoss Community

Re: My jBPM5.2 doesn't work! Like this......

created by 渊 李 in jBPM - View the full discussion

servlet listener:

 




EntityManagerFactory emfTask = Persistence.createEntityManagerFactory("org.jbpm.task");



// (EntityManagerFactory) Constants.ctx



// .getBean("entityManagerFactory");



TaskService taskService = new TaskService(emfTask, SystemEventListenerFactory.getSystemEventListener());



/*



* Add the required users



*/



TaskServiceSession taskSession = taskService.createSession();



taskSession.addUser(new User("Administrator"));



taskSession.addGroup(new Group("Stuff"));



taskSession.addUser(new User("kvsi"));



taskSession.addGroup(new Group("Manager"));



taskSession.addUser(new User("john"));



taskSession.addUser(new User("krisv"));



/* Start Mina server for HT */



MinaTaskServer server = new MinaTaskServer(taskService);



Thread thread = new Thread(server);



thread.start();



System.out.println("Server started ...");

 

 

struts Action

 

  StatefulKnowledgeSession session = null;

                    try {

                              session = JbpmAPIUtil.createKnowledgeSession("bpmn/apply-leave.bpmn");

                              session.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());

                    } catch (Exception e) {

                              e.printStackTrace();

                    }

                    Map<String, Object> params = new HashMap<String, Object>();

                    params.put("manager", "john");

                    session.insert(params);

                    ProcessInstance instance = session.startProcess("bpmn.applyLeave",params);

                    System.out.println(" \n\n process start : " + instance);

 

the other action:

 

List<TaskSummary> tasks = JbpmAPIUtil.getTasksAssignedAsPotentialOwner("john");

                    System.out.println(" size of tasks " + tasks.size());

                    for (TaskSummary ts : tasks) {

                              System.out.println("\n\n  ts :  " + ts);

                    }

 

bpmn:

actorId : #{manager}

 

thanks very much!

Reply to this message by going to Community

Start a new discussion in jBPM at Community