34
34
import org .springframework .aop .IntroductionInfo ;
35
35
import org .springframework .aop .Pointcut ;
36
36
import org .springframework .aop .PointcutAdvisor ;
37
+ import org .springframework .aop .SpringProxy ;
37
38
import org .springframework .aop .TargetSource ;
38
39
import org .springframework .aop .support .DefaultIntroductionAdvisor ;
39
40
import org .springframework .aop .support .DefaultPointcutAdvisor ;
@@ -222,28 +223,28 @@ public void setInterfaces(Class<?>... interfaces) {
222
223
223
224
/**
224
225
* Add a new proxied interface.
225
- * @param intf the additional interface to proxy
226
+ * @param ifc the additional interface to proxy
226
227
*/
227
- public void addInterface (Class <?> intf ) {
228
- Assert .notNull (intf , "Interface must not be null" );
229
- if (!intf .isInterface ()) {
230
- throw new IllegalArgumentException ("[" + intf .getName () + "] is not an interface" );
228
+ public void addInterface (Class <?> ifc ) {
229
+ Assert .notNull (ifc , "Interface must not be null" );
230
+ if (!ifc .isInterface ()) {
231
+ throw new IllegalArgumentException ("[" + ifc .getName () + "] is not an interface" );
231
232
}
232
- if (!this .interfaces .contains (intf )) {
233
- this .interfaces .add (intf );
233
+ if (!this .interfaces .contains (ifc )) {
234
+ this .interfaces .add (ifc );
234
235
adviceChanged ();
235
236
}
236
237
}
237
238
238
239
/**
239
240
* Remove a proxied interface.
240
241
* <p>Does nothing if the given interface isn't proxied.
241
- * @param intf the interface to remove from the proxy
242
+ * @param ifc the interface to remove from the proxy
242
243
* @return {@code true} if the interface was removed; {@code false}
243
244
* if the interface was not found and hence could not be removed
244
245
*/
245
- public boolean removeInterface (Class <?> intf ) {
246
- return this .interfaces .remove (intf );
246
+ public boolean removeInterface (Class <?> ifc ) {
247
+ return this .interfaces .remove (ifc );
247
248
}
248
249
249
250
@ Override
@@ -252,15 +253,37 @@ public Class<?>[] getProxiedInterfaces() {
252
253
}
253
254
254
255
@ Override
255
- public boolean isInterfaceProxied (Class <?> intf ) {
256
+ public boolean isInterfaceProxied (Class <?> ifc ) {
256
257
for (Class <?> proxyIntf : this .interfaces ) {
257
- if (intf .isAssignableFrom (proxyIntf )) {
258
+ if (ifc .isAssignableFrom (proxyIntf )) {
258
259
return true ;
259
260
}
260
261
}
261
262
return false ;
262
263
}
263
264
265
+ boolean hasUserSuppliedInterfaces () {
266
+ for (Class <?> ifc : this .interfaces ) {
267
+ if (!SpringProxy .class .isAssignableFrom (ifc ) && !isAdvisorIntroducedInterface (ifc )) {
268
+ return true ;
269
+ }
270
+ }
271
+ return false ;
272
+ }
273
+
274
+ private boolean isAdvisorIntroducedInterface (Class <?> ifc ) {
275
+ for (Advisor advisor : this .advisors ) {
276
+ if (advisor instanceof IntroductionAdvisor introductionAdvisor ) {
277
+ for (Class <?> introducedInterface : introductionAdvisor .getInterfaces ()) {
278
+ if (introducedInterface == ifc ) {
279
+ return true ;
280
+ }
281
+ }
282
+ }
283
+ }
284
+ return false ;
285
+ }
286
+
264
287
265
288
@ Override
266
289
public final Advisor [] getAdvisors () {
0 commit comments