KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > clusteredsession > nested > NestedStatefulBean


1 /*
2  * JBoss, Home of Professional Open Source
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package org.jboss.ejb3.test.clusteredsession.nested;
9
10 import org.jboss.annotation.ejb.Clustered;
11 import org.jboss.annotation.ejb.cache.tree.CacheConfig;
12 import org.jboss.logging.Logger;
13
14 import javax.ejb.*;
15
16 /**
17  * Nested SFSB
18  *
19  * @author Ben Wang
20  * @version $Revision: 46483 $
21  */

22 @Stateful(name="testNestedStateful")
23 @Clustered
24 @CacheConfig(maxSize=1000, idleTimeoutSeconds=3) // this will get evicted the second time eviction thread wakes up
25
public class NestedStatefulBean implements java.io.Serializable JavaDoc, NestedStateful
26 {
27    private static Logger log = Logger.getLogger(NestedStatefulBean.class);
28    private int counter = 0;
29
30    public int increment()
31    {
32       log.debug("INCREMENT - nested counter: " + (counter++));
33       return counter;
34    }
35
36    public static int postActivateCalled = 0;
37    public static int prePassivateCalled = 0;
38
39    public int getPostActivate()
40    {
41       return postActivateCalled;
42    }
43
44    public int getPrePassivate()
45    {
46       return prePassivateCalled;
47    }
48
49    public void reset()
50    {
51       counter = 0;
52       NestedStatefulBean.postActivateCalled = 0;
53       NestedStatefulBean.prePassivateCalled = 0;
54    }
55
56    @PostActivate
57    public void postActivate()
58    {
59       ++NestedStatefulBean.postActivateCalled;
60    }
61
62    @PrePassivate
63    public void prePassivate()
64    {
65       log.debug("prePassivate: - counter: " + prePassivateCalled);
66       ++NestedStatefulBean.prePassivateCalled;
67    }
68 }
69
Popular Tags