diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateful/CountBean.java | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateful/CountBean.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateful/CountBean.java | 53 |
1 files changed, 53 insertions, 0 deletions
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:
+ * <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()");
+ }
+
+}
|
