Package org.apache.cocoon.components.cron

Examples of org.apache.cocoon.components.cron.JobScheduler


    /**
     * @see org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler#schedule(org.apache.lenya.cms.usecase.Usecase,
     *      java.util.Date)
     */
    public void schedule(Usecase usecase, Date date) {
        JobScheduler scheduler = null;
        try {
            scheduler = (JobScheduler) this.manager.lookup(JobScheduler.ROLE);

            Parameters parameters = new Parameters();
            String[] names = usecase.getParameterNames();
            for (int i = 0; i < names.length; i++) {
                Object value = usecase.getParameter(names[i]);
                if (value instanceof String) {
                    parameters.setParameter(names[i], (String) value);
                } else {
                    getLogger().warn(
                            "Parameter [" + names[i] + "] = [" + value + "] ("
                                    + value.getClass().getName()
                                    + ") ignored, only string values are supported.");
                }
            }

            Map objects = new HashMap();
            objects.put(UsecaseCronJob.USECASE_NAME, usecase.getName());
            objects.put(UsecaseCronJob.SOURCE_URL, usecase.getSourceURL());

            String userId = "";
            Request request = ContextHelper.getRequest(this.context);
            Session session = request.getSession(false);
            if (session != null) {
                Identity identity = (Identity) session.getAttribute(Identity.class.getName());
                if (identity != null) {
                    User user = identity.getUser();
                    if (user != null) {
                        userId = user.getId();
                        objects.put(UsecaseCronJob.USER_ID, userId);
                    }
                    Machine machine = identity.getMachine();
                    if (machine != null) {
                        objects.put(UsecaseCronJob.MACHINE_IP, machine.getIp());
                    }
                }
            }

            String role = CronJob.class.getName() + "/usecase";
            String name = getJobName(usecase, userId);
            scheduler.fireJobAt(date, name, role, parameters, objects);

        } catch (Exception e) {
            getLogger().error("Could not create job: ", e);
            throw new RuntimeException(e);
        } finally {
View Full Code Here


    /**
     * @see org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler#getJobs()
     */
    public JobSchedulerEntry[] getJobs() {
        JobScheduler scheduler = null;
        JobSchedulerEntry[] entries = null;
        try {
            scheduler = (JobScheduler) this.manager.lookup(JobScheduler.ROLE);

            String[] jobNames = scheduler.getJobNames();
            entries = new JobSchedulerEntry[jobNames.length];

            for (int i = 0; i < jobNames.length; i++) {
                JobSchedulerEntry entry = scheduler.getJobSchedulerEntry(jobNames[i]);
                entries[i] = entry;
            }

        } catch (Exception e) {
            getLogger().error("Could not obtain job list: ", e);
View Full Code Here

    /**
     * @see org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler#schedule(org.apache.lenya.cms.usecase.Usecase,
     *      java.util.Date)
     */
    public void schedule(Usecase usecase, Date date) {
        JobScheduler scheduler = null;
        try {
            scheduler = (JobScheduler) this.manager.lookup(JobScheduler.ROLE);

            Parameters parameters = new Parameters();
            String[] names = usecase.getParameterNames();
            for (int i = 0; i < names.length; i++) {
                Object value = usecase.getParameter(names[i]);
                if (value instanceof String) {
                    parameters.setParameter(names[i], (String) value);
                } else {
                    getLogger().warn(
                            "Parameter [" + names[i] + "] = [" + value + "] ("
                                    + value.getClass().getName()
                                    + ") ignored, only string values are supported.");
                }
            }

            Map objects = new HashMap();
            objects.put(UsecaseCronJob.USECASE_NAME, usecase.getName());
            objects.put(UsecaseCronJob.SOURCE_URL, usecase.getSourceURL());

            String userId = "";
            Request request = ContextHelper.getRequest(this.context);
            Session session = request.getSession(false);
            if (session != null) {
                Identity identity = (Identity) session.getAttribute(Identity.class.getName());
                if (identity != null) {
                    User user = identity.getUser();
                    if (user != null) {
                        userId = user.getId();
                        objects.put(UsecaseCronJob.USER_ID, userId);
                    }
                    Machine machine = identity.getMachine();
                    if (machine != null) {
                        objects.put(UsecaseCronJob.MACHINE_IP, machine.getIp());
                    }
                }
            }

            String role = CronJob.class.getName() + "/usecase";
            String name = getJobName(usecase, userId);
            scheduler.fireJobAt(date, name, role, parameters, objects);

        } catch (Exception e) {
            getLogger().error("Could not create job: ", e);
            throw new RuntimeException(e);
        } finally {
View Full Code Here

    /**
     * @see org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler#getJobs()
     */
    public JobSchedulerEntry[] getJobs() {
        JobScheduler scheduler = null;
        JobSchedulerEntry[] entries = null;
        try {
            scheduler = (JobScheduler) this.manager.lookup(JobScheduler.ROLE);

            String[] jobNames = scheduler.getJobNames();
            entries = new JobSchedulerEntry[jobNames.length];

            for (int i = 0; i < jobNames.length; i++) {
                JobSchedulerEntry entry = scheduler.getJobSchedulerEntry(jobNames[i]);
                entries[i] = entry;
            }

        } catch (Exception e) {
            getLogger().error("Could not obtain job list: ", e);
View Full Code Here

    /**
     * @see org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler#schedule(org.apache.lenya.cms.usecase.Usecase,
     *      java.util.Date)
     */
    public void schedule(Usecase usecase, Date date) {
        JobScheduler scheduler = null;
        try {
            scheduler = (JobScheduler) this.manager.lookup(JobScheduler.ROLE);

            Parameters parameters = new Parameters();
            String[] names = usecase.getParameterNames();
            for (int i = 0; i < names.length; i++) {
                Object value = usecase.getParameter(names[i]);
                if (value instanceof String) {
                    parameters.setParameter(names[i], (String) value);
                } else {
                    getLogger().warn(
                            "Parameter [" + names[i] + "] = [" + value + "] ("
                                    + value.getClass().getName()
                                    + ") ignored, only string values are supported.");
                }
            }

            Map objects = new HashMap();
            objects.put(UsecaseCronJob.USECASE_NAME, usecase.getName());
            objects.put(UsecaseCronJob.SOURCE_URL, usecase.getSourceURL());

            String userId = "";
            Request request = ContextHelper.getRequest(this.context);
            Session session = request.getSession(false);
            if (session != null) {
                Identity identity = (Identity) session.getAttribute(Identity.class.getName());
                if (identity != null) {
                    User user = identity.getUser();
                    if (user != null) {
                        userId = user.getId();
                        objects.put(UsecaseCronJob.USER_ID, userId);
                    }
                    Machine machine = identity.getMachine();
                    if (machine != null) {
                        objects.put(UsecaseCronJob.MACHINE_IP, machine.getIp());
                    }
                }
            }

            String role = CronJob.class.getName() + "/usecase";
            String name = getJobName();
            scheduler.fireJobAt(date, name, role, parameters, objects);

        } catch (Exception e) {
            getLogger().error("Could not create job: ", e);
            throw new RuntimeException(e);
        } finally {
View Full Code Here

    /**
     * @see org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler#getJobs()
     */
    public JobSchedulerEntry[] getJobs() {
        JobScheduler scheduler = null;
        JobSchedulerEntry[] entries = null;
        try {
            scheduler = (JobScheduler) this.manager.lookup(JobScheduler.ROLE);

            String[] jobNames = scheduler.getJobNames();
            entries = new JobSchedulerEntry[jobNames.length];

            for (int i = 0; i < jobNames.length; i++) {
                JobSchedulerEntry entry = scheduler.getJobSchedulerEntry(jobNames[i]);
                entries[i] = entry;
            }

        } catch (Exception e) {
            getLogger().error("Could not obtain job list: ", e);
View Full Code Here

    /**
     * @see org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler#schedule(org.apache.lenya.cms.usecase.Usecase,
     *      java.util.Date)
     */
    public void schedule(Usecase usecase, Date date) {
        JobScheduler scheduler = null;
        try {
            scheduler = (JobScheduler) this.manager.lookup(JobScheduler.ROLE);

            Parameters parameters = new Parameters();
            String[] names = usecase.getParameterNames();
            for (int i = 0; i < names.length; i++) {
                parameters.setParameter(names[i], usecase.getParameterAsString(names[i]));
            }

            Map objects = new HashMap();
            objects.put(UsecaseCronJob.USECASE_NAME, usecase.getName());
            objects.put(UsecaseCronJob.SOURCE_URL, usecase.getSourceURL());

            Request request = ContextHelper.getRequest(this.context);
            Session session = request.getSession(false);
            if (session != null) {
                Identity identity = (Identity) session.getAttribute(Identity.class.getName());
                if (identity != null) {
                    User user = identity.getUser();
                    if (user != null) {
                        objects.put(UsecaseCronJob.USER_ID, user.getId());
                    }
                    Machine machine = identity.getMachine();
                    if (machine != null) {
                        objects.put(UsecaseCronJob.MACHINE_IP, machine.getIp());
                    }
                }
            }

            String role = CronJob.class.getName() + "/usecase";
            scheduler.fireJobAt(date, "foo", role, parameters, objects);

        } catch (Exception e) {
            getLogger().error("Could not create job: ", e);
            throw new RuntimeException(e);
        } finally {
View Full Code Here

   
    /**
     * @see org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler#getJobs()
     */
    public JobSchedulerEntry[] getJobs() {
        JobScheduler scheduler = null;
        JobSchedulerEntry[] entries = null;
        try {
            scheduler = (JobScheduler) this.manager.lookup(JobScheduler.ROLE);
           
            String[] jobNames = scheduler.getJobNames();
            entries = new JobSchedulerEntry[jobNames.length];
           
            for (int i = 0; i < jobNames.length; i++) {
                JobSchedulerEntry entry = scheduler.getJobSchedulerEntry(jobNames[i]);
                entries[i] = entry;
            }

        } catch (Exception e) {
            getLogger().error("Could not obtain job list: ", e);
View Full Code Here

   
    void scheduleReconnectionJob(ConnectionConfiguration configuration) {
        if (getLogger().isInfoEnabled()) {
            getLogger().info("Scheduling JMS reconnection job for: " + configuration.getName());
        }
        JobScheduler scheduler = null;
        try {
            scheduler = (JobScheduler) m_serviceManager.lookup(JobScheduler.ROLE);
            Date executionTime = new Date(System.currentTimeMillis() + configuration.getAutoReconnectDelay());
            ReconnectionJob job = new ReconnectionJob(this, configuration);
            scheduler.fireJobAt(executionTime, "reconnect_" + configuration.getName(), job);
        }
        catch (ServiceException e) {
            if (getLogger().isWarnEnabled()) {
                getLogger().warn("Cannot obtain scheduler.",e);
            }
View Full Code Here

   
    void scheduleReconnectionJob(ConnectionConfiguration configuration) {
        if (getLogger().isInfoEnabled()) {
            getLogger().info("Scheduling JMS reconnection job for: " + configuration.getName());
        }
        JobScheduler scheduler = null;
        try {
            scheduler = (JobScheduler) m_serviceManager.lookup(JobScheduler.ROLE);
            Date executionTime = new Date(System.currentTimeMillis() + configuration.getAutoReconnectDelay());
            ReconnectionJob job = new ReconnectionJob(this, configuration);
            scheduler.fireJobAt(executionTime, "reconnect_" + configuration.getName(), job);
        }
        catch (ServiceException e) {
            if (getLogger().isWarnEnabled()) {
                getLogger().warn("Cannot obtain scheduler.",e);
            }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.components.cron.JobScheduler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.