public void inspect ( BeanRuleRegistry beanRuleRegistry ) throws BeanReferenceException , BeanRuleException { Set < Object > brokenReferences = new LinkedHashSet <> ( ) ; for ( Map . Entry < RefererKey , Set < RefererInfo > > entry : refererInfoMap . entrySet ( ) ) { RefererKey refererKey = entry . getKey ( ) ; String beanId = refererKey . getQualifier ( ) ; Class < ? > beanClass = refererKey . getType ( ) ; Set < RefererInfo > refererInfoSet = entry . getValue ( ) ; BeanRule beanRule = null ; BeanRule [ ] beanRules = null ; if ( beanClass != null ) { beanRules = beanRuleRegistry . getBeanRules ( beanClass ) ; if ( beanRules != null ) { if ( beanRules . length == 1 ) { if ( beanId != null ) { if ( beanId . equals ( beanRules [ 0 ] . getId ( ) ) ) { beanRule = beanRules [ 0 ] ; } } else { beanRule = beanRules [ 0 ] ; } } else { if ( beanId != null ) { for ( BeanRule br : beanRules ) { if ( beanId . equals ( br . getId ( ) ) ) { beanRule = br ; break ; } } } } } if ( beanRule == null && beanRules == null ) { beanRule = beanRuleRegistry . getBeanRuleForConfig ( beanClass ) ; } } else if ( beanId != null ) { beanRule = beanRuleRegistry . getBeanRule ( beanId ) ; } if ( beanRule == null ) { if ( beanRules != null && beanRules . length > 1 ) { for ( RefererInfo refererInfo : refererInfoSet ) { if ( beanId != null ) { log . error ( "Cannot resolve reference to bean " + refererKey + "; Referer: " + refererInfo ) ; } else { log . error ( "No unique bean of type [" + beanClass + "] is defined: " + "expected single matching bean but found " + beanRules . length + ": [" + NoUniqueBeanException . getBeanDescriptions ( beanRules ) + "]; Referer: " + refererInfo ) ; } } brokenReferences . add ( refererKey ) ; } else { int count = 0 ; for ( RefererInfo refererInfo : refererInfoSet ) { if ( ! isStaticMethodReference ( refererInfo ) ) { count ++ ; log . error ( "Cannot resolve reference to bean " + refererKey + "; Referer: " + refererInfo ) ; } } if ( count > 0 ) { brokenReferences . add ( refererKey ) ; } } } else { for ( RefererInfo refererInfo : refererInfoSet ) { if ( refererInfo . getBeanRefererType ( ) == BeanRefererType . BEAN_METHOD_ACTION_RULE ) { checkTransletActionParameter ( ( BeanMethodActionRule ) refererInfo . getReferenceable ( ) , beanRule , refererInfo ) ; } } } } if ( ! brokenReferences . isEmpty ( ) ) { throw new BeanReferenceException ( brokenReferences ) ; } }
Inspect bean reference .