01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.test.perf.ejb;
23:
24: import javax.ejb.CreateException;
25: import javax.ejb.EntityContext;
26:
27: import org.jboss.test.perf.interfaces.EntityPK;
28:
29: public abstract class EntityBean implements javax.ejb.EntityBean {
30: private EntityContext context;
31: private transient boolean isDirty;
32:
33: public abstract int getTheKey();
34:
35: public abstract void setTheKey(int theKey);
36:
37: public abstract int getTheValue();
38:
39: public abstract void setTheValue(int theValue);
40:
41: public int read() {
42: setModified(false); // to avoid writing
43: return getTheValue();
44: }
45:
46: public void write(int theValue) {
47: setModified(true); // to force writing
48: setTheValue(theValue);
49: }
50:
51: public EntityPK ejbCreate(int theKey, int theValue)
52: throws CreateException {
53: setTheKey(theKey);
54: setTheValue(theValue);
55: return null;
56: }
57:
58: public void ejbPostCreate(int theKey, int theValue) {
59: }
60:
61: public void ejbRemove() {
62: }
63:
64: public void setEntityContext(EntityContext context) {
65: this .context = context;
66: }
67:
68: public void unsetEntityContext() {
69: this .context = null;
70: }
71:
72: public void ejbActivate() {
73: }
74:
75: public void ejbPassivate() {
76: }
77:
78: public void ejbLoad() {
79: setModified(false); // to avoid writing
80: }
81:
82: public void ejbStore() {
83: setModified(false); // to avoid writing
84: }
85:
86: public String toString() {
87: return "EntityBean[theKey=" + getTheKey() + ",theValue="
88: + getTheValue() + "]";
89: }
90:
91: public boolean isModified() {
92: return isDirty;
93: }
94:
95: public void setModified(boolean flag) {
96: isDirty = flag;
97: }
98:
99: }
|