KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > cache > 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.cache.nested;
9
10 import org.jboss.logging.Logger;
11
12 import javax.ejb.*;
13 import java.rmi.dgc.VMID JavaDoc;
14
15 /**
16  * Nested SFSB
17  *
18  * @author Ben Wang
19  * @version $Revision: 46483 $
20  */

21 @Stateful(name="testNestedStateful")
22 @org.jboss.annotation.ejb.cache.simple.CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
23 public class NestedStatefulBean implements java.io.Serializable JavaDoc, NestedStateful
24 {
25    private static Logger log = Logger.getLogger(NestedStatefulBean.class);
26    private int counter = 0;
27
28    public int increment()
29    {
30       log.debug("INCREMENT - nested counter: " + (counter++));
31       return counter;
32    }
33
34    public static int postActivateCalled = 0;
35    public static int prePassivateCalled = 0;
36
37    public int getPostActivate()
38    {
39       return postActivateCalled;
40    }
41
42    public int getPrePassivate()
43    {
44       return prePassivateCalled;
45    }
46
47    public void reset()
48    {
49       counter = 0;
50       NestedStatefulBean.postActivateCalled = 0;
51       NestedStatefulBean.prePassivateCalled = 0;
52    }
53
54    @PostActivate
55    public void postActivate()
56    {
57       ++NestedStatefulBean.postActivateCalled;
58    }
59
60    @PrePassivate
61    public void prePassivate()
62    {
63       ++NestedStatefulBean.prePassivateCalled;
64    }
65 }
66
Popular Tags