File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
main/java/org/springframework/web/socket/support
test/java/org/springframework/web/socket/support Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,14 @@ public WebSocketHandler getDelegate() {
42
42
return this .delegate ;
43
43
}
44
44
45
+ public WebSocketHandler getLastHandler () {
46
+ WebSocketHandler result = delegate ;
47
+ while (result instanceof WebSocketHandlerDecorator ) {
48
+ result = ((WebSocketHandlerDecorator ) result ).getDelegate ();
49
+ }
50
+ return result ;
51
+ }
52
+
45
53
@ Override
46
54
public void afterConnectionEstablished (WebSocketSession session ) throws Exception {
47
55
this .delegate .afterConnectionEstablished (session );
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2002-2013 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org .springframework .web .socket .support ;
18
+
19
+ import org .junit .Test ;
20
+ import org .springframework .web .socket .adapter .WebSocketHandlerAdapter ;
21
+
22
+ import static org .junit .Assert .*;
23
+
24
+
25
+ /**
26
+ * Test fixture for {@link WebSocketHandlerDecorator}.
27
+ *
28
+ * @author Rossen Stoyanchev
29
+ */
30
+ public class WebSocketHandlerDecoratorTests {
31
+
32
+
33
+ @ Test
34
+ public void getLastHandler () {
35
+ WebSocketHandlerAdapter h1 = new WebSocketHandlerAdapter ();
36
+ WebSocketHandlerDecorator h2 = new WebSocketHandlerDecorator (h1 );
37
+ WebSocketHandlerDecorator h3 = new WebSocketHandlerDecorator (h2 );
38
+
39
+ assertSame (h1 , h3 .getLastHandler ());
40
+ }
41
+
42
+ }
You can’t perform that action at this time.
0 commit comments