소스 검색

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

xueli.xue 8 년 전
부모
커밋
f08cd6a6ce

xxl-job-admin/src/main/resources/applicationcontext-base.xml → xxl-job-admin/src/main/resources/spring/applicationcontext-base.xml 파일 보기

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
 </beans>
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 파일 보기

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

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
 </beans>
45
 </beans>

+ 2 - 2
xxl-job-admin/src/main/webapp/WEB-INF/web.xml 파일 보기

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

+ 18 - 14
xxl-job-executor-example/src/main/resources/applicationcontext-xxl-job.xml 파일 보기

7
            http://www.springframework.org/schema/context
7
            http://www.springframework.org/schema/context
8
            http://www.springframework.org/schema/context/spring-context-3.0.xsd">
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
 	<!-- 配置01、JobHandler 扫描路径 -->
21
 	<!-- 配置01、JobHandler 扫描路径 -->
15
 	<!-- 配置02、执行器 -->
24
 	<!-- 配置02、执行器 -->
16
 	<bean id="xxlJobExecutor" class="com.xxl.job.core.executor.XxlJobExecutor" init-method="start" destroy-method="destroy" >
25
 	<bean id="xxlJobExecutor" class="com.xxl.job.core.executor.XxlJobExecutor" init-method="start" destroy-method="destroy" >
17
 		<!-- 执行器IP[选填],为空则自动获取 -->
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
         <!-- 执行器注册器,默认使用系统提供的 "DbRegistHelper", 推荐将其改为公共的RPC服务 -->
31
         <!-- 执行器注册器,默认使用系统提供的 "DbRegistHelper", 推荐将其改为公共的RPC服务 -->
23
         <property name="registHelper" >
32
         <property name="registHelper" >
24
             <!-- DbRegistHelper, 依赖 "XXL-JOB公共数据源" -->
33
             <!-- DbRegistHelper, 依赖 "XXL-JOB公共数据源" -->
34
 	<!-- 配置03、GlueFactory -->
43
 	<!-- 配置03、GlueFactory -->
35
 	<bean id="glueFactory" class="com.xxl.job.core.glue.GlueFactory">
44
 	<bean id="glueFactory" class="com.xxl.job.core.glue.GlueFactory">
36
 		<!-- GLUE任务示例缓存失效时间, 单位/ms -->
45
 		<!-- GLUE任务示例缓存失效时间, 单位/ms -->
37
-		<property name="cacheTimeout" value="10000" />
46
+		<property name="cacheTimeout" value="${xxl.job.glue.cache.time}" />
38
 		<!-- GLUE源码加载器,默认使用系统提供的 "DbGlueLoader", 推荐将其改为公共的RPC服务 -->
47
 		<!-- GLUE源码加载器,默认使用系统提供的 "DbGlueLoader", 推荐将其改为公共的RPC服务 -->
39
 		<property name="glueLoader" >
48
 		<property name="glueLoader" >
40
             <!-- DbGlueLoader, 依赖 "XXL-JOB公共数据源" -->
49
             <!-- DbGlueLoader, 依赖 "XXL-JOB公共数据源" -->
49
 
58
 
50
 	<!-- 配置04、XXL-JOB公共数据源 -->
59
 	<!-- 配置04、XXL-JOB公共数据源 -->
51
 	<bean id="xxlJobDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
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
 		<property name="initialPoolSize" value="3" />
65
 		<property name="initialPoolSize" value="3" />
57
 		<property name="minPoolSize" value="2" />
66
 		<property name="minPoolSize" value="2" />
58
 		<property name="maxPoolSize" value="10" />
67
 		<property name="maxPoolSize" value="10" />
61
 		<property name="acquireRetryAttempts" value="10" />
70
 		<property name="acquireRetryAttempts" value="10" />
62
 		<property name="preferredTestQuery" value="SELECT 1" />
71
 		<property name="preferredTestQuery" value="SELECT 1" />
63
 	</bean>
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
 </beans>
75
 </beans>

+ 0 - 4
xxl-job-executor-example/src/main/resources/jdbc.properties 파일 보기

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 파일 보기

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 파일 보기

20
 		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
20
 		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
21
 	</listener>
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
 	<welcome-file-list>
23
 	<welcome-file-list>
37
 		<welcome-file>index.html</welcome-file>
24
 		<welcome-file>index.html</welcome-file>
38
 	</welcome-file-list>
25
 	</welcome-file-list>