private Object getBindingObjectInstance ( Context c , Hashtable < ? , ? > envmt , String className , ResourceInfo resourceRefInfo , Reference bindingRef , InjectionBinding < ? > binding ) throws Exception { Object bindingObject = binding . getBindingObject ( ) ; if ( bindingObject instanceof Reference ) { // Handle special Reference. Reference ref = ( Reference ) bindingObject ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "ref=" + ref . getClass ( ) . getName ( ) + ", factory=" + ref . getFactoryClassName ( ) ) ; if ( ref == bindingRef ) { throw new InjectionException ( Tr . formatMessage ( tc , "INDIRECT_LOOKUP_LOOP_CWNEN1008E" ) ) ; } // A resource-ref to a data-source. Propagate resource-ref info. if ( ref instanceof ResourceFactoryReference ) { ResourceFactoryReference factoryRef = ( ResourceFactoryReference ) ref ; ResourceFactory factory = factoryRef . getResourceFactory ( ) ; return factory . createResource ( resourceRefInfo ) ; } // An indirect reference to another indirect reference (e.g., // resource-ref to data-source override). Propagate resource-ref // info if necessary. if ( ref instanceof IndirectReference ) { IndirectReference indirectRef = ( IndirectReference ) ref ; String refBindingName = indirectRef . bindingName ; // resource-ref1 -> resource-ref2 -> data-source should use // resource-ref2's info. String refClassName = ref . getClassName ( ) ; if ( refClassName == null ) { refClassName = className ; } ResourceInfo refResourceRefInfo = indirectRef . resourceInfo ; if ( refResourceRefInfo == null ) { refResourceRefInfo = resourceRefInfo ; } return getObjectInstance ( c , envmt , refClassName , refBindingName , refResourceRefInfo , indirectRef ) ; } } // We could return null and use InitialContext.lookup, but that will // eventually call InjectionBinding.getInjectionObject anyway (assuming // non-conflicting JavaColonNamingHelper), so we might as well just make // the call while we have the InjectionBinding. This also allows // @Resource(lookup="java:...") to work even if JNDI is disabled. return binding . getInjectionObject ( ) ; }
Try to obtain an object instance from an injection binding object .