net.shibboleth.utilities.java.support.resource
Class ClasspathResource

java.lang.Object
  extended by net.shibboleth.utilities.java.support.component.AbstractDestructableInitializableComponent
      extended by net.shibboleth.utilities.java.support.resource.AbstractResource
          extended by net.shibboleth.utilities.java.support.resource.ClasspathResource
All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, ValidatableComponent, Resource

public class ClasspathResource
extends AbstractResource

A resource which reads data from the classpath.


Field Summary
private  URL classpathResource
          URL to the classpath resource.
 
Constructor Summary
ClasspathResource(String resourcePath)
          Constructor.
ClasspathResource(String resourcePath, ClassLoader classLoader)
          Constructor.
 
Method Summary
protected  boolean doExists()
          Checks whether the resource exists.
protected  InputStream doGetInputStream()
          Gets the input stream to the resource's data.
protected  long doGetLastModifiedTime()
          Gets the time, in milliseconds since the epoch, when the resource was last modified.
 
Methods inherited from class net.shibboleth.utilities.java.support.resource.AbstractResource
doValidate, equals, exists, getInputStream, getLastModifiedTime, getLocation, hashCode, setLocation, toString, validate
 
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractDestructableInitializableComponent
destroy, doDestroy, doInitialize, initialize, isDestroyed, isInitialized
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.shibboleth.utilities.java.support.component.DestructableComponent
destroy, isDestroyed
 
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
 

Field Detail

classpathResource

private final URL classpathResource
URL to the classpath resource.

Constructor Detail

ClasspathResource

public ClasspathResource(String resourcePath)
Constructor. ClassLoader used to locate the resource is the loader used to load this class. Default system character set is used as the resource character set.

Parameters:
resourcePath - classpath path to the resource

ClasspathResource

public ClasspathResource(String resourcePath,
                         ClassLoader classLoader)
Constructor.

Parameters:
resourcePath - classpath path to the resource
classLoader - class loader used to locate the resource
Method Detail

doExists

protected boolean doExists()
                    throws ResourceException
Checks whether the resource exists.

Specified by:
doExists in class AbstractResource
Returns:
true if the resource exists, false if not
Throws:
ResourceException - thrown if there is a problem determining if the resource exists

doGetInputStream

protected InputStream doGetInputStream()
                                throws ResourceException
Gets the input stream to the resource's data.

Specified by:
doGetInputStream in class AbstractResource
Returns:
input stream to the resource's data
Throws:
ResourceException - thrown if an input stream can not be created for the resource

doGetLastModifiedTime

protected long doGetLastModifiedTime()
                              throws ResourceException
Gets the time, in milliseconds since the epoch, when the resource was last modified.

Specified by:
doGetLastModifiedTime in class AbstractResource
Returns:
time, in milliseconds since the epoch, when the resource was last modified
Throws:
ResourceException - thrown if the last modified time can not be determined


Copyright © 1999-2012. All Rights Reserved.