blob: 6afd4a34c11a430cbc954cc1c5c678857191747d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package examples.session.stateful;
import javax.ejb.*;
/**
* A Stateful Session Bean Class that shows the basics of
* how to write a stateful session bean.
*
* This Bean is initialized to some integer value. It has a
* business method which increments the value.
*
* The annotations below declare that:
* <ul>
* <li>this is a Stateful Session Bean
* <li>the bean's remote business interface is <code>Count</code>
* <li>any lifecycle callbacks go to the class <code>CountCallbacks</code>
* </ul>
*/
@Stateful
@Remote(Count.class)
@Interceptors(CountCallbacks.class)
public class CountBean implements Count {
/** The current counter is our conversational state. */
private int val;
/**
* The count() business method.
*/
public int count() {
System.out.println("count()");
return ++val;
}
/**
* The set() business method.
*/
public void set(int val) {
this.val = val;
System.out.println("set()");
}
/**
* The remove method is annotated so that the container knows
* it can remove the bean after this method returns.
*/
@Remove
public void remove() {
System.out.println("remove()");
}
}
|