org.firebirdsql.event
Class FBEventManager

java.lang.Object
  extended byorg.firebirdsql.event.FBEventManager
All Implemented Interfaces:
EventManager

public class FBEventManager
extends java.lang.Object
implements EventManager

An EventListener implementation to listen for database events.

Author:
Gabriel Reid

Constructor Summary
FBEventManager()
           
FBEventManager(org.firebirdsql.gds.impl.GDSType gdsType)
           
 
Method Summary
 void addEventListener(java.lang.String eventName, EventListener listener)
          Register an EventListener that will be called when an event occurs.
 void connect()
          Make a connection with a database to listen for events.
 void disconnect()
          Close the connection to the database.
 java.lang.String getDatabase()
          Returns the database path for the connection to the database.
 java.lang.String getHost()
          Returns the host for the connection to the database.
 java.lang.String getPassword()
          Returns the password for the connection to the database.
 int getPort()
          Returns the port for the connection to the database.
 java.lang.String getUser()
          Returns the username for the connection to the databaes.
 boolean isConnected()
          Check whether this object is connected to the database.
 void removeEventListener(java.lang.String eventName, EventListener listener)
          Remove an EventListener for a given event.
 void setDatabase(java.lang.String database)
          Sets the database path for the connection to the database.
 void setHost(java.lang.String host)
          Sets the host for the connection to the database.
 void setPassword(java.lang.String password)
          Sets the password for the connection to the database.
 void setPort(int port)
          Sets the port for the connection to the database.
 void setUser(java.lang.String user)
          Sets the username for the connection to the database .
 int waitForEvent(java.lang.String eventName)
          Wait for the one-time occurence of an event.
 int waitForEvent(java.lang.String eventName, int timeout)
          Wait for the one-time occurence of an event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FBEventManager

public FBEventManager()

FBEventManager

public FBEventManager(org.firebirdsql.gds.impl.GDSType gdsType)
Method Detail

connect

public void connect()
             throws java.sql.SQLException
Make a connection with a database to listen for events.

Specified by:
connect in interface EventManager
Throws:
java.sql.SQLException - If a database communication error occurs

disconnect

public void disconnect()
                throws java.sql.SQLException
Close the connection to the database.

Specified by:
disconnect in interface EventManager
Throws:
java.sql.SQLException - If a database communication error occurs

isConnected

public boolean isConnected()
Check whether this object is connected to the database.

Returns:
true if object is connected to the database, otherwise false.

setUser

public void setUser(java.lang.String user)
Sets the username for the connection to the database .

Specified by:
setUser in interface EventManager

getUser

public java.lang.String getUser()
Returns the username for the connection to the databaes.

Specified by:
getUser in interface EventManager
Returns:
the username for the connection to the database.

setPassword

public void setPassword(java.lang.String password)
Sets the password for the connection to the database.

Specified by:
setPassword in interface EventManager
Parameters:
password - for the connection to the database.

getPassword

public java.lang.String getPassword()
Returns the password for the connection to the database.

Specified by:
getPassword in interface EventManager
Returns:
the password for the connection to the database.

setDatabase

public void setDatabase(java.lang.String database)
Sets the database path for the connection to the database.

Specified by:
setDatabase in interface EventManager
Parameters:
database - path for the connection to the database.

getDatabase

public java.lang.String getDatabase()
Returns the database path for the connection to the database.

Specified by:
getDatabase in interface EventManager
Returns:
the database path for the connection to the database.

getHost

public java.lang.String getHost()
Returns the host for the connection to the database.

Specified by:
getHost in interface EventManager
Returns:
the host for the connection to the database.

setHost

public void setHost(java.lang.String host)
Sets the host for the connection to the database.

Specified by:
setHost in interface EventManager
Parameters:
host - for the connection to the database.

getPort

public int getPort()
Returns the port for the connection to the database.

Specified by:
getPort in interface EventManager
Returns:
the port for the connection to the database.

setPort

public void setPort(int port)
Sets the port for the connection to the database.

Specified by:
setPort in interface EventManager
Parameters:
port - for the connection to the database.

addEventListener

public void addEventListener(java.lang.String eventName,
                             EventListener listener)
                      throws java.sql.SQLException
Register an EventListener that will be called when an event occurs.

Specified by:
addEventListener in interface EventManager
Parameters:
eventName - The name of the event for which the listener will be notified
listener - The EventListener that will be called when the given event occurs
Throws:
java.sql.SQLException - If a database access error occurs

removeEventListener

public void removeEventListener(java.lang.String eventName,
                                EventListener listener)
                         throws java.sql.SQLException
Remove an EventListener for a given event.

Specified by:
removeEventListener in interface EventManager
Parameters:
eventName - The name of the event for which the listener will be unregistered.
listener - The EventListener that is to be unregistered
Throws:
java.sql.SQLException - If a database access error occurs

waitForEvent

public int waitForEvent(java.lang.String eventName)
                 throws java.lang.InterruptedException,
                        java.sql.SQLException
Wait for the one-time occurence of an event. This method blocks indefinitely until the event identified by the value of eventName occurs. The return value is the number of occurrences of the requested event.

Specified by:
waitForEvent in interface EventManager
Parameters:
eventName - The name of the event to wait for
Returns:
The number of occurences of the requested event
Throws:
java.lang.InterruptedException - If interrupted while waiting
java.sql.SQLException - If a database access error occurs

waitForEvent

public int waitForEvent(java.lang.String eventName,
                        int timeout)
                 throws java.lang.InterruptedException,
                        java.sql.SQLException
Wait for the one-time occurence of an event. This method blocks for a maximum of timeout milliseconds, waiting for the event identified by eventName to occur. A timeout value of 0 means wait indefinitely. The return value is the number of occurences of the event in question, or -1 if the call timed out.

Specified by:
waitForEvent in interface EventManager
Parameters:
timeout - The maximum number of milliseconds to wait
Returns:
The number of occurrences of the requested event, or -1 if the call timed out
Throws:
java.lang.InterruptedException - If interrupted while waiting
java.sql.SQLException - If a database access error occurs


Copyright © 2001 David Jencks and other authors. All rights reserved.