1 7 8 package org.jboss.ejb3.test.clusteredsession; 9 10 import org.jboss.ha.framework.interfaces.GenericClusteringException; 11 import org.jboss.logging.Logger; 12 13 import javax.interceptor.AroundInvoke; 14 import javax.interceptor.InvocationContext; 15 16 22 public class ExplicitFailoverInterceptor 23 { 24 private Logger log = Logger.getLogger(ExplicitFailoverInterceptor.class); 25 26 @AroundInvoke 27 public Object invoke(InvocationContext ctx) 28 throws Exception 29 { 30 checkFailoverNeed (ctx); 31 return ctx.proceed(); 32 } 33 34 protected void checkFailoverNeed (InvocationContext ctx) 35 throws Exception 36 { 37 if(ctx.getMethod().getName().equals("setUpFailover")) 38 { 39 return; 40 } 41 42 String failover = (String )System.getProperty ("JBossCluster-DoFail"); 43 boolean doFail = false; 44 45 if (failover != null) 46 { 47 String strFailover = failover; 48 if (strFailover.equalsIgnoreCase ("true")) 49 { 50 doFail = true; 51 } 52 else if (strFailover.equalsIgnoreCase ("once")) 53 { 54 doFail = true; 55 System.setProperty ("JBossCluster-DoFail", "false"); 56 } 57 } 58 59 if (doFail) 60 { 61 log.debug ("WE FAILOVER IN EJB INTERCEPTOR (explicit failover)!"); 62 63 throw new GenericClusteringException 64 (GenericClusteringException.COMPLETED_NO, "Test failover from ejb interceptor", false); 65 } 66 } 67 } 68 | Popular Tags |