@Override
 public void connect() {
   try {
     final Field field = WSHumanTaskHandler.class.getDeclaredField("client");
     TaskClient client = (TaskClient) field.get(this);
     if (client == null) {
       client =
           new TaskClient(
               new JMSTaskClientConnector(
                   "org.jbpm.process.workitem.wsht.WSThroughJMSHumanTaskHandler",
                   new JMSTaskClientHandler(SystemEventListenerFactory.getSystemEventListener()),
                   WSHumanTaskJMSProperties.getInstance().getProperties(),
                   new InitialContext(WSHumanTaskJMSProperties.getInstance().getProperties())));
       field.set(this, client);
       boolean connected = client.connect();
       if (!connected) {
         throw new IllegalArgumentException("Could not connect to the task client");
       }
     }
     super.connect();
   } catch (NoSuchFieldException e) {
     throw new RuntimeException("Problem configuring the human task connector", e);
   } catch (IllegalAccessException e) {
     throw new RuntimeException("Problem accessing the human task connector", e);
   } catch (NamingException e) {
     throw new RuntimeException("Problem accesing the JNDI directory", e);
   }
 }
Example #2
0
  @SuppressWarnings("unchecked")
  private void start() throws Exception {
    Properties conf = new Properties();
    conf.setProperty("mail.smtp.host", "localhost");
    conf.setProperty("mail.smtp.port", "2345");
    conf.setProperty("from", "*****@*****.**");
    conf.setProperty("replyTo", "*****@*****.**");
    conf.setProperty("defaultLanguage", "en-UK");
    SendIcal.initInstance(conf);

    // Use persistence.xml configuration
    emf = Persistence.createEntityManagerFactory("org.drools.task");

    taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
    MockUserInfo userInfo = new MockUserInfo();
    taskService.setUserinfo(userInfo);
    Map<String, Object> vars = new HashMap();

    Reader reader =
        new InputStreamReader(RunTaskService.class.getResourceAsStream("LoadUsers.mvel"));
    Map<String, User> users = (Map<String, User>) eval(reader, vars);
    reader = new InputStreamReader(RunTaskService.class.getResourceAsStream("LoadGroups.mvel"));
    Map<String, Group> groups = (Map<String, Group>) eval(reader, vars);
    taskService.addUsersAndGroups(users, groups);

    server = new MinaTaskServer(taskService);
    Thread thread = new Thread(server);
    thread.start();
    Thread.sleep(500);
    System.out.println("Server started ...");
  }