001 package railo.runtime.cfx.customtag; 002 003 import java.lang.reflect.Method; 004 005 import railo.commons.lang.ClassException; 006 import railo.commons.lang.ClassUtil; 007 import railo.runtime.cfx.CFXTagException; 008 009 import com.allaire.cfx.CustomTag; 010 import com.allaire.cfx.Request; 011 import com.allaire.cfx.Response; 012 013 public class CPPCustomTag implements CustomTag { 014 015 // this is loaded dynamic, because the lib is optional 016 private static Method processRequest; 017 018 private boolean keepAlive; 019 private String procedure; 020 private String serverLibrary; 021 022 public CPPCustomTag(String serverLibrary, String procedure, boolean keepAlive) throws CFXTagException{ 023 this.serverLibrary=serverLibrary; 024 this.procedure=procedure; 025 this.keepAlive=keepAlive; 026 if(processRequest==null){ 027 Class clazz = null; 028 try { 029 clazz = ClassUtil.loadClass("com.naryx.tagfusion.cfx.CFXNativeLib"); 030 } catch (ClassException e) { 031 032 033 throw new CFXTagException( 034 "cannot initialize C++ Custom tag library, make sure you have added all the required jar files. "+ 035 "GO to the Railo Server Administrator and on the page Services/Update, click on \"Update JARs\""); 036 037 } 038 try { 039 processRequest=clazz.getMethod("processRequest", new Class[]{String.class,String.class,Request.class,Response.class,boolean.class}); 040 } catch (NoSuchMethodException e) { 041 throw new CFXTagException(e); 042 } 043 } 044 } 045 046 public void processRequest(Request request, Response response) throws Exception { 047 048 processRequest.invoke(null, new Object[]{serverLibrary, procedure, request, response, keepAlive}); 049 //CFXNativeLib.processRequest(serverLibrary, procedure, request, response, keepAlive); 050 } 051 052 }