1 22 package org.jboss.ejb3.test.interceptors2; 23 24 import java.util.ArrayList ; 25 26 import javax.interceptor.ExcludeDefaultInterceptors; 27 import javax.ejb.PostActivate ; 28 import javax.annotation.PostConstruct; 29 import javax.annotation.PreDestroy; 30 import javax.ejb.PrePassivate ; 31 32 import org.jboss.annotation.ejb.Service; 33 34 39 @Service 40 @ExcludeDefaultInterceptors 41 public class StatusBean implements StatusRemote 42 { 43 static ArrayList <Interception> interceptions = new ArrayList <Interception>(); 44 static ArrayList <Interception> postConstructs = new ArrayList <Interception>(); 45 static ArrayList <Interception> postActivates = new ArrayList <Interception>(); 46 static ArrayList <Interception> prePassivates = new ArrayList <Interception>(); 47 static ArrayList <Interception> preDestroys = new ArrayList <Interception>(); 48 49 public void clear() 50 { 51 System.out.println("Clearing interceptions"); 52 interceptions.clear(); 53 postConstructs.clear(); 54 postActivates.clear(); 55 prePassivates.clear(); 56 preDestroys.clear(); 57 } 58 59 public ArrayList <Interception> getInterceptions() 60 { 61 System.out.println("Getting interceptions " + interceptions.size()); 62 return interceptions; 63 } 64 65 66 public ArrayList <Interception> getPostActivates() 67 { 68 return postActivates; 69 } 70 71 public ArrayList <Interception> getPostConstructs() 72 { 73 return postConstructs; 74 } 75 76 public ArrayList <Interception> getPreDestroys() 77 { 78 return preDestroys; 79 } 80 81 public ArrayList <Interception> getPrePassivates() 82 { 83 return prePassivates; 84 } 85 86 public void addInterception(Interception intercepted) 87 { 88 interceptions.add(intercepted); 89 System.out.println("Adding interception (" + interceptions.size() + ")" + intercepted.getClassname() + "." + intercepted.getMethod() + " - " + intercepted.getInstance()); 90 } 91 92 public static void addInterceptionStatic(Interception intercepted) 93 { 94 interceptions.add(intercepted); 95 System.out.println("Adding interception (" + interceptions.size() + ")" + intercepted.getClassname() + "." + intercepted.getMethod() + " - " + intercepted.getInstance()); 96 } 97 98 public void addLifecycle(Class type, Interception intercepted) 99 { 100 if (type == PostConstruct.class) 101 { 102 addPostConstruct(intercepted); 103 } 104 else if (type == PostActivate .class) 105 { 106 addPostActivate(intercepted); 107 } 108 else if (type == PrePassivate .class) 109 { 110 addPrePassivate(intercepted); 111 } 112 else if (type == PreDestroy.class) 113 { 114 addPreDestroy(intercepted); 115 } 116 } 117 118 public static void addPostConstruct(Interception intercepted) 119 { 120 postConstructs.add(intercepted); 121 System.out.println("Adding PostConstruct (" + postConstructs.size() + ")" + intercepted.getClassname() + "." + intercepted.getMethod() + " - " + intercepted.getInstance()); 122 } 123 124 public static void addPostActivate(Interception intercepted) 125 { 126 postActivates.add(intercepted); 127 System.out.println("Adding PostActivate (" + postConstructs.size() + ")" + intercepted.getClassname() + "." + intercepted.getMethod() + " - " + intercepted.getInstance()); 128 } 129 130 public static void addPrePassivate(Interception intercepted) 131 { 132 prePassivates.add(intercepted); 133 System.out.println("Adding PrePassivate (" + postConstructs.size() + ")" + intercepted.getClassname() + "." + intercepted.getMethod() + " - " + intercepted.getInstance()); 134 } 135 136 public static void addPreDestroy(Interception intercepted) 137 { 138 preDestroys.add(intercepted); 139 System.out.println("Adding PreDestroy (" + postConstructs.size() + ")" + intercepted.getClassname() + "." + intercepted.getMethod() + " - " + intercepted.getInstance()); 140 } 141 142 143 } 144 | Popular Tags |