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

Make all event listener methods default methods

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.0
    • Affects Version/s: None
    • Component/s: Monitoring
    • None

      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.

            Assignee:
            john.stewart@mongodb.com John Stewart (Inactive)
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: