summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateful_dd/CountBean.java
blob: 0a2ab2ce1971693257c43bd61d36b956e052c5d0 (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
package examples.session.stateful_dd;

import java.io.Serializable;

/**
 * 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>
 */

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()");
    }

    /**
     */
    public void remove() {
        System.out.println("remove()");
    }

}