|
|
|
|
@ -2,11 +2,10 @@ package com.xxl.job.executor.sample.frameless.config;
|
|
|
|
|
|
|
|
|
|
import com.xxl.job.executor.sample.frameless.jobhandler.SampleXxlJob;
|
|
|
|
|
import com.xxl.job.core.executor.impl.XxlJobSimpleExecutor;
|
|
|
|
|
import com.xxl.tool.core.PropTool;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
|
|
@ -14,10 +13,10 @@ import java.util.Properties;
|
|
|
|
|
* @author xuxueli 2018-10-31 19:05:43
|
|
|
|
|
*/
|
|
|
|
|
public class FrameLessXxlJobConfig {
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(FrameLessXxlJobConfig.class);
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(FrameLessXxlJobConfig.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static FrameLessXxlJobConfig instance = new FrameLessXxlJobConfig();
|
|
|
|
|
private static final FrameLessXxlJobConfig instance = new FrameLessXxlJobConfig();
|
|
|
|
|
public static FrameLessXxlJobConfig getInstance() {
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
@ -31,7 +30,7 @@ public class FrameLessXxlJobConfig {
|
|
|
|
|
public void initXxlJobExecutor() {
|
|
|
|
|
|
|
|
|
|
// load executor prop
|
|
|
|
|
Properties xxlJobProp = loadProperties("xxl-job-executor.properties");
|
|
|
|
|
Properties xxlJobProp = PropTool.loadProp("xxl-job-executor.properties");
|
|
|
|
|
|
|
|
|
|
// init executor
|
|
|
|
|
xxlJobExecutor = new XxlJobSimpleExecutor();
|
|
|
|
|
@ -65,30 +64,4 @@ public class FrameLessXxlJobConfig {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Properties loadProperties(String propertyFileName) {
|
|
|
|
|
InputStreamReader in = null;
|
|
|
|
|
try {
|
|
|
|
|
ClassLoader loder = Thread.currentThread().getContextClassLoader();
|
|
|
|
|
|
|
|
|
|
in = new InputStreamReader(loder.getResourceAsStream(propertyFileName), "UTF-8");;
|
|
|
|
|
if (in != null) {
|
|
|
|
|
Properties prop = new Properties();
|
|
|
|
|
prop.load(in);
|
|
|
|
|
return prop;
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
logger.error("load {} error!", propertyFileName);
|
|
|
|
|
} finally {
|
|
|
|
|
if (in != null) {
|
|
|
|
|
try {
|
|
|
|
|
in.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
logger.error("close {} error!", propertyFileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|