26
26
import org .apache .commons .logging .LogFactory ;
27
27
28
28
import org .springframework .beans .factory .DisposableBean ;
29
- import org .springframework .context .ApplicationEvent ;
30
- import org .springframework .context .ApplicationEventPublisher ;
31
- import org .springframework .context .ApplicationEventPublisherAware ;
32
29
import org .springframework .util .Assert ;
33
30
import org .springframework .web .socket .CloseStatus ;
34
31
import org .springframework .web .socket .SubProtocolCapable ;
35
32
import org .springframework .web .socket .WebSocketHandler ;
36
33
import org .springframework .web .socket .WebSocketMessage ;
37
34
import org .springframework .web .socket .WebSocketSession ;
38
35
import org .springframework .web .socket .handler .ConcurrentWebSocketSessionDecorator ;
39
- import org .springframework .web .socket .messaging .SessionDisconnectEvent ;
40
36
41
37
/**
42
38
* The high-level 'connection factory pattern' contract over low-level Web-Socket
59
55
* @see org.springframework.integration.websocket.inbound.WebSocketInboundChannelAdapter
60
56
* @see org.springframework.integration.websocket.outbound.WebSocketOutboundMessageHandler
61
57
*/
62
- public abstract class IntegrationWebSocketContainer implements ApplicationEventPublisherAware , DisposableBean {
58
+ public abstract class IntegrationWebSocketContainer implements DisposableBean {
63
59
64
60
protected final Log logger = LogFactory .getLog (this .getClass ());
65
61
@@ -75,8 +71,6 @@ public abstract class IntegrationWebSocketContainer implements ApplicationEventP
75
71
76
72
private volatile int sendBufferSizeLimit = 512 * 1024 ;
77
73
78
- private ApplicationEventPublisher eventPublisher ;
79
-
80
74
public void setSendTimeLimit (int sendTimeLimit ) {
81
75
this .sendTimeLimit = sendTimeLimit ;
82
76
}
@@ -85,11 +79,6 @@ public void setSendBufferSizeLimit(int sendBufferSizeLimit) {
85
79
this .sendBufferSizeLimit = sendBufferSizeLimit ;
86
80
}
87
81
88
- @ Override
89
- public void setApplicationEventPublisher (ApplicationEventPublisher applicationEventPublisher ) {
90
- this .eventPublisher = applicationEventPublisher ;
91
- }
92
-
93
82
public void setMessageListener (WebSocketListener messageListener ) {
94
83
Assert .state (this .messageListener == null || this .messageListener == messageListener ,
95
84
"'messageListener' is already configured" );
@@ -146,15 +135,6 @@ public void destroy() throws Exception {
146
135
this .sessions .clear ();
147
136
}
148
137
149
- private void publishEvent (ApplicationEvent event ) {
150
- try {
151
- this .eventPublisher .publishEvent (event );
152
- }
153
- catch (Throwable ex ) {
154
- logger .error ("Error while publishing " + event , ex );
155
- }
156
- }
157
-
158
138
/**
159
139
* An internal {@link WebSocketHandler} implementation to be used with native
160
140
* Web-Socket containers.
@@ -192,9 +172,6 @@ public void afterConnectionClosed(WebSocketSession session, CloseStatus closeSta
192
172
if (IntegrationWebSocketContainer .this .messageListener != null ) {
193
173
IntegrationWebSocketContainer .this .messageListener .afterSessionEnded (session , closeStatus );
194
174
}
195
- else if (IntegrationWebSocketContainer .this .eventPublisher != null ) {
196
- publishEvent (new SessionDisconnectEvent (this , session .getId (), closeStatus ));
197
- }
198
175
}
199
176
}
200
177
@@ -203,10 +180,8 @@ public void handleTransportError(WebSocketSession session, Throwable exception)
203
180
WebSocketSession removed = IntegrationWebSocketContainer .this .sessions .remove (session .getId ());
204
181
if (removed != null ) {
205
182
IntegrationWebSocketContainer .this .sessions .remove (session .getId ());
206
- if (IntegrationWebSocketContainer .this .eventPublisher != null ) {
207
- publishEvent (new SessionErrorEvent (this , session .getId (), exception ));
208
- }
209
183
}
184
+ throw new Exception (exception );
210
185
}
211
186
212
187
@ Override
0 commit comments