Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3129

Make all event listener methods default methods

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0.0
    • Component/s: Monitoring
    • Labels:
      None

      Description

      With Java 8 as the minimum supported JVM for the 4.0 release, the driver should make all methods in the various event listener interfaces (e.g. ConnectionPoolListener, ClusterListenerdefault methods, which will allow implementers to declare only the methods for the events in the interface that interest them. For example, implementers of ConnectionPoolListener who are only interested in ConnectionAddedEvent can simply write:

              var settings = MongoClientSettings.builder()
                      .applyToConnectionPoolSettings(builder ->
                              builder.addConnectionPoolListener(new ConnectionPoolListener() {
                                  @Override
                                  public void connectionAdded(final ConnectionAddedEvent event) {
                                      System.out.println(event);
                                  }
                              })).build();
      

      This will also allow us to add new methods to existing event listener interfaces without breaking binary compatibility.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: