Class GeneratedResource
java.lang.Object
org.springframework.core.io.AbstractResource
org.broadleafcommerce.common.resource.GeneratedResource
- All Implemented Interfaces:
Serializable
,org.springframework.core.io.InputStreamSource
,org.springframework.core.io.Resource
public class GeneratedResource
extends org.springframework.core.io.AbstractResource
implements Serializable
An in memory generated resource. This class also overrides some parent Spring AbstractResource methods to ensure
compatibility with the
ResourceHttpRequestHandler
.
Note that this class intentionally does not subclass Spring's InMemoryResource
and instead has copied
the fields here because InMemoryResource
does not provide a default constructor. This causes issues when
deserializing an instance from disk (such as in a caching scenario that overflows from memory to disk).
- Author:
- Andre Azzolini (apazzolini)
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNote: This constructor should not be explicitly usedGeneratedResource
(byte[] source, String description) -
Method Summary
Modifier and TypeMethodDescriptionboolean
byte[]
getBytes()
int
hashCode()
long
void
setHashRepresentation
(String hashRepresentation) Methods inherited from class org.springframework.core.io.AbstractResource
contentLength, createRelative, exists, getFile, getFileForLastModifiedCheck, getURI, getURL, isFile, isOpen, isReadable, readableChannel, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.core.io.Resource
getContentAsByteArray, getContentAsString
-
Field Details
-
source
protected final byte[] source -
description
-
timeGenerated
protected long timeGenerated -
hashRepresentation
-
-
Constructor Details
-
GeneratedResource
public GeneratedResource()Note: This constructor should not be explicitly usedTo properly allow for serialization, we must provide this no-arg constructor that will create a "dummy" GeneratedResource. The appropriate fields will be set during deserialization.
-
GeneratedResource
-
-
Method Details
-
getFilename
- Specified by:
getFilename
in interfaceorg.springframework.core.io.Resource
- Overrides:
getFilename
in classorg.springframework.core.io.AbstractResource
-
lastModified
- Specified by:
lastModified
in interfaceorg.springframework.core.io.Resource
- Overrides:
lastModified
in classorg.springframework.core.io.AbstractResource
- Throws:
IOException
-
getHashRepresentation
-
setHashRepresentation
-
getDescription
- Specified by:
getDescription
in interfaceorg.springframework.core.io.Resource
-
getInputStream
- Specified by:
getInputStream
in interfaceorg.springframework.core.io.InputStreamSource
- Throws:
IOException
-
hashCode
public int hashCode()- Overrides:
hashCode
in classorg.springframework.core.io.AbstractResource
-
getBytes
public byte[] getBytes() -
equals
- Overrides:
equals
in classorg.springframework.core.io.AbstractResource
-