01: /**
02: * Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
03: */package com.sun.portal.sample.j2ee.count.ejb;
04:
05: import java.util.*;
06: import java.io.*;
07:
08: /**
09: * A simple stateless bean for the count application. This bean implements one
10: * business method as declared by the remote interface.
11: */
12: public class CountEJB implements javax.ejb.SessionBean {
13:
14: private javax.ejb.SessionContext m_ctx = null;
15: private int count = 0;
16:
17: /**
18: * Sets the session context. Required by EJB spec.
19: * @param ctx A SessionContext object.
20: */
21: public void setSessionContext(javax.ejb.SessionContext ctx) {
22: m_ctx = ctx;
23: }
24:
25: /**
26: * Creates a bean. Required by EJB spec.
27: * @exception throws CreateException.
28: */
29: public void ejbCreate() throws java.rmi.RemoteException,
30: javax.ejb.CreateException {
31: System.out.println("ejbCreate() on obj " + this );
32: }
33:
34: /**
35: * Removes the bean. Required by EJB spec.
36: */
37: public void ejbRemove() {
38: System.out.println("ejbRemove() on obj " + this );
39: }
40:
41: /**
42: * Loads the state of the bean from secondary storage. Required by EJB spec.
43: */
44: public void ejbActivate() {
45: System.out.println("ejbActivate() on obj " + this );
46: }
47:
48: /**
49: * Serializes the state of the bean to secondary storage. Required by EJB spec.
50: */
51: public void ejbPassivate() {
52: System.out.println("ejbPassivate() on obj " + this );
53: }
54:
55: /**
56: * Required by EJB spec.
57: */
58: public void Count() {
59: }
60:
61: /**
62: * Increment and returns the value of a counter.
63: * @return returns the value of the counter as an integer .
64: * @exception throws a RemoteException.
65: */
66: public int getCount() throws java.rmi.RemoteException {
67: return ++count;
68: }
69: }
|