Refactor STOMP package and class names
This commit is contained in:
@@ -490,7 +490,7 @@ project("spring-websocket") {
|
||||
repositories {
|
||||
maven { url "https://repository.apache.org/content/repositories/snapshots" } // tomcat-websocket-* snapshots
|
||||
maven { url "https://maven.java.net/content/repositories/releases" } // javax.websocket, tyrus
|
||||
maven { url 'http://repo.springsource.org/libs-snapshot' } // reactor
|
||||
maven { url 'http://repo.springsource.org/snapshot' } // reactor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,18 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.messaging.stomp.adapter;
|
||||
|
||||
import org.springframework.web.messaging.stomp.StompMessage;
|
||||
import org.springframework.web.messaging.stomp.StompSession;
|
||||
package org.springframework.web.messaging;
|
||||
|
||||
|
||||
/**
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface StompMessageHandler {
|
||||
public enum MessageType {
|
||||
|
||||
void handleMessage(StompSession stompSession, StompMessage message);
|
||||
CONNECT, SUBSCRIBE, UNSUBSCRIBE, SEND, NONE
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.messaging.stomp.server;
|
||||
package org.springframework.web.messaging.stomp.service;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
@@ -63,7 +63,7 @@ public class RelayStompService {
|
||||
|
||||
public RelayStompService(Reactor reactor, TaskExecutor executor) {
|
||||
this.reactor = reactor;
|
||||
this.taskExecutor = executor; // For now, a naively way to manage socket reading
|
||||
this.taskExecutor = executor; // For now, a naive way to manage socket reading
|
||||
|
||||
this.reactor.on(Fn.$(StompCommand.CONNECT), new ConnectConsumer());
|
||||
this.reactor.on(Fn.$(StompCommand.SUBSCRIBE), new RelayConsumer());
|
||||
@@ -228,7 +228,6 @@ public class RelayStompService {
|
||||
relayStompMessage(session, stompMessage);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
clearRelaySession(stompMessage.getStompSessionId());
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.messaging.stomp.server;
|
||||
package org.springframework.web.messaging.stomp.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.web.messaging.stomp.adapter;
|
||||
package org.springframework.web.messaging.stomp.socket;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -34,20 +34,13 @@ import org.springframework.web.socket.adapter.TextWebSocketHandlerAdapter;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*/
|
||||
public class StompWebSocketHandler extends TextWebSocketHandlerAdapter {
|
||||
|
||||
private final StompMessageHandler messageHandler;
|
||||
public abstract class AbstractStompWebSocketHandler extends TextWebSocketHandlerAdapter {
|
||||
|
||||
private final StompMessageConverter messageConverter = new StompMessageConverter();
|
||||
|
||||
private final Map<String, WebSocketStompSession> sessions = new ConcurrentHashMap<String, WebSocketStompSession>();
|
||||
|
||||
|
||||
public StompWebSocketHandler(StompMessageHandler messageHandler) {
|
||||
this.messageHandler = messageHandler;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
||||
WebSocketStompSession stompSession = new WebSocketStompSession(session, this.messageConverter);
|
||||
@@ -67,7 +60,7 @@ public class StompWebSocketHandler extends TextWebSocketHandlerAdapter {
|
||||
// TODO: validate size limits
|
||||
// http://stomp.github.io/stomp-specification-1.2.html#Size_Limits
|
||||
|
||||
this.messageHandler.handleMessage(stompSession, stompMessage);
|
||||
handleStompMessage(stompSession, stompMessage);
|
||||
|
||||
// TODO: send RECEIPT message if incoming message has "receipt" header
|
||||
// http://stomp.github.io/stomp-specification-1.2.html#Header_receipt
|
||||
@@ -86,6 +79,8 @@ public class StompWebSocketHandler extends TextWebSocketHandlerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void handleStompMessage(StompSession stompSession, StompMessage stompMessage);
|
||||
|
||||
@Override
|
||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
|
||||
WebSocketStompSession stompSession = this.sessions.remove(session.getId());
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.web.messaging.stomp.server;
|
||||
package org.springframework.web.messaging.stomp.socket;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -30,7 +30,6 @@ import org.springframework.web.messaging.stomp.StompException;
|
||||
import org.springframework.web.messaging.stomp.StompHeaders;
|
||||
import org.springframework.web.messaging.stomp.StompMessage;
|
||||
import org.springframework.web.messaging.stomp.StompSession;
|
||||
import org.springframework.web.messaging.stomp.adapter.StompMessageHandler;
|
||||
|
||||
import reactor.Fn;
|
||||
import reactor.core.Reactor;
|
||||
@@ -43,9 +42,9 @@ import reactor.fn.Registration;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*/
|
||||
public class ServerStompMessageHandler implements StompMessageHandler {
|
||||
public class DefaultStompWebSocketHandler extends AbstractStompWebSocketHandler {
|
||||
|
||||
private static Log logger = LogFactory.getLog(ServerStompMessageHandler.class);
|
||||
private static Log logger = LogFactory.getLog(DefaultStompWebSocketHandler.class);
|
||||
|
||||
|
||||
private final Reactor reactor;
|
||||
@@ -54,11 +53,11 @@ public class ServerStompMessageHandler implements StompMessageHandler {
|
||||
new ConcurrentHashMap<String, List<Registration<?>>>();
|
||||
|
||||
|
||||
public ServerStompMessageHandler(Reactor reactor) {
|
||||
public DefaultStompWebSocketHandler(Reactor reactor) {
|
||||
this.reactor = reactor;
|
||||
}
|
||||
|
||||
public void handleMessage(StompSession session, StompMessage message) {
|
||||
public void handleStompMessage(StompSession session, StompMessage message) {
|
||||
try {
|
||||
StompCommand command = message.getCommand();
|
||||
if (StompCommand.CONNECT.equals(command) || StompCommand.STOMP.equals(command)) {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.messaging.stomp.adapter;
|
||||
package org.springframework.web.messaging.stomp.socket;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
Reference in New Issue
Block a user