Interface ConnectionListener

  • public interface ConnectionListener

    This interface allows applications to receive events about the state of DataSource for Java's connection to other DataSource peers.


    Should you wish to receive this information in your DataSource, then you must define a class that implements this interface and register it with DataSource for Java using the DataSource.addConnectionListener(ConnectionListener) method.


    Once registered, the implementation will be informed of all changes to peer status.


    Note: The ConnectionListener methods are not called on a dedicated worker thread. Therefore, if any of these methods are likely take a relatively long time to execute, they should be coded to run in a separate thread.


    The following code example shows an implementation of ConnectionListener that logs peer status change events to the logger.


    import java.util.logging.Level;
    import java.util.logging.Logger;
    import com.caplin.datasource.ConnectionListener;
    import com.caplin.datasource.PeerStatusEvent;
    public class ExampleConnectionListener implements ConnectionListener
            private Logger logger;
            public ExampleConnectionListener(Logger logger)
                    this.logger = logger;
            public void onPeerStatus(PeerStatusEvent peerStatusEvent)
            "Peer status updated: {0} {1}",
                    new Object[] {

    • Method Detail

      • onPeerStatus

        void onPeerStatus​(PeerStatusEvent peerStatusEvent)
        Invoked when a DataSource peer changes state.
        peerStatusEvent - An event containing information about the change in the peer's state.