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.util.ListUtil;
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        @Override
033        public Map getClasses() {
034            return classes;
035        }
036            @Override
037            public synchronized CustomTag getCustomTag(String name) throws CFXTagException {
038                    name=name.toLowerCase();
039                    
040                    Object o=classes.get(name);
041                    if(o==null) {
042                            Set<String> set = classes.keySet();
043                            String names = ListUtil.arrayToList(set.toArray(new String[set.size()]),",");
044                            
045                            throw new CFXTagException("there is no Custom Tag (CFX) with name ["+name+"], available Custom Tags are ["+names+"]");
046                    }
047                    CFXTagClass ctc=(CFXTagClass) o;
048                    CustomTag ct = ctc.newInstance();
049                    //if(!(o instanceof CustomTag))throw new CFXTagException("["+name+"] is not of type ["+CustomTag.class.getName()+"]");
050                    return ct;
051            }
052            
053            @Override
054            public synchronized CFXTagClass getCFXTagClass(String name) throws CFXTagException {
055                    name=name.toLowerCase();
056                    CFXTagClass ctc=(CFXTagClass) classes.get(name);
057                    if(ctc==null) throw new CFXTagException("there is not Custom Tag (CFX) with name ["+name+"]");
058                    return ctc;
059            }
060    
061            @Override
062            public synchronized void releaseCustomTag(CustomTag ct) {
063                    //table.put(ct.getClass().toString(),ct);
064            }
065            public synchronized void releaseTag(Object tag) {
066                    //table.put(ct.getClass().toString(),ct);
067            }
068    }