Class 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 of SiteContexts.
    Author:
    Alfonso Vásquez
    • Field Detail

      • applicationContext

        protected org.springframework.context.ApplicationContext applicationContext
      • siteLockFactory

        protected org.craftercms.commons.concurrent.locks.KeyBasedLockFactory<ReentrantLock> siteLockFactory
      • entitlementValidator

        protected org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator
      • waitForContextInit

        protected boolean waitForContextInit
      • jobThreadPoolExecutor

        protected Executor jobThreadPoolExecutor
      • defaultSiteName

        protected String defaultSiteName
    • Constructor Detail

      • SiteContextManager

        public SiteContextManager()
    • Method Detail

      • setApplicationContext

        public void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
        Specified by:
        setApplicationContext in interface org.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 interface org.springframework.beans.factory.DisposableBean
      • 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 the SiteContext for the specified site name. If no context exists, a new one is created.
        Parameters:
        siteName - the context's site name
        fallback - 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 context
        fallback - 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 context
        fallback - if the new context should be a fallback context
        callback - 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()