INT-3511: Document WebSocket Support
JIRA: https://jira.spring.io/browse/INT-3511 Add note about Broker destinations Doc Polishing INT-3511: Fix 'useBroker' Docs and provide compatibility with SF 4.1.1
This commit is contained in:
committed by
Gary Russell
parent
1a0fdc6e53
commit
6814aafe48
@@ -26,9 +26,6 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.socket.CloseStatus;
|
||||
import org.springframework.web.socket.SubProtocolCapable;
|
||||
@@ -36,7 +33,6 @@ import org.springframework.web.socket.WebSocketHandler;
|
||||
import org.springframework.web.socket.WebSocketMessage;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
import org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator;
|
||||
import org.springframework.web.socket.messaging.SessionDisconnectEvent;
|
||||
|
||||
/**
|
||||
* The high-level 'connection factory pattern' contract over low-level Web-Socket
|
||||
@@ -59,7 +55,7 @@ import org.springframework.web.socket.messaging.SessionDisconnectEvent;
|
||||
* @see org.springframework.integration.websocket.inbound.WebSocketInboundChannelAdapter
|
||||
* @see org.springframework.integration.websocket.outbound.WebSocketOutboundMessageHandler
|
||||
*/
|
||||
public abstract class IntegrationWebSocketContainer implements ApplicationEventPublisherAware, DisposableBean {
|
||||
public abstract class IntegrationWebSocketContainer implements DisposableBean {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
@@ -75,8 +71,6 @@ public abstract class IntegrationWebSocketContainer implements ApplicationEventP
|
||||
|
||||
private volatile int sendBufferSizeLimit = 512 * 1024;
|
||||
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
|
||||
public void setSendTimeLimit(int sendTimeLimit) {
|
||||
this.sendTimeLimit = sendTimeLimit;
|
||||
}
|
||||
@@ -85,11 +79,6 @@ public abstract class IntegrationWebSocketContainer implements ApplicationEventP
|
||||
this.sendBufferSizeLimit = sendBufferSizeLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
|
||||
this.eventPublisher = applicationEventPublisher;
|
||||
}
|
||||
|
||||
public void setMessageListener(WebSocketListener messageListener) {
|
||||
Assert.state(this.messageListener == null || this.messageListener == messageListener,
|
||||
"'messageListener' is already configured");
|
||||
@@ -146,15 +135,6 @@ public abstract class IntegrationWebSocketContainer implements ApplicationEventP
|
||||
this.sessions.clear();
|
||||
}
|
||||
|
||||
private void publishEvent(ApplicationEvent event) {
|
||||
try {
|
||||
this.eventPublisher.publishEvent(event);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
logger.error("Error while publishing " + event, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An internal {@link WebSocketHandler} implementation to be used with native
|
||||
* Web-Socket containers.
|
||||
@@ -192,9 +172,6 @@ public abstract class IntegrationWebSocketContainer implements ApplicationEventP
|
||||
if (IntegrationWebSocketContainer.this.messageListener != null) {
|
||||
IntegrationWebSocketContainer.this.messageListener.afterSessionEnded(session, closeStatus);
|
||||
}
|
||||
else if (IntegrationWebSocketContainer.this.eventPublisher != null) {
|
||||
publishEvent(new SessionDisconnectEvent(this, session.getId(), closeStatus));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,10 +180,8 @@ public abstract class IntegrationWebSocketContainer implements ApplicationEventP
|
||||
WebSocketSession removed = IntegrationWebSocketContainer.this.sessions.remove(session.getId());
|
||||
if (removed != null) {
|
||||
IntegrationWebSocketContainer.this.sessions.remove(session.getId());
|
||||
if (IntegrationWebSocketContainer.this.eventPublisher != null) {
|
||||
publishEvent(new SessionErrorEvent(this, session.getId(), exception));
|
||||
}
|
||||
}
|
||||
throw new Exception(exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.websocket;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The {@link ApplicationEvent} implementation to represent the
|
||||
* {@link org.springframework.web.socket.WebSocketSession} errors.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @since 4.1
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class SessionErrorEvent extends ApplicationEvent {
|
||||
|
||||
private final String sessionId;
|
||||
|
||||
private final Throwable exception;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new {@link ApplicationEvent} represented the error on the session.
|
||||
* @param source the component that published the event (never {@code null})
|
||||
* @param sessionId the id of the session
|
||||
* @param exception the exception on the session
|
||||
*/
|
||||
public SessionErrorEvent(Object source, String sessionId, Throwable exception) {
|
||||
super(source);
|
||||
Assert.notNull(sessionId, "'sessionId' must not be null");
|
||||
this.sessionId = sessionId;
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the session id.
|
||||
* @return the sessionId
|
||||
*/
|
||||
public String getSessionId() {
|
||||
return this.sessionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the exception for the session id.
|
||||
* @return the exception
|
||||
*/
|
||||
public Throwable getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SessionErrorEvent: sessionId=" + this.sessionId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -234,7 +234,8 @@
|
||||
</xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.web.socket.sockjs.frame.SockJsMessageCodec"/>
|
||||
<tool:expected-type
|
||||
type="org.springframework.web.socket.sockjs.frame.SockJsMessageCodec"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
@@ -357,7 +358,7 @@
|
||||
<xsd:attribute name="payload-type" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:java.lang.Class">
|
||||
Fully qualified name of the java type for the target `payload`
|
||||
Fully qualified name of the java type for the target 'payload'
|
||||
to convert from the incoming WebSocketMessage.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
@@ -365,11 +366,10 @@
|
||||
<xsd:attribute name="use-broker" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Flag to indicate if this adapter will send non-MESSAGE type WebSocketMessages
|
||||
and messages with broker destinations to the `AbstractBrokerMessageHandler`
|
||||
Flag to indicate if this adapter will send non-MESSAGE type 'WebSocketMessage's
|
||||
and messages with broker destinations to the 'AbstractBrokerMessageHandler'
|
||||
from the application context.
|
||||
If the `AbstractBrokerMessageHandler` bean isn't present the warn log is emitted
|
||||
and adapter behaviour is falling back to default like this attribute is 'false'.
|
||||
The 'Broker Relay' configuration is required when 'use-broker' is 'true'.
|
||||
This attribute is used only on server side. On client side it is ignored.
|
||||
Defaults to 'false'.
|
||||
</xsd:documentation>
|
||||
@@ -441,7 +441,7 @@
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Flag to indicate if the default converters should be registered after any custom
|
||||
converters. This flag is used only if message-converters
|
||||
converters. This flag is used only if 'message-converters'
|
||||
are provided, otherwise all default converters will be registered.
|
||||
Defaults to 'false'.
|
||||
</xsd:documentation>
|
||||
|
||||
Reference in New Issue
Block a user