I\'d like to access the classname of the underlying class which is an instance of java.lang.reflect.Proxy
.
Is this possible?
Here was the solution we used with my team (we need the name of the class behind the proxy) :
if (getTargetName(yourBean) ... ) {
}
With this little helper :
private String getTargetName(final Object target) {
if (target == null) {
return "";
}
if (targetClassIsProxied(target)) {
Advised advised = (Advised) target;
try {
return advised.getTargetSource().getTarget().getClass().getCanonicalName();
} catch (Exception e) {
return "";
}
}
return target.getClass().getCanonicalName();
}
private boolean targetClassIsProxied(final Object target) {
return target.getClass().getCanonicalName().contains("$Proxy");
}
Hope it helps!