Clean Code
This commit is contained in:
parent
9e4f2c6b1e
commit
a5757be432
|
@ -88,11 +88,11 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
|
||||||
![输入图片说明](https://static.oschina.net/uploads/img/201703/07162326_L3VB.png "在这里输入图片标题")
|
![输入图片说明](https://static.oschina.net/uploads/img/201703/07162326_L3VB.png "在这里输入图片标题")
|
||||||
|
|
||||||
#### 1.5 环境
|
#### 1.5 环境
|
||||||
- Servlet/JSP Spec:3.0/2.2
|
- JDK:1.7+
|
||||||
- Jdk:1.7+
|
|
||||||
- Tomcat:7+
|
- Tomcat:7+
|
||||||
|
- Mysql:5.6+
|
||||||
|
- Servlet/JSP Spec:3.0/2.2
|
||||||
- Maven:3+
|
- Maven:3+
|
||||||
- Mysql:5.5+
|
|
||||||
|
|
||||||
|
|
||||||
## 二、快速入门
|
## 二、快速入门
|
||||||
|
@ -717,6 +717,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
|
||||||
- 3、执行器支持手动设置执行地址列表,提供开关切换使用注册地址还是手动设置的地址;
|
- 3、执行器支持手动设置执行地址列表,提供开关切换使用注册地址还是手动设置的地址;
|
||||||
- 4、执行器路由规则:第一个、循环、随机、顺序故障(默认)转移;
|
- 4、执行器路由规则:第一个、循环、随机、顺序故障(默认)转移;
|
||||||
- 5、CleanCode,清理无效的历史参数;
|
- 5、CleanCode,清理无效的历史参数;
|
||||||
|
- 6、规范系统配置数据,通过配置文件统一管理;
|
||||||
|
|
||||||
#### TODO LIST
|
#### TODO LIST
|
||||||
- 1、支持脚本JOB(源码或指定路径), 即shell/python/php等, 日志实时输出并支持在线监控;定制JobHandler实现;
|
- 1、支持脚本JOB(源码或指定路径), 即shell/python/php等, 日志实时输出并支持在线监控;定制JobHandler实现;
|
||||||
|
|
|
@ -45,8 +45,8 @@ public class IndexController {
|
||||||
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember){
|
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember){
|
||||||
if (!PermissionInterceptor.ifLogin(request)) {
|
if (!PermissionInterceptor.ifLogin(request)) {
|
||||||
if (StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(password)
|
if (StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(password)
|
||||||
&& PropertiesUtil.getString("login.username").equals(userName)
|
&& PropertiesUtil.getString("xxl.job.login.username").equals(userName)
|
||||||
&& PropertiesUtil.getString("login.password").equals(password)) {
|
&& PropertiesUtil.getString("xxl.job.login.password").equals(password)) {
|
||||||
boolean ifRem = false;
|
boolean ifRem = false;
|
||||||
if (StringUtils.isNotBlank(ifRemember) && "on".equals(ifRemember)) {
|
if (StringUtils.isNotBlank(ifRemember) && "on".equals(ifRemember)) {
|
||||||
ifRem = true;
|
ifRem = true;
|
||||||
|
|
|
@ -35,7 +35,7 @@ public final class XxlJobDynamicScheduler implements ApplicationContextAware, In
|
||||||
|
|
||||||
// Scheduler
|
// Scheduler
|
||||||
private static Scheduler scheduler;
|
private static Scheduler scheduler;
|
||||||
public static void setScheduler(Scheduler scheduler) {
|
public void setScheduler(Scheduler scheduler) {
|
||||||
XxlJobDynamicScheduler.scheduler = scheduler;
|
XxlJobDynamicScheduler.scheduler = scheduler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
package com.xxl.job.admin.core.util;
|
package com.xxl.job.admin.core.util;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
import javax.mail.internet.MimeMessage;
|
|
||||||
import javax.mail.internet.MimeUtility;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -15,6 +7,13 @@ import org.springframework.mail.javamail.JavaMailSender;
|
||||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
|
|
||||||
|
import javax.mail.internet.MimeMessage;
|
||||||
|
import javax.mail.internet.MimeUtility;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 邮件发送.Util
|
* 邮件发送.Util
|
||||||
* @author xuxueli 2016-3-12 15:06:20
|
* @author xuxueli 2016-3-12 15:06:20
|
||||||
|
@ -29,12 +28,12 @@ public class MailUtil {
|
||||||
private static String sendFrom;
|
private static String sendFrom;
|
||||||
private static String sendNick;
|
private static String sendNick;
|
||||||
static{
|
static{
|
||||||
host = PropertiesUtil.getString("mail.host");
|
host = PropertiesUtil.getString("xxl.job.mail.host");
|
||||||
port = PropertiesUtil.getString("mail.port");
|
port = PropertiesUtil.getString("xxl.job.mail.port");
|
||||||
username = PropertiesUtil.getString("mail.username");
|
username = PropertiesUtil.getString("xxl.job.mail.username");
|
||||||
password = PropertiesUtil.getString("mail.password");
|
password = PropertiesUtil.getString("xxl.job.mail.password");
|
||||||
sendFrom = PropertiesUtil.getString("mail.sendFrom");
|
sendFrom = PropertiesUtil.getString("xxl.job.mail.sendFrom");
|
||||||
sendNick = PropertiesUtil.getString("mail.sendNick");
|
sendNick = PropertiesUtil.getString("xxl.job.mail.sendNick");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,14 +55,14 @@ public class MailUtil {
|
||||||
/**
|
/**
|
||||||
* 发送邮件 (完整版)(结合Spring)
|
* 发送邮件 (完整版)(结合Spring)
|
||||||
*
|
*
|
||||||
* @param javaMailSender: 发送Bean
|
* //@param javaMailSender: 发送Bean
|
||||||
* @param sendFrom : 发送人邮箱
|
* //@param sendFrom : 发送人邮箱
|
||||||
* @param sendNick : 发送人昵称
|
* //@param sendNick : 发送人昵称
|
||||||
* @param toAddress : 收件人邮箱
|
* @param toAddress : 收件人邮箱
|
||||||
* @param mailSubject : 邮件主题
|
* @param mailSubject : 邮件主题
|
||||||
* @param mailBody : 邮件正文
|
* @param mailBody : 邮件正文
|
||||||
* @param mailBodyIsHtml: 邮件正文格式,true:HTML格式;false:文本格式
|
* @param mailBodyIsHtml: 邮件正文格式,true:HTML格式;false:文本格式
|
||||||
* @param files[] : 附件
|
* @param attachments : 附件
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("null")
|
@SuppressWarnings("null")
|
||||||
public static boolean sendMailSpring(String toAddress, String mailSubject, String mailBody, boolean mailBodyIsHtml,File[] attachments) {
|
public static boolean sendMailSpring(String toAddress, String mailSubject, String mailBody, boolean mailBodyIsHtml,File[] attachments) {
|
||||||
|
@ -106,8 +105,8 @@ public class MailUtil {
|
||||||
* @param mailSubject : 邮件主题
|
* @param mailSubject : 邮件主题
|
||||||
* @param mailBody : 邮件正文
|
* @param mailBody : 邮件正文
|
||||||
* @param mailBodyIsHtml: 邮件正文格式,true:HTML格式;false:文本格式
|
* @param mailBodyIsHtml: 邮件正文格式,true:HTML格式;false:文本格式
|
||||||
* @param inLineFile : 内嵌文件
|
* //@param inLineFile : 内嵌文件
|
||||||
* @param files[] : 附件
|
* @param attachments : 附件
|
||||||
*/
|
*/
|
||||||
public static boolean sendMail (String toAddress, String mailSubject, String mailBody,
|
public static boolean sendMail (String toAddress, String mailSubject, String mailBody,
|
||||||
boolean mailBodyIsHtml, File[] attachments){
|
boolean mailBodyIsHtml, File[] attachments){
|
||||||
|
|
|
@ -1,26 +1,25 @@
|
||||||
package com.xxl.job.admin.core.util;
|
package com.xxl.job.admin.core.util;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* properties util
|
* properties util
|
||||||
* @author xuxueli 2015-8-28 10:35:53
|
* @author xuxueli 2015-8-28 10:35:53
|
||||||
*/
|
*/
|
||||||
public class PropertiesUtil {
|
public class PropertiesUtil {
|
||||||
private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class);
|
private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class);
|
||||||
private static final String file_name = "config.properties";
|
private static final String file_name = "xxl-job-admin.properties";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load properties
|
* load properties
|
||||||
* @param propertyFileName
|
* @param propertyFileName
|
||||||
* @param ifClassPath
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Properties loadProperties(String propertyFileName) {
|
public static Properties loadProperties(String propertyFileName) {
|
||||||
|
@ -55,7 +54,7 @@ public class PropertiesUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(getString("triggerLogUrl"));
|
System.out.println(getString("xxl.job.login.username"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,17 +14,17 @@
|
||||||
<property name="fileEncoding" value="utf-8" />
|
<property name="fileEncoding" value="utf-8" />
|
||||||
<property name="locations">
|
<property name="locations">
|
||||||
<list>
|
<list>
|
||||||
<value>classpath*:jdbc.properties</value>
|
<value>classpath*:xxl-job-admin.properties</value>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- part 1 :for datasource -->
|
<!-- part 1 :for datasource -->
|
||||||
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
|
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
|
||||||
<property name="driverClass" value="${c3p0.driverClass}" />
|
<property name="driverClass" value="${xxl.job.db.driverClass}" />
|
||||||
<property name="jdbcUrl" value="${c3p0.url}" />
|
<property name="jdbcUrl" value="${xxl.job.db.url}" />
|
||||||
<property name="user" value="${c3p0.user}" />
|
<property name="user" value="${xxl.job.db.user}" />
|
||||||
<property name="password" value="${c3p0.password}" />
|
<property name="password" value="${xxl.job.db.password}" />
|
||||||
<property name="initialPoolSize" value="3" />
|
<property name="initialPoolSize" value="3" />
|
||||||
<property name="minPoolSize" value="2" />
|
<property name="minPoolSize" value="2" />
|
||||||
<property name="maxPoolSize" value="10" />
|
<property name="maxPoolSize" value="10" />
|
||||||
|
@ -68,4 +68,23 @@
|
||||||
<aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
|
<aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
|
||||||
</aop:config>
|
</aop:config>
|
||||||
|
|
||||||
|
<!-- part 3 :for quartz -->
|
||||||
|
<bean id="quartzScheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
||||||
|
<property name="dataSource" ref="dataSource" />
|
||||||
|
<property name="autoStartup" value="true" /> <!--自动启动 -->
|
||||||
|
<property name="startupDelay" value="20" /> <!--延时启动 -->
|
||||||
|
<property name="applicationContextSchedulerContextKey" value="applicationContextKey" />
|
||||||
|
<property name="configLocation" value="classpath:quartz.properties"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- 协同-调度器 -->
|
||||||
|
<bean id="xxlJobDynamicScheduler" class="com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler" init-method="init" destroy-method="destroy" >
|
||||||
|
<!-- (轻易不要变更“调度器名称”, 任务创建时会绑定该“调度器名称”) -->
|
||||||
|
<property name="scheduler" ref="quartzScheduler"/>
|
||||||
|
<!-- 调度中心回调IP[选填],为空则自动获取 -->
|
||||||
|
<property name="callBackIp" value="${xxl.job.callBackIp}"/>
|
||||||
|
<!-- 调度中心回调端口号 -->
|
||||||
|
<property name="callBackPort" value="${xxl.job.callBackPort}"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
|
@ -1,26 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
|
||||||
|
|
||||||
<!-- quartz-调度器 -->
|
|
||||||
<bean id="quartzScheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
|
||||||
<property name="dataSource" ref="dataSource" />
|
|
||||||
<property name="autoStartup" value="true" /> <!--自动启动 -->
|
|
||||||
<property name="startupDelay" value="20" /> <!--延时启动 -->
|
|
||||||
<property name="applicationContextSchedulerContextKey" value="applicationContextKey" />
|
|
||||||
<property name="configLocation" value="classpath:quartz.properties"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- 协同-调度器 -->
|
|
||||||
<bean id="dynamicSchedulerUtil" class="com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler" init-method="init" destroy-method="destroy" >
|
|
||||||
<!-- (轻易不要变更“调度器名称”, 任务创建时会绑定该“调度器名称”) -->
|
|
||||||
<property name="scheduler" ref="quartzScheduler"/>
|
|
||||||
<!-- 调度中心回调IP[选填],为空则自动获取 -->
|
|
||||||
<!--<property name="callBackIp" value=""/>-->
|
|
||||||
<!-- 调度中心回调端口号 -->
|
|
||||||
<property name="callBackPort" value="8888"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
</beans>
|
|
|
@ -1,11 +0,0 @@
|
||||||
# for email
|
|
||||||
mail.host=smtp.163.com
|
|
||||||
mail.port=25
|
|
||||||
mail.username=ovono802302@163.com
|
|
||||||
mail.password=asdfzxcv
|
|
||||||
mail.sendFrom=ovono802302@163.com
|
|
||||||
mail.sendNick=《任务调度平台XXL-JOB》
|
|
||||||
|
|
||||||
# for login
|
|
||||||
login.username=admin
|
|
||||||
login.password=123456
|
|
|
@ -1,4 +0,0 @@
|
||||||
c3p0.driverClass=com.mysql.jdbc.Driver
|
|
||||||
c3p0.url=jdbc:mysql://localhost:3306/xxl-job?useUnicode=true&characterEncoding=UTF-8
|
|
||||||
c3p0.user=root
|
|
||||||
c3p0.password=root_pwd
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
### xxl-job db
|
||||||
|
xxl.job.db.driverClass=com.mysql.jdbc.Driver
|
||||||
|
xxl.job.db.url=jdbc:mysql://localhost:3306/xxl-job?useUnicode=true&characterEncoding=UTF-8
|
||||||
|
xxl.job.db.user=root
|
||||||
|
xxl.job.db.password=root_pwd
|
||||||
|
|
||||||
|
### xxl-job callback address
|
||||||
|
xxl.job.callBackIp=
|
||||||
|
xxl.job.callBackPort=8888
|
||||||
|
|
||||||
|
### xxl-job email
|
||||||
|
xxl.job.mail.host=smtp.163.com
|
||||||
|
xxl.job.mail.port=25
|
||||||
|
xxl.job.mail.username=ovono802302@163.com
|
||||||
|
xxl.job.mail.password=asdfzxcv
|
||||||
|
xxl.job.mail.sendFrom=ovono802302@163.com
|
||||||
|
xxl.job.mail.sendNick=《任务调度平台XXL-JOB》
|
||||||
|
|
||||||
|
# xxl-job login
|
||||||
|
xxl.job.login.username=admin
|
||||||
|
xxl.job.login.password=123456
|
Loading…
Reference in New Issue