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
HttpResourceStore
implementation.- 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 void
close()
java.nio.file.Path
createDirectory(java.lang.String name)
Creates a new directory.java.nio.file.Path
createFile(java.lang.String name)
Creates a new file.HttpResourceCache
getCache()
Obtains theHttpResourceCache
.HttpFile
getDefaultHttpFile(HttpDirectory directory)
Obtains the defaultHttpFile
for theHttpDirectory
.java.lang.String[]
getDirectoryDefaultResourceNames()
Obtains the directory default resource names.HttpResource
getHttpResource(java.lang.String path)
Obtains theHttpResource
.HttpResourceStore
getHttpResourceStore()
Obtains theHttpResourceStore
.java.lang.String
getLocation()
Obtains the location for theResourceSystem
.void
notifyResourceChanged(java.lang.String resourcePath)
Allows theResourceSystem
to notify that a resource has changed.void
setCharset(java.nio.charset.Charset charset)
Specifies theCharset
for 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.IOException
Instantiate.- Parameters:
location
- Location for theResourceSystemContext
.resourceSystemService
-ResourceSystemFactory
.fileCacheFactory
-FileCacheFactory
.transformers
-ResourceTransformer
instances.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:HttpResourceStore
Obtains theHttpResource
.- Specified by:
getHttpResource
in 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:HttpResourceStore
Obtains the defaultHttpFile
for theHttpDirectory
.- Specified by:
getDefaultHttpFile
in interfaceHttpResourceStore
- Parameters:
directory
-HttpDirectory
.- Returns:
HttpFile
for theHttpDirectory
ornull
if no defaultHttpFile
.- Throws:
java.io.IOException
- If failure in obtaining defaultHttpFile
.
-
getLocation
public java.lang.String getLocation()
Description copied from interface:ResourceSystemContext
Obtains the location for the
ResourceSystem
.The location is a free text value that is interpreted specific to the
ResourceSystem
implementation. For example:- path to a directory of a file system
- class path prefix
- etc
- Specified by:
getLocation
in interfaceResourceSystemContext
- Returns:
- Location for the
ResourceSystem
.
-
getDirectoryDefaultResourceNames
public java.lang.String[] getDirectoryDefaultResourceNames()
Description copied from interface:ResourceSystemContext
Obtains the directory default resource names.- Specified by:
getDirectoryDefaultResourceNames
in interfaceResourceSystemContext
- Returns:
- Directory default resource names.
-
getHttpResourceStore
public HttpResourceStore getHttpResourceStore()
Description copied from interface:ResourceSystemContext
Obtains theHttpResourceStore
.- Specified by:
getHttpResourceStore
in interfaceResourceSystemContext
- Returns:
HttpResourceStore
.
-
createFile
public java.nio.file.Path createFile(java.lang.String name) throws java.io.IOException
Description copied from interface:ResourceSystemContext
Creates a new file.
All files required should be created via this method. This is to ensure the files are managed.
- Specified by:
createFile
in interfaceResourceSystemContext
- Parameters:
name
- Name to aid in identifying the file for debugging.- Returns:
Path
to 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.IOException
Description copied from interface:ResourceSystemContext
Creates a new directory.
All directories should be created via this method. THis is to ensure the directories are managed.
- Specified by:
createDirectory
in interfaceResourceSystemContext
- Parameters:
name
- Name to aid in identifying the directory for debugging.- Returns:
Path
to 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:ResourceSystemContext
Specifies the
Charset
for files within theResourceSystem
.This is optional to invoke. If not configured (or configured with
null
) then theCharset.defaultCharset()
will be used as theCharset
for the files.- Specified by:
setCharset
in interfaceResourceSystemContext
- Parameters:
charset
-Charset
of the files within theResourceSystem
.
-
notifyResourceChanged
public void notifyResourceChanged(java.lang.String resourcePath)
Description copied from interface:ResourceSystemContext
Allows the
ResourceSystem
to notify that a resource has changed.The
HttpResourceStore
will then discard theHttpResource
for the path. Should the path benull
then allHttpResource
instances are discarded.- Specified by:
notifyResourceChanged
in interfaceResourceSystemContext
- Parameters:
resourcePath
- Path for the resource. Ifnull
then all resources will be discarded.
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-