001: // BankOperationECL.java
002:
003: package org.objectweb.clusterDemo;
004:
005: import javax.ejb.CreateException;
006: import javax.ejb.DuplicateKeyException;
007: import javax.ejb.EntityBean;
008: import javax.ejb.EntityContext;
009: import javax.ejb.RemoveException;
010:
011: import org.objectweb.jonas.common.Log;
012: import org.objectweb.util.monolog.api.Logger;
013: import org.objectweb.util.monolog.api.BasicLevel;
014:
015: /**
016: *
017: */
018: public abstract class BankOperationECL implements EntityBean {
019:
020: static private Logger logger = null;
021:
022: EntityContext ejbContext;
023:
024: // ------------------------------------------------------------------
025: // EntityBean implementation
026: // ------------------------------------------------------------------
027:
028: /**
029: * Set the associated entity context. The container invokes this method on
030: * an instance after the instance has been created. This method is called in
031: * an unspecified transaction context.
032: * @param ctx - An EntityContext interface for the instance. The instance
033: * should store the reference to the context in an instance variable.
034: * @throws EJBException Thrown by the method to indicate a failure caused by
035: * a system-level error.
036: */
037: public void setEntityContext(EntityContext ctx) {
038: if (logger == null) {
039: logger = Log.getLogger("org.objectweb.jonas_tests");
040: }
041: logger.log(BasicLevel.DEBUG, "");
042: ejbContext = ctx;
043: }
044:
045: /**
046: * Unset the associated entity context. The container calls this method
047: * before removing the instance. This is the last method that the container
048: * invokes on the instance. The Java garbage collector will eventually
049: * invoke the finalize() method on the instance. This method is called in an
050: * unspecified transaction context.
051: * @throws EJBException Thrown by the method to indicate a failure caused by
052: * a system-level error.
053: */
054: public void unsetEntityContext() {
055: logger.log(BasicLevel.DEBUG, "");
056: ejbContext = null;
057: }
058:
059: /**
060: * A container invokes this method before it removes the EJB object that is
061: * currently associated with the instance. This method is invoked when a
062: * client invokes a remove operation on the enterprise Bean's home interface
063: * or the EJB object's remote interface. This method transitions the
064: * instance from the ready state to the pool of available instances. This
065: * method is called in the transaction context of the remove operation.
066: * @throws RemoveException The enterprise Bean does not allow destruction of
067: * the object.
068: * @throws EJBException - Thrown by the method to indicate a failure caused
069: * by a system-level error.
070: */
071: public void ejbRemove() throws RemoveException {
072: logger.log(BasicLevel.DEBUG, "");
073: }
074:
075: /**
076: * A container invokes this method to instruct the instance to synchronize
077: * its state by loading it state from the underlying database. This method
078: * always executes in the proper transaction context.
079: * @throws EJBException Thrown by the method to indicate a failure caused by
080: * a system-level error.
081: */
082: public void ejbLoad() {
083: logger.log(BasicLevel.DEBUG, "");
084: }
085:
086: /**
087: * A container invokes this method to instruct the instance to synchronize
088: * its state by storing it to the underlying database. This method always
089: * executes in the proper transaction context.
090: * @throws EJBException Thrown by the method to indicate a failure caused by
091: * a system-level error.
092: */
093: public void ejbStore() {
094: logger.log(BasicLevel.DEBUG, "");
095: }
096:
097: /**
098: * There must be an ejbPostCreate par ejbCreate method
099: * @throws CreateException Failure to create an entity EJB object.
100: */
101: public void ejbPostCreate(int v, String r, String d)
102: throws CreateException {
103: logger.log(BasicLevel.DEBUG, "");
104: }
105:
106: /**
107: * The Entity bean can define 0 or more ejbCreate methods.
108: * @throws CreateException Failure to create an entity EJB object.
109: * @throws DuplicateKeyException An object with the same key already exists.
110: */
111: public java.lang.String ejbCreate(int v, String r, String d)
112: throws CreateException, DuplicateKeyException {
113: logger.log(BasicLevel.DEBUG, "");
114:
115: // Init here the bean fields
116: setValue(v);
117: setReason(r);
118: setDate(d);
119:
120: // In CMP, should return null.
121: return null;
122: }
123:
124: /**
125: * A container invokes this method on an instance before the instance
126: * becomes disassociated with a specific EJB object.
127: */
128: public void ejbPassivate() {
129: logger.log(BasicLevel.DEBUG, "");
130: }
131:
132: /**
133: * A container invokes this method when the instance is taken out of the
134: * pool of available instances to become associated with a specific EJB
135: * object.
136: */
137: public void ejbActivate() {
138: logger.log(BasicLevel.DEBUG, "");
139: }
140:
141: // ------------------------------------------------------------------
142: // BankOperation implementation
143: // ------------------------------------------------------------------
144:
145: public abstract int getValue();
146:
147: public abstract String getDate();
148:
149: public abstract String getReason();
150:
151: public abstract void setValue(int v);
152:
153: public abstract void setDate(String d);
154:
155: public abstract void setReason(String r);
156: }
|