001 package railo.runtime.monitor; 002 003 import java.io.IOException; 004 import java.lang.reflect.Method; 005 import java.util.Map; 006 007 import railo.commons.lang.ExceptionUtil; 008 import railo.runtime.PageContext; 009 import railo.runtime.config.ConfigWeb; 010 import railo.runtime.exp.PageException; 011 import railo.runtime.op.Caster; 012 import railo.runtime.type.Query; 013 014 public class RequestMonitorWrap extends MonitorWrap implements RequestMonitor { 015 private static final Class[] PARAMS_LOG = new Class[]{PageContext.class,boolean.class}; 016 017 private Method log; 018 private Method getData; 019 020 private Method getDataRaw; 021 022 023 024 public RequestMonitorWrap(Object monitor) { 025 super(monitor,TYPE_REQUEST); 026 } 027 028 @Override 029 public void log(PageContext pc, boolean error) throws IOException { 030 031 try { 032 if(log==null) { 033 log=monitor.getClass().getMethod("log", PARAMS_LOG); 034 } 035 log.invoke(monitor, new Object[]{pc,Caster.toBoolean(error)}); 036 } catch (Exception e) { 037 throw ExceptionUtil.toIOException(e); 038 } 039 } 040 041 public Query getData(ConfigWeb config,Map<String,Object> arguments) throws PageException{ 042 try { 043 if(getData==null) { 044 getData=monitor.getClass().getMethod("getData", new Class[]{ConfigWeb.class,Map.class}); 045 } 046 return (Query) getData.invoke(monitor, new Object[]{config,arguments}); 047 } catch (Exception e) { 048 throw Caster.toPageException(e); 049 } 050 } 051 052 053 /* 054 public Query getData(ConfigWeb config,long minAge, long maxAge, int maxrows) throws IOException{ 055 try { 056 if(getData==null) { 057 getData=monitor.getClass().getMethod("getData", new Class[]{long.class,long.class,int.class}); 058 } 059 return (Query) getData.invoke(monitor, new Object[]{new Long(minAge),new Long(maxAge),new Integer(maxrows)}); 060 } catch (Exception e) { 061 throw ExceptionUtil.toIOException(e); 062 } 063 } 064 065 public Query getDataRaw(ConfigWeb config, long minAge, long maxAge) throws IOException { 066 try { 067 if(getDataRaw==null) { 068 getDataRaw=monitor.getClass().getMethod("getDataRaw", new Class[]{ConfigWeb.class,long.class,long.class}); 069 } 070 return (Query) getDataRaw.invoke(monitor, new Object[]{config,new Long(minAge),new Long(maxAge)}); 071 } catch (Exception e) {e.printStackTrace(); 072 throw ExceptionUtil.toIOException(e); 073 } 074 }*/ 075 }