试图动态制作Quartz作业监听器

时间:2016-06-09 12:49:29

标签: java generics quartz-scheduler quartz-core

我已经看过几篇关于此的帖子,但是不能在Quartz中使用新的JobListener构建器方法。

我尝试使用存储侦听器类名称的字符串动态创建JobListener。但是,我收到以下编译器错误:

The method addJobListener(JobListener, Matcher<JobKey>) in the type ListenerManager is not applicable for the arguments (Class<capture#4-of ? extends JobListener>, KeyMatcher<JobKey>)

以下是代码段

public class SchedulerTriggerListener<T> {

    private T objReff = null;

    public SchedulerTriggerListener(T param){
        this.objReff = param;
    }

    public T getObjReff(){
        return this.objReff;
    }


    public void printData() throws SchedulerException{
        String s = "ClassName";
        Class<?> listenerClass = null;
        listenerClass = Class.forName (s);
        JobKey jobKey = new JobKey("dummyJobName", "group1");
        Scheduler scheduler = new StdSchedulerFactory().getScheduler();
        scheduler.getListenerManager().addJobListener(
                (Class<? extends JobListener>)listenerClass, KeyMatcher.keyEquals(jobKey)
        );
    }

有什么想法吗?

0 个答案:

没有答案