1 22 package org.jboss.ejb3.test.interceptors2; 23 24 import javax.annotation.Resource; 25 import javax.ejb.EJBContext ; 26 import javax.interceptor.InvocationContext; 27 import javax.naming.InitialContext ; 28 import javax.naming.NamingException ; 29 30 35 public class XMLClassInterceptor extends XMLClassInterceptor2 36 { 37 @Resource 38 EJBContext ejbCtx; 39 40 private StatusRemote findStatusRemote() 41 { 42 try 43 { 44 InitialContext ctx = new InitialContext (); 45 StatusRemote status = findStatusRemote(); 46 return status; 47 } 48 catch (NamingException e) 49 { 50 throw new RuntimeException (e); 51 } 52 } 53 54 55 56 public Object intercept(InvocationContext ctx) throws Exception 57 { 58 System.out.println("XMLClassInterceptor intercepting!"); 59 StatusRemote status = (StatusRemote)new InitialContext ().lookup("StatusBean/remote"); 61 status.addInterception(new Interception(this, "intercept")); 62 return ctx.proceed(); 63 } 64 65 public void postConstruct(InvocationContext ctx) 66 { 67 System.out.println("XMLClassInterceptor pc!"); 68 StatusBean.addPostConstruct(new Interception(this, "postConstruct", instance)); 69 try 70 { 71 ctx.proceed(); 72 } 73 catch (Exception e) 74 { 75 throw new RuntimeException (e); 76 } 77 } 78 79 public void postActivate(InvocationContext ctx) 80 { 81 System.out.println("XMLClassInterceptor pa!"); 82 StatusBean.addPostActivate(new Interception(this, "postActivate", instance)); 83 try 84 { 85 ctx.proceed(); 86 } 87 catch (Exception e) 88 { 89 throw new RuntimeException (e); 90 } 91 } 92 93 public void prePassivate(InvocationContext ctx) 94 { 95 System.out.println("XMLClassInterceptor pp!"); 96 StatusBean.addPrePassivate(new Interception(this, "prePassivate", instance)); 97 try 98 { 99 ctx.proceed(); 100 } 101 catch (Exception e) 102 { 103 throw new RuntimeException (e); 104 } 105 } 106 107 public void preDestroy(InvocationContext ctx) 108 { 109 System.out.println("XMLClassInterceptor pd!"); 110 StatusBean.addPreDestroy(new Interception(this, "preDestroy", instance)); 111 try 112 { 113 ctx.proceed(); 114 } 115 catch (Exception e) 116 { 117 throw new RuntimeException (e); 118 } 119 } 120 121 public Object intercept2(InvocationContext ctx) throws Exception 122 { 123 throw new RuntimeException ("Should not be called"); 124 } 125 126 public void postConstruct2(InvocationContext ctx) 127 { 128 throw new RuntimeException ("Should not be called"); 129 } 130 131 public void postActivate2(InvocationContext ctx) 132 { 133 throw new RuntimeException ("Should not be called"); 134 } 135 136 public void prePassivate2(InvocationContext ctx) 137 { 138 throw new RuntimeException ("Should not be called"); 139 } 140 141 public void preDestroy2(InvocationContext ctx) 142 { 143 throw new RuntimeException ("Should not be called"); 144 } 145 146 } 147 | Popular Tags |