Holger's Java API

## com.antelmann.db
Class DatabaseChangeMonitor

    java.lang.Object
      com.antelmann.db.DatabaseChangeMonitor

    public class DatabaseChangeMonitor

extends Object

listens to database events and propagates committed changes in a database to its DatabaseChangeListeners to its listeners.

Since:
  15. Dezember 2006, 21:06
Author:
  Holger Antelmann
See Also:
  `DatabaseChangeListener`, `DBStoreListener`, `TransactionListener.transactionCommitted(DBTransaction)`, `DBUtils.listenWhileVisible(javax.swing.JComponent, Database, DatabaseChangeListener)`

Constructor Summary
`DatabaseChangeMonitor(Database<?>... dbms)`

Method Summary
`boolean` `addDatabase(Database<?> db)` starts monitoring the given database; changes of any ongoing transaction may not trigger a notification from this monitor.
`boolean` `addListener(DatabaseChangeListener listener)`
`protected void` `finalize()`
`static HashSet<DatabaseChangeMonitor>` `findAllMonitors(Database<?> db)` convenience method to find all monitors on the given database that are added as both, store listener and transaction listener
`protected void` `fireChanges(Database<?> db, DBUpdateEvent... events)`
`protected DBUpdateEvent[]` `getCurrentUpdates(Database<?> db)`
`Database<?>[]` `getDatabases()` returns all databases that are monitored
`Filter<? super DBUpdateEvent>` `getFilter()`
`DatabaseChangeListener[]` `getListeners()`
`void` `removeAllDatabases()` removes all databases from this monitor, so no more resources are bound (this is required for this instance to be garbage-collected)
`void` `removeAllListeners()`
`boolean` `removeDatabase(Database<?> db)` stops monitoring the given database
`boolean` `removeListener(DatabaseChangeListener listener)`
`void` `setFilter(Filter<? super DBUpdateEvent> filter)`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DatabaseChangeMonitor

    public DatabaseChangeMonitor(Database<?>... dbms)

Method Detail

### getFilter

    public Filter<? super DBUpdateEvent> getFilter()

### setFilter

    public void setFilter(Filter<? super DBUpdateEvent> filter)

### getCurrentUpdates

    protected DBUpdateEvent[] getCurrentUpdates(Database<?> db)

### addListener

    public boolean addListener(DatabaseChangeListener listener)

### removeListener

    public boolean removeListener(DatabaseChangeListener listener)

### getListeners

    public DatabaseChangeListener[] getListeners()

### removeAllListeners

    public void removeAllListeners()

### addDatabase

    public boolean addDatabase(Database<?> db)

  starts monitoring the given database; changes of any ongoing transaction may not trigger a notification from this monitor.

### removeDatabase

    public boolean removeDatabase(Database<?> db)

  stops monitoring the given database

### finalize

    protected void finalize()

  Overrides:
    `finalize` in class `Object`

### removeAllDatabases

    public void removeAllDatabases()

  removes all databases from this monitor, so no more resources are bound (this is required for this instance to be garbage-collected)

### getDatabases

    public Database<?>[] getDatabases()

  returns all databases that are monitored

### fireChanges

    protected void fireChanges(Database<?> db,
                               DBUpdateEvent... events)

### findAllMonitors

    public static HashSet<DatabaseChangeMonitor> findAllMonitors(Database<?> db)

  convenience method to find all monitors on the given database that are added as both, store listener and transaction listener

  See Also:
    `DBTransaction.getTransactionListeners()`, `Database.getStoreListeners()`

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