Class SiteContextFactory
- java.lang.Object
-
- org.craftercms.engine.service.context.SiteContextFactory
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
,org.springframework.web.context.ServletContextAware
public class SiteContextFactory extends Object implements org.springframework.context.ApplicationContextAware, org.springframework.web.context.ServletContextAware
Factory for creatingSiteContext
with common properties. It also uses theMacroResolver
to resolve any macros specified in therootFolderPath
before creating the context (remember that macros can vary between requests).- Author:
- Alfonso Vásquez
-
-
Field Summary
Fields Modifier and Type Field Description protected String[]
applicationContextPaths
protected boolean
cacheOn
protected org.craftercms.core.util.cache.CacheTemplate
cacheTemplate
protected SiteCacheWarmer
cacheWarmer
protected boolean
cacheWarmUpEnabled
static String
CONFIG_BEAN_NAME
static String
CONFIG_KEY_ALLOWED_TEMPLATE_PATHS
protected String[]
configPaths
protected org.craftercms.commons.config.EncryptionAwareConfigurationReader
configurationReader
protected String
controllerScriptsPath
static long
DEFAULT_INIT_TIMEOUT
static String
DEFAULT_PUBLISHING_TARGET_MACRO_NAME
static long
DEFAULT_SHUTDOWN_TIMEOUT
static String
DEFAULT_SITE_NAME_MACRO_NAME
protected String[]
defaultPublicBeans
protected boolean
disableVariableRestrictions
protected boolean
enableExpressions
protected boolean
enableSandboxBlacklist
protected boolean
enableScriptSandbox
protected boolean
enableTranslation
protected org.springframework.beans.factory.ObjectFactory<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig>
freeMarkerConfigFactory
protected org.springframework.context.ApplicationContext
globalApplicationContext
protected GraphQLFactory
graphQLFactory
protected String
groovyClassesPath
protected Map<String,Object>
groovyGlobalVars
protected boolean
ignoreHiddenFiles
protected String
initScriptPath
protected long
initTimeout
protected List<ScriptJobResolver>
jobResolvers
protected Executor
jobThreadPoolExecutor
protected MacroResolver
macroResolver
protected int
maxAllowedItemsInCache
protected boolean
mergingOn
protected String[]
proxyConfigPaths
protected String
publishingTargetMacroName
protected org.craftercms.commons.config.PublishingTargetResolver
publishingTargetResolver
protected String
restScriptsPath
protected String
rootFolderPath
protected String
sandboxBlacklist
protected javax.servlet.ServletContext
servletContext
protected long
shutdownTimeout
protected String
siteNameMacroName
protected String
staticAssetsPath
protected org.craftercms.core.service.ContentStoreService
storeService
protected String
storeType
protected String
templatesPath
protected String[]
translationConfigPaths
protected String[]
urlRewriteConfPaths
protected org.craftercms.core.url.UrlTransformationEngine
urlTransformationEngine
-
Constructor Summary
Constructors Constructor Description SiteContextFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.springframework.web.servlet.LocaleResolver
buildLocaleResolver(org.apache.commons.configuration2.HierarchicalConfiguration<?> configuration)
protected void
configureScriptSandbox(SiteContext siteContext, org.springframework.core.io.ResourceLoader resourceLoader)
SiteContext
createContext(String siteName)
protected org.springframework.context.ConfigurableApplicationContext
getApplicationContext(SiteContext siteContext, URLClassLoader classLoader, org.apache.commons.configuration2.HierarchicalConfiguration config, String[] applicationContextPaths, org.springframework.core.io.ResourceLoader resourceLoader)
protected URLClassLoader
getClassLoader(SiteContext siteContext)
protected org.apache.commons.configuration2.HierarchicalConfiguration
getConfig(SiteContext siteContext, String[] configPaths, org.springframework.core.io.ResourceLoader resourceLoader)
protected org.apache.commons.configuration2.HierarchicalConfiguration
getProxyConfig(SiteContext siteContext, List<String> configPaths, org.springframework.core.io.ResourceLoader resourceLoader)
protected ScriptFactory
getScriptFactory(SiteContext siteContext, URLClassLoader classLoader)
protected org.apache.commons.configuration2.HierarchicalConfiguration
getTranslationConfig(SiteContext siteContext, List<String> configPaths, org.springframework.core.io.ResourceLoader resourceLoader)
protected org.tuckey.web.filters.urlrewrite.UrlRewriter
getUrlRewriter(SiteContext siteContext, String[] urlRewriteConfPaths, org.springframework.core.io.ResourceLoader resourceLoader)
protected org.quartz.Scheduler
scheduleJobs(SiteContext siteContext)
void
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
void
setApplicationContextPaths(String[] applicationContextPaths)
void
setCacheOn(boolean cacheOn)
void
setCacheTemplate(org.craftercms.core.util.cache.CacheTemplate cacheTemplate)
void
setCacheWarmer(SiteCacheWarmer cacheWarmer)
void
setCacheWarmUpEnabled(boolean cacheWarmUpEnabled)
void
setConfigPaths(String[] configPaths)
void
setConfigurationReader(org.craftercms.commons.config.EncryptionAwareConfigurationReader configurationReader)
void
setControllerScriptsPath(String controllerScriptsPath)
void
setDefaultPublicBeans(String[] defaultPublicBeans)
void
setDisableVariableRestrictions(boolean disableVariableRestrictions)
void
setEnableExpressions(boolean enableExpressions)
void
setEnableSandboxBlacklist(boolean enableSandboxBlacklist)
void
setEnableScriptSandbox(boolean enableScriptSandbox)
void
setEnableTranslation(boolean enableTranslation)
void
setFreeMarkerConfigFactory(org.springframework.beans.factory.ObjectFactory<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig> freeMarkerConfigFactory)
void
setGraphQLFactory(GraphQLFactory graphQLFactory)
void
setGroovyClassesPath(String groovyClassesPath)
void
setGroovyGlobalVars(Map<String,Object> groovyGlobalVars)
void
setIgnoreHiddenFiles(boolean ignoreHiddenFiles)
void
setInitScriptPath(String initScriptPath)
void
setInitTimeout(long initTimeout)
void
setJobResolvers(List<ScriptJobResolver> jobResolvers)
void
setJobThreadPoolExecutor(Executor jobThreadPoolExecutor)
void
setMacroResolver(MacroResolver macroResolver)
void
setMaxAllowedItemsInCache(int maxAllowedItemsInCache)
void
setMergingOn(boolean mergingOn)
void
setProxyConfigPaths(String[] proxyConfigPaths)
void
setPublishingTargetResolver(org.craftercms.commons.config.PublishingTargetResolver publishingTargetResolver)
void
setRestScriptsPath(String restScriptsPath)
void
setRootFolderPath(String rootFolderPath)
void
setSandboxBlacklist(String sandboxBlacklist)
void
setServletContext(javax.servlet.ServletContext servletContext)
void
setShutdownTimeout(long shutdownTimeout)
void
setSiteNameMacroName(String siteNameMacroName)
void
setStaticAssetsPath(String staticAssetsPath)
void
setStoreService(org.craftercms.core.service.ContentStoreService storeService)
void
setStoreType(String storeType)
void
setTemplatesPath(String templatesPath)
void
setTranslationConfigPaths(String[] translationConfigPaths)
void
setUrlRewriteConfPaths(String[] urlRewriteConfPaths)
void
setUrlTransformationEngine(org.craftercms.core.url.UrlTransformationEngine urlTransformationEngine)
-
-
-
Field Detail
-
DEFAULT_SITE_NAME_MACRO_NAME
public static final String DEFAULT_SITE_NAME_MACRO_NAME
- See Also:
- Constant Field Values
-
DEFAULT_INIT_TIMEOUT
public static final long DEFAULT_INIT_TIMEOUT
- See Also:
- Constant Field Values
-
CONFIG_BEAN_NAME
public static final String CONFIG_BEAN_NAME
- See Also:
- Constant Field Values
-
DEFAULT_SHUTDOWN_TIMEOUT
public static final long DEFAULT_SHUTDOWN_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_PUBLISHING_TARGET_MACRO_NAME
public static final String DEFAULT_PUBLISHING_TARGET_MACRO_NAME
- See Also:
- Constant Field Values
-
CONFIG_KEY_ALLOWED_TEMPLATE_PATHS
public static final String CONFIG_KEY_ALLOWED_TEMPLATE_PATHS
- See Also:
- Constant Field Values
-
servletContext
protected javax.servlet.ServletContext servletContext
-
siteNameMacroName
protected String siteNameMacroName
-
storeType
protected String storeType
-
rootFolderPath
protected String rootFolderPath
-
staticAssetsPath
protected String staticAssetsPath
-
templatesPath
protected String templatesPath
-
initScriptPath
protected String initScriptPath
-
restScriptsPath
protected String restScriptsPath
-
controllerScriptsPath
protected String controllerScriptsPath
-
configPaths
protected String[] configPaths
-
applicationContextPaths
protected String[] applicationContextPaths
-
urlRewriteConfPaths
protected String[] urlRewriteConfPaths
-
proxyConfigPaths
protected String[] proxyConfigPaths
-
translationConfigPaths
protected String[] translationConfigPaths
-
groovyClassesPath
protected String groovyClassesPath
-
mergingOn
protected boolean mergingOn
-
cacheOn
protected boolean cacheOn
-
maxAllowedItemsInCache
protected int maxAllowedItemsInCache
-
ignoreHiddenFiles
protected boolean ignoreHiddenFiles
-
freeMarkerConfigFactory
protected org.springframework.beans.factory.ObjectFactory<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig> freeMarkerConfigFactory
-
urlTransformationEngine
protected org.craftercms.core.url.UrlTransformationEngine urlTransformationEngine
-
storeService
protected org.craftercms.core.service.ContentStoreService storeService
-
cacheTemplate
protected org.craftercms.core.util.cache.CacheTemplate cacheTemplate
-
macroResolver
protected MacroResolver macroResolver
-
globalApplicationContext
protected org.springframework.context.ApplicationContext globalApplicationContext
-
jobResolvers
protected List<ScriptJobResolver> jobResolvers
-
jobThreadPoolExecutor
protected Executor jobThreadPoolExecutor
-
graphQLFactory
protected GraphQLFactory graphQLFactory
-
cacheWarmUpEnabled
protected boolean cacheWarmUpEnabled
-
cacheWarmer
protected SiteCacheWarmer cacheWarmer
-
initTimeout
protected long initTimeout
-
configurationReader
protected org.craftercms.commons.config.EncryptionAwareConfigurationReader configurationReader
-
disableVariableRestrictions
protected boolean disableVariableRestrictions
-
defaultPublicBeans
protected String[] defaultPublicBeans
-
shutdownTimeout
protected long shutdownTimeout
-
publishingTargetResolver
protected org.craftercms.commons.config.PublishingTargetResolver publishingTargetResolver
-
publishingTargetMacroName
protected String publishingTargetMacroName
-
enableScriptSandbox
protected boolean enableScriptSandbox
-
enableSandboxBlacklist
protected boolean enableSandboxBlacklist
-
sandboxBlacklist
protected String sandboxBlacklist
-
enableExpressions
protected boolean enableExpressions
-
enableTranslation
protected boolean enableTranslation
-
-
Method Detail
-
setServletContext
public void setServletContext(javax.servlet.ServletContext servletContext)
- Specified by:
setServletContext
in interfaceorg.springframework.web.context.ServletContextAware
-
setSiteNameMacroName
public void setSiteNameMacroName(String siteNameMacroName)
-
setStoreType
public void setStoreType(String storeType)
-
setRootFolderPath
public void setRootFolderPath(String rootFolderPath)
-
setStaticAssetsPath
public void setStaticAssetsPath(String staticAssetsPath)
-
setTemplatesPath
public void setTemplatesPath(String templatesPath)
-
setInitScriptPath
public void setInitScriptPath(String initScriptPath)
-
setRestScriptsPath
public void setRestScriptsPath(String restScriptsPath)
-
setControllerScriptsPath
public void setControllerScriptsPath(String controllerScriptsPath)
-
setConfigPaths
public void setConfigPaths(String[] configPaths)
-
setApplicationContextPaths
public void setApplicationContextPaths(String[] applicationContextPaths)
-
setUrlRewriteConfPaths
public void setUrlRewriteConfPaths(String[] urlRewriteConfPaths)
-
setProxyConfigPaths
public void setProxyConfigPaths(String[] proxyConfigPaths)
-
setTranslationConfigPaths
public void setTranslationConfigPaths(String[] translationConfigPaths)
-
setGroovyClassesPath
public void setGroovyClassesPath(String groovyClassesPath)
-
setMergingOn
public void setMergingOn(boolean mergingOn)
-
setCacheOn
public void setCacheOn(boolean cacheOn)
-
setMaxAllowedItemsInCache
public void setMaxAllowedItemsInCache(int maxAllowedItemsInCache)
-
setIgnoreHiddenFiles
public void setIgnoreHiddenFiles(boolean ignoreHiddenFiles)
-
setFreeMarkerConfigFactory
public void setFreeMarkerConfigFactory(org.springframework.beans.factory.ObjectFactory<org.springframework.web.servlet.view.freemarker.FreeMarkerConfig> freeMarkerConfigFactory)
-
setUrlTransformationEngine
public void setUrlTransformationEngine(org.craftercms.core.url.UrlTransformationEngine urlTransformationEngine)
-
setStoreService
public void setStoreService(org.craftercms.core.service.ContentStoreService storeService)
-
setCacheTemplate
public void setCacheTemplate(org.craftercms.core.util.cache.CacheTemplate cacheTemplate)
-
setMacroResolver
public void setMacroResolver(MacroResolver macroResolver)
-
setJobResolvers
public void setJobResolvers(List<ScriptJobResolver> jobResolvers)
-
setJobThreadPoolExecutor
public void setJobThreadPoolExecutor(Executor jobThreadPoolExecutor)
-
setGraphQLFactory
public void setGraphQLFactory(GraphQLFactory graphQLFactory)
-
setCacheWarmUpEnabled
public void setCacheWarmUpEnabled(boolean cacheWarmUpEnabled)
-
setCacheWarmer
public void setCacheWarmer(SiteCacheWarmer cacheWarmer)
-
setInitTimeout
public void setInitTimeout(long initTimeout)
-
setConfigurationReader
public void setConfigurationReader(org.craftercms.commons.config.EncryptionAwareConfigurationReader configurationReader)
-
setDisableVariableRestrictions
public void setDisableVariableRestrictions(boolean disableVariableRestrictions)
-
setDefaultPublicBeans
public void setDefaultPublicBeans(String[] defaultPublicBeans)
-
setShutdownTimeout
public void setShutdownTimeout(long shutdownTimeout)
-
setPublishingTargetResolver
public void setPublishingTargetResolver(org.craftercms.commons.config.PublishingTargetResolver publishingTargetResolver)
-
setEnableScriptSandbox
public void setEnableScriptSandbox(boolean enableScriptSandbox)
-
setEnableSandboxBlacklist
public void setEnableSandboxBlacklist(boolean enableSandboxBlacklist)
-
setSandboxBlacklist
public void setSandboxBlacklist(String sandboxBlacklist)
-
setEnableExpressions
public void setEnableExpressions(boolean enableExpressions)
-
setEnableTranslation
public void setEnableTranslation(boolean enableTranslation)
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
createContext
public SiteContext createContext(String siteName)
-
getConfig
protected org.apache.commons.configuration2.HierarchicalConfiguration getConfig(SiteContext siteContext, String[] configPaths, org.springframework.core.io.ResourceLoader resourceLoader)
-
configureScriptSandbox
protected void configureScriptSandbox(SiteContext siteContext, org.springframework.core.io.ResourceLoader resourceLoader)
-
getClassLoader
protected URLClassLoader getClassLoader(SiteContext siteContext)
-
getApplicationContext
protected org.springframework.context.ConfigurableApplicationContext getApplicationContext(SiteContext siteContext, URLClassLoader classLoader, org.apache.commons.configuration2.HierarchicalConfiguration config, String[] applicationContextPaths, org.springframework.core.io.ResourceLoader resourceLoader)
-
getUrlRewriter
protected org.tuckey.web.filters.urlrewrite.UrlRewriter getUrlRewriter(SiteContext siteContext, String[] urlRewriteConfPaths, org.springframework.core.io.ResourceLoader resourceLoader)
-
getProxyConfig
protected org.apache.commons.configuration2.HierarchicalConfiguration getProxyConfig(SiteContext siteContext, List<String> configPaths, org.springframework.core.io.ResourceLoader resourceLoader)
-
getTranslationConfig
protected org.apache.commons.configuration2.HierarchicalConfiguration getTranslationConfig(SiteContext siteContext, List<String> configPaths, org.springframework.core.io.ResourceLoader resourceLoader)
-
buildLocaleResolver
protected org.springframework.web.servlet.LocaleResolver buildLocaleResolver(org.apache.commons.configuration2.HierarchicalConfiguration<?> configuration)
-
getScriptFactory
protected ScriptFactory getScriptFactory(SiteContext siteContext, URLClassLoader classLoader)
-
scheduleJobs
protected org.quartz.Scheduler scheduleJobs(SiteContext siteContext)
-
-