com.vinculumtech.platform.root.persistence
Class InMemoryPersistenceSession

java.lang.Object
  extended bycom.vinculumtech.platform.root.PersistenceSession
      extended bycom.vinculumtech.platform.root.persistence.InMemoryPersistenceSession

public class InMemoryPersistenceSession
extends PersistenceSession

The InMemoryPersistenceSession is a simple PersistenceSession implementation that provides in memory storage of Imageable instances. It may optionally store all manages instances to a serialized file (enabled by the inmemory.persist property, and specified by the inmemory.filename property).

It is intended that this PersistenceSession be used for prototyping new applications before selecting, coupling, and optimizing any commercial or open-source object/relational or object database persistence tool. CarrierWave ships with a few additional PersistenceSession implementations for JDO, and other persistence tools.

Note that the InMemoryObjectFinder and InMemoryCollectionFinder classes can be subclassed for custom typed finder types. Or more conveniently, the OGNLObjectFinder and OGNLCollectionFinder classes can be used with any PersistenceSession implementation as they use the OGNL library to navigate and query Imageable object instances.
*

Version:
$Id: //depot/carrierwave/src/server/com/vinculumtech/platform/root/persistence/InMemoryPersistenceSession.java#24 $

Field Summary
static java.lang.String PERSIST
           
static java.lang.String PERSIST_FILE
           
 
Fields inherited from class com.vinculumtech.platform.root.PersistenceSession
REFERENCEABLE_NAME_FIELD
 
Constructor Summary
InMemoryPersistenceSession()
           
 
Method Summary
 void beginSession(boolean readOnly)
          Initialize the session for the current Thread.
 void commitSession()
          Perform any necessary cleanup before the session is completed.
 java.lang.Object createInstanceOf(java.lang.Class type)
          Create a new persistant instance of the given type.
 void deleteInstance(java.lang.Object object)
          Delete an object.
 java.util.List findAllInstancesOf(java.lang.Class type, boolean excludeSubclasses)
          Return a List of all objects of the given type.
If no object is found, an empty List is returned.
 java.lang.Object findInstanceOf(java.lang.Class type, java.lang.Object objectId)
          Return the existing object of the specified type with the given id.
If no object is found, null is returned.
 java.lang.Object findInstanceOf(java.lang.Class type, java.lang.String referenceableName)
          Return the existing object of the specified type with the given referenceableName.

Referenceable names are names that are more durable than the persistence tool object id, and are suitable for explicit referencing by remote applications.
 java.lang.Object getIdentityOf(java.lang.Object object)
           
static ObjectManager getObjectCache()
           
 boolean isReadOnly()
           
protected  void lock()
           
protected  void release()
           
 void rollbackSession()
          Rollback the current session.
 void setReadOnly(boolean readOnly)
           
 
Methods inherited from class com.vinculumtech.platform.root.PersistenceSession
findAllInstancesOf, findInstanceOf, getReferenceableNameField, getReferenceableNameOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERSIST

public static final java.lang.String PERSIST
See Also:
Constant Field Values

PERSIST_FILE

public static final java.lang.String PERSIST_FILE
See Also:
Constant Field Values
Constructor Detail

InMemoryPersistenceSession

public InMemoryPersistenceSession()
Method Detail

getObjectCache

public static ObjectManager getObjectCache()

lock

protected void lock()

release

protected void release()

isReadOnly

public boolean isReadOnly()

setReadOnly

public void setReadOnly(boolean readOnly)

beginSession

public void beginSession(boolean readOnly)
Description copied from class: PersistenceSession
Initialize the session for the current Thread.

Specified by:
beginSession in class PersistenceSession
Parameters:
readOnly - Specifies whether this session will make modifications to domain objects or not

createInstanceOf

public java.lang.Object createInstanceOf(java.lang.Class type)
Description copied from class: PersistenceSession
Create a new persistant instance of the given type.

Specified by:
createInstanceOf in class PersistenceSession
Parameters:
type -
Returns:

deleteInstance

public void deleteInstance(java.lang.Object object)
Description copied from class: PersistenceSession
Delete an object.

Specified by:
deleteInstance in class PersistenceSession
Parameters:
object -

getIdentityOf

public java.lang.Object getIdentityOf(java.lang.Object object)
Overrides:
getIdentityOf in class PersistenceSession

commitSession

public void commitSession()
Description copied from class: PersistenceSession
Perform any necessary cleanup before the session is completed.

Specified by:
commitSession in class PersistenceSession

rollbackSession

public void rollbackSession()
Description copied from class: PersistenceSession
Rollback the current session.

Specified by:
rollbackSession in class PersistenceSession

findAllInstancesOf

public java.util.List findAllInstancesOf(java.lang.Class type,
                                         boolean excludeSubclasses)
Description copied from class: PersistenceSession
Return a List of all objects of the given type.
If no object is found, an empty List is returned.

Specified by:
findAllInstancesOf in class PersistenceSession
Parameters:
type -
Returns:

findInstanceOf

public java.lang.Object findInstanceOf(java.lang.Class type,
                                       java.lang.Object objectId)
Description copied from class: PersistenceSession
Return the existing object of the specified type with the given id.
If no object is found, null is returned.

Specified by:
findInstanceOf in class PersistenceSession
Parameters:
type -
objectId -
Returns:

findInstanceOf

public java.lang.Object findInstanceOf(java.lang.Class type,
                                       java.lang.String referenceableName)
Description copied from class: PersistenceSession
Return the existing object of the specified type with the given referenceableName.

Referenceable names are names that are more durable than the persistence tool object id, and are suitable for explicit referencing by remote applications. That is, it is not proper to require a client application to remember an object by its object id, that value should be opaque, but the client should be provided an URL like reference to its target object.

This method should use the value of PersistenceSession.REFERENCEABLE_NAME_FIELD when searching for the applicable object. Or it should use a custom naming scheme.

Specified by:
findInstanceOf in class PersistenceSession
Parameters:
type -
referenceableName -
Returns:


Copyright (C) 2002 Vinculum Technologies, Inc. All Rights Reserved.