org.wings.resource
Class ClassPathResource
java.lang.Object
org.wings.Resource
org.wings.StaticResource
org.wings.resource.ClassPathResource
- All Implemented Interfaces:
- Serializable, Renderable, NamedResource, URLResource
- Direct Known Subclasses:
- ClassPathJavascriptResource, ClassPathStylesheetResource, SResourceIcon
public class ClassPathResource
- extends StaticResource
- implements NamedResource
A Classpath Resource is a static resource whose content is
read from a classloader.
- Author:
- Armin Haaf, Henner Zeller
- See Also:
- Serialized Form
| Methods inherited from class org.wings.StaticResource |
bufferResource, getExternalizerFlags, getId, getLength, getMaxBufferSize, getURL, resolveName, setExternalizerFlags, setMaxBufferSize, setMimeType, toString, write |
resourceFileName
protected final String resourceFileName
- The name that identifies the resource in the classpath
ClassPathResource
public ClassPathResource(String resourceFileName)
- A static resource that is obtained from the default classpath.
ClassPathResource
public ClassPathResource(String resourceFileName,
String mimeType)
- A static resource that is obtained from the default classpath.
ClassPathResource
public ClassPathResource(ClassLoader classLoader,
String resourceFileName)
- A static resource that is obtained from the specified class loader
- Parameters:
classLoader - the classLoader from which the resource is obtainedresourceFileName - the resource relative to the baseClass
ClassPathResource
public ClassPathResource(ClassLoader classLoader,
String resourceFileName,
String mimeType)
- A static resource that is obtained from the specified class loader
- Parameters:
classLoader - the classLoader from which the resource is obtainedresourceFileName - the resource relative to the baseClass
getResourceStream
protected InputStream getResourceStream()
throws ResourceNotFoundException
- Specified by:
getResourceStream in class StaticResource
- Throws:
ResourceNotFoundException
hashCode
public int hashCode()
- resources using the same classloader and are denoting the same
name, do have the same hashCode(). Thus the same resources get the
same ID in the System externalizer.
- Overrides:
hashCode in class Object
- Returns:
- a hashcode, comprised from the hashcodes of the classloader
and from the file name of the resource.
equals
public boolean equals(Object o)
- Two ClasspathResouces are equal if both of them use the same
classloader and point to a resource with the same name.
- Overrides:
equals in class Object
- Returns:
- true if classloader and resource name are equal.
getClassLoader
protected ClassLoader getClassLoader()
- Returns:
- The stored classloader or the current context classloader if none fixed passed (prefer this case due to session serialization!)
getResourceName
public String getResourceName()
- Specified by:
getResourceName in interface NamedResource
- Returns:
- A valid name for this externalized HTTP resource.
wingS Swings ;-)