org.apache.cocoon.jxpath
Class JXPathCocoonContexts

java.lang.Object
  extended by org.apache.cocoon.jxpath.JXPathCocoonContexts
All Implemented Interfaces:
Component, Contextualizable, ThreadSafe

public final class JXPathCocoonContexts
extends Object
implements Component, Contextualizable, ThreadSafe

Component that allocate and cache JXPathContexts bound to VariableContext, Cocoon Request, Cocoon Session and Cocoon Context.

If you need to limit the attibute lookup to just one scope, you can use the pre-definded variables "request", "session" and "application". For example, the expression "$session/foo" extracts the value of the session attribute named "foo".

Following are some implementation details. There is a separate JXPathContext for each of the four scopes. These contexts are chained according to the nesting of the scopes. So, the parent of the "variable" JXPathContext is a "request" JXPathContext, whose parent is a "session" JXPathContext (that is if there is a session), whose parent is an "application" context.

Since JXPath chains lookups for variables and extension functions, variables and extension function declared in the outer scopes are also available in the inner scopes.

The "session" variable will be undefined if there is no session for this servlet. JXPath does not automatically create sessions.

Version:
$Id: JXPathCocoonContexts.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Volker Schmitt

Nested Class Summary
 class JXPathCocoonContexts.ContextProxy
           
static class JXPathCocoonContexts.RequestProxy
           
 class JXPathCocoonContexts.SessionProxy
           
 
Field Summary
static String ROLE
           
 
Constructor Summary
JXPathCocoonContexts()
           
 
Method Summary
 void contextualize(Context context)
           
 org.apache.commons.jxpath.JXPathContext getApplicationContext(Context envContext)
          Returns a JXPathContext bound to the "application" scope.
 org.apache.commons.jxpath.JXPathContext getRequestContext()
          Returns a JXPathContext bound to the "request" scope.
 org.apache.commons.jxpath.JXPathContext getSessionContext(Session session, Context envContext)
          Returns a JXPathContext bound to the "session" scope.
 org.apache.commons.jxpath.JXPathContext getVariableContext()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROLE

public static final String ROLE
Constructor Detail

JXPathCocoonContexts

public JXPathCocoonContexts()
Method Detail

contextualize

public void contextualize(Context context)
Specified by:
contextualize in interface Contextualizable

getVariableContext

public final org.apache.commons.jxpath.JXPathContext getVariableContext()

getRequestContext

public final org.apache.commons.jxpath.JXPathContext getRequestContext()
Returns a JXPathContext bound to the "request" scope. Caches that context within the request itself.


getSessionContext

public final org.apache.commons.jxpath.JXPathContext getSessionContext(Session session,
                                                                       Context envContext)
Returns a JXPathContext bound to the "session" scope. Caches that context within the session itself.


getApplicationContext

public final org.apache.commons.jxpath.JXPathContext getApplicationContext(Context envContext)
Returns a JXPathContext bound to the "application" scope. Caches that context within the servlet context itself.



Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.