public abstract class TemplateResourceBase extends Object implements ITemplateResource
Encapsulate the common logic of an ITemplateResource implementation
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
TemplateResourceBase()
There are certain cases that a type of resource does not need a specific loader.
|
TemplateResourceBase(ITemplateResourceLoader loader) |
| Modifier and Type | Method and Description |
|---|---|
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() |
Throwable |
getError() |
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() |
void |
setError(Throwable error) |
protected Long |
userCheckInterval() |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitgetKey, isValidprotected static final ILogger logger
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. Cacheprotected boolean isProdMode
protected String cache
protected long nextCheckPoint
public TemplateResourceBase()
There are certain cases that a type of resource does not need a specific loader. E.g the ToStringTemplateResource
public TemplateResourceBase(ITemplateResourceLoader loader)
public Throwable getError()
getError in interface ITemplateResourcepublic void setError(Throwable error)
setError in interface ITemplateResourceerror - the error to setprotected RythmEngine getEngine()
protected abstract long defCheckInterval()
protected Long userCheckInterval()
protected abstract long lastModified()
protected abstract String reload()
public String asTemplateContent()
ITemplateResourceReturn template content as a string. Call refresh() first to check if the resource has been modified
asTemplateContent in interface ITemplateResourcepublic final boolean refresh()
ITemplateResourceRefresh resource if necessary
refresh in interface ITemplateResourcepublic String getSuggestedClassName()
ITemplateResourcePropose a name of generated java class for this resource
getSuggestedClassName in interface ITemplateResourcepublic static ICodeType getTypeOfPath(RythmEngine engine, String s)
public ICodeType codeType(RythmEngine engine)
ITemplateResourceReturn code type suggested by this resource, e.g. html or js etc
codeType in interface ITemplateResourcepublic ITemplateResourceLoader getLoader()
ITemplateResourceReturn the loader that loaded this resource
getLoader in interface ITemplateResourceCopyright © 2017–2021 OSGL (Open Source General Library). All rights reserved.