Skip to content

Commit 870f76b

Browse files
committed
INTEXT-45 SI 3.0.0.M1 - now 1.0.0.BUILD-SNAPSHOT
- Use core TCP eventing for WebSocketEvents; change Type literals to enumerations - Use a WebSocketMessageMapper instead of rebuilding the message in the interceptor - Use core TCP Abstract Serializer - Use 3.0 API instead of reflection to get key for Deserializer state
1 parent f2d3a87 commit 870f76b

15 files changed

+147
-360
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
reports
2+
fuzz*

spring-integration-ip-extensions/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ext {
3333
log4jVersion = '1.2.12'
3434
mockitoVersion = '1.9.0'
3535
springVersion = '3.1.3.RELEASE'
36-
springIntegrationVersion = '2.2.0.RELEASE'
36+
springIntegrationVersion = '3.0.0.M1'
3737
}
3838

3939
eclipse {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.1.0.BUILD-SNAPSHOT
1+
version=1.0.0.BUILD-SNAPSHOT

spring-integration-ip-extensions/src/main/java/org/springframework/integration/x/ip/serializer/AbstractByteArraySerializer.java

-85
This file was deleted.

spring-integration-ip-extensions/src/main/java/org/springframework/integration/x/ip/serializer/AbstractHttpSwitchingDeserializer.java

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import org.apache.commons.logging.Log;
2828
import org.apache.commons.logging.LogFactory;
29+
import org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer;
2930

3031
/**
3132
* Base class for (de)Serializers that start with an HTTP-like protocol then
@@ -55,6 +56,7 @@ protected ByteArrayCrLfSerializer getCrlfDeserializer() {
5556
return crlfDeserializer;
5657
}
5758

59+
@Override
5860
public abstract DataFrame deserialize(InputStream inputStream) throws IOException;
5961

6062
protected BasicState getStreamState(InputStream inputStream) {
@@ -130,6 +132,7 @@ protected DataFrame createDataFrame(int type, String frameData) {
130132
return new DataFrame(type, frameData);
131133
}
132134

135+
@Override
133136
public void removeState(Object key) {
134137
this.streamState.remove(key);
135138
}

spring-integration-ip-extensions/src/main/java/org/springframework/integration/x/ip/serializer/ByteArrayCrLfSerializer.java

-87
This file was deleted.

spring-integration-ip-extensions/src/main/java/org/springframework/integration/x/ip/tcp/TcpConnectionEvent.java

-82
This file was deleted.

spring-integration-ip-extensions/src/main/java/org/springframework/integration/x/ip/websocket/WebSocketEvent.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package org.springframework.integration.x.ip.websocket;
1717

18-
import org.springframework.integration.ip.tcp.connection.TcpConnection;
19-
import org.springframework.integration.x.ip.tcp.TcpConnectionEvent;
18+
import org.springframework.integration.ip.tcp.connection.TcpConnectionEvent;
19+
import org.springframework.integration.ip.tcp.connection.TcpConnectionSupport;
2020

2121
/**
2222
* @author Gary Russell
@@ -27,15 +27,16 @@ public class WebSocketEvent extends TcpConnectionEvent {
2727

2828
private static final long serialVersionUID = -6788341703196233248L;
2929

30-
public static final String HANDSHAKE_COMPLETE = "HANDSHAKE_COMPLETE";
31-
32-
public static final String WEBSOCKET_CLOSED = "WEBSOCKET_CLOSED";
30+
public enum WebSocketEventType implements EventType {
31+
HANDSHAKE_COMPLETE,
32+
WEBSOCKET_CLOSED
33+
}
3334

3435
private final String path;
3536

3637
private final String queryString;
3738

38-
public WebSocketEvent(TcpConnection connection, String type, String path, String queryString) {
39+
public WebSocketEvent(TcpConnectionSupport connection, WebSocketEventType type, String path, String queryString) {
3940
super(connection, type, "unknown");
4041
this.path = path;
4142
this.queryString = queryString;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
package org.springframework.integration.x.ip.websocket;
17+
18+
import java.util.Map;
19+
20+
import org.springframework.integration.ip.tcp.connection.TcpConnection;
21+
import org.springframework.integration.ip.tcp.connection.TcpMessageMapper;
22+
import org.springframework.integration.x.ip.websocket.WebSocketTcpConnectionInterceptorFactory.WebSocketTcpConnectionInterceptor;
23+
24+
/**
25+
* @author Gary Russell
26+
* @since 3.0
27+
*
28+
*/
29+
public class WebSocketMessageMapper extends TcpMessageMapper {
30+
31+
private final WebSocketTcpConnectionInterceptorFactory connectionInterceptorFactory;
32+
33+
public WebSocketMessageMapper(WebSocketTcpConnectionInterceptorFactory connectionInterceptorFactory) {
34+
this.connectionInterceptorFactory = connectionInterceptorFactory;
35+
}
36+
37+
@Override
38+
protected Map<String, ?> supplyCustomHeaders(TcpConnection connection) {
39+
WebSocketTcpConnectionInterceptor interceptor = this.connectionInterceptorFactory.locateInterceptor(connection);
40+
return interceptor == null ? null : interceptor.getAdditionalHeaders();
41+
}
42+
43+
44+
}

spring-integration-ip-extensions/src/main/java/org/springframework/integration/x/ip/websocket/WebSocketSerializer.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ protected BasicState createState() {
7474
return new WebSocketState();
7575
}
7676

77+
@Override
7778
public void serialize(final Object frame, OutputStream outputStream)
7879
throws IOException {
7980
String data = "";
@@ -199,7 +200,7 @@ private DataFrame doDeserialize(InputStream inputStream, DataFrame protoFrame) t
199200
int maskInx = 0;
200201
int rsv = 0;
201202
while (!done ) {
202-
bite = inputStream.read();
203+
bite = inputStream.read() & 0xff;
203204
// logger.debug("Read:" + Integer.toHexString(bite));
204205
if (bite < 0 && n == 0) {
205206
throw new SoftEndOfStreamException("Stream closed between payloads");

0 commit comments

Comments
 (0)