Created
June 30, 2020 07:49
-
-
Save circlee/c3cbf8f079d0268d0466f200c3a8c6d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Object resolveAutowiringValue(Object autowiringValue, Class<?> requiredType) { | |
if (autowiringValue instanceof ObjectFactory && !requiredType.isInstance(autowiringValue)) { | |
ObjectFactory<?> factory = (ObjectFactory<?>) autowiringValue; | |
if (autowiringValue instanceof Serializable && requiredType.isInterface()) { | |
autowiringValue = Proxy.newProxyInstance(requiredType.getClassLoader(), | |
new Class<?>[] {requiredType}, new ObjectFactoryDelegatingInvocationHandler(factory)); | |
} | |
else { | |
return factory.getObject(); | |
} | |
} | |
return autowiringValue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment