net.walend.lyophil.memory
Class MemStorage

java.lang.Object
  |
  +--net.walend.lyophil.memory.MemStorage
All Implemented Interfaces:
java.io.Serializable

public class MemStorage
extends java.lang.Object
implements java.io.Serializable

An in-memory storage point.

Since:
20010103
Author:
David Walend

Field Summary
protected  Caster caster
           
protected  MultiValueIndex classIndex
           
protected  MemSet memSet
           
static java.lang.String MEMSTORAGE
           
protected  SingleValueIndex typableKeyIndex
           
 
Constructor Summary
MemStorage()
           
 
Method Summary
 void clear()
           
 boolean containsTypableKey(java.lang.String key)
          Returns true if the typable key is in use already.
 int count()
           
 int countByClass(java.lang.Class interf)
          Count the number of freezables that implement this interf.
 SetOfFreezables findByClass(java.lang.Class interf)
          Returns the set of Freezables that can be cast to interf.
 Freezable findByIdentifier(java.io.Serializable identifier)
          Freeze and findByIdentifier methods in MemStorage always return the same instance of the object.
 HasTypableKey findByTypableKey(java.lang.String key)
          Returns the Freezable that has the typable key
 java.io.Serializable findIDForTypableKey(java.lang.String key)
           
 void freeze(Freezable victem)
          Put the victem in all the Maps.
 SetOfFreezables getAll()
           
protected  void init()
          This method should be called by the MemStorage constructor only.
 boolean isAvailable(java.io.Serializable identifier)
           
 void throwOut(java.io.Serializable identifier)
          Remove this victem from all the Maps
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MEMSTORAGE

public static final java.lang.String MEMSTORAGE

memSet

protected MemSet memSet

classIndex

protected MultiValueIndex classIndex

typableKeyIndex

protected SingleValueIndex typableKeyIndex

caster

protected Caster caster
Constructor Detail

MemStorage

public MemStorage()
Method Detail

init

protected void init()
This method should be called by the MemStorage constructor only. It creates a MemSet of size 7 to use inside this Freezer. Override this method if you'd like to use a weak Set, for example.


freeze

public void freeze(Freezable victem)
Put the victem in all the Maps.

Freeze and findByIdentifier methods in MemStorage always return the same instance of the object. This behavior is appropirate for client object caches, but not for safe transactions.


findByIdentifier

public Freezable findByIdentifier(java.io.Serializable identifier)
                           throws NotInFreezerException
Freeze and findByIdentifier methods in MemStorage always return the same instance of the object. This behavior is appropirate for client object caches, but not for safe transactions.


throwOut

public void throwOut(java.io.Serializable identifier)
              throws NotInFreezerException
Remove this victem from all the Maps


isAvailable

public boolean isAvailable(java.io.Serializable identifier)

getAll

public SetOfFreezables getAll()

clear

public void clear()

count

public int count()

countByClass

public int countByClass(java.lang.Class interf)
Count the number of freezables that implement this interf.


findByClass

public SetOfFreezables findByClass(java.lang.Class interf)
Returns the set of Freezables that can be cast to interf.

Throws:
PersistenceFailureException

findByTypableKey

public HasTypableKey findByTypableKey(java.lang.String key)
                               throws NotInFreezerException
Returns the Freezable that has the typable key

Throws:
PersistenceFailureException
NotInFreezerException

findIDForTypableKey

public java.io.Serializable findIDForTypableKey(java.lang.String key)
                                         throws NotInFreezerException

containsTypableKey

public boolean containsTypableKey(java.lang.String key)
Returns true if the typable key is in use already.

Throws:
PersistenceFailureException


Copyright (c) 2000, 2001, David Walend