Create versioned instead of generic frames from STOMP decoder

This commit is contained in:
Ville Skyttä 2015-07-14 11:53:14 +03:00 committed by Clebert Suconic
parent f17991e58c
commit 3deb20f049
5 changed files with 20 additions and 8 deletions

View File

@ -162,8 +162,11 @@ public class StompDecoder
//max len of EOL (default is 1 for '\n')
protected int eolLen = 1;
public StompDecoder()
private final VersionedStompFrameHandler handler;
public StompDecoder(VersionedStompFrameHandler handler)
{
this.handler = handler;
}
public boolean hasBytes()
@ -276,7 +279,9 @@ public class StompDecoder
// reset
StompFrame ret = new StompFrame(command, headers, content);
StompFrame ret = handler.createStompFrame(command);
ret.headers = headers;
ret.setByteBody(content);
init();

View File

@ -33,7 +33,7 @@ public class StompFrame
protected final String command;
protected final Map<String, String> headers;
protected Map<String, String> headers;
private String body;

View File

@ -35,7 +35,7 @@ public class StompFrameHandlerV10 extends VersionedStompFrameHandler implements
public StompFrameHandlerV10(StompConnection connection)
{
super(connection);
decoder = new StompDecoder();
decoder = new StompDecoder(this);
decoder.init();
connection.addStompEventListener(this);
}

View File

@ -41,7 +41,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements
{
super(connection);
connection.addStompEventListener(this);
decoder = new StompDecoderV11();
decoder = new StompDecoderV11(this);
decoder.init();
}
@ -428,6 +428,11 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements
protected boolean isEscaping = false;
protected SimpleBytes holder = new SimpleBytes(1024);
public StompDecoderV11(StompFrameHandlerV11 handler)
{
super(handler);
}
@Override
public void init(StompDecoder decoder)
{

View File

@ -35,7 +35,7 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 implements FrameE
public StompFrameHandlerV12(StompConnection connection)
{
super(connection);
decoder = new StompDecoderV12();
decoder = new StompDecoderV12(this);
decoder.init();
}
@ -99,9 +99,11 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 implements FrameE
{
protected boolean nextEOLChar = false;
public StompDecoderV12()
public StompDecoderV12(StompFrameHandlerV12 handler)
{
//1.2 allow '\r\n'
super(handler);
//1.2 allows '\r\n'
eolLen = 2;
}