atg.multisite
Class SiteContextManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.multisite.SiteContextManager
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 SiteContextManager
extends GenericService

This is a global service that manages SiteContext objects. It can be used to get a new SiteContext object based on a specified SiteContext definition, or a site ID.

This service manages a stack of SiteContext objects so threads can manipulate the current SiteContext via push and pop methods.


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
SiteContextManager()
          Constructs an instanceof SiteContextManager
 
Method Summary
 void clearSiteContextStack()
          clear the stack of all site contexts
protected  void displayStackContents()
          display the contents of the stack for debugging purposes
 void doStartService()
          start service
static Site getCurrentSite()
          a convenience method to get the site associated with the current site context
static SiteContext getCurrentSiteContext()
          get the current site context.
static java.lang.String getCurrentSiteId()
          a convenience method to get the id for the site associated with the current site context
 SiteContext getEmptySiteContext()
          get an empty site context
 Site getSite(java.lang.String pSiteId)
          get a site by site id
 SiteContext getSiteContext(Site pSite)
          create a site context using a specific site item
 SiteContext getSiteContext(java.lang.String pSiteId)
          get a specific site context
 SiteManager getSiteManager()
          get SiteManager
 atg.multisite.SiteStorageAdapter getSiteStorageAdapter()
          get SiteStorageAdapter
 boolean isEnableStackWarnings()
          get EnableStackWarnings
 boolean isMaintainMembershipContext()
           
protected  boolean isSiteSnapshotsEnabledLive()
          check to see if site snapshots are enabled in the live setting, regardless of the current value of enableSiteSnapshots.
 SiteContext popSiteContext(SiteContext pContext)
          pop the current site context off the stack.
 SiteContext popSiteContext(SiteContext pContext, boolean pIgnoreWarning)
          pop the current site context off the stack.
 boolean pushSiteContext(SiteContext pContext)
          push current site context on stack
protected  java.lang.String registerSessionWithSnapshotCache()
          register a site session with the current site snapshot cache.
 void setEnableStackWarnings(boolean pEnableStackWarnings)
          set EnableStackWarnings - if true, will generate warnings for issues with the site context stack
 void setMaintainMembershipContext(boolean pMaintainMembershipContext)
          Do not change this property on a running system.
 void setSiteManager(SiteManager pSiteManager)
          set SiteManager
 void setSiteStorageAdapter(atg.multisite.SiteStorageAdapter pSiteStorageAdapter)
          set SiteStorageAdapter
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, 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

SiteContextManager

public SiteContextManager()
Constructs an instanceof SiteContextManager

Method Detail

setSiteStorageAdapter

public void setSiteStorageAdapter(atg.multisite.SiteStorageAdapter pSiteStorageAdapter)
set SiteStorageAdapter

Parameters:
pSiteStorageAdapter - the SiteStorageAdapter

getSiteStorageAdapter

public atg.multisite.SiteStorageAdapter getSiteStorageAdapter()
get SiteStorageAdapter

Returns:
the SiteStorageAdapter

setEnableStackWarnings

public void setEnableStackWarnings(boolean pEnableStackWarnings)
set EnableStackWarnings - if true, will generate warnings for issues with the site context stack

Parameters:
pEnableStackWarnings - the EnableStackWarnings

isEnableStackWarnings

public boolean isEnableStackWarnings()
get EnableStackWarnings

Returns:
the EnableStackWarnings

setSiteManager

public void setSiteManager(SiteManager pSiteManager)
set SiteManager

Parameters:
pSiteManager - the SiteManager

getSiteManager

public SiteManager getSiteManager()
get SiteManager

Returns:
the SiteManager

isMaintainMembershipContext

public boolean isMaintainMembershipContext()
Returns:

setMaintainMembershipContext

public void setMaintainMembershipContext(boolean pMaintainMembershipContext)
Do not change this property on a running system. It can have unintended consequences due to inconsistent push or pops of membership context.

Parameters:
pMaintainMembershipContext -

doStartService

public void doStartService()
                    throws ServiceException
start service

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

getSite

public Site getSite(java.lang.String pSiteId)
             throws SiteContextException
get a site by site id

Parameters:
pSiteId - the ID of the site to get
Returns:
the Site object for the request site, or null if no Site exists with the passed in ID
Throws:
SiteContextException - if there was an error getting the site

pushSiteContext

public boolean pushSiteContext(SiteContext pContext)
                        throws SiteContextException
push current site context on stack

Parameters:
pContext - the SiteContext to push on the stack
Returns:
true if the SiteContext was successfully pushed, false if not
Throws:
SiteContextException - if pContext is null

popSiteContext

public SiteContext popSiteContext(SiteContext pContext)
pop the current site context off the stack. a warning is logged if the SiteContext passed in does not match the SiteContext currently at the top of the stack. A warning is also logged if the pop call is not made within the same class and method that is making the corresponding push call.

If loggingDebug is set to true on this component, then the stack contents are displayed in the debug output on each push/pop call. Each SiteContext on the stack is displayed along with the name of the calling class and method, as well as the line number of where the push call was made that placed the given SiteContext on the stact.

Parameters:
pContext - the SiteContext to get popped off the stack. must match the SiteContext currently on the top of the stack
Returns:
the SiteContext that was just popped off the stack

popSiteContext

public SiteContext popSiteContext(SiteContext pContext,
                                  boolean pIgnoreWarning)
pop the current site context off the stack. if pIgnoreWarning is set to false, then a warning is logged if the SiteContext passed in does not match the SiteContext currently at the top of the stack, or if the pop call is not made within the same class and method that is making the corresponding push call.

If loggingDebug is set to true on this component, then the stack contents are displayed in the debug output on each push/pop call. Each SiteContext on the stack is displayed along with the name of the calling class and method, as well as the line number of where the push call was made that placed the given SiteContext on the stact.

Parameters:
pContext - the SiteContext to get popped off the stack. must match the SiteContext currently on the top of the stack
pIgnoreWarning - if true, do not log warnings about stack inconsistencies
Returns:
the SiteContext that was just popped off the stack

clearSiteContextStack

public void clearSiteContextStack()
clear the stack of all site contexts


getCurrentSiteId

public static java.lang.String getCurrentSiteId()
a convenience method to get the id for the site associated with the current site context

Returns:
the the id for the site associated with the current site context, or null if the current site context is null, or its associated site is null

getCurrentSite

public static Site getCurrentSite()
a convenience method to get the site associated with the current site context

Returns:
the site associated with the current site context, or null if the current site context is null, or its associated site is null

getCurrentSiteContext

public static SiteContext getCurrentSiteContext()
get the current site context. this is a static method that gets the current SiteContext on the top of the ThreadLocal stack of SiteContexts.

Returns:
the current SiteContext for this thread

getSiteContext

public SiteContext getSiteContext(java.lang.String pSiteId)
                           throws SiteContextException
get a specific site context

Parameters:
pSiteId - the Id of the site to base the SiteContext object off of
Returns:
the SiteContext object backed by the site repository item represented by the passed in site ID
Throws:
SiteContextException - if pSiteId is null

getSiteContext

public SiteContext getSiteContext(Site pSite)
                           throws SiteContextException
create a site context using a specific site item

Parameters:
pSite - the site object to use for this context
Returns:
a new site context object containing the specificed site object
Throws:
SiteContextException - if pSite is null

getEmptySiteContext

public SiteContext getEmptySiteContext()
get an empty site context

Returns:
a SiteContext object whose isEmptySiteContext property value is set to true

displayStackContents

protected void displayStackContents()
display the contents of the stack for debugging purposes


registerSessionWithSnapshotCache

protected java.lang.String registerSessionWithSnapshotCache()
register a site session with the current site snapshot cache. get the value of the current site snapshot cache id

Returns:
the current site cache Id

isSiteSnapshotsEnabledLive

protected boolean isSiteSnapshotsEnabledLive()
check to see if site snapshots are enabled in the live setting, regardless of the current value of enableSiteSnapshots.