16
16
17
17
package org .springframework .boot .devtools .restart ;
18
18
19
+ import java .util .Collections ;
20
+ import java .util .LinkedHashSet ;
21
+ import java .util .Set ;
22
+
19
23
import org .springframework .util .ClassUtils ;
20
24
21
25
/**
26
30
*/
27
31
public abstract class AgentReloader {
28
32
33
+ private static final Set <String > AGENT_CLASSES ;
34
+
35
+ static {
36
+ Set <String > agentClasses = new LinkedHashSet <String >();
37
+ agentClasses .add ("org.zeroturnaround.javarebel.Integration" );
38
+ agentClasses .add ("org.zeroturnaround.javarebel.ReloaderFactory" );
39
+ AGENT_CLASSES = Collections .unmodifiableSet (agentClasses );
40
+ }
41
+
29
42
private AgentReloader () {
30
43
}
31
44
@@ -34,15 +47,17 @@ private AgentReloader() {
34
47
* @return true if agent reloading is active
35
48
*/
36
49
public static boolean isActive () {
37
- return isJRebelActive ();
50
+ return isActive (null ) || isActive (AgentReloader .class .getClassLoader ())
51
+ || isActive (ClassLoader .getSystemClassLoader ());
38
52
}
39
53
40
- /**
41
- * Determine if JRebel is active.
42
- * @return true if JRebel is active
43
- */
44
- public static boolean isJRebelActive () {
45
- return ClassUtils .isPresent ("org.zeroturnaround.javarebel.ReloaderFactory" , null );
54
+ private static boolean isActive (ClassLoader classLoader ) {
55
+ for (String agentClass : AGENT_CLASSES ) {
56
+ if (ClassUtils .isPresent (agentClass , classLoader )) {
57
+ return true ;
58
+ }
59
+ }
60
+ return false ;
46
61
}
47
62
48
63
}
0 commit comments