public static void loadUsersAndGroups( TaskServiceSession taskSession, Map<String, User> users, Map<String, Group> groups) throws Exception { for (User user : users.values()) { taskSession.addUser(user); } for (Group group : groups.values()) { taskSession.addGroup(group); } }
protected void onTearDown() throws Exception { taskSession.dispose(); emfTaskJPA.close(); if (useJTA) { ds.close(); } }
public static void main(String[] args) { EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task"); TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener()); TaskServiceSession taskSession = taskService.createSession(); // Add users Map vars = new HashMap(); InputStream usersin = DemoTaskService.class.getResourceAsStream("LoadUsers.mvel"); if (usersin != null) { Reader reader = new InputStreamReader(usersin); @SuppressWarnings("unchecked") Map<String, User> users = (Map<String, User>) TaskService.eval(reader, vars); for (User user : users.values()) { taskSession.addUser(user); } } InputStream groupsin = DemoTaskService.class.getResourceAsStream("LoadGroups.mvel"); if (groupsin != null) { Reader reader = new InputStreamReader(groupsin); @SuppressWarnings("unchecked") Map<String, Group> groups = (Map<String, Group>) TaskService.eval(reader, vars); for (Group group : groups.values()) { taskSession.addGroup(group); } } // try to get the usergroup callback properties InputStream usergroupsin = DemoTaskService.class.getResourceAsStream("jbpm.usergroup.callback.properties"); if (usergroupsin != null) { Properties callbackproperties = new Properties(); try { // Properties.load(Reader) is a JDK 6 method callbackproperties.load(usergroupsin); UserGroupCallbackManager.getInstance().setCallbackFromProperties(callbackproperties); System.out.println("Task service registered usergroup callback ..."); } catch (Exception e) { System.out.println("Task service unable to register usergroup callback ..."); } } // start server MinaTaskServer server = new MinaTaskServer(taskService); Thread thread = new Thread(server); thread.start(); taskSession.dispose(); System.out.println("Task service started correctly!"); System.out.println("Task service running ..."); }
protected void tearDown() throws Exception { if (taskSession != null) { taskSession.dispose(); } emf.close(); if (useJTA) { pds.close(); } }
private static void setupTaskServer() throws InterruptedException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task"); EscalatedDeadlineHandler handler = buildDeadlineHnadler(); TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener(), handler); // start server TaskServer taskServer = new MinaTaskServer(taskService, 9123); Thread serverThread = new Thread(taskServer); serverThread.start(); Thread.sleep(1000); TaskServiceSession taskSession = taskService.createSession(); taskSession.addUser(new User("john")); taskSession.addUser(new User("mike")); taskSession.addUser(new User("Administrator")); taskSession.dispose(); }
/** Starts the server */ @Override protected void setUp() throws Exception { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); this.context = EasyMock.createMock(Context.class); EasyMock.expect(context.lookup("ConnectionFactory")).andReturn(factory).anyTimes(); EasyMock.replay(context); EntityManagerFactory localEntityManagerFactory = Persistence.createEntityManagerFactory("org.jbpm.task"); TaskService localTaskService = new TaskService( localEntityManagerFactory, SystemEventListenerFactory.getSystemEventListener()); TaskServiceSession localTaskServiceSession = localTaskService.createSession(); for (int i = 0; i < 10; i++) { User user = new User("usr" + i); localTaskServiceSession.addUser(user); } for (int j = 0; j < 3; j++) { localTaskServiceSession.addGroup(new Group("grp" + j)); } Properties serverProperties = new Properties(); serverProperties.setProperty("JMSTaskServer.connectionFactory", "ConnectionFactory"); serverProperties.setProperty("JMSTaskServer.transacted", "true"); serverProperties.setProperty("JMSTaskServer.acknowledgeMode", "AUTO_ACKNOWLEDGE"); serverProperties.setProperty("JMSTaskServer.queueName", "tasksQueue"); serverProperties.setProperty("JMSTaskServer.responseQueueName", "tasksResponseQueue"); this.server = new JMSTaskServer(localTaskService, serverProperties, context); Thread thread = new Thread(this.server); thread.start(); localTaskServiceSession.dispose(); }
protected void stop() throws Exception { server.stop(); taskSession.dispose(); emf.close(); }