org.jdesktop.dataset
Class DataConnection

java.lang.Object
  extended by org.jdesktop.dataset.DataConnection
Direct Known Subclasses:
JDBCDataConnection

public abstract class DataConnection
extends java.lang.Object

Maintains a connection to some underlying data store. Generally used by a DataProvider to interact with the DataStore, however, it is not specifically necessary for a DataProvider to use a DataConnection.

Author:
rbair

Constructor Summary
DataConnection()
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a PropertyChangeListener to this class for any changes to bean properties.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Adds a PropertyChangeListener to this class for specific property changes.
protected abstract  void connect()
          Optional method to make a connection to the data store.
protected abstract  void disconnect()
          Optional method to disconnect from the data store.
 boolean isConnected()
           
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Stops notifying a specific listener of changes to a specific property.
 void setConnected(boolean b)
          Manages the connected state of this DataConnection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataConnection

public DataConnection()
Method Detail

setConnected

public void setConnected(boolean b)
Manages the connected state of this DataConnection. The connected state is this DataConnections "logical" connection status. The underlying connection may be disconnected, and yet the DataConnection may still be "logically" connected. For example, an HTTP based connection may not be persistent, but is always "logically" connected.

It is possible for listeners to be attached to the DataConnection that can react to the connection status. For instance, a status bar icon might change to indicate its disconnected status. Or DataSets could be flushed of their data.

Parameters:
b - If true, opens any necessary connections to the source. For instance, this could be used to open a connection to a database, or to a URL. If false, then any current connections are logically closed, and may be physically closed, depending on the DataConnection implementation
Throws:
java.io.IOException

isConnected

public boolean isConnected()
Returns:
whether the DataStoreConnection is logically connected or not.

connect

protected abstract void connect()
                         throws java.lang.Exception
Optional method to make a connection to the data store. This method is called whenever the connection state changes from !connected to connected. It is up to the child class implementation to manage the physical connection to the data store. This method may or may not be useful in that context.

Throws:
java.lang.Exception

disconnect

protected abstract void disconnect()
                            throws java.lang.Exception
Optional method to disconnect from the data store. This method is called whenever the connection state changes from connected to !connected. It is up to the child class implementation to manage the physical connection to the data store. This method may or may not be useful in that context.

Throws:
java.lang.Exception

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to this class for any changes to bean properties.

Parameters:
listener - The PropertyChangeListener to notify of changes to this instance.

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to this class for specific property changes.

Parameters:
propertyName - The name of the property to listen to changes for.
listener - The PropertyChangeListener to notify of changes to this instance.

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)
Stops notifying a specific listener of changes to a specific property.

Parameters:
propertyName - The name of the property to ignore from now on.
listener - The listener to stop receiving notifications.


Copyright © 2005 Sun Microsystems All Rights Reserved.