22
22
import java .util .Set ;
23
23
import java .util .function .Function ;
24
24
25
- import org .springframework .integration .core .GenericSelector ;
26
- import org .springframework .integration .transformer .GenericTransformer ;
27
25
import org .springframework .util .ReflectionUtils ;
28
26
29
27
/**
@@ -41,23 +39,48 @@ public abstract class ClassUtils {
41
39
ReflectionUtils .findMethod (Function .class , "apply" , (Class <?>[]) null );
42
40
43
41
/**
44
- * The {@link GenericSelector#accept(Object)} method object.
42
+ * The {@code org.springframework.integration.core. GenericSelector#accept(Object)} method object.
45
43
*/
46
- public static final Method SELECTOR_ACCEPT_METHOD =
47
- ReflectionUtils .findMethod (GenericSelector .class , "accept" , (Class <?>[]) null );
44
+ public static final Method SELECTOR_ACCEPT_METHOD ;
48
45
49
46
/**
50
- * The {@link GenericSelector#accept (Object)} method object.
47
+ * The {@code org.springframework.integration.transformer.GenericTransformer#transform (Object)} method object.
51
48
*/
52
- public static final Method TRANSFORMER_TRANSFORM_METHOD =
53
- ReflectionUtils .findMethod (GenericTransformer .class , "transform" , (Class <?>[]) null );
49
+ public static final Method TRANSFORMER_TRANSFORM_METHOD ;
54
50
55
51
/**
56
52
* The {@code org.springframework.integration.handler.GenericHandler#handle(Object, Map)} method object.
57
53
*/
58
54
public static final Method HANDLER_HANDLE_METHOD ;
59
55
60
56
static {
57
+ Class <?> genericSelectorClass = null ;
58
+ try {
59
+ genericSelectorClass =
60
+ org .springframework .util .ClassUtils .forName (
61
+ "org.springframework.integration.core.GenericSelector" ,
62
+ org .springframework .util .ClassUtils .getDefaultClassLoader ());
63
+ }
64
+ catch (ClassNotFoundException e ) {
65
+ ReflectionUtils .rethrowRuntimeException (e );
66
+ }
67
+
68
+ SELECTOR_ACCEPT_METHOD = ReflectionUtils .findMethod (genericSelectorClass , "accept" , (Class <?>[]) null );
69
+
70
+ Class <?> genericTransformerClass = null ;
71
+ try {
72
+ genericTransformerClass =
73
+ org .springframework .util .ClassUtils .forName (
74
+ "org.springframework.integration.transformer.GenericTransformer" ,
75
+ org .springframework .util .ClassUtils .getDefaultClassLoader ());
76
+ }
77
+ catch (ClassNotFoundException e ) {
78
+ ReflectionUtils .rethrowRuntimeException (e );
79
+ }
80
+
81
+ TRANSFORMER_TRANSFORM_METHOD =
82
+ ReflectionUtils .findMethod (genericTransformerClass , "transform" , (Class <?>[]) null );
83
+
61
84
Class <?> genericHandlerClass = null ;
62
85
try {
63
86
genericHandlerClass =
@@ -77,7 +100,7 @@ public abstract class ClassUtils {
77
100
* Map with primitive wrapper type as key and corresponding primitive
78
101
* type as value, for example: Integer.class -> int.class.
79
102
*/
80
- private static final Map <Class <?>, Class <?>> primitiveWrapperTypeMap = new HashMap <Class <?>, Class <?> >(8 );
103
+ private static final Map <Class <?>, Class <?>> primitiveWrapperTypeMap = new HashMap <>(8 );
81
104
82
105
83
106
static {
@@ -102,8 +125,8 @@ public static Class<?> findClosestMatch(Class<?> type, Set<Class<?>> candidates,
102
125
}
103
126
else if (failOnTie && typeDiffWeight < Integer .MAX_VALUE && (typeDiffWeight == minTypeDiffWeight )) {
104
127
throw new IllegalStateException ("Unresolvable ambiguity while attempting to find closest match for [" +
105
- type .getName () + "]. Candidate types [" + closestMatch .getName () + "] and [" + candidate . getName () +
106
- "] have equal weight." );
128
+ type .getName () + "]. Candidate types [" + closestMatch .getName () + "] and [" +
129
+ candidate . getName () + "] have equal weight." );
107
130
}
108
131
}
109
132
return closestMatch ;
0 commit comments