net.walend.lyophil.ejb.ejbbeans
Class IdentifierSourceEJBBean

java.lang.Object
  |
  +--net.walend.lyophil.ejb.ejbbeans.IdentifierSourceEJBBean
All Implemented Interfaces:
javax.ejb.EnterpriseBean, java.io.Serializable, javax.ejb.SessionBean

public class IdentifierSourceEJBBean
extends java.lang.Object
implements javax.ejb.SessionBean

This session bean wraps an IdentifierSource and puts all calls to that IdentifierSource inside their own transactions. This design keeps the same identifier from getting used twice.

Since:
20010801
Author:
David Walend

Field Summary
private  javax.ejb.SessionContext ctx
           
private  IdentifierSource idSource
           
 
Constructor Summary
IdentifierSourceEJBBean()
           
 
Method Summary
 boolean checkSetUp()
          make sure the backing storage is set up correctly
 java.io.Serializable createID()
          Return a new identifier Object.
 void ejbActivate()
           
 void ejbCreate()
           
protected  java.lang.Object ejbCreateGuts(java.lang.String className)
          This method constructs the "guts" object for this Session bean.
 void ejbPassivate()
           
 void ejbRemove()
           
 java.io.Serializable peekNextID()
          Returns the next id to be created, without assigning it as in use.
 void setSessionContext(javax.ejb.SessionContext context)
           
 void setUp()
          set up the backing storage
 void tearDown()
          clean up the backing storage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

idSource

private IdentifierSource idSource

ctx

private javax.ejb.SessionContext ctx
Constructor Detail

IdentifierSourceEJBBean

public IdentifierSourceEJBBean()
Method Detail

ejbCreateGuts

protected java.lang.Object ejbCreateGuts(java.lang.String className)
                                  throws javax.ejb.CreateException
This method constructs the "guts" object for this Session bean. The guts keeps the funcitonality separate from the session bean code, making it easier to test and to reuse.


ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException

setSessionContext

public void setSessionContext(javax.ejb.SessionContext context)
Specified by:
setSessionContext in interface javax.ejb.SessionBean

ejbActivate

public void ejbActivate()
Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbPassivate

public void ejbPassivate()
Specified by:
ejbPassivate in interface javax.ejb.SessionBean

ejbRemove

public void ejbRemove()
Specified by:
ejbRemove in interface javax.ejb.SessionBean

createID

public java.io.Serializable createID()
Return a new identifier Object. The Object should be immutable and unique inside the system. Longs or RMI identifiers are a good choice. Your implementation should periodically log information about how quickly it's using up unique identifiers.

Throws:
an - IdentifierUnavailableException if the IdentifierSource can't get a new unique Object.
a - LastIdentifierUsedException if the IdentifierSource is completely out of unique Objects.

peekNextID

public java.io.Serializable peekNextID()
Returns the next id to be created, without assigning it as in use. I use this method for testing.


checkSetUp

public boolean checkSetUp()
make sure the backing storage is set up correctly

Throws:
<{PersistenceFailureException}>

setUp

public void setUp()
set up the backing storage

Throws:
<{PersistenceFailureException}>

tearDown

public void tearDown()
clean up the backing storage

Throws:
<{PersistenceFailureException}>


Copyright (c) 2000, 2001, David Walend