All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.n3r.quartz.glass.util.Jobs Maven / Gradle / Ivy

There is a newer version: 0.0.9
Show newest version
package org.n3r.quartz.glass.util;

import org.n3r.quartz.glass.job.annotation.GlassJob;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.springframework.util.MethodInvoker;

import java.lang.reflect.Method;

public class Jobs {
    public static Class jobCass(JobDetail jobDetail) {
        JobDataMap jobDataMap = jobDetail.getJobDataMap();
        MethodInvoker methodInvoker = (MethodInvoker) jobDataMap.get(GlassConstants.METHOD_INVOKER);
        return methodInvoker == null ? jobDetail.getJobClass() : methodInvoker.getTargetClass();
    }

    public static GlassJob glassJob(JobDetail jobDetail) {
        JobDataMap jobDataMap = jobDetail.getJobDataMap();
        MethodInvoker methodInvoker = (MethodInvoker) jobDataMap.get(GlassConstants.METHOD_INVOKER);
        if (methodInvoker == null) return jobDetail.getJobClass().getAnnotation(GlassJob.class);

        Method targetMethod = methodInvoker.getPreparedMethod();

        return targetMethod.getDeclaringClass().getAnnotation(GlassJob.class);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy