From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../src/examples/session/stateful/CountBean.java | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateful/CountBean.java (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateful/CountBean.java') diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateful/CountBean.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateful/CountBean.java new file mode 100644 index 0000000..6afd4a3 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateful/CountBean.java @@ -0,0 +1,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: + * + */ + +@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()"); + } + +} -- cgit v1.2.3