Class ExtensibilityContainer
- All Implemented Interfaces:
EventListener
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
,org.springframework.context.ApplicationListener
,org.springframework.extensions.surf.extensibility.HandlesExtensibility
,org.springframework.extensions.webscripts.Container
,org.springframework.extensions.webscripts.RuntimeContainer
A simple extensibility Container
for processing WebScripts. This extends the RepositoryContainer
and
implements the HandlesExtensibility
interface to provide extensibility capabilities.
- Author:
- David Draper
-
Field Summary
Fields inherited from class org.springframework.extensions.webscripts.AbstractRuntimeContainer
applicationContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addExtensibilityDirectives
(Map<String, Object> freeMarkerModel, org.springframework.extensions.surf.extensibility.ExtensibilityModel extModel) Adds the <@markup> directive to the container which allows FreeMarker templates to be extended.void
addExtensionBundleToCache
(String webScriptId, org.springframework.extensions.webscripts.WebScriptPropertyResourceBundle extensionBundle) Adds a new extended bundle to the cache.void
closeExtensibilityModel
(org.springframework.extensions.surf.extensibility.ExtensibilityModel model, Writer out) Flushes theExtensibilityModel
provided and sets its parent as the currentExtensibilityModel
for the current thread.void
executeScript
(org.springframework.extensions.webscripts.WebScriptRequest scriptReq, org.springframework.extensions.webscripts.WebScriptResponse scriptRes, org.springframework.extensions.webscripts.Authenticator auth) Opens a newExtensibilityModel
, defers execution to the extendedRepositoryContainer
and then closes theExtensibilityModel
.getCachedExtendedBundle
(String webScriptId) Checks the cache to see if it has cached an extended bundle (that is a basicResourceBundle
that has had extension modules applied to it.org.springframework.extensions.surf.extensibility.ExtensibilityModel
Returns theExtensibilityModel
for the current thread.List<org.springframework.extensions.surf.extensibility.BasicExtensionModule>
Retrieve the list oforg.springframework.extensions.surf.types.ExtensionModule
instances that have been evaluated as applicable for the current request.org.springframework.extensions.webscripts.ScriptConfigModel
getExtendedScriptConfigModel
(String xmlConfig) Creates a newExtendedScriptConfigModel
instance using the local configuration generated for this request.org.springframework.extensions.webscripts.TemplateConfigModel
getExtendedTemplateConfigModel
(String xmlConfig) Creates a newTemplateConfigModel
instance using the local configuration generated for this request.getExtendingModuleFiles
(String pathBeingProcessed) Retrieves an files for the evaluated modules that are extending the WebScript files being processed.Returns the path of the file currently being processed in the model by the current thread.boolean
org.springframework.extensions.surf.extensibility.ExtensibilityModel
Creates a newExtensibilityModel
and sets it on the current threadvoid
setExtensibilityModuleHandler
(org.springframework.extensions.surf.extensibility.WebScriptExtensibilityModuleHandler extensibilityModuleHandler) Sets theWebScriptExtensibilityModuleHandler
for thisContainer
.void
setFileBeingProcessed
(String file) Sets the path of the file currently being processed in the model by the current thread.void
updateExtendingModuleDependencies
(String pathBeingProcessed, Map<String, Object> model) This method is implemented to perform no action as it is not necessary for a standalone WebScript container to add dependencies for processing.Methods inherited from class org.alfresco.repo.web.scripts.RepositoryContainer
authenticate, executeScriptInternal, getDescription, getNotPublicExceptions, getPublicExceptions, getRequiredAuthentication, getScriptParameters, getTemplateParameters, onApplicationEvent, reset, setAuthorityService, setDescriptorService, setEncryptTempFiles, setFallbackTransactionHelper, setMaxContentSize, setMemoryThreshold, setNotPublicExceptions, setPreserveHeadersPattern, setPublicExceptions, setRepository, setRepositoryImageResolver, setTempDirectoryName, setTransactionService, setup, transactionedExecute
Methods inherited from class org.springframework.extensions.webscripts.AbstractRuntimeContainer
allowCallbacks, getApplicationContext, getConfigService, getFormatRegistry, getName, getRegistry, getScriptParameterFactoryRegistry, getScriptProcessorRegistry, getSearchPath, getTemplateProcessorRegistry, setAllowCallbacks, setApplicationContext, setConfigService, setFormatRegistry, setName, setRegistry, setScriptObjects, setScriptParameterFactoryRegistry, setScriptProcessorRegistry, setSearchPath, setTemplateObjects, setTemplateProcessorRegistry
-
Constructor Details
-
ExtensibilityContainer
public ExtensibilityContainer()
-
-
Method Details
-
isExtensibilitySuppressed
public boolean isExtensibilitySuppressed()- Specified by:
isExtensibilitySuppressed
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
-
executeScript
public void executeScript(org.springframework.extensions.webscripts.WebScriptRequest scriptReq, org.springframework.extensions.webscripts.WebScriptResponse scriptRes, org.springframework.extensions.webscripts.Authenticator auth) throws IOException Opens a new
ExtensibilityModel
, defers execution to the extendedRepositoryContainer
and then closes theExtensibilityModel
.- Specified by:
executeScript
in interfaceorg.springframework.extensions.webscripts.RuntimeContainer
- Overrides:
executeScript
in classRepositoryContainer
- Throws:
IOException
-
setExtensibilityModuleHandler
public void setExtensibilityModuleHandler(org.springframework.extensions.surf.extensibility.WebScriptExtensibilityModuleHandler extensibilityModuleHandler) Sets the
WebScriptExtensibilityModuleHandler
for thisContainer
.- Parameters:
extensibilityModuleHandler
- WebScriptExtensibilityModuleHandler
-
openExtensibilityModel
public org.springframework.extensions.surf.extensibility.ExtensibilityModel openExtensibilityModel()Creates a new
ExtensibilityModel
and sets it on the current thread- Specified by:
openExtensibilityModel
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
-
closeExtensibilityModel
public void closeExtensibilityModel(org.springframework.extensions.surf.extensibility.ExtensibilityModel model, Writer out) Flushes the
ExtensibilityModel
provided and sets its parent as the currentExtensibilityModel
for the current thread.- Specified by:
closeExtensibilityModel
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
-
getCurrentExtensibilityModel
public org.springframework.extensions.surf.extensibility.ExtensibilityModel getCurrentExtensibilityModel()Returns the
ExtensibilityModel
for the current thread.- Specified by:
getCurrentExtensibilityModel
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
-
updateExtendingModuleDependencies
This method is implemented to perform no action as it is not necessary for a standalone WebScript container to add dependencies for processing.
- Specified by:
updateExtendingModuleDependencies
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
-
getCachedExtendedBundle
Checks the cache to see if it has cached an extended bundle (that is a basic
ResourceBundle
that has had extension modules applied to it. Extended bundles can only be safely cached once per request as the modules applied can vary for each request.- Specified by:
getCachedExtendedBundle
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
- Parameters:
webScriptId
- The id of the WebScript to retrieve the extended bundle for.- Returns:
- A cached bundle or
null
if the bundle has not previously been cached.
-
addExtensionBundleToCache
public void addExtensionBundleToCache(String webScriptId, org.springframework.extensions.webscripts.WebScriptPropertyResourceBundle extensionBundle) Adds a new extended bundle to the cache. An extended bundle is a WebScript
ResourceBundle
that has hadResourceBundle
instances merged into it from extension modules that have been applied. These can only be cached for the lifetime of the request as different modules may be applied to the same WebScript for different requests.- Specified by:
addExtensionBundleToCache
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
- Parameters:
webScriptId
- The id of the WebScript to cache the extended bundle against.extensionBundle
- The extended bundle to cache.
-
getFileBeingProcessed
Returns the path of the file currently being processed in the model by the current thread. This information is primarily provided for the purposes of generating debug information.
- Specified by:
getFileBeingProcessed
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
- Returns:
- The path of the file currently being processed.
-
setFileBeingProcessed
Sets the path of the file currently being processed in the model by the current thread. This information should be collected to assist with providing debug information.
- Specified by:
setFileBeingProcessed
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
- Parameters:
file
- The path of the file currently being processed.
-
getExtendingModuleFiles
Retrieves an files for the evaluated modules that are extending the WebScript files being processed.
- Specified by:
getExtendingModuleFiles
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
-
getEvaluatedModules
public List<org.springframework.extensions.surf.extensibility.BasicExtensionModule> getEvaluatedModules()Retrieve the list of
org.springframework.extensions.surf.types.ExtensionModule
instances that have been evaluated as applicable for the current request. If this list has not yet been populated then use theorg.springframework.extensions.surf.extensibility.ExtensibilityModuleHandler
configured in the Spring application context to evaluate them.- Returns:
- A list of
org.springframework.extensions.surf.types.ExtensionModule
instances that are applicable to the current request.
-
getExtendedScriptConfigModel
public org.springframework.extensions.webscripts.ScriptConfigModel getExtendedScriptConfigModel(String xmlConfig) Creates a new
ExtendedScriptConfigModel
instance using the local configuration generated for this request. If configuration for the request will be generated if it does not yet exist. It is likely that this method will be called multiple times within the context of a single request and although the configuration containers will always be the same a newExtendedScriptConfigModel
instance will always be created as the the suppliedxmlConfig
string could be different for each call (because each WebScript invoked in the request will supply different configuration.- Specified by:
getExtendedScriptConfigModel
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
-
getExtendedTemplateConfigModel
public org.springframework.extensions.webscripts.TemplateConfigModel getExtendedTemplateConfigModel(String xmlConfig) Creates a new
TemplateConfigModel
instance using the local configuration generated for this request. If configuration for the request will be generated if it does not yet exist. It is likely that this method will be called multiple times within the context of a single request and although the configuration containers will always be the same a newTemplateConfigModel
instance will always be created as the the suppliedxmlConfig
string could be different for each call (because each WebScript invoked in the request will supply different configuration.- Specified by:
getExtendedTemplateConfigModel
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
-
addExtensibilityDirectives
public void addExtensibilityDirectives(Map<String, Object> freeMarkerModel, org.springframework.extensions.surf.extensibility.ExtensibilityModel extModel) Adds the <@markup> directive to the container which allows FreeMarker templates to be extended.
- Specified by:
addExtensibilityDirectives
in interfaceorg.springframework.extensions.surf.extensibility.HandlesExtensibility
-