enjoy 3.5
This commit is contained in:
@@ -35,6 +35,7 @@ import com.jfinal.template.source.ISource;
|
||||
import com.jfinal.template.source.ISourceFactory;
|
||||
import com.jfinal.template.source.StringSource;
|
||||
import com.jfinal.template.stat.Location;
|
||||
import com.jfinal.template.stat.OutputDirectiveFactory;
|
||||
import com.jfinal.template.stat.Parser;
|
||||
import com.jfinal.template.stat.ast.Define;
|
||||
import com.jfinal.template.stat.ast.Output;
|
||||
@@ -48,14 +49,14 @@ public class EngineConfig {
|
||||
|
||||
WriterBuffer writerBuffer = new WriterBuffer();
|
||||
|
||||
private Map<String, Define> sharedFunctionMap = new HashMap<String, Define>();
|
||||
private Map<String, Define> sharedFunctionMap = createSharedFunctionMap(); // new HashMap<String, Define>(512, 0.25F);
|
||||
private List<ISource> sharedFunctionSourceList = new ArrayList<ISource>(); // for devMode only
|
||||
|
||||
Map<String, Object> sharedObjectMap = null;
|
||||
|
||||
private IOutputDirectiveFactory outputDirectiveFactory = OutputDirectiveFactory.me;
|
||||
private OutputDirectiveFactory outputDirectiveFactory = OutputDirectiveFactory.me;
|
||||
private ISourceFactory sourceFactory = new FileSourceFactory();
|
||||
private Map<String, Class<? extends Directive>> directiveMap = new HashMap<String, Class<? extends Directive>>();
|
||||
private Map<String, Class<? extends Directive>> directiveMap = new HashMap<String, Class<? extends Directive>>(64, 0.5F);
|
||||
private SharedMethodKit sharedMethodKit = new SharedMethodKit();
|
||||
|
||||
private boolean devMode = false;
|
||||
@@ -179,7 +180,7 @@ public class EngineConfig {
|
||||
* 开发者可直接使用模板注释功能将不需要的 function 直接注释掉
|
||||
*/
|
||||
private synchronized void reloadSharedFunctionSourceList() {
|
||||
Map<String, Define> newMap = new HashMap<String, Define>();
|
||||
Map<String, Define> newMap = createSharedFunctionMap();
|
||||
for (int i = 0, size = sharedFunctionSourceList.size(); i < size; i++) {
|
||||
ISource source = sharedFunctionSourceList.get(i);
|
||||
String fileName = source instanceof FileSource ? ((FileSource)source).getFileName() : null;
|
||||
@@ -194,9 +195,13 @@ public class EngineConfig {
|
||||
this.sharedFunctionMap = newMap;
|
||||
}
|
||||
|
||||
private Map<String, Define> createSharedFunctionMap() {
|
||||
return new HashMap<String, Define>(512, 0.25F);
|
||||
}
|
||||
|
||||
public synchronized void addSharedObject(String name, Object object) {
|
||||
if (sharedObjectMap == null) {
|
||||
sharedObjectMap = new HashMap<String, Object>();
|
||||
sharedObjectMap = new HashMap<String, Object>(64, 0.25F);
|
||||
} else if (sharedObjectMap.containsKey(name)) {
|
||||
throw new IllegalArgumentException("Shared object already exists: " + name);
|
||||
}
|
||||
@@ -210,7 +215,7 @@ public class EngineConfig {
|
||||
/**
|
||||
* Set output directive factory
|
||||
*/
|
||||
public void setOutputDirectiveFactory(IOutputDirectiveFactory outputDirectiveFactory) {
|
||||
public void setOutputDirectiveFactory(OutputDirectiveFactory outputDirectiveFactory) {
|
||||
if (outputDirectiveFactory == null) {
|
||||
throw new IllegalArgumentException("outputDirectiveFactory can not be null");
|
||||
}
|
||||
|
Reference in New Issue
Block a user