Search in sources :

Example 1 with SchedulerAdapter

use of nl.nn.adapterframework.scheduler.SchedulerAdapter in project iaf by ibissource.

the class SchedulerHandler method executeSub.

public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    // Extract attributes we will need
    initAction(request);
    String action = request.getParameter("action");
    if (null == action)
        action = mapping.getParameter();
    String jobName = request.getParameter("jobName");
    String groupName = request.getParameter("groupName");
    if (ibisManager == null) {
        error("Cannot find ibismanager", null);
        return null;
    }
    // TODO Dit moet natuurlijk netter...
    DefaultIbisManager manager = (DefaultIbisManager) ibisManager;
    SchedulerHelper sh = manager.getSchedulerHelper();
    SchedulerAdapter schedulerAdapter = new SchedulerAdapter();
    Scheduler scheduler;
    try {
        scheduler = sh.getScheduler();
    } catch (SchedulerException e) {
        error("Cannot find scheduler", e);
        return null;
    }
    try {
        String msg = null;
        if (action.equalsIgnoreCase("startScheduler")) {
            msg = "start scheduler:" + new Date() + HttpUtils.getCommandIssuedBy(request);
            log.info(msg);
            secLog.info(msg);
            scheduler.start();
        } else if (action.equalsIgnoreCase("pauseScheduler")) {
            msg = "pause scheduler:" + new Date() + HttpUtils.getCommandIssuedBy(request);
            log.info(msg);
            secLog.info(msg);
            scheduler.standby();
        } else if (action.equalsIgnoreCase("deleteJob")) {
            msg = "delete job jobName [" + jobName + "] groupName [" + groupName + "] " + HttpUtils.getCommandIssuedBy(request);
            log.info(msg);
            secLog.info(msg);
            scheduler.deleteJob(jobName, groupName);
        } else if (action.equalsIgnoreCase("triggerJob")) {
            msg = "trigger job jobName [" + jobName + "] groupName [" + groupName + "] " + HttpUtils.getCommandIssuedBy(request);
            log.info(msg);
            secLog.info(msg);
            scheduler.triggerJob(jobName, groupName);
        } else {
            log.error("no valid argument for SchedulerHandler:" + action);
        }
    } catch (Exception e) {
        error("", e);
    }
    // Report any errors
    if (!errors.isEmpty()) {
        saveErrors(request, errors);
    }
    // Remove the obsolete form bean
    if (mapping.getAttribute() != null) {
        if ("request".equals(mapping.getScope()))
            request.removeAttribute(mapping.getAttribute());
        else
            session.removeAttribute(mapping.getAttribute());
    }
    // Forward control to the specified success URI
    return (mapping.findForward("success"));
}
Also used : SchedulerHelper(nl.nn.adapterframework.scheduler.SchedulerHelper) SchedulerException(org.quartz.SchedulerException) SchedulerAdapter(nl.nn.adapterframework.scheduler.SchedulerAdapter) Scheduler(org.quartz.Scheduler) DefaultIbisManager(nl.nn.adapterframework.unmanaged.DefaultIbisManager) Date(java.util.Date) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) SchedulerException(org.quartz.SchedulerException)

Example 2 with SchedulerAdapter

use of nl.nn.adapterframework.scheduler.SchedulerAdapter in project iaf by ibissource.

the class ShowSchedulerStatus method executeSub.

public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    // Initialize action
    initAction(request);
    if (ibisManager == null)
        return (mapping.findForward("noIbisContext"));
    if (ibisManager == null) {
        error("Cannot find ibismanager", null);
        return null;
    }
    // TODO Dit moet natuurlijk netter...
    DefaultIbisManager manager = (DefaultIbisManager) ibisManager;
    SchedulerHelper sh = manager.getSchedulerHelper();
    SchedulerAdapter schedulerAdapter = new SchedulerAdapter();
    Scheduler scheduler;
    try {
        scheduler = sh.getScheduler();
    } catch (SchedulerException e) {
        error("Cannot find scheduler", e);
        return null;
    }
    SchedulerAdapter sa = new SchedulerAdapter();
    if (log.isDebugEnabled()) {
        log.debug("set metadata [" + sa.getSchedulerMetaDataToXml(scheduler).toXML() + "]");
        log.debug("set jobdata [" + sa.getJobGroupNamesWithJobsToXml(scheduler, ibisManager).toXML() + "]");
    }
    request.setAttribute("metadata", sa.getSchedulerMetaDataToXml(scheduler).toXML());
    request.setAttribute("jobdata", sa.getJobGroupNamesWithJobsToXml(scheduler, ibisManager).toXML());
    // Forward control to the specified success URI
    log.debug("forward to success");
    return (mapping.findForward("success"));
}
Also used : SchedulerHelper(nl.nn.adapterframework.scheduler.SchedulerHelper) SchedulerException(org.quartz.SchedulerException) SchedulerAdapter(nl.nn.adapterframework.scheduler.SchedulerAdapter) Scheduler(org.quartz.Scheduler) DefaultIbisManager(nl.nn.adapterframework.unmanaged.DefaultIbisManager)

Aggregations

SchedulerAdapter (nl.nn.adapterframework.scheduler.SchedulerAdapter)2 SchedulerHelper (nl.nn.adapterframework.scheduler.SchedulerHelper)2 DefaultIbisManager (nl.nn.adapterframework.unmanaged.DefaultIbisManager)2 Scheduler (org.quartz.Scheduler)2 SchedulerException (org.quartz.SchedulerException)2 IOException (java.io.IOException)1 Date (java.util.Date)1 ServletException (javax.servlet.ServletException)1