org.rythmengine.resource
Class TemplateResourceBase

java.lang.Object
  extended by org.rythmengine.resource.TemplateResourceBase
All Implemented Interfaces:
Serializable, ITemplateResource
Direct Known Subclasses:
ClasspathTemplateResource, FileTemplateResource, StringTemplateResource, ToStringTemplateResource

public abstract class TemplateResourceBase
extends Object
implements ITemplateResource

Encapsulate the common logic of an ITemplateResource implementation

See Also:
Serialized Form

Field Summary
protected  String cache
           
protected  boolean isProdMode
           
protected  ITemplateResourceLoader loader
          When this field is set to null, it assumes using Rythm's singleton mode

This field should be set to null if needs to serialize the template resource to some where, e.g.

protected static ILogger logger
           
protected  long nextCheckPoint
           
 
Constructor Summary
TemplateResourceBase()
          There are certain cases that a type of resource does not need a specific loader.
TemplateResourceBase(ITemplateResourceLoader loader)
           
 
Method Summary
 String asTemplateContent()
          Return template content as a string.
 ICodeType codeType(RythmEngine engine)
          Return code type suggested by this resource, e.g.
protected abstract  long defCheckInterval()
           
 boolean equals(Object obj)
           
protected  RythmEngine getEngine()
           
 ITemplateResourceLoader getLoader()
          Return the loader that loaded this resource
 String getSuggestedClassName()
          Propose a name of generated java class for this resource
static ICodeType getTypeOfPath(RythmEngine engine, String s)
           
 int hashCode()
           
protected abstract  long lastModified()
           
protected static String path2CN(String path)
           
 boolean refresh()
          Refresh resource if necessary
protected abstract  String reload()
           
protected  Long userCheckInterval()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.rythmengine.resource.ITemplateResource
getKey, isValid
 

Field Detail

logger

protected static final ILogger logger

loader

protected final ITemplateResourceLoader loader
When this field is set to null, it assumes using Rythm's singleton mode

This field should be set to null if needs to serialize the template resource to some where, e.g. Cache


isProdMode

protected boolean isProdMode

cache

protected String cache

nextCheckPoint

protected long nextCheckPoint
Constructor Detail

TemplateResourceBase

public TemplateResourceBase()
There are certain cases that a type of resource does not need a specific loader. E.g the ToStringTemplateResource


TemplateResourceBase

public TemplateResourceBase(ITemplateResourceLoader loader)
Method Detail

getEngine

protected RythmEngine getEngine()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

defCheckInterval

protected abstract long defCheckInterval()

userCheckInterval

protected Long userCheckInterval()

lastModified

protected abstract long lastModified()

reload

protected abstract String reload()

asTemplateContent

public String asTemplateContent()
Description copied from interface: ITemplateResource
Return template content as a string. Call refresh() first to check if the resource has been modified

Specified by:
asTemplateContent in interface ITemplateResource
Returns:
resource content

refresh

public final boolean refresh()
Description copied from interface: ITemplateResource
Refresh resource if necessary

Specified by:
refresh in interface ITemplateResource
Returns:
true if resource is modified false otherwise

getSuggestedClassName

public String getSuggestedClassName()
Description copied from interface: ITemplateResource
Propose a name of generated java class for this resource

Specified by:
getSuggestedClassName in interface ITemplateResource
Returns:
suggested class name

getTypeOfPath

public static ICodeType getTypeOfPath(RythmEngine engine,
                                      String s)

codeType

public ICodeType codeType(RythmEngine engine)
Description copied from interface: ITemplateResource
Return code type suggested by this resource, e.g. html or js etc

Specified by:
codeType in interface ITemplateResource
Returns:
code type suggested

getLoader

public ITemplateResourceLoader getLoader()
Description copied from interface: ITemplateResource
Return the loader that loaded this resource

Specified by:
getLoader in interface ITemplateResource
Returns:

path2CN

protected static String path2CN(String path)


Copyright © 2014. All Rights Reserved.