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();
}
}
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;
}
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);
}
}
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);
}
}
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");
}
Aggregations