Class SiteContextManager
- java.lang.Object
-
- org.craftercms.engine.service.context.SiteContextManager
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.DisposableBean
,org.springframework.context.ApplicationContextAware
public class SiteContextManager extends Object implements org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.DisposableBean
Registry and lifecycle manager ofSiteContext
s.- Author:
- Alfonso Vásquez
-
-
Field Summary
Fields Modifier and Type Field Description protected org.springframework.context.ApplicationContext
applicationContext
protected SiteContextFactory
contextFactory
protected Map<String,SiteContext>
contextRegistry
protected String
defaultSiteName
protected org.craftercms.commons.entitlements.validator.EntitlementValidator
entitlementValidator
protected SiteContextFactory
fallbackContextFactory
protected Executor
jobThreadPoolExecutor
protected SiteListResolver
siteListResolver
protected org.craftercms.commons.concurrent.locks.KeyBasedLockFactory<ReentrantLock>
siteLockFactory
protected boolean
waitForContextInit
-
Constructor Summary
Constructors Constructor Description SiteContextManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SiteContext
createContext(String siteName, boolean fallback)
void
createContexts(boolean concurrent)
Creates all contexts (if not already created) from the site list resolvervoid
destroy()
void
destroyAllContexts()
Destroys all contextsprotected void
destroyContext(String siteName)
Destroys the context for the specified site name, and removes it from the registry, effectively purging itprotected void
destroyContext(SiteContext siteContext)
protected void
destroyContexts(Collection<String> siteNames)
SiteContext
getContext(String siteName, boolean fallback)
Gets theSiteContext
for the specified site name.Collection<SiteContext>
listContexts()
protected SiteContext
rebuildContext(String siteName, boolean fallback)
void
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
void
setContextFactory(SiteContextFactory contextFactory)
void
setDefaultSiteName(String defaultSiteName)
void
setEntitlementValidator(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator)
void
setFallbackContextFactory(SiteContextFactory fallbackContextFactory)
void
setJobThreadPoolExecutor(Executor jobThreadPoolExecutor)
void
setSiteListResolver(SiteListResolver siteListResolver)
void
setWaitForContextInit(boolean waitForContextInit)
void
startContextRebuild(String siteName, boolean fallback)
Starts a context rebuild in the backgroundvoid
startContextRebuild(String siteName, boolean fallback, Consumer<SiteContext> callback)
Starts a context rebuild in the backgroundvoid
startDestroyContext(String siteName)
Starts a destroy context in the backgroundvoid
syncContexts()
protected boolean
validateSiteCreationEntitlement()
-
-
-
Field Detail
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext
-
siteLockFactory
protected org.craftercms.commons.concurrent.locks.KeyBasedLockFactory<ReentrantLock> siteLockFactory
-
contextRegistry
protected Map<String,SiteContext> contextRegistry
-
contextFactory
protected SiteContextFactory contextFactory
-
fallbackContextFactory
protected SiteContextFactory fallbackContextFactory
-
siteListResolver
protected SiteListResolver siteListResolver
-
entitlementValidator
protected org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator
-
waitForContextInit
protected boolean waitForContextInit
-
jobThreadPoolExecutor
protected Executor jobThreadPoolExecutor
-
defaultSiteName
protected String defaultSiteName
-
-
Method Detail
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
setContextFactory
public void setContextFactory(SiteContextFactory contextFactory)
-
setFallbackContextFactory
public void setFallbackContextFactory(SiteContextFactory fallbackContextFactory)
-
setSiteListResolver
public void setSiteListResolver(SiteListResolver siteListResolver)
-
setEntitlementValidator
public void setEntitlementValidator(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator)
-
setWaitForContextInit
public void setWaitForContextInit(boolean waitForContextInit)
-
setJobThreadPoolExecutor
public void setJobThreadPoolExecutor(Executor jobThreadPoolExecutor)
-
setDefaultSiteName
public void setDefaultSiteName(String defaultSiteName)
-
destroy
public void destroy()
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
-
listContexts
public Collection<SiteContext> listContexts()
-
createContexts
public void createContexts(boolean concurrent)
Creates all contexts (if not already created) from the site list resolver- Parameters:
concurrent
- if the context creation should be done concurrently
-
syncContexts
public void syncContexts()
-
destroyAllContexts
public void destroyAllContexts()
Destroys all contexts
-
getContext
public SiteContext getContext(String siteName, boolean fallback)
Gets theSiteContext
for the specified site name. If no context exists, a new one is created.- Parameters:
siteName
- the context's site namefallback
- if the context is a fallback (which means it will be used if no context can be resolved during requests- Returns:
- the context
-
startContextRebuild
public void startContextRebuild(String siteName, boolean fallback)
Starts a context rebuild in the background- Parameters:
siteName
- the site name of the contextfallback
- if the new context should be a fallback context
-
startContextRebuild
public void startContextRebuild(String siteName, boolean fallback, Consumer<SiteContext> callback)
Starts a context rebuild in the background- Parameters:
siteName
- the site name of the contextfallback
- if the new context should be a fallback contextcallback
- function to call with the new context after it has been rebuilt
-
startDestroyContext
public void startDestroyContext(String siteName)
Starts a destroy context in the background- Parameters:
siteName
- the site name of the context
-
destroyContext
protected void destroyContext(String siteName)
Destroys the context for the specified site name, and removes it from the registry, effectively purging it- Parameters:
siteName
- the site name of the context to destroy
-
destroyContexts
protected void destroyContexts(Collection<String> siteNames)
-
createContext
protected SiteContext createContext(String siteName, boolean fallback)
-
rebuildContext
protected SiteContext rebuildContext(String siteName, boolean fallback)
-
destroyContext
protected void destroyContext(SiteContext siteContext)
-
validateSiteCreationEntitlement
protected boolean validateSiteCreationEntitlement()
-
-