1 22 package org.jboss.ejb3.test.initial; 23 24 import java.io.Serializable ; 25 26 import javax.interceptor.AroundInvoke; 27 import javax.interceptor.InvocationContext; 28 import javax.ejb.PostActivate ; 29 import javax.annotation.PostConstruct; 30 import javax.annotation.PreDestroy; 31 import javax.ejb.PrePassivate ; 32 33 37 public class FirstInterceptor implements Serializable { 38 39 @AroundInvoke 40 public Object oneMethod(InvocationContext ctx) throws Exception 41 { 42 if (ctx.getMethod().getName().equals("testMethod")) 43 { 44 System.out.println("Intercepting in FirstInterceptor.oneMethod()"); 45 int i = (Integer )ctx.getParameters()[0]; 46 ctx.getContextData().put("DATA", new Integer (i + 1000)); 47 } 48 return ctx.proceed(); 49 } 50 51 @PostConstruct 52 public void postConstruct(InvocationContext ctx) 53 { 54 TestStatusBean.postConstruct = true; 55 try 56 { 57 ctx.proceed(); 58 } 59 catch (Exception e) 60 { 61 throw new RuntimeException (e); 62 } 63 } 64 65 @PreDestroy 66 public void preDestroy(InvocationContext ctx) 67 { 68 TestStatusBean.preDestroy = true; 69 try 70 { 71 ctx.proceed(); 72 } 73 catch (Exception e) 74 { 75 throw new RuntimeException (e); 76 } 77 } 78 79 @PostActivate 80 public void postActivate(InvocationContext ctx) 81 { 82 TestStatusBean.postActivate = true; 83 try 84 { 85 ctx.proceed(); 86 } 87 catch (Exception e) 88 { 89 throw new RuntimeException (e); 90 } 91 } 92 93 @PrePassivate 94 public void prePassivate(InvocationContext ctx) 95 { 96 TestStatusBean.prePassivate = true; 97 try 98 { 99 ctx.proceed(); 100 } 101 catch (Exception e) 102 { 103 throw new RuntimeException (e); 104 } 105 } 106 } 107 | Popular Tags |