Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
熊鹏飞
/
xxljob220
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0f0906ee
authored
Mar 12, 2016
by
xueli.xue
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
重构调度服务注入方式
parent
d81b0749
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
16 deletions
xxl-job-admin/src/main/java/com/xxl/job/core/util/DynamicSchedulerUtil.java
xxl-job-admin/src/main/java/com/xxl/job/service/job/impl/DemoConcurrentJobBean.java
xxl-job-admin/src/main/java/com/xxl/job/service/job/impl/DemoNomalJobBean.java
xxl-job-admin/src/main/java/com/xxl/job/core/util/DynamicSchedulerUtil.java
View file @
0f0906ee
...
@@ -8,8 +8,6 @@ import java.util.List;
...
@@ -8,8 +8,6 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
import
javax.annotation.Resource
;
import
org.quartz.CronScheduleBuilder
;
import
org.quartz.CronScheduleBuilder
;
import
org.quartz.CronTrigger
;
import
org.quartz.CronTrigger
;
import
org.quartz.Job
;
import
org.quartz.Job
;
...
@@ -27,7 +25,10 @@ import org.quartz.impl.matchers.GroupMatcher;
...
@@ -27,7 +25,10 @@ import org.quartz.impl.matchers.GroupMatcher;
import
org.quartz.impl.triggers.CronTriggerImpl
;
import
org.quartz.impl.triggers.CronTriggerImpl
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
com.xxl.job.client.util.JacksonUtil
;
import
com.xxl.job.client.util.JacksonUtil
;
...
@@ -39,32 +40,30 @@ import com.xxl.job.dao.IXxlJobLogDao;
...
@@ -39,32 +40,30 @@ import com.xxl.job.dao.IXxlJobLogDao;
* base quartz scheduler util
* base quartz scheduler util
* @author xuxueli 2015-12-19 16:13:53
* @author xuxueli 2015-12-19 16:13:53
*/
*/
public
final
class
DynamicSchedulerUtil
implements
InitializingBean
{
public
final
class
DynamicSchedulerUtil
implements
ApplicationContextAware
,
InitializingBean
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
DynamicSchedulerUtil
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
DynamicSchedulerUtil
.
class
);
// xxlJobLogDao
public
static
IXxlJobLogDao
xxlJobLogDao
;
@Resource
public
void
setXxlJobLogDao
(
IXxlJobLogDao
xxlJobLogDao
)
{
DynamicSchedulerUtil
.
xxlJobLogDao
=
xxlJobLogDao
;
}
// xxlJobInfoDao
public
static
IXxlJobInfoDao
xxlJobInfoDao
;
@Resource
public
void
setXxlJobInfoDao
(
IXxlJobInfoDao
xxlJobInfoDao
)
{
DynamicSchedulerUtil
.
xxlJobInfoDao
=
xxlJobInfoDao
;
}
// Scheduler
// Scheduler
private
static
Scheduler
scheduler
;
private
static
Scheduler
scheduler
;
public
static
void
setScheduler
(
Scheduler
scheduler
)
{
public
static
void
setScheduler
(
Scheduler
scheduler
)
{
DynamicSchedulerUtil
.
scheduler
=
scheduler
;
DynamicSchedulerUtil
.
scheduler
=
scheduler
;
}
}
// xxlJobLogDao、xxlJobInfoDao
public
static
IXxlJobLogDao
xxlJobLogDao
;
public
static
IXxlJobInfoDao
xxlJobInfoDao
;
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
DynamicSchedulerUtil
.
xxlJobLogDao
=
applicationContext
.
getBean
(
IXxlJobLogDao
.
class
);
DynamicSchedulerUtil
.
xxlJobInfoDao
=
applicationContext
.
getBean
(
IXxlJobInfoDao
.
class
);
}
@Override
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
public
void
afterPropertiesSet
()
throws
Exception
{
Assert
.
notNull
(
scheduler
,
"quartz scheduler is null"
);
Assert
.
notNull
(
scheduler
,
"quartz scheduler is null"
);
logger
.
info
(
">>>>>>>>> init quartz scheduler success.[{}]"
,
scheduler
);
logger
.
info
(
">>>>>>>>> init quartz scheduler success.[{}]"
,
scheduler
);
}
}
// getJobKeys
// getJobKeys
...
@@ -266,4 +265,5 @@ public final class DynamicSchedulerUtil implements InitializingBean {
...
@@ -266,4 +265,5 @@ public final class DynamicSchedulerUtil implements InitializingBean {
return
result
;
return
result
;
}
}
}
}
\ No newline at end of file
xxl-job-admin/src/main/java/com/xxl/job/service/job/impl/DemoConcurrentJobBean.java
View file @
0f0906ee
...
@@ -6,6 +6,10 @@ import org.quartz.DisallowConcurrentExecution;
...
@@ -6,6 +6,10 @@ import org.quartz.DisallowConcurrentExecution;
import
com.xxl.job.service.job.LocalNomalJobBean
;
import
com.xxl.job.service.job.LocalNomalJobBean
;
/**
* demo job bean for no-concurrent
* @author xuxueli 2016-3-12 14:25:14
*/
@DisallowConcurrentExecution
// 串行;线程数要多配置几个,否则不生效;
@DisallowConcurrentExecution
// 串行;线程数要多配置几个,否则不生效;
public
class
DemoConcurrentJobBean
extends
LocalNomalJobBean
{
public
class
DemoConcurrentJobBean
extends
LocalNomalJobBean
{
...
...
xxl-job-admin/src/main/java/com/xxl/job/service/job/impl/DemoNomalJobBean.java
View file @
0f0906ee
...
@@ -7,6 +7,10 @@ import org.slf4j.LoggerFactory;
...
@@ -7,6 +7,10 @@ import org.slf4j.LoggerFactory;
import
com.xxl.job.service.job.LocalNomalJobBean
;
import
com.xxl.job.service.job.LocalNomalJobBean
;
/**
* demo job bean for concurrent
* @author xuxueli 2016-3-12 14:25:57
*/
public
class
DemoNomalJobBean
extends
LocalNomalJobBean
{
public
class
DemoNomalJobBean
extends
LocalNomalJobBean
{
private
static
Logger
Logger
=
LoggerFactory
.
getLogger
(
DemoNomalJobBean
.
class
);
private
static
Logger
Logger
=
LoggerFactory
.
getLogger
(
DemoNomalJobBean
.
class
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment