JobProcessorHolder.java
1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.yoho.quartz.job;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Author:yanzhang.fu
* Date:2017/12/14
* Description:
* Modified By:
**/
public class JobProcessorHolder {
private static final Logger logger = LoggerFactory.getLogger(JobProcessorHolder.class);
private static final Map<String,YhJob> holder = new ConcurrentHashMap<String,YhJob>();
public static void putPorcessor(YhJob jobProcessor){
holder.put(jobProcessor.getClass().getCanonicalName(),jobProcessor);
}
public static void putAllProcessor(Map<String, YhJob> processors){
for (YhJob processor : processors.values()){
putPorcessor(processor);
}
}
public static YhJob getProcessor(String clazzName){
return holder.get(clazzName);
}
public static void printHolder(){
for (Map.Entry<String, YhJob> entry : holder.entrySet()) {
logger.info("holder info: key:{}, value:{}", entry.getKey(), entry.getValue());
}
}
}