/**
  * Finally this method does the lookup for the passed resource identifier
  * using the also passed connection.
  *
  * @param \AppserverIo\Psr\Naming\ResourceIdentifier              $resourceIdentifier The identifier for the requested bean
  * @param \AppserverIo\RemoteMethodInvocation\ConnectionInterface $connection         The connection we use for loading the bean
  * @param string                                                  $sessionId          The session-ID, necessary for lookup stateful session beans
  *
  * @return object The been proxy instance
  */
 protected function doLookup(ResourceIdentifier $resourceIdentifier, ConnectionInterface $connection, $sessionId = null)
 {
     // initialize the context session
     $session = $connection->createContextSession();
     // check if we've a HTTP session ID passed
     if ($sessionId == null) {
         // simulate a unique session ID
         $session->setSessionId(SessionUtils::generateRandomString());
     } else {
         // else, set the passed session ID
         $session->setSessionId($sessionId);
     }
     // check if we've a HTTP servlet request that may contain a session
     if ($servletRequest = $this->getServletRequest()) {
         $session->injectServletRequest($servletRequest);
     }
     // load the class name from the resource identifier => that is the path information
     $className = $resourceIdentifier->getClassName();
     // lookup and return the requested remote bean instance
     return $session->createInitialContext()->lookup($className);
 }