Package org.apache.synapse.task

Examples of org.apache.synapse.task.Task


        String jobClassName = (String) jdm.get(CLASSNAME);
        if (jobClassName == null) {
            handleException("No " + CLASSNAME + " in JobDetails");
        }

        Task task = null;
        try {
            task = (Task) getClass().getClassLoader().loadClass(jobClassName).newInstance();
        } catch (Exception e) {
            handleException("Cannot instantiate task : " + jobClassName, e);
        }

        Set properties = (Set) jdm.get(PROPERTIES);
        for (Object property : properties) {
            OMElement prop = (OMElement) property;
            log.debug("Found Property : " + prop.toString());
            PropertyHelper.setStaticProperty(prop, task);
        }

        // 1. Initialize
        SynapseEnvironment se = (SynapseEnvironment) jdm.get("SynapseEnvironment");
        if (task instanceof ManagedLifecycle && se != null) {
            ((ManagedLifecycle) task).init(se);
        }

        // 2. Execute
        if (se != null && task != null && se.isInitialized()) {
            task.execute();
        }

        // 3. Destroy
        if (task instanceof ManagedLifecycle && se != null) {
            ((ManagedLifecycle) task).destroy();
View Full Code Here


            handleException("No " + CLASSNAME + " in JobDetails");
        }

        boolean initRequired = false;

        Task task = (Task) jdm.get(TaskDescription.INSTANCE);
        if (task == null) {
            initRequired = true;
        }

        SynapseEnvironment se = (SynapseEnvironment) jdm.get("SynapseEnvironment");

        if (initRequired) {
            try {
                task = (Task) getClass().getClassLoader().loadClass(jobClassName).newInstance();
            } catch (Exception e) {
                handleException("Cannot instantiate task : " + jobClassName, e);
            }

            Set properties = (Set) jdm.get(PROPERTIES);
            for (Object property : properties) {
                OMElement prop = (OMElement) property;
                log.debug("Found Property : " + prop.toString());
                PropertyHelper.setStaticProperty(prop, task);
            }

            // 1. Initialize
            if (task instanceof ManagedLifecycle && se != null) {
                ((ManagedLifecycle) task).init(se);
            }
        }

        // 2. Execute
        if (se != null && task != null && se.isInitialized()) {
            task.execute();
        }

        if (initRequired) {
            // 3. Destroy
            if (task instanceof ManagedLifecycle && se != null) {
View Full Code Here

     * @param jobExecutionContext jobExecutionContext that contains the details required for the
     *                            job execution.
     * @throws JobExecutionException JobExecutionException
     */
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        Task task;

        JobDetail jobDetail = jobExecutionContext.getJobDetail();

        if (log.isDebugEnabled()) {
            log.debug("Executing scheduling task :" + jobDetail.getFullName());
        }

        JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap();
        String jobClassName = (String) jobDataMap.get(TaskSchedulerConstants.CLASS_NAME);

        try {
            task = (Task) getClass().getClassLoader().loadClass(jobClassName).newInstance();

            if (task instanceof TaskSchedulerLifeCycleCallback) {
                ((TaskSchedulerLifeCycleCallback) task).init(jobDetail.getJobDataMap());
            }

            task.execute();

            if (task instanceof TaskSchedulerLifeCycleCallback) {
                ((TaskSchedulerLifeCycleCallback) task).destroy();
            }

View Full Code Here

    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        try {

            Task task = null;

            JobDetail jobDetail = jobExecutionContext.getJobDetail();

            if (log.isDebugEnabled()) {
                log.debug("Executing Function scheduling task : " + jobDetail.getFullName());
            }

            Map mjdm = jobExecutionContext.getMergedJobDataMap();
            String jobClassName = (String) mjdm.get(CLASSNAME);
            if (jobClassName == null) {
                throw new CarbonException("No " + CLASSNAME + " in JobDetails");
            }

            try {
                task = (Task) getClass().getClassLoader().loadClass(jobClassName).newInstance();
            } catch (Exception e) {
                throw new CarbonException("Cannot instantiate Function scheduling task : " + jobClassName, e);
            }

            /*Set properties = (Set) mjdm.get(PROPERTIES);
            for (Object property : properties) {
                OMElement prop = (OMElement) property;
                log.debug("Found Property : " + prop.toString());
                PropertyHelper.setStaticProperty(prop, task);
            }*/

            // 1. Initialize
            if (task instanceof FunctionExecutionTaskLifeCycleCallBack) {
                // initialize FunctionExecutionTask with JobDataMap
                ((FunctionExecutionTask) task).init(
                        jobDetail.getJobDataMap());
            }

            // 2. Execute
            task.execute();

            // 3. Destroy
            if (task instanceof FunctionExecutionTaskLifeCycleCallBack) {
                ((FunctionExecutionTaskLifeCycleCallBack) task).destroy();
            }
View Full Code Here

    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        try {

            Task task = null;

            JobDetail jobDetail = jobExecutionContext.getJobDetail();

            if (log.isDebugEnabled()) {
                log.debug("Executing Autoscaler task : " + jobDetail.getKey().getName());
View Full Code Here

                    scheduler.init(null);
                }
            }
           
            String autoscalerClass = lbConfig.getLoadBalancerConfig().getAutoscalerTaskClass();
            Task task;
            if (autoscalerClass != null) {
                try {
                    task = (Task) Class.forName(autoscalerClass).newInstance();
                } catch (Exception e) {
                    String msg = "Cannot instantiate Autoscaling Task. Class: " + autoscalerClass
View Full Code Here

TOP

Related Classes of org.apache.synapse.task.Task

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.