public class ClassPathSource extends Object implements ISource
注意: 1:如果被加载的文件是 class path 中的普通文件,则该文件支持热加载 2:如果被加载的文件处于 jar 包之中,则该文件不支持热加载,jar 包之中的文件在运行时通常不会被修改 在极少数情况下如果需要对 jar 包之中的模板文件进行热加载,可以通过继承 ClassPathSource 的方式进行扩展 3:JFinal Template Engine 开启热加载需要配置 engine.setDevMode(true)
Modifier and Type | Field and Description |
---|---|
protected ClassLoader |
classLoader |
protected String |
encoding |
protected String |
fileName |
protected String |
finalFileName |
protected boolean |
isInJar |
protected long |
lastModified |
protected URL |
url |
Constructor and Description |
---|
ClassPathSource(String fileName) |
ClassPathSource(String baseTemplatePath,
String fileName) |
ClassPathSource(String baseTemplatePath,
String fileName,
String encoding) |
Modifier and Type | Method and Description |
---|---|
protected String |
buildFinalFileName(String baseTemplatePath,
String fileName) |
protected ClassLoader |
getClassLoader() |
StringBuilder |
getContent()
content of ISource
|
String |
getEncoding()
encoding of content
|
String |
getKey()
key used to cache, return null if do not cache the template
注意:如果不希望缓存从该 ISource 解析出来的 Template 对象
让 getKey() 返回 null 值即可
|
protected long |
getLastModified() |
boolean |
isModified()
模板文件在 jar 包文件之内则不支持热加载
|
static StringBuilder |
loadFile(InputStream inputStream,
String encoding) |
protected void |
processIsInJarAndlastModified() |
String |
toString() |
protected String finalFileName
protected String fileName
protected String encoding
protected boolean isInJar
protected long lastModified
protected ClassLoader classLoader
protected URL url
public ClassPathSource(String fileName)
protected void processIsInJarAndlastModified()
protected ClassLoader getClassLoader()
public String getKey()
ISource
public String getEncoding()
ISource
getEncoding
in interface ISource
protected long getLastModified()
public boolean isModified()
isModified
in interface ISource
public StringBuilder getContent()
ISource
getContent
in interface ISource
public static StringBuilder loadFile(InputStream inputStream, String encoding)
Copyright © 2018. All rights reserved.