org.objectweb.jac.aspects.persistence
Class PostgresStorage

java.lang.Object
  |
  +--org.objectweb.jac.aspects.persistence.SQLStorage
        |
        +--org.objectweb.jac.aspects.persistence.PostgresStorage
All Implemented Interfaces:
Serializable, Storage

public class PostgresStorage
extends SQLStorage

Implements the storage to store within a PostgreSQL database.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.objectweb.jac.aspects.persistence.SQLStorage
SQLStorage.InvalidStorageException
 
Field Summary
 
Fields inherited from class org.objectweb.jac.aspects.persistence.SQLStorage
db, id
 
Constructor Summary
PostgresStorage(PersistenceAC ac, String database, String user, String password)
          Creates a new storage for a PostgreSQL database.
 
Method Summary
protected  void doUpdates()
           
protected  boolean ensureSequenceExists(String sequence)
           
protected  String[] getClassNames()
           
protected  String getClassSeqName(String className)
           
 long getCurrVal(String sequence)
           
 Map getNameCounters()
          Gets the name counters used to generate new names.
 long getNextVal(String sequence)
          Returns the next value of a sequence
protected  boolean hasSequence(String name)
           
protected  boolean hasTable(String name)
          Tells wether a table with a given name exists
 String newName(String className)
          Generate a new name for an instance.
 void updateNameCounters(Map counters)
          Sets the name counters used to generate new names.
 
Methods inherited from class org.objectweb.jac.aspects.persistence.SQLStorage
addSlashes, addToList, addToList, addToSet, bindOIDToName, checkStorage, clearList, clearMap, clearSet, close, collectionContains, commit, createObject, deleteName, deleteObject, execute, executeQuery, executeSilent, executeUpdate, getClassID, getCollectionID, getCollectionValues, getField, getFields, getFromMap, getId, getIndexInList, getInt, getInternalIndexInList, getLastIndexInList, getList, getList, getListItem, getListSize, getLong, getMap, getMap, getMapSize, getNameFromOID, getObjects, getObjects, getOID, getOIDFromName, getRootObjects, getSet, getSet, getSetSize, listContains, mapContainsKey, mapContainsValue, putInMap, removeField, removeFromList, removeFromList, removeFromMap, removeFromSet, rollback, setConnection, setContains, setField, setId, setListItem, startTransaction, updateField, updateJacNames
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PostgresStorage

public PostgresStorage(PersistenceAC ac,
                       String database,
                       String user,
                       String password)
                throws SQLException,
                       Exception
Creates a new storage for a PostgreSQL database.

Parameters:
database - the database. It may take on eof the following form:
user - the user name
password - the password for this user
Method Detail

getClassNames

protected String[] getClassNames()
                          throws Exception
Exception

doUpdates

protected void doUpdates()
                  throws Exception,
                         SQLException
Exception
SQLException

getNextVal

public long getNextVal(String sequence)
                throws Exception
Description copied from class: SQLStorage
Returns the next value of a sequence

Specified by:
getNextVal in class SQLStorage
Exception

getCurrVal

public long getCurrVal(String sequence)
                throws Exception
Exception

ensureSequenceExists

protected boolean ensureSequenceExists(String sequence)
                                throws Exception
Exception

newName

public String newName(String className)
               throws Exception
Description copied from interface: Storage
Generate a new name for an instance.

Specified by:
newName in interface Storage
Specified by:
newName in class SQLStorage
Parameters:
className - the className of the instance for which to generate a name
Returns:
the generated name, null if failure
Exception

getNameCounters

public Map getNameCounters()
                    throws Exception
Description copied from interface: Storage
Gets the name counters used to generate new names.

Specified by:
getNameCounters in interface Storage
Specified by:
getNameCounters in class SQLStorage
Returns:
a Map associating counter names to a Long value. The value is the next value to be used.
Exception
See Also:
Storage.updateNameCounters(Map)

getClassSeqName

protected String getClassSeqName(String className)

hasTable

protected boolean hasTable(String name)
                    throws SQLException
Description copied from class: SQLStorage
Tells wether a table with a given name exists

Specified by:
hasTable in class SQLStorage
SQLException

hasSequence

protected boolean hasSequence(String name)
                       throws Exception
Exception

updateNameCounters

public void updateNameCounters(Map counters)
                        throws Exception
Description copied from interface: Storage
Sets the name counters used to generate new names.

Specified by:
updateNameCounters in interface Storage
Specified by:
updateNameCounters in class SQLStorage
Parameters:
counters - a Map associating counter names to a Long value. The value is the next value to be used. A counter is updated only if the suplied value is greater than the current value.
Exception
See Also:
Storage.getNameCounters()