public function registerResReference(ResReferenceDescriptorInterface $resReference)
    {
        try {
            // load the application instance and reference name
            $application = $this->getApplication();

            // initialize the resource URI
            $uri = sprintf('php:global/%s/%s', $application->getUniqueName(), $resReference->getRefName());

            // query whether the reference has already been bound to the application
            if ($application->getNamingDirectory()->isBound($uri)) {
                // log a message that the reference has already been bound
                $application->getInitialContext()->getSystemLogger()->debug(
                    sprintf('Resource reference %s has already been bound to naming directory', $uri)
                );

                // return immediately
                return;
            }

        // catch the NamingException if the ref name is not bound yet
        } catch (NamingException $e) {
            // log a message that we've to register the resource reference now
            $application->getInitialContext()->getSystemLogger()->debug(
                sprintf('Resource reference %s has not been bound to naming directory', $uri)
            );
        }

        try {
            // try to use the lookup to bind the reference to
            if ($lookup = $resReference->getLookup()) {
                // create a reference to a resource in the global directory
                $application->getNamingDirectory()->bindReference($uri, $lookup);

            // try to bind the reference by the specified type
            } elseif ($type = $resReference->getType()) {
                // bind a reference to the resource shortname
                $application->getNamingDirectory()
                            ->bindReference(
                                $uri,
                                sprintf('php:global/%s/%s', $application->getUniqueName(), $type)
                            );

            // log a critical message that we can't bind the reference
            } else {
                $application->getInitialContext()->getSystemLogger()->critical(
                    sprintf('Can\'t bind resource reference %s to naming directory, because of missing source bean/lookup name', $uri)
                );
            }

        // catch all other exceptions
        } catch (\Exception $e) {
            $application->getInitialContext()->getSystemLogger()->critical($e->__toString());
        }
    }
public function registerResReference(ResReferenceDescriptorInterface $resReference)
    {
        try {
            // load the application instance and reference name
            $application = $this->getApplication();

            // initialize the resource URI
            $uri = sprintf('php:global/%s/%s', $application->getUniqueName(), $resReference->getRefName());

            // query whether the reference has already been bound to the application
            if ($application->getNamingDirectory()->isBound($uri)) {
                // log a message that the reference has already been bound
                $application->getInitialContext()->getSystemLogger()->debug(
                    sprintf('Resource reference %s has already been bound to naming directory', $uri)
                );

                // return immediately
                return;
            }

        // catch the NamingException if the ref name is not bound yet
        } catch (NamingException $e) {
            // log a message that we've to register the resource reference now
            $application->getInitialContext()->getSystemLogger()->debug(
                sprintf('Resource reference %s has not been bound to naming directory', $uri)
            );
        }

        try {
            // try to use the lookup to bind the reference to
            if ($lookup = $resReference->getLookup()) {
                // create a reference to a resource in the global directory
                $application->getNamingDirectory()->bindReference($uri, $lookup);

            // try to bind the reference by the specified type
            } elseif ($type = $resReference->getType()) {
                // bind a reference to the resource shortname
                $application->getNamingDirectory()
                            ->bindReference(
                                $uri,
                                sprintf('php:global/%s/%s', $application->getUniqueName(), $type)
                            );

            // log a critical message that we can't bind the reference
            } else {
                $application->getInitialContext()->getSystemLogger()->critical(
                    sprintf('Can\'t bind resource reference %s to naming directory, because of missing source bean/lookup name', $uri)
                );
            }

        // catch all other exceptions
        } catch (\Exception $e) {
            $application->getInitialContext()->getSystemLogger()->critical($e->__toString());
        }
    }
public function registerResReference ( ResReferenceDescriptorInterface $ resReference ) { try { // load the application instance and reference name $ application = $ this -> getApplication ( ) ; // initialize the resource URI $ uri = sprintf ( 'php:global/%s/%s' , $ application -> getUniqueName ( ) , $ resReference -> getRefName ( ) ) ; // query whether the reference has already been bound to the application if ( $ application -> getNamingDirectory ( ) -> isBound ( $ uri ) ) { // log a message that the reference has already been bound $ application -> getInitialContext ( ) -> getSystemLogger ( ) -> debug ( sprintf ( 'Resource reference %s has already been bound to naming directory' , $ uri ) ) ; // return immediately return ; } // catch the NamingException if the ref name is not bound yet } catch ( NamingException $ e ) { // log a message that we've to register the resource reference now $ application -> getInitialContext ( ) -> getSystemLogger ( ) -> debug ( sprintf ( 'Resource reference %s has not been bound to naming directory' , $ uri ) ) ; } try { // try to use the lookup to bind the reference to if ( $ lookup = $ resReference -> getLookup ( ) ) { // create a reference to a resource in the global directory $ application -> getNamingDirectory ( ) -> bindReference ( $ uri , $ lookup ) ; // try to bind the reference by the specified type } elseif ( $ type = $ resReference -> getType ( ) ) { // bind a reference to the resource shortname $ application -> getNamingDirectory ( ) -> bindReference ( $ uri , sprintf ( 'php:global/%s/%s' , $ application -> getUniqueName ( ) , $ type ) ) ; // log a critical message that we can't bind the reference } else { $ application -> getInitialContext ( ) -> getSystemLogger ( ) -> critical ( sprintf ( 'Can\'t bind resource reference %s to naming directory, because of missing source bean/lookup name' , $ uri ) ) ; } // catch all other exceptions } catch ( \ Exception $ e ) { $ application -> getInitialContext ( ) -> getSystemLogger ( ) -> critical ( $ e -> __toString ( ) ) ; } }
Registers the passed resource reference in the applications directory.

@param \AppserverIo\Psr\EnterpriseBeans\Description\ResReferenceDescriptorInterface $resReference The resource reference to register

@return void
Registers the passed resource reference in the applications directory .