com.gridsystems.storage
Class DAOManager

java.lang.Object
  extended by com.gridsystems.storage.DAOManager

public final class DAOManager
extends java.lang.Object

Manages object load and store through a DAO instance.

Version:
1.0
Author:
Rodrigo Ruiz, Xmas (Generics)

Method Summary
static
<T> void
delete(DAO<T> dao, T obj)
          Deletes all files associated to the specified object.
static
<T> T
load(DAO<T> dao, java.util.Map<java.lang.String,java.lang.String> data)
          Loads an object from the specified DAO, using data as initialization info.
static
<T> void
store(DAO<T> dao, T obj)
          Stores an object through the specified DAO.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

load

public static <T> T load(DAO<T> dao,
                         java.util.Map<java.lang.String,java.lang.String> data)
              throws java.lang.Exception
Loads an object from the specified DAO, using data as initialization info.

It first attempts to load from the regular files. If an error occurs, it will try again with the backup files.

Type Parameters:
T - Class to store/load.
Parameters:
dao - The DAO to delegate to
data - The initialization data
Returns:
The loaded object
Throws:
java.lang.Exception - In case of unrecoverable load error

store

public static <T> void store(DAO<T> dao,
                             T obj)
                  throws java.lang.Exception
Stores an object through the specified DAO.

It first stores the object in the backup file. If no error occurs, it then stores the regular ones.

Type Parameters:
T - Class to store/load.
Parameters:
dao - The DAO to delegate to
obj - The object to store
Throws:
java.lang.Exception - In case of unrecoverable error

delete

public static <T> void delete(DAO<T> dao,
                              T obj)
Deletes all files associated to the specified object.

Type Parameters:
T - Class to store/load.
Parameters:
dao - The DAO to use
obj - The object whose files to delete


Copyright © 2007-2008 Grid Systems, S.A.. All Rights Reserved.