@ FFDCIgnore ( { NamingException . class } ) @ Sensitive Object resolveObject ( Object o , WSName subname ) throws NamingException { ServiceReference < ? > ref = null ; try { if ( o instanceof ContextNode ) return new WSContext ( userContext , ( ContextNode ) o , env ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Resolving object" , o ) ; if ( o instanceof ServiceReference ) { ref = ( ServiceReference < ? > ) o ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "External service registry entry." ) ; } else if ( o instanceof AutoBindNode ) { if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "AutoBindNode entry." ) ; AutoBindNode abNode = ( AutoBindNode ) o ; ref = ( ServiceReference < ? > ) abNode . getLastEntry ( ) ; // null means the node was removed in another thread. if ( ref == null ) { // Use the same semantics as ContextNode.lookup. throw new NameNotFoundException ( subname . toString ( ) ) ; } } else if ( o instanceof ServiceRegistration ) { ref = ( ( ServiceRegistration < ? > ) o ) . getReference ( ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Programmatic JNDI entry." ) ; } boolean getObjectInstance ; if ( ref == null ) { getObjectInstance = true ; } else { o = getReference ( userContext , ref ) ; if ( o == null ) { throw new NamingException ( Tr . formatMessage ( tc , "jndi.servicereference.failed" , subname . toString ( ) ) ) ; } Object origin = ref . getProperty ( JNDIServiceBinder . OSGI_JNDI_SERVICE_ORIGIN ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Retrieved service from registry" , o , JNDIServiceBinder . OSGI_JNDI_SERVICE_ORIGIN + "=" + origin , Constants . OBJECTCLASS + "=" + Arrays . toString ( ( String [ ] ) ref . getProperty ( Constants . OBJECTCLASS ) ) ) ; getObjectInstance = JNDIServiceBinder . OSGI_JNDI_SERVICE_ORIGIN_VALUE . equals ( origin ) || contains ( ( String [ ] ) ref . getProperty ( Constants . OBJECTCLASS ) , Reference . class . getName ( ) ) ; } if ( getObjectInstance ) { // give JNDI a chance to resolve any references try { Object oldO = o ; o = NamingManager . getObjectInstance ( o , subname , this , env ) ; if ( o != oldO ) if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Resolved object through NamingManager" ) ; // remove logging object o since it might contain the sensitive information. } catch ( NamingException e ) { throw e ; } catch ( Exception e ) { // FFDC and proceed } } return o ; } catch ( NamingException e ) { throw e ; } catch ( Exception e ) { NamingException ne = new NamingException ( ) ; ne . setRootCause ( e ) ; throw ne ; } }
Perform any needed conversions on an object retrieved from the context tree .