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.exp.PageException;
009    import railo.runtime.op.Caster;
010    import railo.runtime.type.Query;
011    
012    public class IntervallMonitorWrap extends MonitorWrap implements IntervallMonitor {
013            private static final Object[] PARAMS_LOG = new Object[0];
014    
015            private Method log;
016            private Method getData;
017    
018            public IntervallMonitorWrap(Object monitor) {
019                    super(monitor,TYPE_INTERVALL);
020            }
021    
022            @Override
023            public void log() throws IOException {
024    
025                    try {
026                            if(log==null) {
027                                    log=monitor.getClass().getMethod("log", new Class[0]);
028                            }
029                            log.invoke(monitor, PARAMS_LOG);
030                    } catch (Exception e) {e.printStackTrace();
031                            throw ExceptionUtil.toIOException(e);
032                    } 
033            }
034    
035            public Query getData(Map<String,Object> arguments) throws PageException{
036                    try {
037                            if(getData==null) {
038                                    getData=monitor.getClass().getMethod("getData", new Class[]{Map.class});
039                            }
040                            return (Query) getData.invoke(monitor, new Object[]{arguments});
041                    } catch (Exception e) {
042                            throw Caster.toPageException(e);
043                    } 
044            }
045    
046            /*public Query getData(long minAge, long maxAge, int maxrows) throws IOException{
047                    try {
048                            if(getData==null) {
049                                    getData=monitor.getClass().getMethod("getData", new Class[]{long.class,long.class,int.class});
050                            }
051                            return (Query) getData.invoke(monitor, new Object[]{new Long(minAge),new Long(maxAge),new Integer(maxrows)});
052                    } catch (Exception e) {
053                            throw ExceptionUtil.toIOException(e);
054                    } 
055            }*/
056    
057    }