@@ -517,6 +517,11 @@ public class Options {
517
517
* {@link Builder#callbackThreadFactory(ThreadFactory) callbackThreadFactory}.
518
518
*/
519
519
public static final String PROP_CALLBACK_THREAD_FACTORY_CLASS = "callback.thread.factory.class" ;
520
+ /**
521
+ * Property used to set class name for the ReaderListener implementation
522
+ * {@link Builder#readListener(ReadListener) readListener}.
523
+ */
524
+ public static final String PROP_READ_LISTENER_CLASS = "read.listener.class" ;
520
525
521
526
// ----------------------------------------------------------------------------------------------------
522
527
// PROTOCOL CONNECT OPTION CONSTANTS
@@ -658,6 +663,7 @@ public class Options {
658
663
private final ErrorListener errorListener ;
659
664
private final TimeTraceLogger timeTraceLogger ;
660
665
private final ConnectionListener connectionListener ;
666
+ private ReadListener readListener ;
661
667
private final StatisticsCollector statisticsCollector ;
662
668
private final String dataPortType ;
663
669
@@ -779,6 +785,7 @@ public static class Builder {
779
785
private ErrorListener errorListener = null ;
780
786
private TimeTraceLogger timeTraceLogger = null ;
781
787
private ConnectionListener connectionListener = null ;
788
+ private ReadListener readListener = null ;
782
789
private StatisticsCollector statisticsCollector = null ;
783
790
private String dataPortType = DEFAULT_DATA_PORT_TYPE ;
784
791
private ExecutorService executor ;
@@ -896,6 +903,7 @@ public Builder properties(Properties props) {
896
903
classnameProperty (props , PROP_ERROR_LISTENER , o -> this .errorListener = (ErrorListener ) o );
897
904
classnameProperty (props , PROP_TIME_TRACE_LOGGER , o -> this .timeTraceLogger = (TimeTraceLogger ) o );
898
905
classnameProperty (props , PROP_CONNECTION_CB , o -> this .connectionListener = (ConnectionListener ) o );
906
+ classnameProperty (props , PROP_READ_LISTENER_CLASS , o -> this .readListener = (ReadListener ) o );
899
907
classnameProperty (props , PROP_STATISTICS_COLLECTOR , o -> this .statisticsCollector = (StatisticsCollector ) o );
900
908
901
909
stringProperty (props , PROP_DATA_PORT_TYPE , s -> this .dataPortType = s );
@@ -914,7 +922,6 @@ public Builder properties(Properties props) {
914
922
classnameProperty (props , PROP_EXECUTOR_SERVICE_CLASS , o -> this .executor = (ExecutorService ) o );
915
923
classnameProperty (props , PROP_CONNECT_THREAD_FACTORY_CLASS , o -> this .connectThreadFactory = (ThreadFactory ) o );
916
924
classnameProperty (props , PROP_CALLBACK_THREAD_FACTORY_CLASS , o -> this .callbackThreadFactory = (ThreadFactory ) o );
917
-
918
925
return this ;
919
926
}
920
927
@@ -1551,6 +1558,17 @@ public Builder connectionListener(ConnectionListener listener) {
1551
1558
return this ;
1552
1559
}
1553
1560
1561
+ /**
1562
+ * Sets a listener to be notified on incoming protocol/message
1563
+ *
1564
+ * @param readListener the listener
1565
+ * @return the Builder for chaining
1566
+ */
1567
+ public Builder readListener (ReadListener readListener ) {
1568
+ this .readListener = readListener ;
1569
+ return this ;
1570
+ }
1571
+
1554
1572
/**
1555
1573
* Set the {@link StatisticsCollector StatisticsCollector} to collect connection metrics.
1556
1574
* <p>
@@ -1960,6 +1978,7 @@ public Builder(Options o) {
1960
1978
this .errorListener = o .errorListener ;
1961
1979
this .timeTraceLogger = o .timeTraceLogger ;
1962
1980
this .connectionListener = o .connectionListener ;
1981
+ this .readListener = o .readListener ;
1963
1982
this .statisticsCollector = o .statisticsCollector ;
1964
1983
this .dataPortType = o .dataPortType ;
1965
1984
this .trackAdvancedStats = o .trackAdvancedStats ;
@@ -2027,6 +2046,7 @@ private Options(Builder b) {
2027
2046
this .errorListener = b .errorListener ;
2028
2047
this .timeTraceLogger = b .timeTraceLogger ;
2029
2048
this .connectionListener = b .connectionListener ;
2049
+ this .readListener = b .readListener ;
2030
2050
this .statisticsCollector = b .statisticsCollector ;
2031
2051
this .dataPortType = b .dataPortType ;
2032
2052
this .trackAdvancedStats = b .trackAdvancedStats ;
@@ -2112,6 +2132,13 @@ public ConnectionListener getConnectionListener() {
2112
2132
return this .connectionListener ;
2113
2133
}
2114
2134
2135
+ /**
2136
+ * @return the read listener, or null, see {@link Builder#readListener(ReadListener) readListener()} in the builder doc
2137
+ */
2138
+ public ReadListener getReadListener () {
2139
+ return this .readListener ;
2140
+ }
2141
+
2115
2142
/**
2116
2143
* @return the statistics collector, or null, see {@link Builder#statisticsCollector(StatisticsCollector) statisticsCollector()} in the builder doc
2117
2144
*/
0 commit comments