to.etc.domui.util.resources
Class ReloadingClassResourceRef

java.lang.Object
  extended by to.etc.domui.util.resources.ReloadingClassResourceRef
All Implemented Interfaces:
IModifyableResource, IResourceRef

public class ReloadingClassResourceRef
extends java.lang.Object
implements IResourceRef, IModifyableResource

This is a resource reference to something on the classpath used only in debug mode. This version allows reloading of classpath resources when they change while the server is running.

Author:
Frits Jalvingh Created on Mar 15, 2010

Constructor Summary
ReloadingClassResourceRef(IModifyableResource mr, java.lang.String name)
          Create a root-based class resource ref.
 
Method Summary
 boolean exists()
          Return T if this resource actually exists.
 java.io.InputStream getInputStream()
          This is a funny one....
 long getLastModified()
          Return the current last modification time.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReloadingClassResourceRef

public ReloadingClassResourceRef(IModifyableResource mr,
                                 java.lang.String name)
Create a root-based class resource ref.

Parameters:
mr -
name -
Method Detail

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.lang.Exception
This is a funny one.... When a class resource is loaded from a .jar file Java will cache that data. This means that even though the underlying .jar file has changed the resource as read originally will be returned, defeating the purpose of DomUI debug mode. To fix this we need to ensure that a //different// instance is returned every time the class is accessed...

Specified by:
getInputStream in interface IResourceRef
Returns:
Throws:
java.lang.Exception

exists

public boolean exists()
Description copied from interface: IResourceRef
Return T if this resource actually exists.

Specified by:
exists in interface IResourceRef
Returns:

getLastModified

public long getLastModified()
Description copied from interface: IModifyableResource
Return the current last modification time. This must return the ACTUAL modification time of the resource; the time returned by this call will be compared with the time that the resource was last used (stored somewhere else) to decide if this resource has changed in the meantime. This call must return -1 for a resource that does not exist - because non-existence is a valid caching criteria too!

Specified by:
getLastModified in interface IModifyableResource
Returns:
See Also:
IModifyableResource.getLastModified()

toString

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