[JAVA-3129] Make all event listener methods default methods Created: 30/Dec/18  Updated: 28/Oct/23  Resolved: 23/Aug/19

Status: Closed
Project: Java Driver
Component/s: Monitoring
Affects Version/s: None
Fix Version/s: 4.0.0

Type: New Feature Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: John Stewart (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 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.



 Comments   
Comment by Githook User [ 15/Jan/20 ]

Author:

{'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}

Message: Replace use of deprecated event listener adapters

Now that all the methods in the event listener interfaces have no-op
default implementations, there is no need for the adapters, hence
their deprecation.

As a follow-on, replace all internal use of the adapters with
direct implementation of the interface.

JAVA-3129
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/f018b6c334d9cdf6f4791bcf80c69f32d9701971

Comment by Githook User [ 15/Jan/20 ]

Author:

{'name': 'John Stewart', 'username': 'jstewart-mongo', 'email': 'john.stewart@mongodb.com'}

Message: Make all event listener methods default methods

JAVA-3129
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/724f43c95dcf0673b6d7829e6d945dd704d822a3

Generated at Thu Feb 08 08:58:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.