xueli.xue 8 gadus atpakaļ
vecāks
revīzija
a5757be432

+ 4 - 3
README.md Parādīt failu

@@ -88,11 +88,11 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
88 88
 ![输入图片说明](https://static.oschina.net/uploads/img/201703/07162326_L3VB.png "在这里输入图片标题")
89 89
 
90 90
 #### 1.5 环境
91
-- Servlet/JSP Spec:3.0/2.2
92
-- Jdk:1.7+
91
+- JDK:1.7+
93 92
 - Tomcat:7+
93
+- Mysql:5.6+
94
+- Servlet/JSP Spec:3.0/2.2
94 95
 - Maven:3+
95
-- Mysql:5.5+
96 96
 
97 97
 
98 98
 ## 二、快速入门
@@ -717,6 +717,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
717 717
 - 3、执行器支持手动设置执行地址列表,提供开关切换使用注册地址还是手动设置的地址;
718 718
 - 4、执行器路由规则:第一个、循环、随机、顺序故障(默认)转移;
719 719
 - 5、CleanCode,清理无效的历史参数;
720
+- 6、规范系统配置数据,通过配置文件统一管理;
720 721
 
721 722
 #### TODO LIST
722 723
 - 1、支持脚本JOB(源码或指定路径), 即shell/python/php等, 日志实时输出并支持在线监控;定制JobHandler实现;

+ 2 - 2
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/IndexController.java Parādīt failu

@@ -45,8 +45,8 @@ public class IndexController {
45 45
 	public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember){
46 46
 		if (!PermissionInterceptor.ifLogin(request)) {
47 47
 			if (StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(password)
48
-					&& PropertiesUtil.getString("login.username").equals(userName) 
49
-					&& PropertiesUtil.getString("login.password").equals(password)) {
48
+					&& PropertiesUtil.getString("xxl.job.login.username").equals(userName)
49
+					&& PropertiesUtil.getString("xxl.job.login.password").equals(password)) {
50 50
 				boolean ifRem = false;
51 51
 				if (StringUtils.isNotBlank(ifRemember) && "on".equals(ifRemember)) {
52 52
 					ifRem = true;

+ 1 - 1
xxl-job-admin/src/main/java/com/xxl/job/admin/core/schedule/XxlJobDynamicScheduler.java Parādīt failu

@@ -35,7 +35,7 @@ public final class XxlJobDynamicScheduler implements ApplicationContextAware, In
35 35
     
36 36
     // Scheduler
37 37
     private static Scheduler scheduler;
38
-    public static void setScheduler(Scheduler scheduler) {
38
+    public void setScheduler(Scheduler scheduler) {
39 39
 		XxlJobDynamicScheduler.scheduler = scheduler;
40 40
 	}
41 41
     

+ 19 - 20
xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/MailUtil.java Parādīt failu

@@ -1,13 +1,5 @@
1 1
 package com.xxl.job.admin.core.util;
2 2
 
3
-import java.io.File;
4
-import java.util.Properties;
5
-import java.util.concurrent.ExecutorService;
6
-import java.util.concurrent.Executors;
7
-
8
-import javax.mail.internet.MimeMessage;
9
-import javax.mail.internet.MimeUtility;
10
-
11 3
 import org.apache.commons.lang.ArrayUtils;
12 4
 import org.slf4j.Logger;
13 5
 import org.slf4j.LoggerFactory;
@@ -15,6 +7,13 @@ import org.springframework.mail.javamail.JavaMailSender;
15 7
 import org.springframework.mail.javamail.JavaMailSenderImpl;
16 8
 import org.springframework.mail.javamail.MimeMessageHelper;
17 9
 
10
+import javax.mail.internet.MimeMessage;
11
+import javax.mail.internet.MimeUtility;
12
+import java.io.File;
13
+import java.util.Properties;
14
+import java.util.concurrent.ExecutorService;
15
+import java.util.concurrent.Executors;
16
+
18 17
 /**
19 18
  * 邮件发送.Util
20 19
  * @author xuxueli 2016-3-12 15:06:20
@@ -29,12 +28,12 @@ public class MailUtil {
29 28
 	private static String sendFrom;
30 29
 	private static String sendNick;
31 30
 	static{
32
-		host = PropertiesUtil.getString("mail.host");
33
-		port = PropertiesUtil.getString("mail.port");
34
-		username = PropertiesUtil.getString("mail.username");
35
-		password = PropertiesUtil.getString("mail.password");
36
-		sendFrom = PropertiesUtil.getString("mail.sendFrom");
37
-		sendNick = PropertiesUtil.getString("mail.sendNick");
31
+		host = PropertiesUtil.getString("xxl.job.mail.host");
32
+		port = PropertiesUtil.getString("xxl.job.mail.port");
33
+		username = PropertiesUtil.getString("xxl.job.mail.username");
34
+		password = PropertiesUtil.getString("xxl.job.mail.password");
35
+		sendFrom = PropertiesUtil.getString("xxl.job.mail.sendFrom");
36
+		sendNick = PropertiesUtil.getString("xxl.job.mail.sendNick");
38 37
 	}
39 38
 	
40 39
 	/**
@@ -56,14 +55,14 @@ public class MailUtil {
56 55
 	/**
57 56
 	 * 发送邮件 (完整版)(结合Spring)
58 57
 	 * 
59
-	 * @param javaMailSender: 发送Bean
60
-	 * @param sendFrom		: 发送人邮箱
61
-	 * @param sendNick		: 发送人昵称
58
+	 * //@param javaMailSender: 发送Bean
59
+	 * //@param sendFrom		: 发送人邮箱
60
+	 * //@param sendNick		: 发送人昵称
62 61
 	 * @param toAddress		: 收件人邮箱
63 62
 	 * @param mailSubject	: 邮件主题
64 63
 	 * @param mailBody		: 邮件正文
65 64
 	 * @param mailBodyIsHtml: 邮件正文格式,true:HTML格式;false:文本格式
66
-	 * @param files[]		: 附件
65
+	 * @param attachments	: 附件
67 66
 	 */
68 67
 	@SuppressWarnings("null")
69 68
 	public static boolean sendMailSpring(String toAddress, String mailSubject, String mailBody, boolean mailBodyIsHtml,File[] attachments) {
@@ -106,8 +105,8 @@ public class MailUtil {
106 105
 	 * @param mailSubject	: 邮件主题
107 106
 	 * @param mailBody		: 邮件正文
108 107
 	 * @param mailBodyIsHtml: 邮件正文格式,true:HTML格式;false:文本格式
109
-	 * @param inLineFile	: 内嵌文件
110
-	 * @param files[]		: 附件
108
+	 * //@param inLineFile	: 内嵌文件
109
+	 * @param attachments	: 附件
111 110
 	 */
112 111
 	public static boolean sendMail (String toAddress, String mailSubject, String mailBody, 
113 112
 			boolean mailBodyIsHtml, File[] attachments){

+ 5 - 6
xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/PropertiesUtil.java Parādīt failu

@@ -1,26 +1,25 @@
1 1
 package com.xxl.job.admin.core.util;
2 2
 
3
+import org.slf4j.Logger;
4
+import org.slf4j.LoggerFactory;
5
+
3 6
 import java.io.FileInputStream;
4 7
 import java.io.IOException;
5 8
 import java.io.InputStreamReader;
6 9
 import java.net.URL;
7 10
 import java.util.Properties;
8 11
 
9
-import org.slf4j.Logger;
10
-import org.slf4j.LoggerFactory;
11
-
12 12
 /**
13 13
  * properties util
14 14
  * @author xuxueli 2015-8-28 10:35:53
15 15
  */
16 16
 public class PropertiesUtil {
17 17
 	private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class);
18
-	private static final String file_name = "config.properties";
18
+	private static final String file_name = "xxl-job-admin.properties";
19 19
 	
20 20
 	/**
21 21
 	 * load properties
22 22
 	 * @param propertyFileName
23
-	 * @param ifClassPath
24 23
 	 * @return
25 24
 	 */
26 25
 	public static Properties loadProperties(String propertyFileName) {
@@ -55,7 +54,7 @@ public class PropertiesUtil {
55 54
 	}
56 55
 	
57 56
 	public static void main(String[] args) {
58
-		System.out.println(getString("triggerLogUrl"));
57
+		System.out.println(getString("xxl.job.login.username"));
59 58
 	}
60 59
 
61 60
 }

xxl-job-admin/src/main/resources/applicationcontext-database.xml → xxl-job-admin/src/main/resources/applicationcontext-xxl-job-admin.xml Parādīt failu

@@ -1,71 +1,90 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<beans xmlns="http://www.springframework.org/schema/beans"
3
-	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
-	   xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
5
-	   xsi:schemaLocation="http://www.springframework.org/schema/beans
6
-		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7
-		http://www.springframework.org/schema/aop 
8
-		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
9
-		http://www.springframework.org/schema/tx 
10
-		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
11
-	
12
-	
13
-	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
14
-		<property name="fileEncoding" value="utf-8" />
15
-		<property name="locations">
16
-			<list>
17
-				<value>classpath*:jdbc.properties</value>
18
-			</list>
19
-		</property>
20
-	</bean>
21
-
22
-	<!-- part 1 :for datasource -->
23
-	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  destroy-method="close">  
24
-	    <property name="driverClass" value="${c3p0.driverClass}" />  
25
-	    <property name="jdbcUrl" value="${c3p0.url}" />  
26
-	    <property name="user" value="${c3p0.user}" />  
27
-	    <property name="password" value="${c3p0.password}" />  
28
-	    <property name="initialPoolSize" value="3" />  
29
-	    <property name="minPoolSize" value="2" />  
30
-	    <property name="maxPoolSize" value="10" />  
31
-	    <property name="maxIdleTime" value="60" />
32
-	    <property name="acquireRetryDelay" value="1000" />
33
-	    <property name="acquireRetryAttempts" value="10" />
34
-	    <property name="preferredTestQuery" value="SELECT 1" />
35
-	</bean>
36
-	
37
-	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
38
-		<property name="dataSource" ref="dataSource" />
39
-		<property name="mapperLocations" value="classpath:mybatis-mapper/*.xml"/>
40
-	</bean>
41
-    
42
-    <!-- scope must be "prototype" when junit -->
43
-    <bean id="sqlSessionTemplate"  class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">  
44
-          <constructor-arg index="0" ref="sqlSessionFactory" />  
45
-    </bean> 
46
-    
47
-    <!-- part 2 :for tx -->
48
-    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
49
-		<property name="dataSource" ref="dataSource" />
50
-	</bean>
51
-      
52
-	<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
53
-	
54
-	<tx:advice id="txAdvice" transaction-manager="transactionManager">
55
-		<tx:attributes>
56
-			<tx:method name="detail*" propagation="SUPPORTS" />
57
-			<tx:method name="visit*" propagation="SUPPORTS" />
58
-			<tx:method name="get*" propagation="SUPPORTS" />
59
-			<tx:method name="find*" propagation="SUPPORTS" />
60
-			<tx:method name="check*" propagation="SUPPORTS" />
61
-			<tx:method name="list*" propagation="SUPPORTS" />
62
-			<tx:method name="*" propagation="REQUIRED" rollback-for="exception" />
63
-		</tx:attributes>
64
-	</tx:advice>
65
-
66
-	<aop:config>
67
-		<aop:pointcut id="txoperation" expression="execution(* com.xxl.job.admin.service.impl.*.*(..))" />
68
-		<aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
69
-	</aop:config>
70
-	
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+	   xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
5
+	   xsi:schemaLocation="http://www.springframework.org/schema/beans
6
+		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7
+		http://www.springframework.org/schema/aop 
8
+		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
9
+		http://www.springframework.org/schema/tx 
10
+		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
11
+	
12
+	
13
+	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
14
+		<property name="fileEncoding" value="utf-8" />
15
+		<property name="locations">
16
+			<list>
17
+				<value>classpath*:xxl-job-admin.properties</value>
18
+			</list>
19
+		</property>
20
+	</bean>
21
+
22
+	<!-- part 1 :for datasource -->
23
+	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  destroy-method="close">  
24
+	    <property name="driverClass" value="${xxl.job.db.driverClass}" />
25
+	    <property name="jdbcUrl" value="${xxl.job.db.url}" />
26
+	    <property name="user" value="${xxl.job.db.user}" />
27
+	    <property name="password" value="${xxl.job.db.password}" />
28
+	    <property name="initialPoolSize" value="3" />  
29
+	    <property name="minPoolSize" value="2" />  
30
+	    <property name="maxPoolSize" value="10" />  
31
+	    <property name="maxIdleTime" value="60" />
32
+	    <property name="acquireRetryDelay" value="1000" />
33
+	    <property name="acquireRetryAttempts" value="10" />
34
+	    <property name="preferredTestQuery" value="SELECT 1" />
35
+	</bean>
36
+	
37
+	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
38
+		<property name="dataSource" ref="dataSource" />
39
+		<property name="mapperLocations" value="classpath:mybatis-mapper/*.xml"/>
40
+	</bean>
41
+    
42
+    <!-- scope must be "prototype" when junit -->
43
+    <bean id="sqlSessionTemplate"  class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">  
44
+          <constructor-arg index="0" ref="sqlSessionFactory" />  
45
+    </bean> 
46
+    
47
+    <!-- part 2 :for tx -->
48
+    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
49
+		<property name="dataSource" ref="dataSource" />
50
+	</bean>
51
+      
52
+	<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
53
+	
54
+	<tx:advice id="txAdvice" transaction-manager="transactionManager">
55
+		<tx:attributes>
56
+			<tx:method name="detail*" propagation="SUPPORTS" />
57
+			<tx:method name="visit*" propagation="SUPPORTS" />
58
+			<tx:method name="get*" propagation="SUPPORTS" />
59
+			<tx:method name="find*" propagation="SUPPORTS" />
60
+			<tx:method name="check*" propagation="SUPPORTS" />
61
+			<tx:method name="list*" propagation="SUPPORTS" />
62
+			<tx:method name="*" propagation="REQUIRED" rollback-for="exception" />
63
+		</tx:attributes>
64
+	</tx:advice>
65
+
66
+	<aop:config>
67
+		<aop:pointcut id="txoperation" expression="execution(* com.xxl.job.admin.service.impl.*.*(..))" />
68
+		<aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
69
+	</aop:config>
70
+
71
+	<!-- part 3 :for quartz -->
72
+	<bean id="quartzScheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
73
+		<property name="dataSource" ref="dataSource" />
74
+		<property name="autoStartup" value="true" />	<!--自动启动 -->
75
+		<property name="startupDelay" value="20" />		<!--延时启动 -->
76
+		<property name="applicationContextSchedulerContextKey"  value="applicationContextKey" />
77
+		<property name="configLocation" value="classpath:quartz.properties"/>
78
+	</bean>
79
+
80
+	<!-- 协同-调度器 -->
81
+	<bean id="xxlJobDynamicScheduler" class="com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler" init-method="init" destroy-method="destroy" >
82
+		<!-- (轻易不要变更“调度器名称”, 任务创建时会绑定该“调度器名称”) -->
83
+		<property name="scheduler" ref="quartzScheduler"/>
84
+		<!-- 调度中心回调IP[选填],为空则自动获取 -->
85
+		<property name="callBackIp" value="${xxl.job.callBackIp}"/>
86
+		<!-- 调度中心回调端口号 -->
87
+		<property name="callBackPort" value="${xxl.job.callBackPort}"/>
88
+	</bean>
89
+	
71 90
 </beans>

+ 0 - 26
xxl-job-admin/src/main/resources/applicationcontext-xxl-job.xml Parādīt failu

@@ -1,26 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<beans xmlns="http://www.springframework.org/schema/beans"
3
-	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
-	   xsi:schemaLocation="http://www.springframework.org/schema/beans
5
-           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
6
-
7
-	<!-- quartz-调度器 -->
8
-	<bean id="quartzScheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
9
-		<property name="dataSource" ref="dataSource" />
10
-        <property name="autoStartup" value="true" />	<!--自动启动 -->
11
-        <property name="startupDelay" value="20" />		<!--延时启动 -->
12
-		<property name="applicationContextSchedulerContextKey"  value="applicationContextKey" /> 
13
-        <property name="configLocation" value="classpath:quartz.properties"/>
14
-	</bean>
15
-	
16
-	<!-- 协同-调度器 -->
17
-	<bean id="dynamicSchedulerUtil" class="com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler" init-method="init" destroy-method="destroy" >
18
-		<!-- (轻易不要变更“调度器名称”, 任务创建时会绑定该“调度器名称”) -->
19
-        <property name="scheduler" ref="quartzScheduler"/>
20
-		<!-- 调度中心回调IP[选填],为空则自动获取 -->
21
-		<!--<property name="callBackIp" value=""/>-->
22
-		<!-- 调度中心回调端口号 -->
23
-        <property name="callBackPort" value="8888"/>
24
-    </bean>
25
-
26
-</beans>

+ 0 - 11
xxl-job-admin/src/main/resources/config.properties Parādīt failu

@@ -1,11 +0,0 @@
1
-# for email
2
-mail.host=smtp.163.com
3
-mail.port=25
4
-mail.username=ovono802302@163.com
5
-mail.password=asdfzxcv
6
-mail.sendFrom=ovono802302@163.com
7
-mail.sendNick=《任务调度平台XXL-JOB》
8
-
9
-# for login
10
-login.username=admin
11
-login.password=123456

+ 0 - 4
xxl-job-admin/src/main/resources/jdbc.properties Parādīt failu

@@ -1,4 +0,0 @@
1
-c3p0.driverClass=com.mysql.jdbc.Driver
2
-c3p0.url=jdbc:mysql://localhost:3306/xxl-job?useUnicode=true&amp;characterEncoding=UTF-8
3
-c3p0.user=root
4
-c3p0.password=root_pwd

+ 21 - 0
xxl-job-admin/src/main/resources/xxl-job-admin.properties Parādīt failu

@@ -0,0 +1,21 @@
1
+### xxl-job db
2
+xxl.job.db.driverClass=com.mysql.jdbc.Driver
3
+xxl.job.db.url=jdbc:mysql://localhost:3306/xxl-job?useUnicode=true&amp;characterEncoding=UTF-8
4
+xxl.job.db.user=root
5
+xxl.job.db.password=root_pwd
6
+
7
+### xxl-job callback address
8
+xxl.job.callBackIp=
9
+xxl.job.callBackPort=8888
10
+
11
+### xxl-job email
12
+xxl.job.mail.host=smtp.163.com
13
+xxl.job.mail.port=25
14
+xxl.job.mail.username=ovono802302@163.com
15
+xxl.job.mail.password=asdfzxcv
16
+xxl.job.mail.sendFrom=ovono802302@163.com
17
+xxl.job.mail.sendNick=《任务调度平台XXL-JOB》
18
+
19
+# xxl-job login
20
+xxl.job.login.username=admin
21
+xxl.job.login.password=123456