@@ -90,12 +90,22 @@ public AbstractSockJsService(TaskScheduler scheduler) {
90
90
91
91
92
92
/**
93
- * A unique name for the service mainly for logging purposes.
93
+ * A scheduler instance to use for scheduling heart-beat messages.
94
+ */
95
+ public TaskScheduler getTaskScheduler () {
96
+ return this .taskScheduler ;
97
+ }
98
+
99
+ /**
100
+ * Set a unique name for this service (mainly for logging purposes).
94
101
*/
95
102
public void setName (String name ) {
96
103
this .name = name ;
97
104
}
98
105
106
+ /**
107
+ * Return the unique name associated with this service.
108
+ */
99
109
public String getName () {
100
110
return this .name ;
101
111
}
@@ -121,8 +131,7 @@ public void setSockJsClientLibraryUrl(String clientLibraryUrl) {
121
131
}
122
132
123
133
/**
124
- * The URL to the SockJS JavaScript client library.
125
- * @see #setSockJsClientLibraryUrl(String)
134
+ * Return he URL to the SockJS JavaScript client library.
126
135
*/
127
136
public String getSockJsClientLibraryUrl () {
128
137
return this .clientLibraryUrl ;
@@ -132,7 +141,7 @@ public String getSockJsClientLibraryUrl() {
132
141
* Streaming transports save responses on the client side and don't free
133
142
* memory used by delivered messages. Such transports need to recycle the
134
143
* connection once in a while. This property sets a minimum number of bytes
135
- * that can be send over a single HTTP streaming request before it will be
144
+ * that can be sent over a single HTTP streaming request before it will be
136
145
* closed. After that client will open a new request. Setting this value to
137
146
* one effectively disables streaming and will make streaming transports to
138
147
* behave like polling transports.
@@ -142,6 +151,10 @@ public void setStreamBytesLimit(int streamBytesLimit) {
142
151
this .streamBytesLimit = streamBytesLimit ;
143
152
}
144
153
154
+ /**
155
+ * Return the minimum number of bytes that can be sent over a single HTTP
156
+ * streaming request before it will be closed.
157
+ */
145
158
public int getStreamBytesLimit () {
146
159
return this .streamBytesLimit ;
147
160
}
@@ -168,32 +181,28 @@ public void setSessionCookieNeeded(boolean sessionCookieNeeded) {
168
181
}
169
182
170
183
/**
171
- * Whether JSESSIONID cookie is required for the application to function. For
172
- * more detail see {@link #setSessionCookieNeeded(boolean)}.
184
+ * Return whether the JSESSIONID cookie is required for the application to function.
173
185
*/
174
186
public boolean isSessionCookieNeeded () {
175
187
return this .sessionCookieNeeded ;
176
188
}
177
189
178
190
/**
179
- * The amount of time in milliseconds when the server has not sent any
180
- * messages and after which the server should send a heartbeat frame to the
181
- * client in order to keep the connection from breaking.
191
+ * Specify the amount of time in milliseconds when the server has not sent
192
+ * any messages and after which the server should send a heartbeat frame
193
+ * to the client in order to keep the connection from breaking.
182
194
* <p>The default value is 25,000 (25 seconds).
183
195
*/
184
196
public void setHeartbeatTime (long heartbeatTime ) {
185
197
this .heartbeatTime = heartbeatTime ;
186
198
}
187
199
188
- public long getHeartbeatTime () {
189
- return this .heartbeatTime ;
190
- }
191
-
192
200
/**
193
- * A scheduler instance to use for scheduling heart-beat messages.
201
+ * Return the amount of time in milliseconds when the server has not sent
202
+ * any messages.
194
203
*/
195
- public TaskScheduler getTaskScheduler () {
196
- return this .taskScheduler ;
204
+ public long getHeartbeatTime () {
205
+ return this .heartbeatTime ;
197
206
}
198
207
199
208
/**
@@ -214,12 +223,12 @@ public long getDisconnectDelay() {
214
223
}
215
224
216
225
/**
217
- * The number of server-to-client messages that a session can cache while waiting for
218
- * the next HTTP polling request from the client. All HTTP transports use this
226
+ * The number of server-to-client messages that a session can cache while waiting
227
+ * for the next HTTP polling request from the client. All HTTP transports use this
219
228
* property since even streaming transports recycle HTTP requests periodically.
220
- * <p>The amount of time between HTTP requests should be relatively brief and will not
221
- * exceed the allows disconnect delay (see
222
- * {@link #setDisconnectDelay(long)}), 5 seconds by default.
229
+ * <p>The amount of time between HTTP requests should be relatively brief and will
230
+ * not exceed the allows disconnect delay (see {@link #setDisconnectDelay(long)});
231
+ * 5 seconds by default.
223
232
* <p>The default size is 100.
224
233
*/
225
234
public void setHttpMessageCacheSize (int httpMessageCacheSize ) {
@@ -234,7 +243,7 @@ public int getHttpMessageCacheSize() {
234
243
}
235
244
236
245
/**
237
- * Some load balancers don't support WebSocket. This option can be used to
246
+ * Some load balancers do not support WebSocket. This option can be used to
238
247
* disable the WebSocket transport on the server side.
239
248
* <p>The default value is "true".
240
249
*/
@@ -243,18 +252,16 @@ public void setWebSocketEnabled(boolean webSocketEnabled) {
243
252
}
244
253
245
254
/**
246
- * Whether WebSocket transport is enabled.
247
- * @see #setWebSocketEnabled(boolean)
255
+ * Return whether WebSocket transport is enabled.
248
256
*/
249
257
public boolean isWebSocketEnabled () {
250
258
return this .webSocketEnabled ;
251
259
}
252
260
253
261
254
262
/**
255
- * {@inheritDoc}
256
- * <p>This method determines the SockJS path and handles SockJS static URLs. Session
257
- * URLs and raw WebSocket requests are delegated to abstract methods.
263
+ * This method determines the SockJS path and handles SockJS static URLs.
264
+ * Session URLs and raw WebSocket requests are delegated to abstract methods.
258
265
*/
259
266
@ Override
260
267
public final void handleRequest (ServerHttpRequest request , ServerHttpResponse response ,
@@ -271,7 +278,6 @@ public final void handleRequest(ServerHttpRequest request, ServerHttpResponse re
271
278
if (logger .isDebugEnabled ()) {
272
279
logger .debug (request .getMethod () + " with SockJS path [" + sockJsPath + "]" );
273
280
}
274
-
275
281
try {
276
282
request .getHeaders ();
277
283
}
@@ -309,7 +315,6 @@ else if (sockJsPath.equals("/websocket")) {
309
315
String serverId = pathSegments [0 ];
310
316
String sessionId = pathSegments [1 ];
311
317
String transport = pathSegments [2 ];
312
-
313
318
if (!validateRequest (serverId , sessionId , transport )) {
314
319
response .setStatusCode (HttpStatus .NOT_FOUND );
315
320
return ;
@@ -360,7 +365,6 @@ protected abstract void handleTransportRequest(ServerHttpRequest request, Server
360
365
protected void addCorsHeaders (ServerHttpRequest request , ServerHttpResponse response , HttpMethod ... httpMethods ) {
361
366
HttpHeaders requestHeaders = request .getHeaders ();
362
367
HttpHeaders responseHeaders = response .getHeaders ();
363
-
364
368
try {
365
369
// Perhaps a CORS Filter has already added this?
366
370
if (!CollectionUtils .isEmpty (responseHeaders .get ("Access-Control-Allow-Origin" ))) {
@@ -373,8 +377,7 @@ protected void addCorsHeaders(ServerHttpRequest request, ServerHttpResponse resp
373
377
}
374
378
375
379
String origin = requestHeaders .getFirst ("origin" );
376
- origin = ((origin == null ) || origin .equals ("null" )) ? "*" : origin ;
377
-
380
+ origin = (origin == null || origin .equals ("null" ) ? "*" : origin );
378
381
responseHeaders .add ("Access-Control-Allow-Origin" , origin );
379
382
responseHeaders .add ("Access-Control-Allow-Credentials" , "true" );
380
383
0 commit comments