1 22 package org.jboss.ejb3.test.entitycallback; 23 24 import java.util.HashMap ; 25 import javax.ejb.Stateful ; 26 import javax.ejb.Remote ; 27 28 32 @Stateful 33 @Remote (CallbackCounter.class) 34 public class CallbackCounterBean implements CallbackCounter, java.io.Serializable 35 { 36 public static HashMap <String , HashMap > callbacks = new HashMap <String , HashMap >(); 37 38 public static void addCallback(String className, Class callbackAnnotation) 39 { 40 System.out.println("***** Adding " + callbackAnnotation.getName() + " callback to " + className); 41 42 HashMap <Class , Integer > classCallbacks = callbacks.get(className); 43 if (classCallbacks == null) 44 { 45 classCallbacks = new HashMap <Class , Integer >(); 46 47 callbacks.put(className, classCallbacks); 48 } 49 Integer i = classCallbacks.get(callbackAnnotation); 50 if (i == null) 51 { 52 i = 0; 53 } 54 i++; 55 System.out.println("count: " + i); 56 classCallbacks.put(callbackAnnotation, i); 57 } 58 59 public int getCallbacks(String beanClass, Class callbackAnnotation) 60 { 61 HashMap <Class , Integer > classCallbacks = callbacks.get(beanClass); 62 if (classCallbacks == null) 63 { 64 return 0; 65 } 66 67 Integer i = classCallbacks.get(callbackAnnotation); 68 if (i != null) 69 { 70 return i; 71 } 72 73 return 0; 74 } 75 76 public static void clear() 77 { 78 callbacks = new HashMap <String , HashMap >(); 79 } 80 } 81 | Popular Tags |