Holger's Java API

## com.antelmann.db.remote
Class ChangeNotificationServer

    java.lang.Object
      com.antelmann.db.remote.ChangeNotificationServer

All Implemented Interfaces:
  NetConnectionHandler

    public class ChangeNotificationServer

extends Object
implements NetConnectionHandler

implements a server for a change notification mechanism. It is recommended to use the same connection instance for both, `RemoteDBChangeNotifier` and `RemoteDatabaseChangeHandler`, as this implementation automatically prevents to propagate changes to the same connection. This implementation also allows filtering based on `RemoteDBChangeFilter`, which can be set from the client through the connection.

Since:
  20.08.2008, 16:42:32
Author:
  Holger Antelmann
See Also:
  `ChangeNotificationClient`, `RemoteDBUpdateEvent`, `RemoteDBChangeFilter`

Field Summary
`static int` `PORT`

Constructor Summary
`ChangeNotificationServer(String databaseName, int port, Logger logger)`
`ChangeNotificationServer(String databaseName, Logger logger)`

Method Summary
`void` `connectionLost(NetConnection connection)` called when a connection caused an IOException during reading or writing; the connection may not have been closed at this point.
`static Handshake` `createHandshake(String databaseName)`
`String` `getDatabaseName()` provides the name for this notification server; connecting clients must use the same name
`NetConnectionServer` `getServer()` provides access to the server to start/stop it
`void` `handleMessage(Object message, NetConnection connection)` called when a message is received by the given NetConnection object
`boolean` `isDeliverToSelf()`
`void` `setDeliverToSelf(boolean deliverToSelf)` only if set to true, database changes are also delivered to the connection the message came from (the default is false)
`static void` `startGUIServer(String databaseName)`
`static void` `startGUIServer(String databaseName, int port)` starts a demo change notification server that utilizes a `JTextComponentLog`

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

Field Detail

### PORT

    public static final int PORT

See Also:
  Constant Field Values

Constructor Detail

### ChangeNotificationServer

    public ChangeNotificationServer(String databaseName,
                                    Logger logger)
                             throws IOException

Throws:
  `IOException`

### ChangeNotificationServer

    public ChangeNotificationServer(String databaseName,
                                    int port,
                                    Logger logger)
                             throws IOException

Throws:
  `IOException`

Method Detail

### createHandshake

    public static Handshake createHandshake(String databaseName)

### isDeliverToSelf

    public boolean isDeliverToSelf()

### setDeliverToSelf

    public void setDeliverToSelf(boolean deliverToSelf)

  only if set to true, database changes are also delivered to the connection the message came from (the default is false)

### getDatabaseName

    public String getDatabaseName()

  provides the name for this notification server; connecting clients must use the same name

### getServer

    public NetConnectionServer getServer()

  provides access to the server to start/stop it

### handleMessage

    public void handleMessage(Object message,
                              NetConnection connection)

  Description copied from interface: `NetConnectionHandler`
  called when a message is received by the given NetConnection object

  Specified by:
    `handleMessage` in interface `NetConnectionHandler`

### connectionLost

    public void connectionLost(NetConnection connection)

  Description copied from interface: `NetConnectionHandler`
  called when a connection caused an IOException during reading or writing; the connection may not have been closed at this point.
  Usually, it is a good idea to close the connection here explicitly.

  Specified by:
    `connectionLost` in interface `NetConnectionHandler`

### startGUIServer

    public static void startGUIServer(String databaseName)
                               throws IOException

  Throws:
    `IOException`

### startGUIServer

    public static void startGUIServer(String databaseName,
                                      int port)
                               throws IOException

  starts a demo change notification server that utilizes a `JTextComponentLog`

  Parameters:
    `databaseName` - the name of the database that clients use to connect to this server
    `port` - the local server port to be used
  Throws:
    `IOException`

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