String[] filenames=getFileNames(config, name);
boolean doCache=config.useCTPathCache();
boolean doCustomTagDeepSearch = config.doCustomTagDeepSearch();
PageSource ps=null;
InitFile initFile;
// CACHE
// check local
String localCacheName=null;
Mapping[] actms = pc.getApplicationContext().getCustomTagMappings();
Mapping[] cctms = config.getCustomTagMappings();
if(doCache) {
if(pc.getConfig().doLocalCustomTag()){
localCacheName=pc.getCurrentPageSource().getDisplayPath().replace('\\', '/');
localCacheName="local:"+localCacheName.substring(0,localCacheName.lastIndexOf('/')+1).concat(name);
initFile=config.getCTInitFile(pc, localCacheName);
if(initFile!=null) return initFile;
}
// cache application mapping
if(actms!=null)for(int i=0;i<actms.length;i++){
initFile=config.getCTInitFile(pc,"application:"+actms[i].hashCode()+"/"+name);
if(initFile!=null)return initFile;
}
// cache config mapping
if(cctms!=null)for(int i=0;i<cctms.length;i++){
initFile=config.getCTInitFile(pc,"config:"+cctms[i].hashCode()+"/"+name);
if(initFile!=null)return initFile;
}
}
// SEARCH
// search local
if(pc.getConfig().doLocalCustomTag()){
for(int i=0;i<filenames.length;i++){
PageSource[] arr = ((PageContextImpl)pc).getRelativePageSources(filenames[i]);
//ps=pc.getRelativePageSource(filenames[i]);
ps=MappingImpl.isOK(arr);
if(ps !=null) {
initFile= new InitFile(ps,filenames[i],filenames[i].endsWith('.'+config.getCFCExtension()));
if(doCache)config.putCTInitFile(localCacheName, initFile);
return initFile;
}
}
}
// search application custom tag mapping
if(actms!=null){
for(int i=0;i<filenames.length;i++){
ps=getMapping(actms, filenames[i],doCustomTagDeepSearch);
if(ps!=null) {
initFile=new InitFile(ps,filenames[i],filenames[i].endsWith('.'+config.getCFCExtension()));
if(doCache)config.putCTInitFile("application:"+ps.getMapping().hashCode()+"/"+name, initFile);
return initFile;
}
}
}
// search custom tag mappings
for(int i=0;i<filenames.length;i++){
ps=getMapping(cctms, filenames[i], doCustomTagDeepSearch);
if(ps!=null) {
initFile=new InitFile(ps,filenames[i],filenames[i].endsWith('.'+config.getCFCExtension()));
if(doCache)config.putCTInitFile("config:"+ps.getMapping().hashCode()+"/"+name, initFile);
return initFile;
}
}
return defaultValue;