Holger's
Java API

com.antelmann.mgmt
Class AbstractDatabase<T>

java.lang.Object
  extended by com.antelmann.mgmt.AbstractDatabase<T>
All Implemented Interfaces:
Database<T>
Direct Known Subclasses:
SQLDatabase

public abstract class AbstractDatabase<T>
extends Object
implements Database<T>

leaves the transaction management to the inheriting class by leaving the implementation of getTransaction(). Each database access through DBClassStore objects is monitored by this implementation as every DBClassStore instance is wrapped by a proxy. Other than that, the logging is also left to an inheriting class.

Author:
Holger Antelmann

Field Summary
protected  LogWriter logWriter
           
 
Constructor Summary
AbstractDatabase(T database, User user, LogWriter logWriter)
           
 
Method Summary
 void addListener(DBListener listener)
           
<T extends Resource>
ArrayList<T>
fetch(Class<T> c, Filter<T> filter)
           
 Set<Class<? extends Resource>> getAvailableClassStores()
           
<T extends Resource>
DBClassStore<T>
getClassStore(Class<T> c)
          returns a monitored Proxy of the previously added DBClassStore for c or null
 T getDatabaseSerivce()
          provides access to the actual database service that is used by the implementation of this interface
 DBListener[] getListeners()
           
 Logger getLogger()
          a logger that contains the logWriter given in the constructor; it is used to log all database access with the special level 'dbaccess' by default
 User getUser()
          returns the user credentials of the one currently using this database
<T extends Resource>
DBClassStore<T>
putClassStore(Class<T> c, DBClassStore<T> dbcs)
           
<T extends Resource>
DBClassStore<T>
remove(Class<T> c)
           
 void removeListener(DBListener listener)
           
 void setUser(User user)
          sets the user credentials for accessing resources
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.antelmann.mgmt.Database
getTransaction
 

Field Detail

logWriter

protected LogWriter logWriter
Constructor Detail

AbstractDatabase

public AbstractDatabase(T database,
                        User user,
                        LogWriter logWriter)
Method Detail

getDatabaseSerivce

public T getDatabaseSerivce()
Description copied from interface: Database
provides access to the actual database service that is used by the implementation of this interface

Specified by:
getDatabaseSerivce in interface Database<T>

getAvailableClassStores

public Set<Class<? extends Resource>> getAvailableClassStores()
Specified by:
getAvailableClassStores in interface Database<T>

remove

public <T extends Resource> DBClassStore<T> remove(Class<T> c)

getClassStore

public <T extends Resource> DBClassStore<T> getClassStore(Class<T> c)
returns a monitored Proxy of the previously added DBClassStore for c or null

Specified by:
getClassStore in interface Database<T>
Returns:
a persistence service for the given Resource class or null if such service doesn't exist

putClassStore

public <T extends Resource> DBClassStore<T> putClassStore(Class<T> c,
                                                          DBClassStore<T> dbcs)

fetch

public <T extends Resource> ArrayList<T> fetch(Class<T> c,
                                               Filter<T> filter)
                                    throws DatabaseException
Throws:
DatabaseException

getUser

public User getUser()
Description copied from interface: Database
returns the user credentials of the one currently using this database

Specified by:
getUser in interface Database<T>

setUser

public void setUser(User user)
Description copied from interface: Database
sets the user credentials for accessing resources

Specified by:
setUser in interface Database<T>

getLogger

public Logger getLogger()
a logger that contains the logWriter given in the constructor; it is used to log all database access with the special level 'dbaccess' by default

Specified by:
getLogger in interface Database<T>

addListener

public void addListener(DBListener listener)
Specified by:
addListener in interface Database<T>

removeListener

public void removeListener(DBListener listener)
Specified by:
removeListener in interface Database<T>

getListeners

public DBListener[] getListeners()


(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads