项目名更新

v1.3
xueli.xue 9 years ago
parent 55f29157ac
commit cd32557db0

@ -39,9 +39,9 @@ git.osc地址http://git.oschina.net/xuxueli0323/xxl-job
5、支持“串行执行”并行执行
说明V1.2版本将系统架构按功能拆分为:
调度模块[xxl-job-admin]:负责管理调度信息,按照调度配置发出调度请求;
任务模块[xxl-job-client-demo]:负责接收调度请求并执行任务逻辑;任务模块可以方便的嵌入web项目可以参考此demo
通讯模块[xxl-job-client]:负责调度模块和任务模块之间的信息通讯;
调度模块(调度中心):负责管理调度信息,按照调度配置发出调度请求;
执行模块(执行器):负责接收调度请求并执行任务逻辑;
通讯模块:负责调度模块和任务模块之间的信息通讯;
优点:
解耦:任务模块提供任务接口,调度模块维护调度信息,业务相互独立;
高扩展性;
@ -56,7 +56,13 @@ git.osc地址http://git.oschina.net/xuxueli0323/xxl-job
“执行器” 模式简介:
BEAN模式执行器每个执行器都是Spring的一个Bean实例XXL-JOB通过注解@JobHander识别和调度执行器
GLUE模式执行器每个执行器对应一段代码在线Web编辑和维护动态编译生效执行器负责加载GLUE代码和执行
# 源码目录说明
/xxl-job-admin 【调度中心】:负责管理调度信息,按照调度配置发出调度请求;
/xxl-job-core 公共依赖
/xxl-job-executor-example 【执行器】:负责接收调度请求并执行任务逻辑;
/db 建表脚本
/doc 用户手册
# Tips
更多接入公司欢迎在https://github.com/xuxueli/xxl-job/issues/1 登记。
@ -64,4 +70,5 @@ git.osc地址http://git.oschina.net/xuxueli0323/xxl-job
![image](http://images2015.cnblogs.com/blog/554415/201605/554415-20160513183306234-1939652116.png)
技术的发展离不开你的支持,请作者喝杯咖啡吧!

@ -2,4 +2,5 @@
/.settings/
/.classpath
/.project
/xxl-job-admin.iml
/xxl-job-admin.iml
/target/

@ -144,10 +144,10 @@
<version>2.2.3</version>
</dependency>
<!-- xxl-job-client -->
<!-- xxl-job-core -->
<dependency>
<groupId>com.xxl</groupId>
<artifactId>xxl-job-client</artifactId>
<artifactId>xxl-job-core</artifactId>
<version>1.3.1</version>
</dependency>

@ -1,4 +1,4 @@
package com.xxl.job.controller;
package com.xxl.job.admin.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -10,10 +10,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xxl.job.controller.annotation.PermessionLimit;
import com.xxl.job.controller.interceptor.PermissionInterceptor;
import com.xxl.job.core.model.ReturnT;
import com.xxl.job.core.util.PropertiesUtil;
import com.xxl.job.admin.controller.annotation.PermessionLimit;
import com.xxl.job.admin.controller.interceptor.PermissionInterceptor;
import com.xxl.job.admin.core.model.ReturnT;
import com.xxl.job.admin.core.util.PropertiesUtil;
/**
* index controller

@ -1,4 +1,4 @@
package com.xxl.job.controller;
package com.xxl.job.admin.controller;
import java.util.List;
@ -10,11 +10,11 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xxl.job.core.model.ReturnT;
import com.xxl.job.core.model.XxlJobInfo;
import com.xxl.job.core.model.XxlJobLogGlue;
import com.xxl.job.dao.IXxlJobInfoDao;
import com.xxl.job.dao.IXxlJobLogGlueDao;
import com.xxl.job.admin.core.model.ReturnT;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.model.XxlJobLogGlue;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
import com.xxl.job.admin.dao.IXxlJobLogGlueDao;
/**
* job code controller

@ -1,4 +1,4 @@
package com.xxl.job.controller;
package com.xxl.job.admin.controller;
import java.util.HashMap;
import java.util.List;
@ -15,16 +15,16 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xxl.job.client.handler.HandlerRepository;
import com.xxl.job.client.util.JacksonUtil;
import com.xxl.job.core.constant.Constants.JobGroupEnum;
import com.xxl.job.core.model.ReturnT;
import com.xxl.job.core.model.XxlJobInfo;
import com.xxl.job.core.util.DynamicSchedulerUtil;
import com.xxl.job.dao.IXxlJobInfoDao;
import com.xxl.job.dao.IXxlJobLogDao;
import com.xxl.job.dao.IXxlJobLogGlueDao;
import com.xxl.job.service.job.RemoteHttpJobBean;
import com.xxl.job.admin.core.constant.Constants.JobGroupEnum;
import com.xxl.job.admin.core.jobbean.RemoteHttpJobBean;
import com.xxl.job.admin.core.model.ReturnT;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.util.DynamicSchedulerUtil;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
import com.xxl.job.admin.dao.IXxlJobLogDao;
import com.xxl.job.admin.dao.IXxlJobLogGlueDao;
import com.xxl.job.core.handler.HandlerRepository;
import com.xxl.job.core.util.JacksonUtil;
/**
* index controller

@ -1,4 +1,4 @@
package com.xxl.job.controller;
package com.xxl.job.admin.controller;
import java.text.ParseException;
import java.util.Date;
@ -16,14 +16,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xxl.job.client.handler.HandlerRepository;
import com.xxl.job.client.util.HttpUtil;
import com.xxl.job.client.util.HttpUtil.RemoteCallBack;
import com.xxl.job.client.util.JacksonUtil;
import com.xxl.job.core.constant.Constants.JobGroupEnum;
import com.xxl.job.core.model.ReturnT;
import com.xxl.job.core.model.XxlJobLog;
import com.xxl.job.dao.IXxlJobLogDao;
import com.xxl.job.admin.core.constant.Constants.JobGroupEnum;
import com.xxl.job.admin.core.model.ReturnT;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.dao.IXxlJobLogDao;
import com.xxl.job.core.handler.HandlerRepository;
import com.xxl.job.core.util.HttpUtil;
import com.xxl.job.core.util.HttpUtil.RemoteCallBack;
import com.xxl.job.core.util.JacksonUtil;
/**
* index controller

@ -1,4 +1,4 @@
package com.xxl.job.controller.annotation;
package com.xxl.job.admin.controller.annotation;
import java.lang.annotation.ElementType;

@ -1,4 +1,4 @@
package com.xxl.job.controller.interceptor;
package com.xxl.job.admin.controller.interceptor;
import java.util.HashMap;

@ -1,4 +1,4 @@
package com.xxl.job.controller.interceptor;
package com.xxl.job.admin.controller.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -6,8 +6,8 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.xxl.job.controller.annotation.PermessionLimit;
import com.xxl.job.core.util.CookieUtil;
import com.xxl.job.admin.controller.annotation.PermessionLimit;
import com.xxl.job.admin.core.util.CookieUtil;
/**
* ,

@ -1,4 +1,4 @@
package com.xxl.job.controller.resolver;
package com.xxl.job.admin.controller.resolver;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -10,8 +10,8 @@ import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
import com.xxl.job.client.util.JacksonUtil;
import com.xxl.job.core.model.ReturnT;
import com.xxl.job.admin.core.model.ReturnT;
import com.xxl.job.core.util.JacksonUtil;
/**
* common exception resolver

@ -1,4 +1,4 @@
package com.xxl.job.core.callback;
package com.xxl.job.admin.core.callback;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler;
@ -9,13 +9,13 @@ import org.eclipse.jetty.util.thread.ExecutorThreadPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.xxl.job.client.util.IpUtil;
import com.xxl.job.core.util.IpUtil;
/**
* Created by xuxueli on 2016-5-22 11:15:42
*/
public class XxlJobCallbackServer {
private static final Logger logger = LoggerFactory.getLogger(XxlJobCallbackServer.class);
public class XxlJobLogCallbackServer {
private static final Logger logger = LoggerFactory.getLogger(XxlJobLogCallbackServer.class);
private static String trigger_log_address;
public static String getTrigger_log_address() {
@ -43,7 +43,7 @@ public class XxlJobCallbackServer {
// handler
HandlerCollection handlerc =new HandlerCollection();
handlerc.setHandlers(new Handler[]{new XxlJobCallbackServerHandler()});
handlerc.setHandlers(new Handler[]{new XxlJobLogCallbackServerHandler()});
server.setHandler(handlerc);
try {

@ -1,4 +1,4 @@
package com.xxl.job.core.callback;
package com.xxl.job.admin.core.callback;
import java.io.IOException;
import java.util.Date;
@ -11,15 +11,15 @@ import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
import com.xxl.job.client.util.HttpUtil.RemoteCallBack;
import com.xxl.job.client.util.JacksonUtil;
import com.xxl.job.core.model.XxlJobLog;
import com.xxl.job.core.util.DynamicSchedulerUtil;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.core.util.DynamicSchedulerUtil;
import com.xxl.job.core.util.HttpUtil.RemoteCallBack;
import com.xxl.job.core.util.JacksonUtil;
/**
* Created by xuxueli on 2016-5-22 11:15:42
*/
public class XxlJobCallbackServerHandler extends AbstractHandler {
public class XxlJobLogCallbackServerHandler extends AbstractHandler {
@Override
public void handle(String s, Request baseRequest, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {

@ -1,3 +1,4 @@
package com.xxl.job.admin.core.jobbean;
//package com.xxl.job.service.job;
//
//import java.io.PrintWriter;

@ -1,4 +1,4 @@
package com.xxl.job.service.job;
package com.xxl.job.admin.core.jobbean;
import java.util.Date;
import java.util.HashMap;
@ -11,15 +11,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.quartz.QuartzJobBean;
import com.xxl.job.client.handler.HandlerRepository;
import com.xxl.job.client.util.HttpUtil;
import com.xxl.job.client.util.HttpUtil.RemoteCallBack;
import com.xxl.job.client.util.JacksonUtil;
import com.xxl.job.core.callback.XxlJobCallbackServer;
import com.xxl.job.core.model.XxlJobInfo;
import com.xxl.job.core.model.XxlJobLog;
import com.xxl.job.core.thread.JobMonitorHelper;
import com.xxl.job.core.util.DynamicSchedulerUtil;
import com.xxl.job.admin.core.callback.XxlJobLogCallbackServer;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.core.thread.JobMonitorHelper;
import com.xxl.job.admin.core.util.DynamicSchedulerUtil;
import com.xxl.job.core.handler.HandlerRepository;
import com.xxl.job.core.util.HttpUtil;
import com.xxl.job.core.util.HttpUtil.RemoteCallBack;
import com.xxl.job.core.util.JacksonUtil;
/**
* http job bean
@ -58,7 +58,7 @@ public class RemoteHttpJobBean extends QuartzJobBean {
params.put(HandlerRepository.NAMESPACE, HandlerRepository.NameSpaceEnum.RUN.name());
params.put(HandlerRepository.TRIGGER_LOG_ID, String.valueOf(jobLog.getId()));
params.put(HandlerRepository.TRIGGER_LOG_ADDRESS, XxlJobCallbackServer.getTrigger_log_address());
params.put(HandlerRepository.TRIGGER_LOG_ADDRESS, XxlJobLogCallbackServer.getTrigger_log_address());
params.put(HandlerRepository.HANDLER_NAME, jobDataMap.get(HandlerRepository.HANDLER_NAME));
params.put(HandlerRepository.HANDLER_PARAMS, jobDataMap.get(HandlerRepository.HANDLER_PARAMS));

@ -1,3 +1,4 @@
package com.xxl.job.admin.core.jobbean.impl;
//package com.xxl.job.service.job.impl;
//
//import java.util.concurrent.TimeUnit;

@ -1,3 +1,4 @@
package com.xxl.job.admin.core.jobbean.impl;
//package com.xxl.job.service.job.impl;
//
//import java.util.concurrent.TimeUnit;

@ -1,4 +1,4 @@
package com.xxl.job.core.model;
package com.xxl.job.admin.core.model;
/**
* common return

@ -1,4 +1,4 @@
package com.xxl.job.core.model;
package com.xxl.job.admin.core.model;
import java.util.Date;

@ -1,4 +1,4 @@
package com.xxl.job.core.model;
package com.xxl.job.admin.core.model;
import java.util.Date;

@ -1,4 +1,4 @@
package com.xxl.job.core.model;
package com.xxl.job.admin.core.model;
/**
* xxl-job log for glue, used to track job code process

@ -1,4 +1,4 @@
package com.xxl.job.core.thread;
package com.xxl.job.admin.core.thread;
import java.text.MessageFormat;
import java.util.concurrent.ConcurrentHashMap;
@ -11,11 +11,11 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.xxl.job.client.util.HttpUtil.RemoteCallBack;
import com.xxl.job.core.model.XxlJobInfo;
import com.xxl.job.core.model.XxlJobLog;
import com.xxl.job.core.util.DynamicSchedulerUtil;
import com.xxl.job.core.util.MailUtil;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.core.util.DynamicSchedulerUtil;
import com.xxl.job.admin.core.util.MailUtil;
import com.xxl.job.core.util.HttpUtil.RemoteCallBack;
/**
* job monitor helper
@ -62,7 +62,7 @@ public class JobMonitorHelper {
XxlJobInfo info = DynamicSchedulerUtil.xxlJobInfoDao.load(log.getJobGroup(), log.getJobName());
if (count >= info.getAlarmThreshold()) {
MailUtil.sendMail(info.getAlarmEmail(), "《调度平台中心-监控报警》",
MessageFormat.format("调度任务[{0}]失败报警,连续失败次数:", monotorKey, count), false, null);
MessageFormat.format("调度任务[{0}]失败报警,连续失败次数:{1}", monotorKey, count), false, null);
countMap.remove(monotorKey);
}
}

@ -1,4 +1,4 @@
package com.xxl.job.core.util;
package com.xxl.job.admin.core.util;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

@ -1,4 +1,4 @@
package com.xxl.job.core.util;
package com.xxl.job.admin.core.util;
import java.util.ArrayList;
import java.util.Date;
@ -31,11 +31,11 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.util.Assert;
import com.xxl.job.client.util.JacksonUtil;
import com.xxl.job.core.callback.XxlJobCallbackServer;
import com.xxl.job.core.model.XxlJobInfo;
import com.xxl.job.dao.IXxlJobInfoDao;
import com.xxl.job.dao.IXxlJobLogDao;
import com.xxl.job.admin.core.callback.XxlJobLogCallbackServer;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
import com.xxl.job.admin.dao.IXxlJobLogDao;
import com.xxl.job.core.util.JacksonUtil;
/**
* base quartz scheduler util
@ -60,7 +60,7 @@ public final class DynamicSchedulerUtil implements ApplicationContextAware, Init
public void init(){
try {
// start callback server
new XxlJobCallbackServer().start(callBackPort);
new XxlJobLogCallbackServer().start(callBackPort);
} catch (Exception e) {
e.printStackTrace();
}

@ -1,4 +1,4 @@
package com.xxl.job.core.util;
package com.xxl.job.admin.core.util;
import java.io.File;
import java.util.Properties;

@ -1,4 +1,4 @@
package com.xxl.job.core.util;
package com.xxl.job.admin.core.util;
import java.io.FileInputStream;
import java.io.IOException;

@ -1,8 +1,9 @@
package com.xxl.job.dao;
package com.xxl.job.admin.dao;
import java.util.List;
import com.xxl.job.core.model.XxlJobInfo;
import com.xxl.job.admin.core.model.XxlJobInfo;
/**
* job info

@ -1,9 +1,9 @@
package com.xxl.job.dao;
package com.xxl.job.admin.dao;
import java.util.Date;
import java.util.List;
import com.xxl.job.core.model.XxlJobLog;
import com.xxl.job.admin.core.model.XxlJobLog;
/**
* job log

@ -1,8 +1,8 @@
package com.xxl.job.dao;
package com.xxl.job.admin.dao;
import java.util.List;
import com.xxl.job.core.model.XxlJobLogGlue;
import com.xxl.job.admin.core.model.XxlJobLogGlue;
/**
* job log for glue

@ -1,4 +1,4 @@
package com.xxl.job.dao.impl;
package com.xxl.job.admin.dao.impl;
import java.util.HashMap;
import java.util.List;
@ -8,8 +8,8 @@ import javax.annotation.Resource;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
import com.xxl.job.core.model.XxlJobInfo;
import com.xxl.job.dao.IXxlJobInfoDao;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
/**
* job info

@ -1,4 +1,4 @@
package com.xxl.job.dao.impl;
package com.xxl.job.admin.dao.impl;
import java.util.Date;
import java.util.HashMap;
@ -9,8 +9,8 @@ import javax.annotation.Resource;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
import com.xxl.job.core.model.XxlJobLog;
import com.xxl.job.dao.IXxlJobLogDao;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.dao.IXxlJobLogDao;
/**
* job log

@ -1,4 +1,4 @@
package com.xxl.job.dao.impl;
package com.xxl.job.admin.dao.impl;
import java.util.HashMap;
import java.util.List;
@ -8,8 +8,8 @@ import javax.annotation.Resource;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
import com.xxl.job.core.model.XxlJobLogGlue;
import com.xxl.job.dao.IXxlJobLogGlueDao;
import com.xxl.job.admin.core.model.XxlJobLogGlue;
import com.xxl.job.admin.dao.IXxlJobLogGlueDao;
/**
* job log for glue

@ -9,8 +9,7 @@
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<context:annotation-config />
<context:component-scan base-package="com.xxl.job.service, com.xxl.job.dao" />
<context:component-scan base-package="com.xxl.job.admin.dao" />
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/template/" />
@ -21,13 +20,4 @@
</property>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="fileEncoding" value="utf-8" />
<property name="locations">
<list>
<value>classpath*:jdbc.properties</value>
</list>
</property>
</bean>
</beans>

@ -11,10 +11,18 @@
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="com.xxl.service.impl, com.xxl.dao.impl" />
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="fileEncoding" value="utf-8" />
<property name="locations">
<list>
<value>classpath*:jdbc.properties</value>
</list>
</property>
</bean>
<!-- part 1 :for datasource -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${c3p0.driverClass}" />
<property name="jdbcUrl" value="${c3p0.url}" />
@ -38,5 +46,29 @@
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
<!-- part 2 :for tx -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="detail*" propagation="SUPPORTS" />
<tx:method name="visit*" propagation="SUPPORTS" />
<tx:method name="get*" propagation="SUPPORTS" />
<tx:method name="find*" propagation="SUPPORTS" />
<tx:method name="check*" propagation="SUPPORTS" />
<tx:method name="list*" propagation="SUPPORTS" />
<tx:method name="*" propagation="REQUIRED" rollback-for="exception" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="txoperation" expression="execution(* com.xxl.job.admin.service.imp.*.*(..))" />
<aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
</aop:config>
</beans>

@ -18,7 +18,7 @@
</bean>
<!-- 协同-调度器 -->
<bean id="dynamicSchedulerUtil" class="com.xxl.job.core.util.DynamicSchedulerUtil" init-method="init">
<bean id="dynamicSchedulerUtil" class="com.xxl.job.admin.core.util.DynamicSchedulerUtil" init-method="init">
<!-- (轻易不要变更“调度器名称”, 任务创建时会绑定该“调度器名称”) -->
<property name="scheduler" ref="quartzScheduler"/>
<property name="callBackPort" value="8888"/>

@ -1,38 +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" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="detail*" propagation="SUPPORTS" />
<tx:method name="visit*" propagation="SUPPORTS" />
<tx:method name="get*" propagation="SUPPORTS" />
<tx:method name="find*" propagation="SUPPORTS" />
<tx:method name="check*" propagation="SUPPORTS" />
<tx:method name="list*" propagation="SUPPORTS" />
<tx:method name="*" propagation="REQUIRED" rollback-for="exception" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="txoperation" expression="execution(* com.xxl.service.imp.*.*(..))" />
<aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
</aop:config>
</beans>

@ -3,7 +3,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="XxlJobInfoMapper">
<resultMap id="XxlJobInfo" type="com.xxl.job.core.model.XxlJobInfo" >
<resultMap id="XxlJobInfo" type="com.xxl.job.admin.core.model.XxlJobInfo" >
<result column="id" property="id" />
<result column="job_group" property="jobGroup" />
@ -71,7 +71,7 @@
</trim>
</select>
<insert id="save" parameterType="com.xxl.job.core.model.XxlJobInfo" useGeneratedKeys="true" keyProperty="id" >
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" useGeneratedKeys="true" keyProperty="id" >
INSERT INTO `xxl_job_qrtz_trigger_info` (
job_group,
job_name,
@ -115,7 +115,7 @@
AND t.job_name = #{jobName}
</select>
<update id="update" parameterType="com.xxl.job.core.model.XxlJobInfo" >
<update id="update" parameterType="com.xxl.job.admin.core.model.XxlJobInfo" >
UPDATE `xxl_job_qrtz_trigger_info`
SET
job_cron = #{jobCron},

@ -3,7 +3,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="XxlJobLogGlueMapper">
<resultMap id="XxlJobLogGlue" type="com.xxl.job.core.model.XxlJobLogGlue" >
<resultMap id="XxlJobLogGlue" type="com.xxl.job.admin.core.model.XxlJobLogGlue" >
<result column="id" property="id" />
<result column="job_group" property="jobGroup" />
<result column="job_name" property="jobName" />
@ -23,7 +23,7 @@
t.update_time
</sql>
<insert id="save" parameterType="com.xxl.job.core.model.XxlJobLogGlue" useGeneratedKeys="true" keyProperty="id" >
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobLogGlue" useGeneratedKeys="true" keyProperty="id" >
INSERT INTO `xxl_job_qrtz_trigger_logglue` (
`job_group`,
`job_name`,

@ -3,7 +3,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="XxlJobLogMapper">
<resultMap id="XxlJobLog" type="com.xxl.job.core.model.XxlJobLog" >
<resultMap id="XxlJobLog" type="com.xxl.job.admin.core.model.XxlJobLog" >
<result column="id" property="id" />
<result column="job_group" property="jobGroup" />
@ -91,7 +91,7 @@
AND t.job_name = #{jobName}
</select>
<insert id="save" parameterType="com.xxl.job.core.model.XxlJobLog" useGeneratedKeys="true" keyProperty="id" >
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobLog" useGeneratedKeys="true" keyProperty="id" >
INSERT INTO `xxl_job_qrtz_trigger_log` (
`job_group`,
`job_name`,

@ -19,7 +19,7 @@
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="com.xxl.job.controller" />
<context:component-scan base-package="com.xxl.job.admin.controller" />
<mvc:resources mapping="/favicon.ico" location="/favicon.ico" />
<mvc:resources mapping="/static/**" location="/static/" />
@ -41,13 +41,13 @@
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<bean class="com.xxl.job.controller.interceptor.PermissionInterceptor"/>
<bean class="com.xxl.job.admin.controller.interceptor.PermissionInterceptor"/>
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<bean class="com.xxl.job.controller.interceptor.CookieInterceptor"/>
<bean class="com.xxl.job.admin.controller.interceptor.CookieInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>
<bean id="exceptionResolver" class="com.xxl.job.controller.resolver.WebExceptionResolver" />
<bean id="exceptionResolver" class="com.xxl.job.admin.controller.resolver.WebExceptionResolver" />
</beans>

@ -9,8 +9,8 @@ import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.xxl.job.core.model.XxlJobInfo;
import com.xxl.job.dao.IXxlJobInfoDao;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.dao.IXxlJobInfoDao;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:applicationcontext-*.xml")

@ -10,10 +10,10 @@ import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.xxl.job.client.handler.IJobHandler;
import com.xxl.job.client.util.HttpUtil.RemoteCallBack;
import com.xxl.job.core.model.XxlJobLog;
import com.xxl.job.dao.IXxlJobLogDao;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.dao.IXxlJobLogDao;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.util.HttpUtil.RemoteCallBack;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:applicationcontext-*.xml")

@ -1,25 +0,0 @@
package com.xxl.job.service.handler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.xxl.job.client.handler.IJobHandler;
import com.xxl.job.client.handler.annotation.JobHander;
/**
* demo job handler
* @author xuxueli 2015-12-19 19:43:36
*/
@JobHander(name="demoJobHandler")
@Service
public class DemoJobHandler extends IJobHandler {
private static transient Logger logger = LoggerFactory.getLogger(DemoJobHandler.class);
@Override
public JobHandleStatus handle(String... params) throws Exception {
logger.info("XXL-JOB, Hello World.");
return JobHandleStatus.SUCCESS;
}
}

@ -3,3 +3,4 @@
/.project
/.settings/
/xxl-job-client.iml
/target/

@ -6,7 +6,7 @@
<artifactId>xxl-job</artifactId>
<version>1.3.0-SNAPSHOT</version>
</parent>
<artifactId>xxl-job-client</artifactId>
<artifactId>xxl-job-core</artifactId>
<version>1.3.1</version>
<dependencies>

@ -1,4 +1,4 @@
package com.xxl.job.client.netcom.jetty;
package com.xxl.job.core.executor.jetty;
import java.util.Map;
@ -14,15 +14,15 @@ import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import com.xxl.job.client.handler.HandlerRepository;
import com.xxl.job.client.handler.IJobHandler;
import com.xxl.job.client.handler.annotation.JobHander;
import com.xxl.job.core.handler.HandlerRepository;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHander;
/**
* Created by xuxueli on 2016/3/2 21:14.
*/
public class XxlJobJettyServer implements ApplicationContextAware {
private static final Logger logger = LoggerFactory.getLogger(XxlJobJettyServer.class);
public class XxlJobExecutor implements ApplicationContextAware {
private static final Logger logger = LoggerFactory.getLogger(XxlJobExecutor.class);
private int port = 9999;
public void setPort(int port) {
@ -45,7 +45,7 @@ public class XxlJobJettyServer implements ApplicationContextAware {
// handler
HandlerCollection handlerc =new HandlerCollection();
handlerc.setHandlers(new Handler[]{new XxlJobJettyServerHandler()});
handlerc.setHandlers(new Handler[]{new XxlJobExecutorHandler()});
server.setHandler(handlerc);
try {
@ -64,7 +64,7 @@ public class XxlJobJettyServer implements ApplicationContextAware {
public static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
XxlJobJettyServer.applicationContext = applicationContext;
XxlJobExecutor.applicationContext = applicationContext;
initJobHandler();
}
@ -72,7 +72,7 @@ public class XxlJobJettyServer implements ApplicationContextAware {
* init job handler service
*/
public void initJobHandler(){
Map<String, Object> serviceBeanMap = XxlJobJettyServer.applicationContext.getBeansWithAnnotation(JobHander.class);
Map<String, Object> serviceBeanMap = XxlJobExecutor.applicationContext.getBeansWithAnnotation(JobHander.class);
if (serviceBeanMap!=null && serviceBeanMap.size()>0) {
for (Object serviceBean : serviceBeanMap.values()) {
String jobName = serviceBean.getClass().getAnnotation(JobHander.class).name();

@ -1,6 +1,6 @@
package com.xxl.job.client.netcom.jetty;
package com.xxl.job.core.executor.jetty;
import com.xxl.job.client.handler.HandlerRepository;
import com.xxl.job.core.handler.HandlerRepository;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
@ -14,7 +14,7 @@ import java.util.Map;
/**
* Created by xuxueli on 2016/3/2 21:23.
*/
public class XxlJobJettyServerHandler extends AbstractHandler {
public class XxlJobExecutorHandler extends AbstractHandler {
@Override
public void handle(String s, Request baseRequest, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {

@ -1,4 +1,4 @@
package com.xxl.job.client.glue;
package com.xxl.job.core.glue;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@ -13,10 +13,10 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.annotation.AnnotationUtils;
import com.xxl.job.client.glue.cache.LocalCache;
import com.xxl.job.client.glue.loader.GlueLoader;
import com.xxl.job.client.handler.IJobHandler;
import com.xxl.job.client.handler.IJobHandler.JobHandleStatus;
import com.xxl.job.core.glue.cache.LocalCache;
import com.xxl.job.core.glue.loader.GlueLoader;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.IJobHandler.JobHandleStatus;
import groovy.lang.GroovyClassLoader;
@ -158,7 +158,7 @@ public class GlueFactory implements ApplicationContextAware {
// ----------------------------- util -----------------------------
public static JobHandleStatus glue(String job_group, String job_name, String... params) throws Exception{
return GlueFactory.glueFactory.loadInstance(job_group, job_name).handle(params);
return GlueFactory.glueFactory.loadInstance(job_group, job_name).execute(params);
}
}

@ -1,4 +1,4 @@
package com.xxl.job.client.glue.cache;
package com.xxl.job.core.glue.cache;
/**
* chche interface

@ -1,4 +1,4 @@
package com.xxl.job.client.glue.cache;
package com.xxl.job.core.glue.cache;
import java.util.concurrent.ConcurrentHashMap;

@ -1,4 +1,4 @@
package com.xxl.job.client.glue.loader;
package com.xxl.job.core.glue.loader;
/**
* code source loader

@ -1,4 +1,4 @@
package com.xxl.job.client.handler;
package com.xxl.job.core.handler;
import java.util.Date;
import java.util.Map;
@ -7,10 +7,10 @@ import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.xxl.job.client.handler.impl.GlueJobHandler;
import com.xxl.job.client.log.XxlJobFileAppender;
import com.xxl.job.client.util.HttpUtil.RemoteCallBack;
import com.xxl.job.client.util.JacksonUtil;
import com.xxl.job.core.handler.impl.GlueJobHandler;
import com.xxl.job.core.log.XxlJobFileAppender;
import com.xxl.job.core.util.HttpUtil.RemoteCallBack;
import com.xxl.job.core.util.JacksonUtil;
/**
* handler repository

@ -1,4 +1,4 @@
package com.xxl.job.client.handler;
package com.xxl.job.core.handler;
import java.io.PrintWriter;
import java.io.StringWriter;
@ -11,10 +11,10 @@ import org.eclipse.jetty.util.ConcurrentHashSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.xxl.job.client.handler.IJobHandler.JobHandleStatus;
import com.xxl.job.client.log.XxlJobFileAppender;
import com.xxl.job.client.util.HttpUtil;
import com.xxl.job.client.util.HttpUtil.RemoteCallBack;
import com.xxl.job.core.handler.IJobHandler.JobHandleStatus;
import com.xxl.job.core.log.XxlJobFileAppender;
import com.xxl.job.core.util.HttpUtil;
import com.xxl.job.core.util.HttpUtil.RemoteCallBack;
/**
* handler thread
@ -79,7 +79,7 @@ public class HandlerThread extends Thread{
try {
XxlJobFileAppender.contextHolder.set(trigger_log_id);
logger.info(">>>>>>>>>>> xxl-job handle start.");
_status = handler.handle(handlerParams);
_status = handler.execute(handlerParams);
} catch (Exception e) {
logger.info("HandlerThread Exception:", e);
StringWriter out = new StringWriter();

@ -1,4 +1,4 @@
package com.xxl.job.client.handler;
package com.xxl.job.core.handler;
/**
* remote job handler
@ -13,7 +13,7 @@ public abstract class IJobHandler extends HandlerRepository{
* @return
* @throws Exception
*/
public abstract JobHandleStatus handle(String... params) throws Exception;
public abstract JobHandleStatus execute(String... params) throws Exception;
public static enum JobHandleStatus{
/**

@ -1,4 +1,4 @@
package com.xxl.job.client.handler.annotation;
package com.xxl.job.core.handler.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

@ -1,7 +1,7 @@
package com.xxl.job.client.handler.impl;
package com.xxl.job.core.handler.impl;
import com.xxl.job.client.glue.GlueFactory;
import com.xxl.job.client.handler.IJobHandler;
import com.xxl.job.core.glue.GlueFactory;
import com.xxl.job.core.handler.IJobHandler;
/**
* glue job handler
@ -17,7 +17,7 @@ public class GlueJobHandler extends IJobHandler {
}
@Override
public JobHandleStatus handle(String... params) throws Exception {
public JobHandleStatus execute(String... params) throws Exception {
return GlueFactory.glue(job_group, job_name, params);
}

@ -1,4 +1,4 @@
package com.xxl.job.client.log;
package com.xxl.job.core.log;
import java.io.BufferedReader;
import java.io.File;

@ -1,4 +1,4 @@
package com.xxl.job.client.util;
package com.xxl.job.core.util;
import java.io.IOException;
import java.io.PrintWriter;

@ -1,4 +1,4 @@
package com.xxl.job.client.util;
package com.xxl.job.core.util;
import java.net.InetAddress;
import java.net.NetworkInterface;

@ -1,4 +1,4 @@
package com.xxl.job.client.util;
package com.xxl.job.core.util;
import java.io.IOException;

@ -3,3 +3,4 @@
/.project
/.settings/
/xxl-job-client-demo.iml
/target/

@ -6,7 +6,7 @@
<artifactId>xxl-job</artifactId>
<version>1.3.0-SNAPSHOT</version>
</parent>
<artifactId>xxl-job-client-demo</artifactId>
<artifactId>xxl-job-executor-example</artifactId>
<version>1.3.1-SNAPSHOT</version>
<packaging>war</packaging>
@ -75,10 +75,10 @@
<version>5.1.29</version>
</dependency>
<!-- xxl-job-client -->
<!-- xxl-job-core -->
<dependency>
<groupId>com.xxl</groupId>
<artifactId>xxl-job-client</artifactId>
<artifactId>xxl-job-core</artifactId>
<version>1.3.1</version>
</dependency>

@ -1,13 +1,17 @@
package com.xxl.job.service.loader;
package com.xxl.job.executor.loader;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.xxl.job.client.glue.loader.GlueLoader;
import com.xxl.job.dao.IXxlJobInfoDao;
import com.xxl.job.dao.model.XxlJobInfo;
import com.xxl.job.core.glue.loader.GlueLoader;
import com.xxl.job.executor.loader.dao.IXxlJobInfoDao;
import com.xxl.job.executor.loader.dao.model.XxlJobInfo;
/**
* GLUE RPC
* @author xuxueli
*/
@Service("dbGlueLoader")
public class DbGlueLoader implements GlueLoader {

@ -1,6 +1,6 @@
package com.xxl.job.dao;
package com.xxl.job.executor.loader.dao;
import com.xxl.job.dao.model.XxlJobInfo;
import com.xxl.job.executor.loader.dao.model.XxlJobInfo;
/**
* job log for glue

@ -1,4 +1,4 @@
package com.xxl.job.dao.impl;
package com.xxl.job.executor.loader.dao.impl;
import java.util.HashMap;
@ -7,8 +7,9 @@ import javax.annotation.Resource;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
import com.xxl.job.dao.IXxlJobInfoDao;
import com.xxl.job.dao.model.XxlJobInfo;
import com.xxl.job.executor.loader.dao.IXxlJobInfoDao;
import com.xxl.job.executor.loader.dao.model.XxlJobInfo;
/**
* job log for glue

@ -0,0 +1,32 @@
package com.xxl.job.executor.service.jobhandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHander;
/**
* HandlerDemoBean
*
*
* 1 IJobHandler
* 2Spring @Service
* 3 @JobHander namename使
*
* @author xuxueli 2015-12-19 19:43:36
*/
@JobHander(name="demoJobHandler")
@Service
public class DemoJobHandler extends IJobHandler {
private static transient Logger logger = LoggerFactory.getLogger(DemoJobHandler.class);
@Override
public JobHandleStatus execute(String... params) throws Exception {
logger.info("XXL-JOB, Hello World.");
return JobHandleStatus.SUCCESS;
}
}

@ -12,8 +12,6 @@
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:component-scan base-package="com.xxl.job.service, com.xxl.job.dao" />
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="fileEncoding" value="utf-8" />
<property name="locations">

@ -9,16 +9,16 @@
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<context:component-scan base-package="com.xxl.job.service" />
<context:component-scan base-package="com.xxl.job.executor" />
<!-- 执行器 -->
<bean id="xxlJobJettyServer" class="com.xxl.job.client.netcom.jetty.XxlJobJettyServer" init-method="start">
<bean id="xxlJobJettyServer" class="com.xxl.job.core.executor.jetty.XxlJobExecutor" init-method="start">
<property name="port" value="9999" />
</bean>
<bean id="glueFactory" class="com.xxl.job.client.glue.GlueFactory">
<bean id="glueFactory" class="com.xxl.job.core.glue.GlueFactory">
<property name="cacheTimeout" value="5000" />
<property name="glueLoader" ref="dbGlueLoader" />
<property name="glueLoader" ref="dbGlueLoader" /> <!-- GLUE 代码加载器推荐将该服务配置成RPC服务 -->
</bean>
</beans>

@ -18,7 +18,7 @@
</layout>
</appender>
<appender name="xxl-job" class="com.xxl.job.client.log.XxlJobFileAppender">
<appender name="xxl-job" class="com.xxl.job.core.log.XxlJobFileAppender">
<param name="filePath" value="/logs/xxl-job/"/>
<param name="append" value="true"/>
<param name="encoding" value="UTF-8"/>

@ -3,7 +3,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="XxlJobInfoMapper">
<resultMap id="XxlJobInfo" type="com.xxl.job.dao.model.XxlJobInfo" >
<resultMap id="XxlJobInfo" type="com.xxl.job.executor.loader.dao.model.XxlJobInfo" >
<result column="job_group" property="jobGroup" />
<result column="job_name" property="jobName" />
<result column="glue_source" property="glueSource" />
Loading…
Cancel
Save