|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2023 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
52 | 52 | *
|
53 | 53 | * @author Rossen Stoyanchev
|
54 | 54 | * @author Sam Brannen
|
| 55 | + * @author Brian Clozel |
55 | 56 | * @since 4.1
|
56 | 57 | */
|
57 | 58 | public class WebSocketMessageBrokerStats implements SmartInitializingSingleton {
|
@@ -160,25 +161,63 @@ private ScheduledFuture<?> initLoggingTask(long initialDelay) {
|
160 | 161 |
|
161 | 162 | /**
|
162 | 163 | * Get stats about WebSocket sessions.
|
| 164 | + * @deprecated as of 6.2 in favor of {@link #getWebSocketSessionStats()}. |
163 | 165 | */
|
| 166 | + @Deprecated(since = "6.2", forRemoval = true) |
164 | 167 | public String getWebSocketSessionStatsInfo() {
|
165 | 168 | return (this.webSocketHandler != null ? this.webSocketHandler.getStatsInfo() : "null");
|
166 | 169 | }
|
167 | 170 |
|
| 171 | + /** |
| 172 | + * Get stats about WebSocket sessions. |
| 173 | + * Can return {@code null} if no {@link #setSubProtocolWebSocketHandler(SubProtocolWebSocketHandler) WebSocket handler} |
| 174 | + * is configured. |
| 175 | + * @since 6.2 |
| 176 | + */ |
| 177 | + @Nullable |
| 178 | + public SubProtocolWebSocketHandler.Stats getWebSocketSessionStats() { |
| 179 | + return (this.webSocketHandler != null ? this.webSocketHandler.getStats() : null); |
| 180 | + } |
| 181 | + |
168 | 182 | /**
|
169 | 183 | * Get stats about STOMP-related WebSocket message processing.
|
| 184 | + * @deprecated as of 6.2 in favor of {@link #getStompSubProtocolStats()}. |
170 | 185 | */
|
| 186 | + @Deprecated(since = "6.2", forRemoval = true) |
171 | 187 | public String getStompSubProtocolStatsInfo() {
|
172 | 188 | return (this.stompSubProtocolHandler != null ? this.stompSubProtocolHandler.getStatsInfo() : "null");
|
173 | 189 | }
|
174 | 190 |
|
| 191 | + /** |
| 192 | + * Get stats about STOMP-related WebSocket message processing. |
| 193 | + * Can return {@code null} if no {@link SubProtocolHandler} was found. |
| 194 | + * @since 6.2 |
| 195 | + */ |
| 196 | + @Nullable |
| 197 | + public StompSubProtocolHandler.Stats getStompSubProtocolStats() { |
| 198 | + return (this.stompSubProtocolHandler != null ? this.stompSubProtocolHandler.getStats() : null); |
| 199 | + } |
| 200 | + |
175 | 201 | /**
|
176 | 202 | * Get stats about STOMP broker relay (when using a full-featured STOMP broker).
|
| 203 | + * @deprecated as of 6.2 in favor of {@link #getStompBrokerRelayStats()}. |
177 | 204 | */
|
| 205 | + @Deprecated(since = "6.2", forRemoval = true) |
178 | 206 | public String getStompBrokerRelayStatsInfo() {
|
179 | 207 | return (this.stompBrokerRelay != null ? this.stompBrokerRelay.getStatsInfo() : "null");
|
180 | 208 | }
|
181 | 209 |
|
| 210 | + /** |
| 211 | + * Get stats about STOMP broker relay (when using a full-featured STOMP broker). |
| 212 | + * Can return {@code null} if no {@link #setStompBrokerRelay(StompBrokerRelayMessageHandler) STOMP broker relay} |
| 213 | + * is configured. |
| 214 | + * @since 6.2 |
| 215 | + */ |
| 216 | + @Nullable |
| 217 | + public StompBrokerRelayMessageHandler.Stats getStompBrokerRelayStats() { |
| 218 | + return (this.stompBrokerRelay != null ? this.stompBrokerRelay.getStats() : null); |
| 219 | + } |
| 220 | + |
182 | 221 | /**
|
183 | 222 | * Get stats about the executor processing incoming messages from WebSocket clients.
|
184 | 223 | */
|
@@ -231,6 +270,7 @@ private String getExecutorStatsInfo(@Nullable Executor executor) {
|
231 | 270 | }
|
232 | 271 |
|
233 | 272 | @Override
|
| 273 | + @SuppressWarnings("removal") |
234 | 274 | public String toString() {
|
235 | 275 | return "WebSocketSession[" + getWebSocketSessionStatsInfo() + "]" +
|
236 | 276 | ", stompSubProtocol[" + getStompSubProtocolStatsInfo() + "]" +
|
|
0 commit comments