@ Override @ SuppressFBWarnings ( value = "UL_UNRELEASED_LOCK" , justification = "False positive from FindBugs" ) public < T > T get ( Contextual < T > contextual , CreationalContext < T > creationalContext ) { if ( ! isActive ( ) ) { throw new ContextNotActiveException ( ) ; } checkContextInitialized ( ) ; final BeanStore beanStore = getBeanStore ( ) ; if ( beanStore == null ) { return null ; } if ( contextual == null ) { throw ContextLogger . LOG . contextualIsNull ( ) ; } BeanIdentifier id = getId ( contextual ) ; ContextualInstance < T > beanInstance = beanStore . get ( id ) ; if ( beanInstance != null ) { return beanInstance . getInstance ( ) ; } else if ( creationalContext != null ) { LockedBean lock = null ; try { if ( multithreaded ) { lock = beanStore . lock ( id ) ; beanInstance = beanStore . get ( id ) ; if ( beanInstance != null ) { return beanInstance . getInstance ( ) ; } } T instance = contextual . create ( creationalContext ) ; if ( instance != null ) { beanInstance = new SerializableContextualInstanceImpl < Contextual < T > , T > ( contextual , instance , creationalContext , serviceRegistry . get ( ContextualStore . class ) ) ; beanStore . put ( id , beanInstance ) ; } return instance ; } finally { if ( lock != null ) { lock . unlock ( ) ; } } } else { return null ; } }
Get the bean if it exists in the contexts .