|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.primix.vlib.ejb.impl.KeyAllocatorBean
Implementation of the KeyAllocator stateless session bean.
We're cheating a little; they KeyAllocator does have state, it just doesn't get persisted ever. Since the operation on it is atomic ("gimme a key") it doesn't need to have conversational state with its clients.
The KeyAllocator records in the database the "next key to allocate". When it needs a key, it allocates a block of keys (by advancing the next key by a some number).
If the KeyAllocator instance is purged from the pool, then some number of keys that it has allocated will be lost. Big deal.
Constructor Summary | |
KeyAllocatorBean()
|
Method Summary | |
protected void |
allocateBlock(int count)
Allocates a block of keys from the database. |
java.lang.Integer |
allocateKey()
Allocates a single key, going to the database only if it has no keys in its internal cache. |
java.lang.Integer[] |
allocateKeys(int count)
Allocates a block of keys, going to the database if there are insufficient keys in its internal cache. |
void |
ejbActivate()
Does nothing, not invoked in stateless session beans. |
void |
ejbCreate()
Activates the bean. |
void |
ejbPassivate()
Does nothing, not invoked in stateless session beans. |
void |
ejbRemove()
Does nothing. |
protected java.sql.Connection |
getConnection()
Gets a database connection from the pool. |
void |
setSessionContext(SessionContext value)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public KeyAllocatorBean()
Method Detail |
public void ejbCreate()
public void ejbPassivate()
ejbPassivate
in interface SessionBean
public void setSessionContext(SessionContext value)
setSessionContext
in interface SessionBean
public void ejbActivate()
ejbActivate
in interface SessionBean
public void ejbRemove()
ejbRemove
in interface SessionBean
public java.lang.Integer allocateKey()
public java.lang.Integer[] allocateKeys(int count)
protected void allocateBlock(int count)
It is assumed that this operation takes place within a transaction.
protected java.sql.Connection getConnection()
EJBException
- if a SQLException
is thrown.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |