1 22 package org.jboss.ha.framework.test; 23 24 import org.jboss.invocation.Invocation; 25 import org.jboss.invocation.PayloadKey; 26 27 43 44 public class ExplicitFailoverClientInterceptor extends org.jboss.proxy.Interceptor 45 { 46 47 49 51 53 55 public ExplicitFailoverClientInterceptor () 56 { 57 } 58 59 61 63 65 public Object invoke (Invocation mi) throws Throwable 66 { 67 Object failover = System.getProperty ("JBossCluster-DoFail"); 68 boolean doFail = false; 69 70 if (failover != null && 71 failover instanceof java.lang.String ) 72 { 73 String strFailover = (java.lang.String )failover; 74 if (strFailover.equalsIgnoreCase ("true")) 75 { 76 doFail = true; 77 } 78 else if (strFailover.equalsIgnoreCase ("once")) 79 { 80 doFail = true; 81 System.setProperty ("JBossCluster-DoFail", "false"); 82 } 83 } 84 85 if (doFail) 86 { 87 mi.setValue ("DO_FAIL_DURING_NEXT_CALL", Boolean.TRUE, PayloadKey.AS_IS); 88 System.out.println("SYSTEM : We fail during next call!!!"); 89 } 90 else 91 mi.setValue ("DO_FAIL_DURING_NEXT_CALL", Boolean.FALSE, PayloadKey.AS_IS); 92 93 94 return getNext().invoke(mi); 95 } 96 97 99 101 103 105 } 106 | Popular Tags |