org.broadleafcommerce.common.resource
Class GeneratedResource

java.lang.Object
  extended by org.springframework.core.io.AbstractResource
      extended by 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:
Serialized Form

Field Summary
protected  String description
           
protected  String hashRepresentation
           
protected  byte[] source
           
protected  long timeGenerated
           
 
Constructor Summary
GeneratedResource()
          Note: This constructor should not be explicitly used To properly allow for serialization, we must provide this no-arg constructor that will create a "dummy" GeneratedResource.
GeneratedResource(byte[] source, String description)
           
 
Method Summary
 boolean equals(Object res)
           
 String getDescription()
           
 String getFilename()
           
 String getHashRepresentation()
           
 InputStream getInputStream()
           
 int hashCode()
           
 long lastModified()
           
 void setHashRepresentation(String hashRepresentation)
           
 
Methods inherited from class org.springframework.core.io.AbstractResource
contentLength, createRelative, exists, getFile, getFileForLastModifiedCheck, getURI, getURL, isOpen, isReadable, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

timeGenerated

protected long timeGenerated

hashRepresentation

protected String hashRepresentation

source

protected final byte[] source

description

protected final String description
Constructor Detail

GeneratedResource

public GeneratedResource()
Note: This constructor should not be explicitly used To 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

public GeneratedResource(byte[] source,
                         String description)
Method Detail

getFilename

public String getFilename()
Specified by:
getFilename in interface org.springframework.core.io.Resource
Overrides:
getFilename in class org.springframework.core.io.AbstractResource

lastModified

public long lastModified()
                  throws IOException
Specified by:
lastModified in interface org.springframework.core.io.Resource
Overrides:
lastModified in class org.springframework.core.io.AbstractResource
Throws:
IOException

getHashRepresentation

public String getHashRepresentation()

setHashRepresentation

public void setHashRepresentation(String hashRepresentation)

getDescription

public String getDescription()
Specified by:
getDescription in interface org.springframework.core.io.Resource

getInputStream

public InputStream getInputStream()
                           throws IOException
Specified by:
getInputStream in interface org.springframework.core.io.InputStreamSource
Throws:
IOException

hashCode

public int hashCode()
Overrides:
hashCode in class org.springframework.core.io.AbstractResource

equals

public boolean equals(Object res)
Overrides:
equals in class org.springframework.core.io.AbstractResource


Copyright © 2013. All Rights Reserved.