public static Object unwrapProxy ( Object bean , Boolean recursive ) { Assert . notNull ( recursive , "recursive" ) ; Object unwrapped = bean ; // If the given object is a proxy, set the return value as the object being proxied, otherwise return the given // object if ( ( bean != null ) && ( bean instanceof Advised ) && ( AopUtils . isAopProxy ( bean ) ) ) { final Advised advised = ( Advised ) bean ; try { final Object target = advised . getTargetSource ( ) . getTarget ( ) ; unwrapped = recursive ? ObjectUtils . unwrapProxy ( target , recursive ) : target ; } catch ( Exception e ) { unwrapped = bean ; ObjectUtils . LOGGER . warn ( "Failure unwrapping \"" + bean + "\"." , e ) ; } } return unwrapped ; }
This is a utility method for getting raw objects that may have been proxied . It is intended to be used in cases where raw implementations are needed rather than working with interfaces which they implement .