Class ClassPathStore
java.lang.Object
org.springframework.extensions.webscripts.AbstractStore
org.springframework.extensions.webscripts.ClassPathStore
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,Store
public class ClassPathStore
extends AbstractStore
implements org.springframework.context.ApplicationContextAware, Store
ClassPath based Web Script Store
- Author:
- davidc, kevinr, muzquiano
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classClass Path Store implementation of a Template Loader Retrieves templates either from classes in the class path or classes inside of JAR files within the class pathprotected classTemplate Source - loads from a Class Path Store -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContextprotected Stringprotected booleanprotected booleanprotected ClassPathStoreResourceResolverprotected String[]protected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final StringFields inherited from class org.springframework.extensions.webscripts.AbstractStore
DESC_PATH_PATTERN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateDocument(String documentPath, String content) Creates a document.static StringcreatePath(String path, String relativePath) Helper method for creating fully qualified pathsbooleanexists()Determines whether the store actually existsprotected static URLextractJarFileURL(URL jarUrl) Extract the URL for the actual jar file from the given URL (which may point to a resource in a jar file or to a jar file itself).String[]Gets the paths of all documents in this storeGets the base path of the storeString[]Gets the paths of all Web Script description documents in this storegetDocument(String documentPath) Gets a document.String[]getDocumentPaths(String path, boolean includeSubPaths, String documentPattern) Gets the paths of given document pattern within given path/sub-paths in this storeString[]getScriptDocumentPaths(WebScript script) Gets the paths of all implementation files for a given Web ScriptGets the script loader for this storefreemarker.cache.TemplateLoaderGets the template loader for this storebooleanhasDocument(String documentPath) Determines if the document exists.voidinit()Initialise Store (called once)protected static booleanDetermine whether the given URL points to a resource in a jar file, that is, has protocol "jar", "zip", "vfszip", "wsjar" or "code-source".booleanWhether the store is in read-only modebooleanisSecure()Returns true if this store is considered secure - i.e.longlastModified(String documentPath) Gets the last modified timestamp for the document.booleanremoveDocument(String documentPath) Removes an existing document.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetClassPath(String classPath) Sets the class pathvoidsetMustExist(boolean mustExist) Sets whether the class path must exist If it must exist, but it doesn't exist, an exception is thrown on initialisation of the storetoString()voidupdateDocument(String documentPath, String content) Updates an existing document.Methods inherited from class org.springframework.extensions.webscripts.AbstractStore
createDocuments, getDocumentPaths, getPreviewContext, setPreviewContextProvider, setReadOnlyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.extensions.webscripts.Store
createDocuments, getDocumentPaths
-
Field Details
-
VFSFILE_URL_PREFIX
- See Also:
-
VFSZIP_URL_PREFIX
- See Also:
-
VFSJAR_URL_SEPARATOR
- See Also:
-
VFSWAR_URL_SEPARATOR
- See Also:
-
VFSWAR_CLASSES_URL_SEPARATOR
- See Also:
-
resolver
-
storeDirs
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
classPath
-
mustExist
protected boolean mustExist -
exists
protected boolean exists
-
-
Constructor Details
-
ClassPathStore
public ClassPathStore()
-
-
Method Details
-
setMustExist
public void setMustExist(boolean mustExist) Sets whether the class path must exist If it must exist, but it doesn't exist, an exception is thrown on initialisation of the store- Parameters:
mustExist- boolean
-
setClassPath
Sets the class path- Parameters:
classPath- classpath
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
init
public void init()Description copied from interface:StoreInitialise Store (called once) -
exists
public boolean exists()Description copied from interface:StoreDetermines whether the store actually exists -
getBasePath
Description copied from interface:StoreGets the base path of the store- Specified by:
getBasePathin interfaceStore- Returns:
- base path
-
isSecure
public boolean isSecure()Description copied from interface:StoreReturns true if this store is considered secure - i.e. on the app-server classpath. Scripts in secure stores can be run under the identity of a declared user (via the runas attribute) rather than the authenticated user. -
isReadOnly
public boolean isReadOnly()Description copied from class:AbstractStoreWhether the store is in read-only mode- Specified by:
isReadOnlyin interfaceStore- Overrides:
isReadOnlyin classAbstractStore- Returns:
- boolean
-
getAllDocumentPaths
Description copied from interface:StoreGets the paths of all documents in this store- Specified by:
getAllDocumentPathsin interfaceStore- Returns:
- array of all document paths
-
getDocumentPaths
public String[] getDocumentPaths(String path, boolean includeSubPaths, String documentPattern) throws IOException Description copied from interface:StoreGets the paths of given document pattern within given path/sub-paths in this store- Specified by:
getDocumentPathsin interfaceStore- Parameters:
path- start pathincludeSubPaths- if true, include sub-pathsdocumentPattern- document name, allows wildcards, eg. *.ftl or my*.ftl- Returns:
- array of document paths
- Throws:
IOException
-
getDescriptionDocumentPaths
Description copied from interface:StoreGets the paths of all Web Script description documents in this store- Specified by:
getDescriptionDocumentPathsin interfaceStore- Returns:
- array of description document paths
- Throws:
IOException
-
getScriptDocumentPaths
Description copied from interface:StoreGets the paths of all implementation files for a given Web Script- Specified by:
getScriptDocumentPathsin interfaceStore- Parameters:
script- web script- Returns:
- array of implementation document paths
- Throws:
IOException
-
lastModified
Description copied from interface:StoreGets the last modified timestamp for the document.- Specified by:
lastModifiedin interfaceStore- Parameters:
documentPath- document path to an existing document- Returns:
- last modified timestamp
- Throws:
IOException- if the document does not exist in the store
-
hasDocument
Description copied from interface:StoreDetermines if the document exists.- Specified by:
hasDocumentin interfaceStore- Parameters:
documentPath- document path- Returns:
- true => exists, false => does not exist
-
getDocument
Description copied from interface:StoreGets a document. Note a raw InputStream to the content is returned and must be closed by the accessing method.- Specified by:
getDocumentin interfaceStore- Parameters:
documentPath- document path- Returns:
- input stream onto document
- Throws:
IOException- if the document does not exist in the store
-
createDocument
Description copied from interface:StoreCreates a document.- Specified by:
createDocumentin interfaceStore- Parameters:
documentPath- document pathcontent- content of the document to write- Throws:
IOException- if the document already exists or the create fails
-
updateDocument
Description copied from interface:StoreUpdates an existing document.- Specified by:
updateDocumentin interfaceStore- Parameters:
documentPath- document pathcontent- content to update the document with- Throws:
IOException- if the document does not exist or the update fails
-
removeDocument
Description copied from interface:StoreRemoves an existing document.- Specified by:
removeDocumentin interfaceStore- Parameters:
documentPath- document path- Returns:
- whether the operation succeeded
- Throws:
IOException- if the document does not exist or the remove fails
-
getTemplateLoader
public freemarker.cache.TemplateLoader getTemplateLoader()Description copied from interface:StoreGets the template loader for this store- Specified by:
getTemplateLoaderin interfaceStore- Returns:
- template loader
-
getScriptLoader
Description copied from interface:StoreGets the script loader for this store- Specified by:
getScriptLoaderin interfaceStore- Returns:
- script loader
-
createPath
Helper method for creating fully qualified paths- Parameters:
path- StringrelativePath- String- Returns:
- full qualified path
-
toString
-
isJarURL
Determine whether the given URL points to a resource in a jar file, that is, has protocol "jar", "zip", "vfszip", "wsjar" or "code-source"."zip" and "wsjar" and "vfszip" are used by BEA WebLogic Server and IBM WebSphere and JBoss, respectively, but can be treated like jar files. The same applies to "code-source" URLs on Oracle OC4J, provided that the path contains a jar separator.
- Parameters:
url- the URL to check- Returns:
- whether the URL has been identified as a JAR URL
-
extractJarFileURL
Extract the URL for the actual jar file from the given URL (which may point to a resource in a jar file or to a jar file itself).- Parameters:
jarUrl- the original URL- Returns:
- the URL for the actual jar file
- Throws:
MalformedURLException- if no valid jar file URL could be extracted
-