01: package org.objectweb.jonas.jtests.beans.ejbql;
02:
03: import javax.ejb.EntityContext;
04: import javax.naming.InitialContext;
05:
06: public abstract class PhoneBean implements javax.ejb.EntityBean {
07: private SequenceSessionLocalHome seqHome = null;
08: private SequenceSessionLocal seqLocal = null;
09:
10: public Object ejbCreate(String number, byte type)
11: throws javax.ejb.CreateException {
12: setNumber(number);
13: setType(type);
14: int id = seqLocal.getNextNumberInSequence("Phone");
15: setId(new Integer(id));
16: return null;
17: }
18:
19: public void ejbPostCreate(String number, byte type) {
20: }
21:
22: // persistent fields
23:
24: public abstract Integer getId();
25:
26: public abstract void setId(Integer id);
27:
28: public abstract String getNumber();
29:
30: public abstract void setNumber(String number);
31:
32: public abstract byte getType();
33:
34: public abstract void setType(byte type);
35:
36: // standard call back methods
37:
38: public void setEntityContext(EntityContext ec) {
39: try {
40: InitialContext cntx = new InitialContext();
41: SequenceSessionLocalHome seqHome = (SequenceSessionLocalHome) cntx
42: .lookup("java:comp/env/ejb/SequenceSessionLocalHome");
43: seqLocal = seqHome.create();
44: } catch (Exception e) {
45: throw new javax.ejb.EJBException(e);
46: }
47: }
48:
49: public void unsetEntityContext() {
50: }
51:
52: public void ejbLoad() {
53: }
54:
55: public void ejbStore() {
56: }
57:
58: public void ejbActivate() {
59: }
60:
61: public void ejbPassivate() {
62: }
63:
64: public void ejbRemove() throws javax.ejb.RemoveException {
65: }
66:
67: }
|