001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.tag; 020 021import lucee.runtime.cfx.CFXTagException; 022import lucee.runtime.cfx.CFXTagPool; 023import lucee.runtime.cfx.RequestImpl; 024import lucee.runtime.cfx.ResponseImpl; 025import lucee.runtime.exp.PageException; 026import lucee.runtime.ext.tag.AppendixTag; 027import lucee.runtime.ext.tag.DynamicAttributes; 028import lucee.runtime.ext.tag.TagImpl; 029import lucee.runtime.op.Caster; 030import lucee.runtime.type.Collection; 031import lucee.runtime.type.KeyImpl; 032import lucee.runtime.type.Struct; 033import lucee.runtime.type.StructImpl; 034 035import com.allaire.cfx.CustomTag; 036import com.allaire.cfx.Request; 037import com.allaire.cfx.Response; 038 039/** 040* Creates a CFML CFX Tag 041* 042* 043* 044**/ 045public final class CFXTag extends TagImpl implements DynamicAttributes,AppendixTag { 046 047 private Struct attributes=new StructImpl(); 048 private String appendix; 049 050 @Override 051 public void release() { 052 attributes.clear(); 053 appendix=null; 054 } 055 056 @Override 057 public void setAppendix(String appendix) { 058 //print.out(appendix); 059 this.appendix = appendix; 060 } 061 062 @Override 063 public void setDynamicAttribute(String domain, String key, Object value) { 064 setDynamicAttribute(domain, KeyImpl.init(key), value); 065 } 066 067 @Override 068 public void setDynamicAttribute(String domain, Collection.Key key, Object value) { 069 attributes.setEL(key,value); 070 } 071 072 @Override 073 public int doStartTag() throws PageException { 074 // RR SerialNumber sn = pageContext.getConfig().getSerialNumber(); 075 // if(sn.getVersion()==SerialNumber.VERSION_COMMUNITY) 076 // throw new SecurityException("no access to this functionality with the "+sn.getStringVersion()+" version of lucee"); 077 078 079 CFXTagPool pool=pageContext.getConfig().getCFXTagPool(); 080 CustomTag ct; 081 try { 082 ct = pool.getCustomTag(appendix); 083 } 084 catch (CFXTagException e) { 085 throw Caster.toPageException(e); 086 } 087 Request req=new RequestImpl(pageContext,attributes); 088 Response rsp=new ResponseImpl(pageContext,req.debug()); 089 try { 090 ct.processRequest(req,rsp); 091 } catch (Exception e) { 092 throw Caster.toPageException(e); 093 } 094 pool.releaseCustomTag(ct); 095 096 return SKIP_BODY; 097 } 098 099 public String getAppendix() { 100 return appendix; 101 } 102}