Class HttpResourceStoreImpl
- All Implemented Interfaces:
Closeable,AutoCloseable,HttpResourceStore,ResourceSystemContext
HttpResourceStore implementation.- Author:
- Daniel Sagenschneider
-
Constructor Summary
ConstructorsConstructorDescriptionHttpResourceStoreImpl(String location, ResourceSystemFactory resourceSystemService, FileCacheFactory fileCacheFactory, ResourceTransformer[] transformers, String[] directoryDefaultResourceNames) Instantiate. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()createDirectory(String name) Creates a new directory.createFile(String name) Creates a new file.getCache()Obtains theHttpResourceCache.getDefaultHttpFile(HttpDirectory directory) Obtains the defaultHttpFilefor theHttpDirectory.String[]Obtains the directory default resource names.getHttpResource(String path) Obtains theHttpResource.Obtains theHttpResourceStore.Obtains the location for theResourceSystem.voidnotifyResourceChanged(String resourcePath) Allows theResourceSystemto notify that a resource has changed.voidsetCharset(Charset charset) Specifies theCharsetfor files within theResourceSystem.
-
Constructor Details
-
HttpResourceStoreImpl
public HttpResourceStoreImpl(String location, ResourceSystemFactory resourceSystemService, FileCacheFactory fileCacheFactory, ResourceTransformer[] transformers, String[] directoryDefaultResourceNames) throws IOException Instantiate.- Parameters:
location- Location for theResourceSystemContext.resourceSystemService-ResourceSystemFactory.fileCacheFactory-FileCacheFactory.transformers-ResourceTransformerinstances.directoryDefaultResourceNames- Directory default resource names.- Throws:
IOException- If fails to instantiate theHttpResourceStore.
-
-
Method Details
-
getCache
Obtains theHttpResourceCache.- Returns:
HttpResourceCache.
-
getHttpResource
Description copied from interface:HttpResourceStoreObtains theHttpResource.- Specified by:
getHttpResourcein interfaceHttpResourceStore- Parameters:
path- Path to theHttpResource.- Returns:
HttpResource.- Throws:
IOException- If failure in finding theHttpResource.
-
getDefaultHttpFile
Description copied from interface:HttpResourceStoreObtains the defaultHttpFilefor theHttpDirectory.- Specified by:
getDefaultHttpFilein interfaceHttpResourceStore- Parameters:
directory-HttpDirectory.- Returns:
HttpFilefor theHttpDirectoryornullif no defaultHttpFile.- Throws:
IOException- If failure in obtaining defaultHttpFile.
-
getLocation
Description copied from interface:ResourceSystemContextObtains the location for the
ResourceSystem.The location is a free text value that is interpreted specific to the
ResourceSystemimplementation. For example:- path to a directory of a file system
- class path prefix
- etc
- Specified by:
getLocationin interfaceResourceSystemContext- Returns:
- Location for the
ResourceSystem.
-
getDirectoryDefaultResourceNames
Description copied from interface:ResourceSystemContextObtains the directory default resource names.- Specified by:
getDirectoryDefaultResourceNamesin interfaceResourceSystemContext- Returns:
- Directory default resource names.
-
getHttpResourceStore
Description copied from interface:ResourceSystemContextObtains theHttpResourceStore.- Specified by:
getHttpResourceStorein interfaceResourceSystemContext- Returns:
HttpResourceStore.
-
createFile
Description copied from interface:ResourceSystemContextCreates a new file.
All files required should be created via this method. This is to ensure the files are managed.
- Specified by:
createFilein interfaceResourceSystemContext- Parameters:
name- Name to aid in identifying the file for debugging.- Returns:
Pathto the new file.- Throws:
IOException- If fails to create the new file.
-
createDirectory
Description copied from interface:ResourceSystemContextCreates a new directory.
All directories should be created via this method. THis is to ensure the directories are managed.
- Specified by:
createDirectoryin interfaceResourceSystemContext- Parameters:
name- Name to aid in identifying the directory for debugging.- Returns:
Pathto the new directory.- Throws:
IOException- If fails to create the new directory.
-
setCharset
Description copied from interface:ResourceSystemContextSpecifies the
Charsetfor files within theResourceSystem.This is optional to invoke. If not configured (or configured with
null) then theCharset.defaultCharset()will be used as theCharsetfor the files.- Specified by:
setCharsetin interfaceResourceSystemContext- Parameters:
charset-Charsetof the files within theResourceSystem.
-
notifyResourceChanged
Description copied from interface:ResourceSystemContextAllows the
ResourceSystemto notify that a resource has changed.The
HttpResourceStorewill then discard theHttpResourcefor the path. Should the path benullthen allHttpResourceinstances are discarded.- Specified by:
notifyResourceChangedin interfaceResourceSystemContext- Parameters:
resourcePath- Path for the resource. Ifnullthen all resources will be discarded.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-