1 7 8 package org.jboss.ejb3.test.stateful.nested; 9 10 import org.jboss.annotation.ejb.cache.simple.CacheConfig; 11 import org.jboss.logging.Logger; 12 13 import javax.ejb.*; 14 import javax.annotation.PostConstruct; 15 import javax.ejb.EJB ; 16 17 23 @Stateful(name="testParentStateful") 24 @CacheConfig(maxSize=1000, idleTimeoutSeconds=3) @Remote(ParentStatefulRemote.class) 26 public class ParentStatefulBean implements java.io.Serializable , ParentStatefulRemote 27 { 28 private Logger log = Logger.getLogger(ParentStatefulBean.class); 29 private int counter = 0; 30 31 @EJB 32 private NestedStateful nested; 33 34 public int increment() 35 { 36 counter = nested.increment(); 37 38 log.debug("INCREMENT - counter: " + counter); 39 return counter; 40 } 41 42 public static int postActivateCalled = 0; 43 public static int prePassivateCalled = 0; 44 45 49 public void longRunning() throws Exception 50 { 51 log.debug("+++ longRunning() enter "); 52 Thread.sleep(10000); 53 log.debug("+++ longRunning() leave "); 54 } 55 56 public int getPostActivate() 57 { 58 return ParentStatefulBean.postActivateCalled; 59 } 60 61 public int getPrePassivate() 62 { 63 return ParentStatefulBean.prePassivateCalled; 64 } 65 66 public void reset() 67 { 68 counter = 0; 69 ParentStatefulBean.postActivateCalled = 0; 70 ParentStatefulBean.prePassivateCalled = 0; 71 } 72 73 @PostActivate 74 public void postActivate() 75 { 76 ++ParentStatefulBean.postActivateCalled; 77 log.debug("Activate with counter: " + counter); 78 } 79 80 @PrePassivate 81 public void prePassivate() 82 { 83 ++ParentStatefulBean.prePassivateCalled; 84 log.debug("Passivate with counter: " + counter); 85 } 86 87 @Remove 88 public void remove() 89 { 90 } 91 92 @PostConstruct 93 public void ejbCreate() 94 { 95 } 96 97 99 } 100 | Popular Tags |