-
Type: New Feature
-
Resolution: Fixed
-
Priority: Major - P3
-
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, ClusterListener) default 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.