org.olat.core.gui.media
Class ClasspathMediaResource

java.lang.Object
  extended by org.olat.core.logging.LogDelegator
      extended by org.olat.core.gui.media.ClasspathMediaResource
All Implemented Interfaces:
MediaResource

public class ClasspathMediaResource
extends LogDelegator
implements MediaResource

The ClasspathMediaResource delivers files directly from the classpath, e.g. to deliver a css file that is located in the _static directory in your package (src dir or from jar). Normally you just use the JsAndCSSComponent or the ClassPathStaticDispatcher

Author:
Felix Jost

Constructor Summary
ClasspathMediaResource(java.lang.Class clazz, java.lang.String location)
          Constructor that uses class cloader of given class
ClasspathMediaResource(java.lang.Package pakkage, java.lang.String location)
          Constructor that uses class loader of this (ClasspathMediaResource) class
 
Method Summary
 java.lang.String getContentType()
           
 java.io.InputStream getInputStream()
           
 java.lang.Long getLastModified()
           
 java.lang.Long getSize()
           
 void prepare(javax.servlet.http.HttpServletResponse hres)
           
 void release()
           
 boolean resourceExists()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClasspathMediaResource

public ClasspathMediaResource(java.lang.Package pakkage,
                              java.lang.String location)
Constructor that uses class loader of this (ClasspathMediaResource) class

Parameters:
pakkage - the package name (e.g. org.olat.core)
location - the relative file path (e.g. _static/my/file.css)

ClasspathMediaResource

public ClasspathMediaResource(java.lang.Class clazz,
                              java.lang.String location)
Constructor that uses class cloader of given class

Parameters:
clazz -
location - the relative file path (e.g. _static/my/file.css)
Method Detail

getContentType

public java.lang.String getContentType()
Specified by:
getContentType in interface MediaResource
Returns:
See Also:
MediaResource.getContentType()

getSize

public java.lang.Long getSize()
Specified by:
getSize in interface MediaResource
Returns:
See Also:
MediaResource.getSize()

getInputStream

public java.io.InputStream getInputStream()
Specified by:
getInputStream in interface MediaResource
Returns:
See Also:
MediaResource.getInputStream()

getLastModified

public java.lang.Long getLastModified()
Specified by:
getLastModified in interface MediaResource
Returns:
See Also:
MediaResource.getLastModified()

release

public void release()
Specified by:
release in interface MediaResource
See Also:
MediaResource.release()

prepare

public void prepare(javax.servlet.http.HttpServletResponse hres)
Specified by:
prepare in interface MediaResource
See Also:
MediaResource.prepare(javax.servlet.http.HttpServletResponse)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

resourceExists

public boolean resourceExists()
Returns:
true: resource exists and can be delivered; false: resource could not be found, delivery will fail