001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: SequenceEC2.java 6612 2005-04-22 07:43:55Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.beans.sequence;
027:
028: import javax.ejb.CreateException;
029: import javax.ejb.EntityBean;
030: import javax.ejb.EntityContext;
031: import javax.ejb.RemoveException;
032:
033: /**
034: * SequenceEC2 controls the sequence block requests.
035: *
036: */
037: public abstract class SequenceEC2 implements EntityBean {
038:
039: protected EntityContext entCtx;
040:
041: /*
042: * Method ejbCreate
043: * @param id Sequence identifier
044: * @param firstNumber Starting number
045: * @return null
046: * @throws CreateException Create error
047: */
048: public String ejbCreate(String id, int firstNumber)
049: throws CreateException {
050: setId(id);
051: setNextNumber(firstNumber);
052: return null;
053: }
054:
055: /**
056: * Method ejbPostCreate
057: * @param id Sequence identifier
058: * @param firstNumber First number
059: */
060: public void ejbPostCreate(String id, int firstNumber) {
061: }
062:
063: /**
064: * Method ejbRemove
065: * @throws RemoveException Remove error
066: */
067: public void ejbRemove() throws RemoveException {
068: }
069:
070: /**
071: * Method getId
072: * @return The sequence identifier
073: */
074: public abstract String getId();
075:
076: /**
077: * Method setId
078: * @param The sequence identifier
079: */
080: public abstract void setId(String id);
081:
082: /**
083: * Method getNextNumber gets the next number
084: * @return The next sequence number.
085: */
086: public abstract int getNextNumber();
087:
088: /**
089: * Method setNextNumber gets the next number
090: * @param The next sequence number.
091: */
092: public abstract void setNextNumber(int nextNumber);
093:
094: /**
095: * Method ejbActivate
096: */
097: public void ejbActivate() {
098:
099: }
100:
101: /**
102: * Method ejbPassivate
103: */
104: public void ejbPassivate() {
105:
106: }
107:
108: /**
109: * Method ejbLoad
110: */
111: public void ejbLoad() {
112: }
113:
114: /**
115: * Method ejbStore
116: */
117: public void ejbStore() {
118:
119: }
120:
121: /**
122: * Method setEntityContext
123: * @param entCtx The context of this entity bean.
124: */
125: public void setEntityContext(EntityContext entCtx) {
126: this .entCtx = entCtx;
127: }
128:
129: /**
130: * Method unsetEntityContext
131: */
132: public void unsetEntityContext() {
133: this .entCtx = null;
134: }
135:
136: /**
137: * Get a unique PK number, and increment the count for next call.
138: */
139: public int getUniqPk() {
140: int ret = getNextNumber();
141: setNextNumber(++ret);
142: return ret;
143: }
144:
145: }
|