AppserverIo\Appserver\PersistenceContainer\PersistenceManager::lookupProxy PHP Method

lookupProxy() public method

This returns a proxy to the requested session bean.
public lookupProxy ( string $lookupName, string $sessionId = null ) : AppserverIo\RemoteMethodInvocation\RemoteObjectInterface
$lookupName string The lookup name for the requested session bean
$sessionId string The session-ID if available
return AppserverIo\RemoteMethodInvocation\RemoteObjectInterface The proxy instance
    public function lookupProxy($lookupName, $sessionId = null)
    {
        // initialize the remote method call parser and the session storage
        $sessions = new ArrayList();
        // initialize the local context connection
        $connection = new DoctrineLocalContextConnection();
        $connection->injectSessions($sessions);
        $connection->injectApplication($this->getApplication());
        // 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);
        }
        // lookup and return the requested remote bean instance
        return $session->createInitialContext()->lookup($lookupName);
    }