Search in sources :

Example 6 with MifosScheduler

use of org.mifos.framework.components.batchjobs.MifosScheduler in project head by mifos.

the class BatchjobsServiceFacadeWebTier method suspend.

@Override
public void suspend(ServletContext context, String doSuspend) throws SchedulerException {
    MifosScheduler mifosScheduler = (MifosScheduler) context.getAttribute(MifosScheduler.class.getName());
    Scheduler scheduler = mifosScheduler.getScheduler();
    if (doSuspend.equals(ApplicationContextProvider.getBean(MessageLookup.class).lookup("systemAdministration.batchjobs.suspend")) && !scheduler.isInStandbyMode()) {
        scheduler.standby();
    }
    if (doSuspend.equals(ApplicationContextProvider.getBean(MessageLookup.class).lookup("systemAdministration.batchjobs.activate")) && scheduler.isInStandbyMode()) {
        scheduler.start();
    }
}
Also used : Scheduler(org.quartz.Scheduler) MifosScheduler(org.mifos.framework.components.batchjobs.MifosScheduler) MessageLookup(org.mifos.application.master.MessageLookup) MifosScheduler(org.mifos.framework.components.batchjobs.MifosScheduler)

Example 7 with MifosScheduler

use of org.mifos.framework.components.batchjobs.MifosScheduler in project head by mifos.

the class ProductStatusHelperIntegrationTest method getMifosScheduler.

private MifosScheduler getMifosScheduler(String taskConfigurationPath) throws TaskSystemException, IOException, FileNotFoundException {
    ConfigurationLocator mockConfigurationLocator = createMock(ConfigurationLocator.class);
    expect(mockConfigurationLocator.getResource(SchedulerConstants.CONFIGURATION_FILE_NAME)).andReturn(MifosResourceUtil.getClassPathResourceAsResource(taskConfigurationPath));
    expectLastCall().times(2);
    replay(mockConfigurationLocator);
    MifosScheduler mifosScheduler = new MifosScheduler();
    mifosScheduler.setConfigurationLocator(mockConfigurationLocator);
    mifosScheduler.initialize();
    return mifosScheduler;
}
Also used : ConfigurationLocator(org.mifos.framework.util.ConfigurationLocator) MifosScheduler(org.mifos.framework.components.batchjobs.MifosScheduler)

Example 8 with MifosScheduler

use of org.mifos.framework.components.batchjobs.MifosScheduler in project head by mifos.

the class StandardTestingService method runIndividualBatchJob.

@Override
public void runIndividualBatchJob(final String requestedJob, final ServletContext ctx) throws MifosException {
    logger.info("running batch job with name: " + requestedJob);
    boolean jobFound = false;
    String jobToRun = null;
    final MifosScheduler mifosScheduler = (MifosScheduler) ctx.getAttribute(MifosScheduler.class.getName());
    try {
        for (String taskName : mifosScheduler.getTaskNames()) {
            if (taskName.equals(requestedJob)) {
                jobFound = true;
                jobToRun = taskName;
                break;
            }
        }
        if (!jobFound) {
            throw new IllegalArgumentException(requestedJob + " is unknown and will not be executed.");
        }
        mifosScheduler.runIndividualTask(jobToRun);
    } catch (TaskSystemException se) {
        throw new MifosException("Scheduler's inner exception while running individual batch job!", se);
    }
}
Also used : TaskSystemException(org.mifos.framework.components.batchjobs.exceptions.TaskSystemException) MifosException(org.mifos.core.MifosException) MifosScheduler(org.mifos.framework.components.batchjobs.MifosScheduler)

Example 9 with MifosScheduler

use of org.mifos.framework.components.batchjobs.MifosScheduler in project head by mifos.

the class ApplicationInitializer method setAttributesOnContext.

public void setAttributesOnContext(ServletContext servletContext) throws TaskSystemException {
    // FIXME: replace with Spring-managed beans
    final MifosScheduler mifosScheduler = new MifosScheduler();
    final ShutdownManager shutdownManager = new ShutdownManager();
    Configuration.getInstance();
    configureAuditLogValues(Localization.getInstance().getConfiguredLocale());
    LocaleSetting configLocale = new LocaleSetting();
    @SuppressWarnings("deprecation") final UserLocale userLocale = new UserLocale(ApplicationContextProvider.getBean(PersonnelServiceFacade.class));
    if (servletContext != null) {
        mifosScheduler.initialize();
        servletContext.setAttribute(MifosScheduler.class.getName(), mifosScheduler);
        servletContext.setAttribute(ShutdownManager.class.getName(), shutdownManager);
        servletContext.setAttribute(LocaleSetting.class.getSimpleName(), configLocale);
        servletContext.setAttribute(UserLocale.class.getSimpleName(), userLocale);
    }
}
Also used : LocaleSetting(org.mifos.config.LocaleSetting) ShutdownManager(org.mifos.application.admin.system.ShutdownManager) PersonnelServiceFacade(org.mifos.application.admin.servicefacade.PersonnelServiceFacade) MifosScheduler(org.mifos.framework.components.batchjobs.MifosScheduler) UserLocale(org.mifos.config.UserLocale)

Example 10 with MifosScheduler

use of org.mifos.framework.components.batchjobs.MifosScheduler in project head by mifos.

the class ApplicationInitializer method contextDestroyed.

@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
    ServletContext ctx = servletContextEvent.getServletContext();
    logger.info("shutting down scheduler");
    final MifosScheduler mifosScheduler = (MifosScheduler) ctx.getAttribute(MifosScheduler.class.getName());
    ctx.removeAttribute(MifosScheduler.class.getName());
    try {
        if (mifosScheduler != null) {
            mifosScheduler.shutdown();
        }
    } catch (Exception e) {
        logger.error("error while shutting down scheduler", e);
    }
    // WebApplicationContext applicationContext = null;
    //  if (ctx != null) {
    //     applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(ctx);
    // }
    StaticHibernateUtil.shutdown();
    unregisterMySQLDriver();
    cancelMySQLStatement();
    logger.info("destroyed context");
}
Also used : ServletContext(javax.servlet.ServletContext) MifosScheduler(org.mifos.framework.components.batchjobs.MifosScheduler) SystemException(org.mifos.framework.exceptions.SystemException) TaskSystemException(org.mifos.framework.components.batchjobs.exceptions.TaskSystemException) XMLReaderException(org.mifos.framework.exceptions.XMLReaderException) HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ConfigurationException(org.mifos.config.exceptions.ConfigurationException) AppNotConfiguredException(org.mifos.framework.exceptions.AppNotConfiguredException) AccountException(org.mifos.accounts.exceptions.AccountException) FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) IOException(java.io.IOException) HibernateStartUpException(org.mifos.framework.exceptions.HibernateStartUpException) ApplicationException(org.mifos.framework.exceptions.ApplicationException)

Aggregations

MifosScheduler (org.mifos.framework.components.batchjobs.MifosScheduler)10 TaskSystemException (org.mifos.framework.components.batchjobs.exceptions.TaskSystemException)3 ConfigurationLocator (org.mifos.framework.util.ConfigurationLocator)3 Scheduler (org.quartz.Scheduler)3 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)1 ServletContext (javax.servlet.ServletContext)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 FinancialException (org.mifos.accounts.financial.exceptions.FinancialException)1 BatchjobsDto (org.mifos.application.admin.servicefacade.BatchjobsDto)1 BatchjobsSchedulerDto (org.mifos.application.admin.servicefacade.BatchjobsSchedulerDto)1 PersonnelServiceFacade (org.mifos.application.admin.servicefacade.PersonnelServiceFacade)1 ShutdownManager (org.mifos.application.admin.system.ShutdownManager)1 MessageLookup (org.mifos.application.master.MessageLookup)1 LocaleSetting (org.mifos.config.LocaleSetting)1 UserLocale (org.mifos.config.UserLocale)1 ConfigurationException (org.mifos.config.exceptions.ConfigurationException)1 MifosException (org.mifos.core.MifosException)1