KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > freeforums > util > AutoNumberBean


1 /*
2  * AutoNumberBean.java
3  *
4  * AutoNumberBean implementation
5  *
6  * @author: Devraj Mukherjee
7  *
8  * Created: 23rd June 2001
9  *
10  */

11
12  package freeforums.util;
13
14  import java.rmi.RemoteException JavaDoc;
15  import javax.ejb.*;
16
17  public class AutoNumberBean implements EntityBean {
18
19      transient private EntityContext context;
20
21      public Integer JavaDoc autoNumberValue;
22      public String JavaDoc referenceName;
23
24      public String JavaDoc ejbCreate(String JavaDoc referenceName) throws CreateException {
25
26          this.referenceName = referenceName;
27          this.autoNumberValue = new Integer JavaDoc(0);
28          return null;
29
30      }
31
32      public void ejbPostCreate(String JavaDoc referenceName) { }
33
34      public void setEntityContext(EntityContext context) { this.context = context; }
35
36      public void unsetEntityContext() { context = null; }
37
38      public void ejbActivate() { }
39      public void ejbPassivate() { }
40      public void ejbLoad() { }
41      public void ejbStore() { }
42      public void ejbRemove() { }
43
44      /* The following are the implementation of the method from the
45         AutoNumber Remote interface
46       */

47
48      public Integer JavaDoc getAutoNumberValue() throws RemoteException JavaDoc {
49
50          Integer JavaDoc currentValue = autoNumberValue;
51          autoNumberValue = new Integer JavaDoc(currentValue.intValue()+1);
52          return currentValue;
53
54      }
55
56  } // end class file
57
Popular Tags