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
66adbd68
authored
May 20, 2016
by
xueli.xue
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
移除clazz缓存
parent
6717d8d5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
35 deletions
xxl-job-client/src/main/java/com/xxl/job/client/glue/GlueFactory.java
xxl-job-client/src/main/java/com/xxl/job/client/glue/GlueFactory.java
View file @
66adbd68
...
...
@@ -101,48 +101,25 @@ public class GlueFactory implements ApplicationContextAware {
}
// ----------------------------- load instance -----------------------------
// load class,
public
static
String
generateClassCacheKey
(
String
job_group
,
String
job_name
){
return
job_group
.
concat
(
"_"
).
concat
(
job_name
).
concat
(
"_class"
);
}
public
Class
<?>
loadClass
(
String
job_group
,
String
job_name
)
throws
Exception
{
// load new instance, prototype
public
IJobHandler
loadNewInstance
(
String
job_group
,
String
job_name
)
throws
Exception
{
if
(
job_group
==
null
||
job_group
.
trim
().
length
()==
0
||
job_name
==
null
||
job_name
.
trim
().
length
()==
0
)
{
return
null
;
}
String
cacheClassKey
=
generateClassCacheKey
(
job_group
,
job_name
);
Object
cacheClass
=
LocalCache
.
getInstance
().
get
(
cacheClassKey
);
if
(
cacheClass
!=
null
)
{
return
(
Class
<?>)
cacheClass
;
}
String
codeSource
=
glueLoader
.
load
(
job_group
,
job_name
);
if
(
codeSource
!=
null
&&
codeSource
.
trim
().
length
()>
0
)
{
Class
<?>
clazz
=
groovyClassLoader
.
parseClass
(
codeSource
);
if
(
clazz
!=
null
)
{
LocalCache
.
getInstance
().
set
(
cacheClassKey
,
clazz
,
cacheTimeout
);
logger
.
info
(
">>>>>>>>>>>> xxl-glue, fresh class, cacheClassKey:{}"
,
cacheClassKey
);
return
clazz
;
}
}
return
null
;
}
// load new instance, prototype
public
IJobHandler
loadNewInstance
(
String
job_group
,
String
job_name
)
throws
Exception
{
if
(
job_group
==
null
||
job_group
.
trim
().
length
()==
0
||
job_name
==
null
||
job_name
.
trim
().
length
()==
0
)
{
return
null
;
}
Class
<?>
clazz
=
loadClass
(
job_group
,
job_name
);
if
(
clazz
!=
null
)
{
Object
instance
=
clazz
.
newInstance
();
if
(
instance
!=
null
)
{
if
(!(
instance
instanceof
IJobHandler
))
{
throw
new
IllegalArgumentException
(
">>>>>>>>>>> xxl-glue, loadNewInstance error, "
+
"cannot convert from instance["
+
instance
.
getClass
()
+
"] to IJobHandler"
);
if
(
clazz
!=
null
)
{
Object
instance
=
clazz
.
newInstance
();
if
(
instance
!=
null
)
{
if
(
instance
instanceof
IJobHandler
)
{
this
.
injectService
(
instance
);
return
(
IJobHandler
)
instance
;
}
else
{
throw
new
IllegalArgumentException
(
">>>>>>>>>>> xxl-glue, loadNewInstance error, "
+
"cannot convert from instance["
+
instance
.
getClass
()
+
"] to IJobHandler"
);
}
}
this
.
injectService
(
instance
);
return
(
IJobHandler
)
instance
;
}
}
throw
new
IllegalArgumentException
(
">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null"
);
...
...
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