net.sourceforge.domian.repository
Enum PersistenceDefinition

java.lang.Object
  extended by java.lang.Enum<PersistenceDefinition>
      extended by net.sourceforge.domian.repository.PersistenceDefinition
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<PersistenceDefinition>

public enum PersistenceDefinition
extends java.lang.Enum<PersistenceDefinition>

Definitions regarding the nature of the different persistence mechanisms that Domian repositories may inhibit. Each individual repository implementation supports one or more of these definitions.

Since:
0.4
Author:
Eirik Torske

Enum Constant Summary
DELEGATED
          This persistence definition dictates that all Repository operations are delegated to an external persistence mechanism.
FILE
          This persistence definition dictates that all Repository operations are directly forwarded to one or more files.
INMEMORY
          This persistence definition should really be denominated NO_PERSISTENCE.
INMEMORY_AND_DELEGATED
          This persistence definition dictates an asynchronous persistence scheme.
INMEMORY_AND_FILE
          This persistence definition dictates an asynchronous persistence scheme.
 
Method Summary
 boolean isDelegated()
           
 boolean isDelegatedOnly()
           
 boolean isFileBased()
           
 boolean isFileBasedOnly()
           
 boolean isMemoryBased()
           
 boolean isMemoryBasedOnly()
           
 boolean isNotMemoryBased()
           
 boolean supportsAsynchronousPersistence()
           
 java.lang.String toString()
           
static PersistenceDefinition valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static PersistenceDefinition[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

FILE

public static final PersistenceDefinition FILE
This persistence definition dictates that all Repository operations are directly forwarded to one or more files. No Domian in-memory functionality are in use. The load and persist methods are deactivated, as put, update, and find have taken their role in this particular persistence definition.

Resolving possibly duplicate entities must be done manually in client code, as this definition implies that repositories always returns fresh objects.

Repositories implementing the semantics of this definition, and working in shared mode, must also do some sort of file locking for safe usage.

NB! File-based stores counts as persistent storage media, although the nature of the writings to disc obviously depends on the file system implementations involved.

To be considered: The in-memory entities are kept as a read-only cache. (establish another definition for this)
To be considered: The persistence timestamp is used to choose between entity versions.


DELEGATED

public static final PersistenceDefinition DELEGATED
This persistence definition dictates that all Repository operations are delegated to an external persistence mechanism. That mechanism will be provided by some third-party library, typically reflected in the repository name. The repository method semantics will depend on the delegated persistence implementation and should be thoroughly described in the repository documentation.


INMEMORY

public static final PersistenceDefinition INMEMORY
This persistence definition should really be denominated NO_PERSISTENCE. It is included for completeness, and as a basis for the asynchronous persistence definitions INMEMORY_AND_*, described below..


INMEMORY_AND_FILE

public static final PersistenceDefinition INMEMORY_AND_FILE
This persistence definition dictates an asynchronous persistence scheme. The main working area for stored entities will be in-memory. At specified points in time, all entities will be written to one or more files.

For this persistence definition load() means purging all your in-memory entities and replacing them with the persisted entities. persist() means purging all your persisted entities and replacing them with the in-memory entities.

Repositories implementing this definition semantics should always be working in embedded mode, as shared mode could easily overwrite each other's data. A strict locking mechanism must be applied to prevent such unfortunate scenarios.

NB! File-based stores counts as persistent storage media, although the nature of the writings to disc obviously depends on the file system implementations involved.


INMEMORY_AND_DELEGATED

public static final PersistenceDefinition INMEMORY_AND_DELEGATED
This persistence definition dictates an asynchronous persistence scheme. The main working area for stored entities will be in-memory. At specified points in time, all entities will be written to an external persistence provider.

For this persistence definition load() means purging all your in-memory entities and replacing them with the persisted entities. persist() means purging all your persisted entities and replacing them with the in-memory entities.

Repositories implementing this definition semantics should always be working in embedded mode, as shared mode could easily overwrite each other's data. A strict locking mechanism must be applied to prevent such unfortunate scenarios.

Method Detail

values

public static PersistenceDefinition[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (PersistenceDefinition c : PersistenceDefinition.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static PersistenceDefinition valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

isFileBased

public boolean isFileBased()

isFileBasedOnly

public boolean isFileBasedOnly()

isMemoryBased

public boolean isMemoryBased()

isMemoryBasedOnly

public boolean isMemoryBasedOnly()

isDelegated

public boolean isDelegated()

isDelegatedOnly

public boolean isDelegatedOnly()

isNotMemoryBased

public boolean isNotMemoryBased()

supportsAsynchronousPersistence

public boolean supportsAsynchronousPersistence()
Returns:
true if this repository inhibit asynchronous persistence capabilities

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Enum<PersistenceDefinition>


Copyright © 2006-2010. All Rights Reserved.