Class HttpResourceStoreImpl
- java.lang.Object
-
- net.officefloor.web.resource.impl.HttpResourceStoreImpl
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,HttpResourceStore,ResourceSystemContext
public class HttpResourceStoreImpl extends java.lang.Object implements HttpResourceStore, ResourceSystemContext, java.io.Closeable
HttpResourceStoreimplementation.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description HttpResourceStoreImpl(java.lang.String location, ResourceSystemFactory resourceSystemService, FileCacheFactory fileCacheFactory, ResourceTransformer[] transformers, java.lang.String[] directoryDefaultResourceNames)Instantiate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()java.nio.file.PathcreateDirectory(java.lang.String name)Creates a new directory.java.nio.file.PathcreateFile(java.lang.String name)Creates a new file.HttpResourceCachegetCache()Obtains theHttpResourceCache.HttpFilegetDefaultHttpFile(HttpDirectory directory)Obtains the defaultHttpFilefor theHttpDirectory.java.lang.String[]getDirectoryDefaultResourceNames()Obtains the directory default resource names.HttpResourcegetHttpResource(java.lang.String path)Obtains theHttpResource.HttpResourceStoregetHttpResourceStore()Obtains theHttpResourceStore.java.lang.StringgetLocation()Obtains the location for theResourceSystem.voidnotifyResourceChanged(java.lang.String resourcePath)Allows theResourceSystemto notify that a resource has changed.voidsetCharset(java.nio.charset.Charset charset)Specifies theCharsetfor files within theResourceSystem.
-
-
-
Constructor Detail
-
HttpResourceStoreImpl
public HttpResourceStoreImpl(java.lang.String location, ResourceSystemFactory resourceSystemService, FileCacheFactory fileCacheFactory, ResourceTransformer[] transformers, java.lang.String[] directoryDefaultResourceNames) throws java.io.IOExceptionInstantiate.- Parameters:
location- Location for theResourceSystemContext.resourceSystemService-ResourceSystemFactory.fileCacheFactory-FileCacheFactory.transformers-ResourceTransformerinstances.directoryDefaultResourceNames- Directory default resource names.- Throws:
java.io.IOException- If fails to instantiate theHttpResourceStore.
-
-
Method Detail
-
getCache
public HttpResourceCache getCache()
Obtains theHttpResourceCache.- Returns:
HttpResourceCache.
-
getHttpResource
public HttpResource getHttpResource(java.lang.String path) throws java.io.IOException
Description copied from interface:HttpResourceStoreObtains theHttpResource.- Specified by:
getHttpResourcein interfaceHttpResourceStore- Parameters:
path- Path to theHttpResource.- Returns:
HttpResource.- Throws:
java.io.IOException- If failure in finding theHttpResource.
-
getDefaultHttpFile
public HttpFile getDefaultHttpFile(HttpDirectory directory) throws java.io.IOException
Description copied from interface:HttpResourceStoreObtains the defaultHttpFilefor theHttpDirectory.- Specified by:
getDefaultHttpFilein interfaceHttpResourceStore- Parameters:
directory-HttpDirectory.- Returns:
HttpFilefor theHttpDirectoryornullif no defaultHttpFile.- Throws:
java.io.IOException- If failure in obtaining defaultHttpFile.
-
getLocation
public java.lang.String 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
public java.lang.String[] getDirectoryDefaultResourceNames()
Description copied from interface:ResourceSystemContextObtains the directory default resource names.- Specified by:
getDirectoryDefaultResourceNamesin interfaceResourceSystemContext- Returns:
- Directory default resource names.
-
getHttpResourceStore
public HttpResourceStore getHttpResourceStore()
Description copied from interface:ResourceSystemContextObtains theHttpResourceStore.- Specified by:
getHttpResourceStorein interfaceResourceSystemContext- Returns:
HttpResourceStore.
-
createFile
public java.nio.file.Path createFile(java.lang.String name) throws java.io.IOExceptionDescription 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:
java.io.IOException- If fails to create the new file.
-
createDirectory
public java.nio.file.Path createDirectory(java.lang.String name) throws java.io.IOExceptionDescription 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:
java.io.IOException- If fails to create the new directory.
-
setCharset
public void setCharset(java.nio.charset.Charset charset)
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
public void notifyResourceChanged(java.lang.String resourcePath)
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
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-