|
@@ -1,6 +1,5 @@
|
1
|
1
|
package com.xxl.job.core.glue;
|
2
|
2
|
|
3
|
|
-import com.xxl.job.core.glue.loader.GlueLoader;
|
4
|
3
|
import com.xxl.job.core.handler.IJobHandler;
|
5
|
4
|
import groovy.lang.GroovyClassLoader;
|
6
|
5
|
import org.slf4j.Logger;
|
|
@@ -27,17 +26,6 @@ public class GlueFactory implements ApplicationContextAware {
|
27
|
26
|
* groovy class loader
|
28
|
27
|
*/
|
29
|
28
|
private GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
|
30
|
|
-
|
31
|
|
- /**
|
32
|
|
- * code source loader
|
33
|
|
- */
|
34
|
|
- private GlueLoader glueLoader;
|
35
|
|
- public void setGlueLoader(GlueLoader glueLoader) {
|
36
|
|
- this.glueLoader = glueLoader;
|
37
|
|
- }
|
38
|
|
- public static boolean isActive() {
|
39
|
|
- return GlueFactory.glueFactory.glueLoader!=null;
|
40
|
|
- }
|
41
|
29
|
|
42
|
30
|
// ----------------------------- spring support -----------------------------
|
43
|
31
|
private static ApplicationContext applicationContext;
|
|
@@ -56,7 +44,7 @@ public class GlueFactory implements ApplicationContextAware {
|
56
|
44
|
* inject action of spring
|
57
|
45
|
* @param instance
|
58
|
46
|
*/
|
59
|
|
- public void injectService(Object instance){
|
|
47
|
+ private void injectService(Object instance){
|
60
|
48
|
if (instance==null) {
|
61
|
49
|
return;
|
62
|
50
|
}
|
|
@@ -106,11 +94,7 @@ public class GlueFactory implements ApplicationContextAware {
|
106
|
94
|
|
107
|
95
|
// ----------------------------- load instance -----------------------------
|
108
|
96
|
// load new instance, prototype
|
109
|
|
- public IJobHandler loadNewInstance(int jobId) throws Exception{
|
110
|
|
- if (jobId==0) {
|
111
|
|
- return null;
|
112
|
|
- }
|
113
|
|
- String codeSource = glueLoader.load(jobId);
|
|
97
|
+ public IJobHandler loadNewInstance(String codeSource) throws Exception{
|
114
|
98
|
if (codeSource!=null && codeSource.trim().length()>0) {
|
115
|
99
|
Class<?> clazz = groovyClassLoader.parseClass(codeSource);
|
116
|
100
|
if (clazz != null) {
|