org.wings.resource
Class ClassPathResource

java.lang.Object
  extended by org.wings.Resource
      extended by org.wings.StaticResource
          extended by 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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.wings.StaticResource
StaticResource.LimitedBuffer
 
Nested classes/interfaces inherited from class org.wings.Resource
Resource.HeaderEntry
 
Field Summary
protected  String resourceFileName
          The name that identifies the resource in the classpath
 
Fields inherited from class org.wings.StaticResource
buffer, externalizerFlags, maxBufferSize, size
 
Fields inherited from class org.wings.Resource
extension, headers, id, mimeType
 
Constructor Summary
ClassPathResource(ClassLoader classLoader, String resourceFileName)
          A static resource that is obtained from the specified class loader
ClassPathResource(ClassLoader classLoader, String resourceFileName, String mimeType)
          A static resource that is obtained from the specified class loader
ClassPathResource(String resourceFileName)
          A static resource that is obtained from the default classpath.
ClassPathResource(String resourceFileName, String mimeType)
          A static resource that is obtained from the default classpath.
 
Method Summary
 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.
protected  ClassLoader getClassLoader()
           
 String getResourceName()
           
protected  InputStream getResourceStream()
           
 int hashCode()
          resources using the same classloader and are denoting the same name, do have the same hashCode().
 
Methods inherited from class org.wings.StaticResource
bufferResource, getExternalizerFlags, getId, getLength, getMaxBufferSize, getURL, resolveName, setExternalizerFlags, setMaxBufferSize, setMimeType, toString, write
 
Methods inherited from class org.wings.Resource
getExtension, getHeaders, getMimeType, getSession, setHeaders
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

resourceFileName

protected final String resourceFileName
The name that identifies the resource in the classpath

Constructor Detail

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 obtained
resourceFileName - 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 obtained
resourceFileName - the resource relative to the baseClass
Method Detail

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 ;-)