Package org.exist.xquery.functions.session

Examples of org.exist.xquery.functions.session.SessionModule


   *
   * @param createSession  Create session?
   */
  private Variable getSessionVar( boolean createSession ) throws XPathException
  {
    final SessionModule sessionModule = (SessionModule)context.getModule( SessionModule.NAMESPACE_URI );
        Variable var = sessionModule.resolveVariable( SessionModule.SESSION_VAR );
   
    if( createSession && ( var == null || var.getValue() == null ) ) {
      SessionWrapper session  = null;
      final RequestModule reqModule = (RequestModule)context.getModule( RequestModule.NAMESPACE_URI );
   
      // request object is read from global variable $request
      final Variable reqVar = reqModule.resolveVariable( RequestModule.REQUEST_VAR );
     
      if( reqVar == null || reqVar.getValue() == null ) {
          logger.error("No request object found in the current XQuery context.");

          throw( new XPathException( this, "No request object found in the current XQuery context." ) );
      }
      if( reqVar.getValue().getItemType() != Type.JAVA_OBJECT ) {
          logger.error( "Variable $request is not bound to an Java object.");
        throw( new XPathException( this, "Variable $request is not bound to an Java object." ) );
      }
     
      final JavaObjectValue reqValue = (JavaObjectValue)reqVar.getValue().itemAt( 0) ;
     
      if( reqValue.getObject() instanceof RequestWrapper ) {
        session = ((RequestWrapper)reqValue.getObject()).getSession( true );
        var = sessionModule.declareVariable( SessionModule.SESSION_VAR, session );
      }
    }
    return( var );
  }
View Full Code Here

TOP

Related Classes of org.exist.xquery.functions.session.SessionModule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.