net.walend.collection.lyophil.jdbc
Class JDBCAoNMutableSetTray

java.lang.Object
  |
  +--net.walend.collection.lyophil.jdbc.JDBCAoNMutableSetTray
All Implemented Interfaces:
ConcreteTray, Tray

public class JDBCAoNMutableSetTray
extends java.lang.Object
implements ConcreteTray

A very simple backing for FreezableSets that uses the jdbc kit. A jdbc-based Freezer or a Frozen EJB for MutableSets can use this class for database access.

On freeze, this tray updates a database table with the set's contents. On thaw, it copies the contents in the database to the set.

Since:
20010213
Author:
David Walend

Field Summary
static java.lang.String PROPKEY
           
 
Fields inherited from interface net.walend.lyophil.Tray
TRAY
 
Constructor Summary
JDBCAoNMutableSetTray()
           
 
Method Summary
private  void addAllMembersToTable(java.io.Serializable id, FreezableSet mutantSet)
           
private  void addIdentifiersFromTable(java.io.Serializable id, FreezableSet set)
           
private  void addMemberToTable(java.io.Serializable id, java.io.Serializable member)
           
protected  java.lang.Long castIdentifier(java.io.Serializable identifier)
           
 boolean checkSetUp()
          make sure the backing storage is set up correctly
protected  void clearMemberTable(java.io.Serializable id)
           
 void delete(java.io.Serializable id)
          Remove everything about this id from the Tray.
 void freeze(Freezable object)
          Puts the Freezable in cold storage.
 Set getAllIdentifiersInTray()
          Get a Set containing all the identifiers in this Tray.
protected  java.lang.String getDatabaseName()
           
protected  PropertySource getPropertySource()
           
private  Set identifierSetFromTable(java.io.Serializable id)
           
 void insertNew(Freezable object)
          Stick a new Freezable into the database.
 boolean isAbsent(java.io.Serializable id)
          For this tray only, is the id not represented by data? In most cases, this is simply !isPresent(id).
 boolean isPresent(java.io.Serializable id)
          For this tray only, is the tray ready for data about this id?
 void setUp()
          Set up the backing storage
 void tearDown()
          clean up the backing storage
 Freezable thaw(java.io.Serializable identifier)
          Gets a Freezable out of cold storage.
 void throwOut(java.io.Serializable identifier)
          Remove a frozen instance from cold storage.
 void updateOld(Freezable object)
          Update an old Freezable in the database.
 void validate(java.io.Serializable id, InvalidFrozenMap ifm)
          Validates identifier.
 void validateAll(InvalidFrozenMap ifm, Caster caster)
          Validates all the identifiers in the Caster.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPKEY

public static final java.lang.String PROPKEY
Constructor Detail

JDBCAoNMutableSetTray

public JDBCAoNMutableSetTray()
Method Detail

getPropertySource

protected PropertySource getPropertySource()

getDatabaseName

protected java.lang.String getDatabaseName()

castIdentifier

protected java.lang.Long castIdentifier(java.io.Serializable identifier)

clearMemberTable

protected void clearMemberTable(java.io.Serializable id)

addMemberToTable

private void addMemberToTable(java.io.Serializable id,
                              java.io.Serializable member)

addAllMembersToTable

private void addAllMembersToTable(java.io.Serializable id,
                                  FreezableSet mutantSet)

isPresent

public boolean isPresent(java.io.Serializable id)
Description copied from interface: Tray
For this tray only, is the tray ready for data about this id?

Specified by:
isPresent in interface Tray

isAbsent

public boolean isAbsent(java.io.Serializable id)
Description copied from interface: Tray
For this tray only, is the id not represented by data? In most cases, this is simply !isPresent(id). For empty sets, both can return true.

Specified by:
isAbsent in interface Tray

insertNew

public void insertNew(Freezable object)
Description copied from interface: Tray
Stick a new Freezable into the database. Don't look at it first to make sure it's not there.

Specified by:
insertNew in interface Tray

updateOld

public void updateOld(Freezable object)
Description copied from interface: Tray
Update an old Freezable in the database. Don't look first to make sure that it's there.

Specified by:
updateOld in interface Tray

delete

public void delete(java.io.Serializable id)
Description copied from interface: Tray
Remove everything about this id from the Tray.

A recursive method.

Specified by:
delete in interface Tray

validate

public void validate(java.io.Serializable id,
                     InvalidFrozenMap ifm)
Description copied from interface: Tray
Validates identifier.

Specified by:
validate in interface Tray

validateAll

public void validateAll(InvalidFrozenMap ifm,
                        Caster caster)
Description copied from interface: Tray
Validates all the identifiers in the Caster.

Specified by:
validateAll in interface Tray

getAllIdentifiersInTray

public Set getAllIdentifiersInTray()
Description copied from interface: Tray
Get a Set containing all the identifiers in this Tray. It doesn't use the Freezables table.

Specified by:
getAllIdentifiersInTray in interface Tray

freeze

public void freeze(Freezable object)
Description copied from interface: ConcreteTray
Puts the Freezable in cold storage.

Specified by:
freeze in interface ConcreteTray

identifierSetFromTable

private Set identifierSetFromTable(java.io.Serializable id)

addIdentifiersFromTable

private void addIdentifiersFromTable(java.io.Serializable id,
                                     FreezableSet set)

thaw

public Freezable thaw(java.io.Serializable identifier)
Description copied from interface: ConcreteTray
Gets a Freezable out of cold storage. Normally, this should be a new instance of a previously frozen Freezable.

Specified by:
thaw in interface ConcreteTray

throwOut

public void throwOut(java.io.Serializable identifier)
              throws NotInFreezerException
Remove a frozen instance from cold storage.

Specified by:
throwOut in interface ConcreteTray
Throws:
CannotThrowOutException
NotInFreezerException

checkSetUp

public boolean checkSetUp()
Description copied from interface: Tray
make sure the backing storage is set up correctly

Specified by:
checkSetUp in interface Tray

setUp

public void setUp()
Description copied from interface: Tray
Set up the backing storage

Specified by:
setUp in interface Tray

tearDown

public void tearDown()
Description copied from interface: Tray
clean up the backing storage

Specified by:
tearDown in interface Tray


Copyright (c) 2000, 2001, David Walend