summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateful/CountBean.java
diff options
context:
space:
mode:
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.java53
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()");
+ }
+
+}