1 16 package org.directwebremoting.filter; 17 18 import java.lang.reflect.Method ; 19 20 import org.directwebremoting.AjaxFilter; 21 import org.directwebremoting.AjaxFilterChain; 22 23 30 public class ExtraLatencyAjaxFilter implements AjaxFilter 31 { 32 35 public Object doFilter(Object obj, Method method, Object [] params, AjaxFilterChain chain) throws Exception 36 { 37 synchronized (this) 38 { 39 try 40 { 41 wait(delay/2); 42 } 43 catch (InterruptedException ex) 44 { 45 ex.printStackTrace(); 46 } 47 } 48 49 Object reply = chain.doFilter(obj, method, params); 50 51 synchronized (this) 52 { 53 try 54 { 55 wait(delay/2); 56 } 57 catch (InterruptedException ex) 58 { 59 ex.printStackTrace(); 60 } 61 } 62 63 return reply; 64 } 65 66 69 public long getDelay() 70 { 71 return delay; 72 } 73 74 77 public void setDelay(long delay) 78 { 79 this.delay = delay; 80 } 81 82 private long delay = 100; 83 } 84 | Popular Tags |