createContextSession() public method

Initializes a new session instance.
See also: AppserverIo\RemoteMethodInvocation\ConnectionInterface::createContextSession()
public createContextSession ( ) : AppserverIo\RemoteMethodInvocation\SessionInterface
return AppserverIo\RemoteMethodInvocation\SessionInterface The session instance
 /**
  * This returns a proxy to the requested session bean.
  *
  * @param string $lookupName The lookup name for the requested session bean
  * @param string $sessionId  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);
 }