Search in sources :

Example 1 with QuartzSheduler

use of org.exoplatform.services.scheduler.impl.QuartzSheduler in project kernel by exoplatform.

the class TestPersistedQuartzScheduler method setUp.

public void setUp() throws Exception {
    manager = PortalContainer.getInstance();
    manager.getComponentInstanceOfType(InitialContextInitializer.class);
    DataSource dataSource = (DataSource) new InitialContext().lookup("jdbcjcr");
    connection = dataSource.getConnection();
    connection.setAutoCommit(true);
    st = connection.createStatement();
    /**
     *init quartz tables**
     */
    String scripts = IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream("/quartz_hsqldb.sql"));
    for (String query : splitWithSQLDelimiter(scripts)) {
        st.executeUpdate(query);
    }
    /**
     *init QuartzSheduler Service**
     */
    InitParams initParams = new InitParams();
    ValueParam valueParam = new ValueParam();
    valueParam.setName("org.quartz.dataSource.quartzDS.jndiURL");
    valueParam.setValue("jdbcjcr");
    initParams.addParameter(valueParam);
    valueParam = new ValueParam();
    valueParam.setName("org.quartz.jobStore.driverDelegateClass");
    valueParam.setValue("org.quartz.impl.jdbcjobstore.StdJDBCDelegate");
    initParams.addParameter(valueParam);
    valueParam = new ValueParam();
    valueParam.setName("org.quartz.jobStore.class");
    valueParam.setValue("org.quartz.impl.jdbcjobstore.JobStoreTX");
    initParams.addParameter(valueParam);
    valueParam = new ValueParam();
    valueParam.setName("org.quartz.threadPool.threadCount");
    valueParam.setValue("5");
    initParams.addParameter(valueParam);
    valueParam = new ValueParam();
    valueParam.setName("org.quartz.jobStore.dataSource");
    valueParam.setValue("quartzDS");
    initParams.addParameter(valueParam);
    valueParam = new ValueParam();
    valueParam.setName("org.quartz.jobStore.tablePrefix");
    valueParam.setValue("QRTZ_");
    initParams.addParameter(valueParam);
    valueParam = new ValueParam();
    valueParam.setName("org.quartz.jobStore.useProperties");
    valueParam.setValue("true");
    initParams.addParameter(valueParam);
    QueueTasks queueTasks = new QueueTasks();
    QuartzSheduler quartzSheduler = new QuartzSheduler(PortalContainer.getInstance().getContext(), initParams);
    jobSchedulerService = new JobSchedulerServiceImpl(quartzSheduler, queueTasks);
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) QuartzSheduler(org.exoplatform.services.scheduler.impl.QuartzSheduler) ValueParam(org.exoplatform.container.xml.ValueParam) InitialContext(javax.naming.InitialContext) JobSchedulerServiceImpl(org.exoplatform.services.scheduler.impl.JobSchedulerServiceImpl) DataSource(javax.sql.DataSource)

Aggregations

InitialContext (javax.naming.InitialContext)1 DataSource (javax.sql.DataSource)1 InitParams (org.exoplatform.container.xml.InitParams)1 ValueParam (org.exoplatform.container.xml.ValueParam)1 JobSchedulerServiceImpl (org.exoplatform.services.scheduler.impl.JobSchedulerServiceImpl)1 QuartzSheduler (org.exoplatform.services.scheduler.impl.QuartzSheduler)1