Example usage for org.apache.commons.jxpath.servlet Constants JXPATH_CONTEXT

List of usage examples for org.apache.commons.jxpath.servlet Constants JXPATH_CONTEXT

Introduction

In this page you can find the example usage for org.apache.commons.jxpath.servlet Constants JXPATH_CONTEXT.

Prototype

String JXPATH_CONTEXT

To view the source code for org.apache.commons.jxpath.servlet Constants JXPATH_CONTEXT.

Click Source Link

Document

Attribute name used in page context, requst, session, and servlet context to store the corresponding org.apache.commons.jxpath.JXPathContext .

Usage

From source file:org.apache.cocoon.jxpath.JXPathCocoonContexts.java

/**
 * Returns a JXPathContext bound to the "request" scope.
 * Caches that context within the request itself.
 *///from   www .ja va  2s.c  o m
public final JXPathContext getRequestContext() {
    final Map objectModel = ContextHelper.getObjectModel(this.context);

    Request request = ObjectModelHelper.getRequest(objectModel);
    JXPathContext context = (JXPathContext) request.getAttribute(Constants.JXPATH_CONTEXT);
    if (context == null) {
        Context envContext = ObjectModelHelper.getContext(objectModel);
        JXPathContext parentContext = null;

        Session session = request.getSession(false);
        if (session != null) {
            parentContext = getSessionContext(session, envContext);
        } else {
            parentContext = getApplicationContext(envContext);
        }

        request = new RequestProxy(request);
        context = factory.newContext(parentContext, request);
        context.setVariables(new KeywordVariables(Constants.REQUEST_SCOPE, request));
        request.setAttribute(Constants.JXPATH_CONTEXT, context);
    }
    return context;
}

From source file:org.apache.cocoon.jxpath.JXPathCocoonContexts.java

/**
 * Returns a JXPathContext bound to the "session" scope.
 * Caches that context within the session itself.
 *//*from www. ja  v a 2s  .c o  m*/
public final JXPathContext getSessionContext(Session session, Context envContext) {
    JXPathContext context = (JXPathContext) session.getAttribute(Constants.JXPATH_CONTEXT);
    if (context == null) {
        JXPathContext parentContext = getApplicationContext(envContext);
        session = new SessionProxy(session);
        context = factory.newContext(parentContext, session);
        context.setVariables(new KeywordVariables(Constants.SESSION_SCOPE, session));
        session.setAttribute(Constants.JXPATH_CONTEXT, context);
    }
    return context;
}

From source file:org.apache.cocoon.jxpath.JXPathCocoonContexts.java

/**
 * Returns a JXPathContext bound to the "application" scope. Caches that context
 * within the servlet context itself./*from  w w  w . j  ava  2 s .  co  m*/
 */
public final JXPathContext getApplicationContext(Context envContext) {
    JXPathContext context = (JXPathContext) envContext.getAttribute(Constants.JXPATH_CONTEXT);
    if (context == null) {
        envContext = new ContextProxy(envContext);
        context = factory.newContext(null, envContext);
        context.setVariables(new KeywordVariables(Constants.APPLICATION_SCOPE, envContext));
        envContext.setAttribute(Constants.JXPATH_CONTEXT, context);
    }
    return context;
}