001 package railo.runtime.cfx.customtag; 002 003 import java.util.Map; 004 import java.util.Set; 005 006 import railo.commons.collections.HashTable; 007 import railo.runtime.cfx.CFXTagException; 008 import railo.runtime.cfx.CFXTagPool; 009 import railo.runtime.config.Config; 010 import railo.runtime.type.List; 011 012 import com.allaire.cfx.CustomTag; 013 014 015 /** 016 * 017 */ 018 public final class CFXTagPoolImpl implements CFXTagPool { 019 020 Config config; 021 Map classes; 022 Map objects=new HashTable(); 023 024 /** 025 * constructor of the class 026 * @param classes 027 */ 028 public CFXTagPoolImpl(Map classes) { 029 this.classes=classes; 030 } 031 032 /** 033 * @see railo.runtime.cfx.CFXTagPool#getClasses() 034 */ 035 public Map getClasses() { 036 return classes; 037 } 038 /** 039 * @see railo.runtime.cfx.CFXTagPool#getCustomTag(java.lang.String) 040 */ 041 public synchronized CustomTag getCustomTag(String name) throws CFXTagException { 042 name=name.toLowerCase(); 043 044 Object o=classes.get(name); 045 if(o==null) { 046 Set<String> set = classes.keySet(); 047 String names = List.arrayToList(set.toArray(new String[set.size()]),","); 048 049 throw new CFXTagException("there is no Custom Tag (CFX) with name ["+name+"], available Custom Tags are ["+names+"]"); 050 } 051 CFXTagClass ctc=(CFXTagClass) o; 052 CustomTag ct = ctc.newInstance(); 053 //if(!(o instanceof CustomTag))throw new CFXTagException("["+name+"] is not of type ["+CustomTag.class.getName()+"]"); 054 return ct; 055 } 056 057 // FUTURE add to interface 058 public synchronized CFXTagClass getCFXTagClass(String name) throws CFXTagException { 059 name=name.toLowerCase(); 060 CFXTagClass ctc=(CFXTagClass) classes.get(name); 061 if(ctc==null) throw new CFXTagException("there is not Custom Tag (CFX) with name ["+name+"]"); 062 return ctc; 063 } 064 065 /** 066 * @see railo.runtime.cfx.CFXTagPool#releaseCustomTag(com.allaire.cfx.CustomTag) 067 */ 068 public synchronized void releaseCustomTag(CustomTag ct) { 069 //table.put(ct.getClass().toString(),ct); 070 } 071 public synchronized void releaseTag(Object tag) { 072 //table.put(ct.getClass().toString(),ct); 073 } 074 }