Browse Source

规范执行器配置信息,通过配置文件统一管理

xueli.xue 8 years ago
parent
commit
f08cd6a6ce

xxl-job-admin/src/main/resources/applicationcontext-base.xml → xxl-job-admin/src/main/resources/spring/applicationcontext-base.xml View File

@@ -1,21 +1,21 @@
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:context="http://www.springframework.org/schema/context"
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/context
8
-           http://www.springframework.org/schema/context/spring-context-3.0.xsd">
9
-
10
-	<context:component-scan base-package="com.xxl.job.admin.service, com.xxl.job.admin.dao" />
11
-
12
-	<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
13
-		<property name="templateLoaderPath" value="/WEB-INF/template/" />
14
-		<property name="freemarkerSettings">
15
-			<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
16
-				<property name="location" value="classpath:freemarker.properties" />
17
-			</bean>
18
-		</property>
19
-	</bean>
20
-
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:context="http://www.springframework.org/schema/context"
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/context
8
+           http://www.springframework.org/schema/context/spring-context-3.0.xsd">
9
+
10
+	<context:component-scan base-package="com.xxl.job.admin.service, com.xxl.job.admin.dao" />
11
+
12
+	<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
13
+		<property name="templateLoaderPath" value="/WEB-INF/template/" />
14
+		<property name="freemarkerSettings">
15
+			<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
16
+				<property name="location" value="classpath:freemarker.properties" />
17
+			</bean>
18
+		</property>
19
+	</bean>
20
+
21 21
 </beans>

xxl-job-admin/src/main/resources/applicationcontext-xxl-job-admin.xml → xxl-job-admin/src/main/resources/spring/applicationcontext-xxl-job-admin.xml View File

@@ -19,8 +19,9 @@
19 19
 		</property>
20 20
 	</bean>
21 21
 
22
-	<!-- part 1 :for datasource -->
23
-	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  destroy-method="close">  
22
+	<!-- ********************************* part 1 :for datasource ********************************* -->
23
+
24
+	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  destroy-method="close">
24 25
 	    <property name="driverClass" value="${xxl.job.db.driverClass}" />
25 26
 	    <property name="jdbcUrl" value="${xxl.job.db.url}" />
26 27
 	    <property name="user" value="${xxl.job.db.user}" />
@@ -44,7 +45,8 @@
44 45
           <constructor-arg index="0" ref="sqlSessionFactory" />  
45 46
     </bean> 
46 47
     
47
-    <!-- part 2 :for tx -->
48
+	<!-- ********************************* part 2 :for tx ********************************* -->
49
+
48 50
     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
49 51
 		<property name="dataSource" ref="dataSource" />
50 52
 	</bean>
@@ -68,7 +70,8 @@
68 70
 		<aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
69 71
 	</aop:config>
70 72
 
71
-	<!-- part 3 :for quartz -->
73
+	<!-- ********************************* part 3 :for xxl-job scheduler ********************************* -->
74
+
72 75
 	<bean id="quartzScheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
73 76
 		<property name="dataSource" ref="dataSource" />
74 77
 		<property name="autoStartup" value="true" />	<!--自动启动 -->
@@ -77,7 +80,6 @@
77 80
 		<property name="configLocation" value="classpath:quartz.properties"/>
78 81
 	</bean>
79 82
 
80
-	<!-- 协同-调度器 -->
81 83
 	<bean id="xxlJobDynamicScheduler" class="com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler" init-method="init" destroy-method="destroy" >
82 84
 		<!-- (轻易不要变更“调度器名称”, 任务创建时会绑定该“调度器名称”) -->
83 85
 		<property name="scheduler" ref="quartzScheduler"/>

xxl-job-admin/src/main/resources/springmvc-context.xml → xxl-job-admin/src/main/resources/spring/springmvc-context.xml View File

@@ -1,45 +1,45 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<beans xmlns="http://www.springframework.org/schema/beans"
3
-	   xmlns:context="http://www.springframework.org/schema/context"
4
-	   xmlns:mvc="http://www.springframework.org/schema/mvc"
5
-	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
-	   xsi:schemaLocation="http://www.springframework.org/schema/beans
7
-		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
8
-		http://www.springframework.org/schema/context 
9
-		http://www.springframework.org/schema/context/spring-context-3.0.xsd
10
-		http://www.springframework.org/schema/mvc
11
-		http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
12
-
13
-	<mvc:annotation-driven /> 
14
-	<context:component-scan base-package="com.xxl.job.admin.controller" />
15
-	
16
-	<mvc:resources mapping="/favicon.ico" location="/favicon.ico" />
17
-	<mvc:resources mapping="/static/**" location="/static/" />
18
-	<mvc:resources mapping="/**/*.html" location="/" />
19
-	
20
-	<bean id="viewResolver"	class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
21
-		<property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
22
-		<property name="prefix" value="" />
23
-		<property name="suffix" value=".ftl" />
24
-		<property name="contentType" value="text/html;charset=UTF-8" />
25
-		<property name="exposeSpringMacroHelpers" value="true" />
26
-		<property name="exposeRequestAttributes" value="true" />
27
-		<property name="exposeSessionAttributes" value="true" />
28
-		<property name="requestContextAttribute" value="request" />
29
-		<property name="cache" value="true" />
30
-		<property name="order" value="0" />
31
-	</bean>
32
-	
33
- 	<mvc:interceptors>
34
-		<mvc:interceptor>
35
-			<mvc:mapping path="/**"/>
36
-			<bean class="com.xxl.job.admin.controller.interceptor.PermissionInterceptor"/>
37
-		</mvc:interceptor>
38
-		<mvc:interceptor>
39
-			<mvc:mapping path="/**"/>
40
-			<bean class="com.xxl.job.admin.controller.interceptor.CookieInterceptor"/>
41
-		</mvc:interceptor>
42
-	</mvc:interceptors>
43
-	<bean id="exceptionResolver" class="com.xxl.job.admin.controller.resolver.WebExceptionResolver" />
44
-	
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+	   xmlns:context="http://www.springframework.org/schema/context"
4
+	   xmlns:mvc="http://www.springframework.org/schema/mvc"
5
+	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
+	   xsi:schemaLocation="http://www.springframework.org/schema/beans
7
+		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
8
+		http://www.springframework.org/schema/context 
9
+		http://www.springframework.org/schema/context/spring-context-3.0.xsd
10
+		http://www.springframework.org/schema/mvc
11
+		http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
12
+
13
+	<mvc:annotation-driven /> 
14
+	<context:component-scan base-package="com.xxl.job.admin.controller" />
15
+	
16
+	<mvc:resources mapping="/favicon.ico" location="/favicon.ico" />
17
+	<mvc:resources mapping="/static/**" location="/static/" />
18
+	<mvc:resources mapping="/**/*.html" location="/" />
19
+	
20
+	<bean id="viewResolver"	class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
21
+		<property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
22
+		<property name="prefix" value="" />
23
+		<property name="suffix" value=".ftl" />
24
+		<property name="contentType" value="text/html;charset=UTF-8" />
25
+		<property name="exposeSpringMacroHelpers" value="true" />
26
+		<property name="exposeRequestAttributes" value="true" />
27
+		<property name="exposeSessionAttributes" value="true" />
28
+		<property name="requestContextAttribute" value="request" />
29
+		<property name="cache" value="true" />
30
+		<property name="order" value="0" />
31
+	</bean>
32
+	
33
+ 	<mvc:interceptors>
34
+		<mvc:interceptor>
35
+			<mvc:mapping path="/**"/>
36
+			<bean class="com.xxl.job.admin.controller.interceptor.PermissionInterceptor"/>
37
+		</mvc:interceptor>
38
+		<mvc:interceptor>
39
+			<mvc:mapping path="/**"/>
40
+			<bean class="com.xxl.job.admin.controller.interceptor.CookieInterceptor"/>
41
+		</mvc:interceptor>
42
+	</mvc:interceptors>
43
+	<bean id="exceptionResolver" class="com.xxl.job.admin.controller.resolver.WebExceptionResolver" />
44
+	
45 45
 </beans>

+ 2 - 2
xxl-job-admin/src/main/webapp/WEB-INF/web.xml View File

@@ -11,7 +11,7 @@
11 11
 
12 12
 	<context-param>
13 13
 		<param-name>contextConfigLocation</param-name>
14
-		<param-value>classpath*:applicationcontext-*.xml</param-value>
14
+		<param-value>classpath*:spring/applicationcontext-*.xml</param-value>
15 15
 	</context-param>
16 16
 
17 17
 	<listener>
@@ -43,7 +43,7 @@
43 43
 		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
44 44
 		<init-param>
45 45
 			<param-name>contextConfigLocation</param-name>
46
-			<param-value>classpath*:springmvc-context.xml</param-value>
46
+			<param-value>classpath*:spring/springmvc-context.xml</param-value>
47 47
 		</init-param>
48 48
 		<load-on-startup>1</load-on-startup>
49 49
 	</servlet>

+ 18 - 14
xxl-job-executor-example/src/main/resources/applicationcontext-xxl-job.xml View File

@@ -7,6 +7,15 @@
7 7
            http://www.springframework.org/schema/context
8 8
            http://www.springframework.org/schema/context/spring-context-3.0.xsd">
9 9
 
10
+	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
11
+		<property name="fileEncoding" value="utf-8" />
12
+		<property name="locations">
13
+			<list>
14
+				<value>classpath*:xxl-job-executor.properties</value>
15
+			</list>
16
+		</property>
17
+	</bean>
18
+
10 19
     <!-- ********************************* 基础配置 ********************************* -->
11 20
 
12 21
 	<!-- 配置01、JobHandler 扫描路径 -->
@@ -15,10 +24,10 @@
15 24
 	<!-- 配置02、执行器 -->
16 25
 	<bean id="xxlJobExecutor" class="com.xxl.job.core.executor.XxlJobExecutor" init-method="start" destroy-method="destroy" >
17 26
 		<!-- 执行器IP[选填],为空则自动获取 -->
18
-		<!--<property name="ip" value="" />-->
27
+		<property name="ip" value="${xxl.job.executor.ip}" />
19 28
 		<!-- 执行器端口号 -->
20
-		<property name="port" value="9999" />
21
-        <property name="appName" value="xxl-job-executor-example" />
29
+		<property name="port" value="${xxl.job.executor.port}" />
30
+        <property name="appName" value="${xxl.job.executor.appname}" />
22 31
         <!-- 执行器注册器,默认使用系统提供的 "DbRegistHelper", 推荐将其改为公共的RPC服务 -->
23 32
         <property name="registHelper" >
24 33
             <!-- DbRegistHelper, 依赖 "XXL-JOB公共数据源" -->
@@ -34,7 +43,7 @@
34 43
 	<!-- 配置03、GlueFactory -->
35 44
 	<bean id="glueFactory" class="com.xxl.job.core.glue.GlueFactory">
36 45
 		<!-- GLUE任务示例缓存失效时间, 单位/ms -->
37
-		<property name="cacheTimeout" value="10000" />
46
+		<property name="cacheTimeout" value="${xxl.job.glue.cache.time}" />
38 47
 		<!-- GLUE源码加载器,默认使用系统提供的 "DbGlueLoader", 推荐将其改为公共的RPC服务 -->
39 48
 		<property name="glueLoader" >
40 49
             <!-- DbGlueLoader, 依赖 "XXL-JOB公共数据源" -->
@@ -49,10 +58,10 @@
49 58
 
50 59
 	<!-- 配置04、XXL-JOB公共数据源 -->
51 60
 	<bean id="xxlJobDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
52
-		<property name="driverClass" value="${c3p0.driverClass}" />
53
-		<property name="jdbcUrl" value="${c3p0.url}" />
54
-		<property name="user" value="${c3p0.user}" />
55
-		<property name="password" value="${c3p0.password}" />
61
+		<property name="driverClass" value="${xxl.job.db.driverClass}" />
62
+		<property name="jdbcUrl" value="${xxl.job.db.url}" />
63
+		<property name="user" value="${xxl.job.db.user}" />
64
+		<property name="password" value="${xxl.job.db.password}" />
56 65
 		<property name="initialPoolSize" value="3" />
57 66
 		<property name="minPoolSize" value="2" />
58 67
 		<property name="maxPoolSize" value="10" />
@@ -61,11 +70,6 @@
61 70
 		<property name="acquireRetryAttempts" value="10" />
62 71
 		<property name="preferredTestQuery" value="SELECT 1" />
63 72
 	</bean>
64
-	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
65
-		<property name="fileEncoding" value="utf-8" />
66
-		<property name="location">
67
-			<value>classpath:jdbc.properties</value>
68
-		</property>
69
-	</bean>
73
+
70 74
 
71 75
 </beans>

+ 0 - 4
xxl-job-executor-example/src/main/resources/jdbc.properties View File

@@ -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

+ 13 - 0
xxl-job-executor-example/src/main/resources/xxl-job-executor.properties View File

@@ -0,0 +1,13 @@
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 glue cache time/ms
8
+xxl.job.glue.cache.time=10000
9
+
10
+### xxl-job executor address
11
+xxl.job.executor.appname=xxl-job-executor-example
12
+xxl.job.executor.ip=
13
+xxl.job.executor.port=9999

+ 0 - 13
xxl-job-executor-example/src/main/webapp/WEB-INF/web.xml View File

@@ -20,19 +20,6 @@
20 20
 		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
21 21
 	</listener>
22 22
 	
23
-	<!-- [@Deprecated] Servlet任务执行器,推荐使用Jetty任务执行器 -->
24
-	<!-- 
25
-	<servlet>
26
-		<servlet-name>XxlJobServlet</servlet-name>
27
-		<servlet-class>com.xxl.job.client.netcom.servlet.XxlJobServlet</servlet-class>
28
-		<load-on-startup>1</load-on-startup>
29
-	</servlet>
30
-	<servlet-mapping>
31
-		<servlet-name>XxlJobServlet</servlet-name>
32
-		<url-pattern>/xxlJobServlet</url-pattern>
33
-	</servlet-mapping> 
34
-	-->
35
-	
36 23
 	<welcome-file-list>
37 24
 		<welcome-file>index.html</welcome-file>
38 25
 	</welcome-file-list>