public function loadDependency(ReferenceDescriptorInterface $referenceDescriptor)
    {

        // load the session ID from the execution environment
        $sessionId = Environment::singleton()->getAttribute(EnvironmentKeys::SESSION_ID);

        // prepare the lookup name
        $lookupName = sprintf('php:global/%s/%s', $this->getApplication()->getUniqueName(), $referenceDescriptor->getRefName());

        // at least we need a type for instanciation, if we've a bean reference
        if ($referenceDescriptor instanceof BeanReferenceDescriptorInterface && $type = $referenceDescriptor->getType()) {
            // load the object manager instance
            /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */
            $objectManager = $this->getNamingDirectory()->search(
                sprintf('php:global/%s/%s', $this->getApplication()->getUniqueName(), ObjectManagerInterface::IDENTIFIER)
            );

            // try to directly instanciate the class by its defined type
            return $this->get($objectManager->getPreference($type), $sessionId);
        }

        // query if the instance is available, if yes load the instance by lookup the initial context
        if ($this->getNamingDirectory()->isBound($lookupName)) {
            return $this->getNamingDirectory()->search($lookupName, array($sessionId));
        }

        // throw an exception if the dependency can't be instanciated
        throw new \Exception(sprintf('Can\'t lookup bean "%s" nor find a DI type definition', $lookupName));
    }
public function loadDependency(ReferenceDescriptorInterface $referenceDescriptor)
    {

        // load the session ID from the execution environment
        $sessionId = Environment::singleton()->getAttribute(EnvironmentKeys::SESSION_ID);

        // prepare the lookup name
        $lookupName = sprintf('php:global/%s/%s', $this->getApplication()->getUniqueName(), $referenceDescriptor->getRefName());

        // at least we need a type for instanciation, if we've a bean reference
        if ($referenceDescriptor instanceof BeanReferenceDescriptorInterface && $type = $referenceDescriptor->getType()) {
            // load the object manager instance
            /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */
            $objectManager = $this->getNamingDirectory()->search(
                sprintf('php:global/%s/%s', $this->getApplication()->getUniqueName(), ObjectManagerInterface::IDENTIFIER)
            );

            // try to directly instanciate the class by its defined type
            return $this->get($objectManager->getPreference($type), $sessionId);
        }

        // query if the instance is available, if yes load the instance by lookup the initial context
        if ($this->getNamingDirectory()->isBound($lookupName)) {
            return $this->getNamingDirectory()->search($lookupName, array($sessionId));
        }

        // throw an exception if the dependency can't be instanciated
        throw new \Exception(sprintf('Can\'t lookup bean "%s" nor find a DI type definition', $lookupName));
    }
public function loadDependency ( ReferenceDescriptorInterface $ referenceDescriptor ) { // load the session ID from the execution environment $ sessionId = Environment :: singleton ( ) -> getAttribute ( EnvironmentKeys :: SESSION_ID ) ; // prepare the lookup name $ lookupName = sprintf ( 'php:global/%s/%s' , $ this -> getApplication ( ) -> getUniqueName ( ) , $ referenceDescriptor -> getRefName ( ) ) ; // at least we need a type for instanciation, if we've a bean reference if ( $ referenceDescriptor instanceof BeanReferenceDescriptorInterface && $ type = $ referenceDescriptor -> getType ( ) ) { // load the object manager instance /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */ $ objectManager = $ this -> getNamingDirectory ( ) -> search ( sprintf ( 'php:global/%s/%s' , $ this -> getApplication ( ) -> getUniqueName ( ) , ObjectManagerInterface :: IDENTIFIER ) ) ; // try to directly instanciate the class by its defined type return $ this -> get ( $ objectManager -> getPreference ( $ type ) , $ sessionId ) ; } // query if the instance is available, if yes load the instance by lookup the initial context if ( $ this -> getNamingDirectory ( ) -> isBound ( $ lookupName ) ) { return $ this -> getNamingDirectory ( ) -> search ( $ lookupName , array ( $ sessionId ) ) ; } // throw an exception if the dependency can't be instanciated throw new \ Exception ( sprintf ( 'Can\'t lookup bean "%s" nor find a DI type definition' , $ lookupName ) ) ; }
Load's and return's the dependency instance for the passed reference.

@param \AppserverIo\Psr\EnterpriseBeans\Description\ReferenceDescriptorInterface $referenceDescriptor The reference descriptor

@return object The reference instance
@throws \Exception Is thrown, if no DI type definition for the passed reference is available
Load s and return s the dependency instance for the passed reference .