org.ow2.jonas.web.tomcat6.versioning
Class VirtualContext

java.lang.Object
  extended by org.ow2.jonas.web.tomcat6.versioning.AbsVirtualContext
      extended by org.ow2.jonas.web.tomcat6.versioning.VirtualContext
All Implemented Interfaces:
VirtualContextJMXInterface, VirtualContextMBean, WebModuleContext

public class VirtualContext
extends AbsVirtualContext

Virtual Context implementation that handles operations with the additional contexts and defines a new context called "private".

Author:
Frederic Germaneau, S. Ali Tokmen

Field Summary
 
Fields inherited from class org.ow2.jonas.web.tomcat6.versioning.AbsVirtualContext
defaultContext, userURI
 
Constructor Summary
VirtualContext(JmxService jmxService, String userURI, org.apache.catalina.Context contextInstance)
          Creates and registers a virtual context.
 
Method Summary
protected  void addContextInternal(org.apache.catalina.Context contextInstance, String policy)
          Adds a new context.
 String findContext(org.apache.catalina.connector.Request req)
          Finds the context URI string for a request.
protected  org.apache.catalina.Context findContextObject(String versionedPath)
          Finds the context object corresponding to a path.
protected  org.apache.catalina.Context findDeleteContextObject(String versionedPath, boolean delete)
          Finds and optionally deletes a context object.
protected  String findDisabledContext(org.apache.catalina.connector.Request req)
          Checks if a given session has a disabled context.
protected  String findPrivateContext(org.apache.catalina.connector.Request req)
          Checks if a given request has a private context.
 Map<String,String> getContexts()
           
 boolean hasContext(String versionedPath)
          Checks whether a given context has been registered.
 boolean rebindContext(String versionedPath, String policy)
          Rebinds a context.
 boolean removeContext(String versionedPath)
          Removes a context.
 
Methods inherited from class org.ow2.jonas.web.tomcat6.versioning.AbsVirtualContext
addContext, findMappingObject, findStaticResources, getwarURL, getwelcomeFiles, removeVirtualContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VirtualContext

public VirtualContext(JmxService jmxService,
                      String userURI,
                      org.apache.catalina.Context contextInstance)
Creates and registers a virtual context.

Parameters:
jmxService - JMX server.
userURI - User (virtual) URI of this context.
contextInstance - The first context instance, will be mapped as default context.
Method Detail

addContextInternal

protected void addContextInternal(org.apache.catalina.Context contextInstance,
                                  String policy)
                           throws IllegalArgumentException
Adds a new context. Called by the parent if the policy is not default.

Specified by:
addContextInternal in class AbsVirtualContext
Parameters:
contextInstance - Context instance (versioned path).
policy - Policy (extensible).
Throws:
IllegalArgumentException - If policy not recognized.

getContexts

public Map<String,String> getContexts()
Returns:
All versioned contexts with their POLICIES for this virtual context.

findPrivateContext

protected String findPrivateContext(org.apache.catalina.connector.Request req)
Checks if a given request has a private context.

Parameters:
req - Request to check.
Returns:
The private context for this request, null if none found.

findDisabledContext

protected String findDisabledContext(org.apache.catalina.connector.Request req)
Checks if a given session has a disabled context.

Parameters:
req - Request to check.
Returns:
The disabled context for this request, null if none found.

rebindContext

public boolean rebindContext(String versionedPath,
                             String policy)
Rebinds a context.

Parameters:
versionedPath - Versioned path of the context.
policy - New policy.
Returns:
true if succeeded, false otherwise.

findContextObject

protected org.apache.catalina.Context findContextObject(String versionedPath)
Finds the context object corresponding to a path. This implementation calls parent and check additional contexts.

Overrides:
findContextObject in class AbsVirtualContext
Parameters:
versionedPath - Path to check against.
Returns:
Context object corresponding to versionedPath, null if none.

findDeleteContextObject

protected org.apache.catalina.Context findDeleteContextObject(String versionedPath,
                                                              boolean delete)
Finds and optionally deletes a context object.

Parameters:
versionedPath - Path to check against.
delete - Whether to delete when found.
Returns:
Context corresponding to versionedPath, null if none found.

removeContext

public boolean removeContext(String versionedPath)
Removes a context. If no more contexts left, will also remove this virtual context.

Overrides:
removeContext in class AbsVirtualContext
Parameters:
versionedPath - Versioned path of the context.
Returns:
true if succeeded, false otherwise.

hasContext

public boolean hasContext(String versionedPath)
Checks whether a given context has been registered.

Specified by:
hasContext in interface VirtualContextJMXInterface
Overrides:
hasContext in class AbsVirtualContext
Parameters:
versionedPath - Versioned path of the context.
Returns:
true if found, false otherwise.

findContext

public String findContext(org.apache.catalina.connector.Request req)
Finds the context URI string for a request.

Parameters:
req - Request.
Returns:
Context URI string for that request, null if none found.


Copyright © 2010 OW2 Consortium. All Rights Reserved.