001    package railo.runtime.tag;
002    
003    import railo.runtime.cfx.CFXTagException;
004    import railo.runtime.cfx.CFXTagPool;
005    import railo.runtime.cfx.RequestImpl;
006    import railo.runtime.cfx.ResponseImpl;
007    import railo.runtime.exp.PageException;
008    import railo.runtime.ext.tag.AppendixTag;
009    import railo.runtime.ext.tag.DynamicAttributes;
010    import railo.runtime.ext.tag.TagImpl;
011    import railo.runtime.op.Caster;
012    import railo.runtime.type.Collection;
013    import railo.runtime.type.KeyImpl;
014    import railo.runtime.type.Struct;
015    import railo.runtime.type.StructImpl;
016    
017    import com.allaire.cfx.CustomTag;
018    import com.allaire.cfx.Request;
019    import com.allaire.cfx.Response;
020    
021    /**
022    * Creates a CFML CFX Tag
023    *
024    *
025    *
026    **/
027    public final class CFXTag extends TagImpl implements DynamicAttributes,AppendixTag {
028    
029            private Struct attributes=new StructImpl();
030            private String appendix;
031            
032            @Override
033            public void release() {
034                    attributes.clear();
035                    appendix=null;
036            }
037    
038            @Override
039            public void setAppendix(String appendix) {
040            //print.out(appendix);
041            this.appendix = appendix;
042        }
043            
044        @Override
045            public void setDynamicAttribute(String domain, String key, Object value) {
046                    setDynamicAttribute(domain, KeyImpl.init(key), value);
047            }
048            
049            @Override
050            public void setDynamicAttribute(String domain, Collection.Key key, Object value) {
051                    attributes.setEL(key,value);
052            }
053    
054            @Override
055            public int doStartTag() throws PageException {
056                // RR SerialNumber sn = pageContext.getConfig().getSerialNumber();
057                // if(sn.getVersion()==SerialNumber.VERSION_COMMUNITY)
058                //     throw new SecurityException("no access to this functionality with the "+sn.getStringVersion()+" version of railo");
059                
060                    
061                    CFXTagPool pool=pageContext.getConfig().getCFXTagPool();
062                    CustomTag ct;
063                    try {
064                            ct = pool.getCustomTag(appendix);
065                    } 
066            catch (CFXTagException e) {
067                            throw Caster.toPageException(e);
068                    }
069                    Request req=new RequestImpl(pageContext,attributes);
070                    Response rsp=new ResponseImpl(pageContext,req.debug());
071                    try {
072                            ct.processRequest(req,rsp);
073                    } catch (Exception e) {
074                            throw Caster.toPageException(e);
075                    }
076                    pool.releaseCustomTag(ct);
077                    
078                    return SKIP_BODY;
079            }
080    
081        public String getAppendix() {
082            return appendix;
083        }
084    }