1 22 package org.jboss.ha.framework.test; 23 24 import org.jboss.invocation.Invocation; 25 import org.jboss.ha.framework.interfaces.GenericClusteringException; 26 27 43 44 public class ExplicitFailoverServerInterceptor extends org.jboss.ejb.plugins.AbstractInterceptor 45 { 46 47 49 51 protected org.jboss.ejb.Container container; 52 53 55 57 public ExplicitFailoverServerInterceptor () 58 { 59 } 60 61 63 public void setContainer(org.jboss.ejb.Container container) 64 { 65 this.container = container; 66 } 67 68 public org.jboss.ejb.Container getContainer() 69 { 70 return container; 71 } 72 73 75 77 public Object invokeHome(Invocation mi) 78 throws Exception 79 { 80 checkFailoverNeed (mi); 81 82 return super.invokeHome (mi); 83 } 84 85 public Object invoke(Invocation mi) 86 throws Exception 87 { 88 checkFailoverNeed (mi); 89 90 return super.invoke (mi); 91 } 92 93 95 97 protected void checkFailoverNeed (Invocation mi) 98 throws GenericClusteringException 99 { 100 Object data = mi.getValue ("DO_FAIL_DURING_NEXT_CALL"); 101 102 if (data != null && 103 data instanceof java.lang.Boolean && 104 data.equals (java.lang.Boolean.TRUE)) 105 { 106 Object alreadyDone = mi.getValue ("FAILOVER_COUNTER"); 109 110 if (alreadyDone != null && 111 alreadyDone instanceof java.lang.Integer && 112 ((java.lang.Integer )alreadyDone).intValue () == 0) 113 { 114 this.log.debug ("WE FAILOVER IN SERVER INTERCEPTOR (explicit failover asked by client interceptor)!"); 117 throw new GenericClusteringException 118 (GenericClusteringException.COMPLETED_NO, "Test failover from server interceptor", false); 119 } 120 } 121 } 122 123 125 127 } 128 | Popular Tags |