Пример #1
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 ...");
  }
Пример #2
0
  protected void setUp() 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);

    Properties dsProps = loadDataSourceProperties();
    String txType = dsProps.getProperty("txType", "RESOURCE_LOCAL");
    if ("RESOURCE_LOCAL".equals(txType)) {
      useJTA = false;
    } else if ("JTA".equals(txType)) {
      useJTA = true;
    }

    if (useJTA) {
      pds = new PoolingDataSource();
      pds.setUniqueName("jdbc/taskDS");
      pds.setClassName(dsProps.getProperty("className"));
      pds.setMaxPoolSize(Integer.parseInt(dsProps.getProperty("maxPoolSize")));
      pds.setAllowLocalTransactions(
          Boolean.parseBoolean(dsProps.getProperty("allowLocalTransactions")));
      for (String propertyName : new String[] {"user", "password"}) {
        pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
      }

      setDatabaseSpecificDataSourceProperties(pds, dsProps);

      pds.init();
    }

    // Use persistence.xml configuration
    emf = createEntityManagerFactory();

    taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
    MockUserInfo userInfo = new MockUserInfo();
    taskService.setUserinfo(userInfo);
    users = fillUsersOrGroups("LoadUsers.mvel");
    groups = fillUsersOrGroups("LoadGroups.mvel");
    taskService.addUsersAndGroups(users, groups);
    disableUserGroupCallback();

    logger = LoggerFactory.getLogger(getClass());

    taskSession = taskService.createSession();
  }
Пример #3
0
  protected void onSetUp() throws Exception {
    ServiceReference kbuilderRef =
        bundleContext.getServiceReference(KnowledgeBuilderFactoryService.class.getName());
    Thread.currentThread()
        .setContextClassLoader(bundleContext.getService(kbuilderRef).getClass().getClassLoader());

    // --
    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);

    if (useJTA) {
      ds = new PoolingDataSource();
      ds.setUniqueName("jdbc/taskDS");
      ds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
      ds.setMaxPoolSize(3);
      ds.setAllowLocalTransactions(true);
      ds.getDriverProperties().put("user", "sa");
      ds.getDriverProperties().put("password", "sasa");
      ds.getDriverProperties().put("url", "jdbc:h2:mem:taskDb");
      ds.getDriverProperties().put("driverClassName", "org.h2.Driver");
      ds.init();
    }

    // Use persistence.xml configuration
    emfTaskJPA = createEntityManagerFactory();

    taskService = new TaskService(emfTaskJPA, SystemEventListenerFactory.getSystemEventListener());
    MockUserInfo userInfo = new MockUserInfo();
    taskService.setUserinfo(userInfo);
    users = fillUsersOrGroups("LoadUsers.mvel");
    groups = fillUsersOrGroups("LoadGroups.mvel");
    taskService.addUsersAndGroups(users, groups);
    disableUserGroupCallback();

    logger = LoggerFactory.getLogger(getClass());

    taskSession = taskService.createSession();
  }