|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -272,23 +272,21 @@ abstract class AutowireUtils {
@@ -272,23 +272,21 @@ abstract class AutowireUtils {
|
|
|
|
|
|
|
|
|
|
private final ObjectFactory<?> objectFactory; |
|
|
|
|
|
|
|
|
|
public ObjectFactoryDelegatingInvocationHandler(ObjectFactory<?> objectFactory) { |
|
|
|
|
ObjectFactoryDelegatingInvocationHandler(ObjectFactory<?> objectFactory) { |
|
|
|
|
this.objectFactory = objectFactory; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { |
|
|
|
|
String methodName = method.getName(); |
|
|
|
|
if (methodName.equals("equals")) { |
|
|
|
|
// Only consider equal when proxies are identical.
|
|
|
|
|
return (proxy == args[0]); |
|
|
|
|
} |
|
|
|
|
else if (methodName.equals("hashCode")) { |
|
|
|
|
// Use hashCode of proxy.
|
|
|
|
|
return System.identityHashCode(proxy); |
|
|
|
|
} |
|
|
|
|
else if (methodName.equals("toString")) { |
|
|
|
|
return this.objectFactory.toString(); |
|
|
|
|
switch (method.getName()) { |
|
|
|
|
case "equals": |
|
|
|
|
// Only consider equal when proxies are identical.
|
|
|
|
|
return (proxy == args[0]); |
|
|
|
|
case "hashCode": |
|
|
|
|
// Use hashCode of proxy.
|
|
|
|
|
return System.identityHashCode(proxy); |
|
|
|
|
case "toString": |
|
|
|
|
return this.objectFactory.toString(); |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
return method.invoke(this.objectFactory.getObject(), args); |
|
|
|
|
|