atg.servlet
Class VirtualContextRootService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.servlet.ContextRootSwappingService
              extended by atg.servlet.VirtualContextRootService
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class VirtualContextRootService
extends ContextRootSwappingService

This service provides a central location for multiple components to access defined virtual context root mappings.


Nested Class Summary
 
Nested classes/interfaces inherited from class atg.servlet.ContextRootSwappingService
ContextRootSwappingService.ServletContextInfo
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
VirtualContextRootService()
          Constructs an instanceof VirtualContextRootService
 
Method Summary
 java.lang.String findContextRootFromServletPath(java.lang.String pServletPath)
          find the context root within a servlet path
 java.lang.String getAdditionalProductionURLPropertyName()
          get AdditionalProductionURLPropertyName
 ContextRootSwappingService.ServletContextInfo getContextRootForVirtualContextRoot(javax.servlet.ServletContext pServletContext, java.lang.String pServletPath)
          get a ServletContext for a virtual context root
 ContextRootSwappingService.ServletContextInfo getContextRootForVirtualContextRoot(javax.servlet.ServletContext pServletContext, java.lang.String pServletPath, boolean pCheckForValidPath)
          get a ServletContext for a virtual context root
 java.lang.String getContextRootPropertyName()
          get ContextRootPropertyName
 java.lang.String getProductionURLPropertyName()
          get ProductionURLPropertyName
 java.lang.String getRealContextRoot(java.lang.String pVirtualContextRoot)
          get the real context root for a given virtual context root, or null if there isn't one
 java.lang.String getRealServletPath(java.lang.String pServletPath)
          transform the given servlet path containing a virtual context root into a servlet path with the corresponding real context root.
 SiteContextManager getSiteContextManager()
          get SiteContextManager
protected  Site getSiteForVCRURL(java.lang.String pURL)
          given a url containing a virtual context root, get the associated site object
 URLPatternMatchingRuleFilter getURLPatternMatchingRuleFilter()
          get URLPatternMatchingRuleFilter
 boolean hasVirtualContextRootMappings()
          check to see if this service has any virtual context root mappings
 boolean hasVirtualContextRootMappings(java.lang.String pURL)
          check to see if this service has any virtual context root mappings
 boolean isEnabled()
          get Enabled - this determines if any VirtualContextRoot features will be enabled.
 void setAdditionalProductionURLPropertyName(java.lang.String pAdditionalProductionURLPropertyName)
          set AdditionalProductionURLPropertyName
 void setContextRootPropertyName(java.lang.String pContextRootPropertyName)
          set ContextRootPropertyName
 void setEnabled(boolean pEnabled)
          set Enabled - this determines if any VirtualContextRoot features will be enabled.
 void setProductionURLPropertyName(java.lang.String pProductionURLPropertyName)
          set ProductionURLPropertyName
 void setSiteContextManager(SiteContextManager pSiteContextManager)
          set SiteContextManager
 void setURLPatternMatchingRuleFilter(URLPatternMatchingRuleFilter pURLPatternMatchingRuleFilter)
          set URLPatternMatchingRuleFilter
 java.lang.String transformRealURLToVirtualURL(java.lang.String pOriginalURL, java.lang.String pRealURL)
          given an original URL containing a virtual context root, and second URL containing a real context root, return a URL containing the virtual context root of the first URL, and the servlet path of the second URL, if the second URL's context root is the real context root corresponding to the virual context root in the first URL
protected  java.lang.String trimLevel(java.lang.String pURI)
          trim one directory level off the URI
 
Methods inherited from class atg.servlet.ContextRootSwappingService
canGetResource, canGetResourceAsStream, findWelcomeFile, getDefaultWelcomeFiles, getWebAppFileExistenceService, getWelcomeFiles, setDefaultWelcomeFiles, setWebAppFileExistenceService
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

VirtualContextRootService

public VirtualContextRootService()
Constructs an instanceof VirtualContextRootService

Method Detail

setContextRootPropertyName

public void setContextRootPropertyName(java.lang.String pContextRootPropertyName)
set ContextRootPropertyName

Parameters:
pContextRootPropertyName - the ContextRootPropertyName

getContextRootPropertyName

public java.lang.String getContextRootPropertyName()
get ContextRootPropertyName

Returns:
the ContextRootPropertyName

setProductionURLPropertyName

public void setProductionURLPropertyName(java.lang.String pProductionURLPropertyName)
set ProductionURLPropertyName

Parameters:
pProductionURLPropertyName - the ProductionURLPropertyName

getProductionURLPropertyName

public java.lang.String getProductionURLPropertyName()
get ProductionURLPropertyName

Returns:
the ProductionURLPropertyName

setAdditionalProductionURLPropertyName

public void setAdditionalProductionURLPropertyName(java.lang.String pAdditionalProductionURLPropertyName)
set AdditionalProductionURLPropertyName

Parameters:
pAdditionalProductionURLPropertyName - the AdditionalProductionURLPropertyName

getAdditionalProductionURLPropertyName

public java.lang.String getAdditionalProductionURLPropertyName()
get AdditionalProductionURLPropertyName

Returns:
the AdditionalProductionURLPropertyName

setEnabled

public void setEnabled(boolean pEnabled)
set Enabled - this determines if any VirtualContextRoot features will be enabled. This is set to false by default.

Parameters:
pEnabled - the Enabled

isEnabled

public boolean isEnabled()
get Enabled - this determines if any VirtualContextRoot features will be enabled. This is set to false by default.

Returns:
the Enabled

setURLPatternMatchingRuleFilter

public void setURLPatternMatchingRuleFilter(URLPatternMatchingRuleFilter pURLPatternMatchingRuleFilter)
set URLPatternMatchingRuleFilter

Parameters:
pURLPatternMatchingRuleFilter - the URLPatternMatchingRuleFilter

getURLPatternMatchingRuleFilter

public URLPatternMatchingRuleFilter getURLPatternMatchingRuleFilter()
get URLPatternMatchingRuleFilter

Returns:
the URLPatternMatchingRuleFilter

setSiteContextManager

public void setSiteContextManager(SiteContextManager pSiteContextManager)
set SiteContextManager

Parameters:
pSiteContextManager - the SiteContextManager

getSiteContextManager

public SiteContextManager getSiteContextManager()
get SiteContextManager

Returns:
the SiteContextManager

hasVirtualContextRootMappings

public boolean hasVirtualContextRootMappings()
check to see if this service has any virtual context root mappings

Returns:
true if there are any virtual context root mappings, false if not

hasVirtualContextRootMappings

public boolean hasVirtualContextRootMappings(java.lang.String pURL)
check to see if this service has any virtual context root mappings

Parameters:
pURL - the url used to determine the site that corresponds to the virtual context root, if null, then the site associated with the current thread is used
Returns:
true if there are any virtual context root mappings, false if not

getContextRootForVirtualContextRoot

public ContextRootSwappingService.ServletContextInfo getContextRootForVirtualContextRoot(javax.servlet.ServletContext pServletContext,
                                                                                         java.lang.String pServletPath)
get a ServletContext for a virtual context root

Parameters:
pServletContext - the current servlet context, if this is null then no ServletContext will be returned within the ServletContextInfo object, and no logic will be performed to determine the welcome file path for the given servlet path
pServletPath - the servlet path
Returns:
a ServletContextInfo object containing a ServletContext for the real context root that is mapped to from the virtual context root contained in pServletPath, or null, if there is no defined virtual context root in pServletPath. The ServletContextInfo also contains a new servlet path to hand to the request dispatcher, a String corresponding to the real context root, as well as a String corresponding to the virtual context root

getContextRootForVirtualContextRoot

public ContextRootSwappingService.ServletContextInfo getContextRootForVirtualContextRoot(javax.servlet.ServletContext pServletContext,
                                                                                         java.lang.String pServletPath,
                                                                                         boolean pCheckForValidPath)
get a ServletContext for a virtual context root

Parameters:
pServletContext - the current servlet context, if this is null then no ServletContext will be returned within the ServletContextInfo object, and no logic will be performed to determine the welcome file path for the given servlet path
pServletPath - the servlet path
pCheckForValidPath - - if true, will check to make sure there is a resource at the given location before returning the context info. if false, will return the context info regardless of whether the resource exists. Useful for getting servlets, which can't be checked against ServletContext.getResourceAsStream()
Returns:
a ServletContextInfo object containing a ServletContext for the real context root that is mapped to from the virtual context root contained in pServletPath, or null, if there is no defined virtual context root in pServletPath. The ServletContextInfo also contains a new servlet path to hand to the request dispatcher, a String corresponding to the real context root, as well as a String corresponding to the virtual context root

getRealServletPath

public java.lang.String getRealServletPath(java.lang.String pServletPath)
transform the given servlet path containing a virtual context root into a servlet path with the corresponding real context root. If there's no corresponding real context roof for pServletPath, then pServletPath is returned

Parameters:
pServletPath - the virtual context root servlet path
Returns:
the real context root servlet path, or null, if pServletPath is null

findContextRootFromServletPath

public java.lang.String findContextRootFromServletPath(java.lang.String pServletPath)
find the context root within a servlet path


getRealContextRoot

public java.lang.String getRealContextRoot(java.lang.String pVirtualContextRoot)
get the real context root for a given virtual context root, or null if there isn't one

Parameters:
pVirtualContextRoot - the virtual context root
Returns:
the real context root that corresponds to pVirtualContextRoot

trimLevel

protected java.lang.String trimLevel(java.lang.String pURI)
trim one directory level off the URI


getSiteForVCRURL

protected Site getSiteForVCRURL(java.lang.String pURL)
given a url containing a virtual context root, get the associated site object

Parameters:
pURL - the virtual context root url
Returns:
the Site object whose siteBaseURL or additionalURLs contains maps to the given url, or null if there is no Site whose siteBaseURL or additionalURLs maps to the given url

transformRealURLToVirtualURL

public java.lang.String transformRealURLToVirtualURL(java.lang.String pOriginalURL,
                                                     java.lang.String pRealURL)
given an original URL containing a virtual context root, and second URL containing a real context root, return a URL containing the virtual context root of the first URL, and the servlet path of the second URL, if the second URL's context root is the real context root corresponding to the virual context root in the first URL

Parameters:
pOriginalURL - the url containing the virtual context root
pRealURL - the url containing the real context root
Returns:
a URL containing the virtual context root of pOriginalURL, and the servlet path of pRealURL, if the pRealURL's context root is the real context root corresponding to the virual context root in pOriginalURL. Return null if there are any issues with transforming the url