@@ -46,7 +46,8 @@ public class ProviderSqlSource implements SqlSource {
46
46
private Integer providerContextIndex ;
47
47
48
48
/**
49
- * @deprecated Please use the {@link #ProviderSqlSource(Configuration, Object, Class, Method)} instead of this.
49
+ * @deprecated Since 3.5.3, Please use the {@link #ProviderSqlSource(Configuration, Annotation, Class, Method)} instead of this.
50
+ * This constructor will remove at a future version.
50
51
*/
51
52
@ Deprecated
52
53
public ProviderSqlSource (Configuration configuration , Object provider ) {
@@ -55,16 +56,26 @@ public ProviderSqlSource(Configuration configuration, Object provider) {
55
56
56
57
/**
57
58
* @since 3.4.5
59
+ * @deprecated Since 3.5.3, Please use the {@link #ProviderSqlSource(Configuration, Annotation, Class, Method)} instead of this.
60
+ * This constructor will remove at a future version.
58
61
*/
62
+ @ Deprecated
59
63
public ProviderSqlSource (Configuration configuration , Object provider , Class <?> mapperType , Method mapperMethod ) {
64
+ this (configuration , (Annotation ) provider , mapperType , mapperMethod );
65
+ }
66
+
67
+ /**
68
+ * @since 3.5.3
69
+ */
70
+ public ProviderSqlSource (Configuration configuration , Annotation provider , Class <?> mapperType , Method mapperMethod ) {
60
71
String providerMethodName ;
61
72
try {
62
73
this .configuration = configuration ;
63
74
this .mapperMethod = mapperMethod ;
64
75
Lang lang = mapperMethod == null ? null : mapperMethod .getAnnotation (Lang .class );
65
76
this .languageDriver = configuration .getLanguageDriver (lang == null ? null : lang .value ());
66
77
this .providerType = getProviderType (provider , mapperMethod );
67
- providerMethodName = (String ) provider .getClass ().getMethod ("method" ).invoke (provider );
78
+ providerMethodName = (String ) provider .annotationType ().getMethod ("method" ).invoke (provider );
68
79
69
80
if (providerMethodName .length () == 0 && ProviderMethodResolver .class .isAssignableFrom (this .providerType )) {
70
81
this .providerMethod = ((ProviderMethodResolver ) this .providerType .getDeclaredConstructor ().newInstance ())
@@ -192,18 +203,18 @@ private String invokeProviderMethod(Object... args) throws Exception {
192
203
return sql != null ? sql .toString () : null ;
193
204
}
194
205
195
- private Class <?> getProviderType (Object providerAnnotation , Method mapperMethod )
206
+ private Class <?> getProviderType (Annotation providerAnnotation , Method mapperMethod )
196
207
throws NoSuchMethodException , InvocationTargetException , IllegalAccessException {
197
- Class <?> type = (Class <?>) providerAnnotation .getClass ().getMethod ("type" ).invoke (providerAnnotation );
198
- Class <?> value = (Class <?>) providerAnnotation .getClass ().getMethod ("value" ).invoke (providerAnnotation );
208
+ Class <?> type = (Class <?>) providerAnnotation .annotationType ().getMethod ("type" ).invoke (providerAnnotation );
209
+ Class <?> value = (Class <?>) providerAnnotation .annotationType ().getMethod ("value" ).invoke (providerAnnotation );
199
210
if (value == void .class && type == void .class ) {
200
211
throw new BuilderException ("Please specify either 'value' or 'type' attribute of @"
201
- + (( Annotation ) providerAnnotation ) .annotationType ().getSimpleName ()
212
+ + providerAnnotation .annotationType ().getSimpleName ()
202
213
+ " at the '" + mapperMethod .toString () + "'." );
203
214
}
204
215
if (value != void .class && type != void .class && value != type ) {
205
216
throw new BuilderException ("Cannot specify different class on 'value' and 'type' attribute of @"
206
- + (( Annotation ) providerAnnotation ) .annotationType ().getSimpleName ()
217
+ + providerAnnotation .annotationType ().getSimpleName ()
207
218
+ " at the '" + mapperMethod .toString () + "'." );
208
219
}
209
220
return value == void .class ? type : value ;
0 commit comments