diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompException.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompException.java index 471bc8b88d..a42e9d481e 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompException.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompException.java @@ -77,13 +77,13 @@ public class ActiveMQStompException extends Exception StompFrame frame = null; if (handler == null) { - frame = new StompFrame("ERROR"); + frame = new StompFrame(Stomp.Responses.ERROR); } else { - frame = handler.createStompFrame("ERROR"); + frame = handler.createStompFrame(Stomp.Responses.ERROR); } - frame.addHeader("message", this.getMessage()); + frame.addHeader(Stomp.Headers.Error.MESSAGE, this.getMessage()); for (Header header : headers) { frame.addHeader(header.key, header.val); diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java index 9795574c5f..b8e26eefb2 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java @@ -475,15 +475,15 @@ public final class StompConnection implements RemotingConnection requestVersions.add(tokenizer.nextToken()); } - if (requestVersions.contains("1.2")) + if (requestVersions.contains(StompVersions.V1_2.toString())) { this.version = StompVersions.V1_2; } - else if (requestVersions.contains("1.1")) + else if (requestVersions.contains(StompVersions.V1_1.toString())) { this.version = StompVersions.V1_1; } - else if (requestVersions.contains("1.0")) + else if (requestVersions.contains(StompVersions.V1_0.toString())) { this.version = StompVersions.V1_0; } @@ -491,8 +491,8 @@ public final class StompConnection implements RemotingConnection { //not a supported version! ActiveMQStompException error = BUNDLE.versionNotSupported(acceptVersion); - error.addHeader("version", acceptVersion); - error.addHeader("content-type", "text/plain"); + error.addHeader(Stomp.Headers.Error.VERSION, acceptVersion); + error.addHeader(Stomp.Headers.CONTENT_TYPE, "text/plain"); error.setBody("Supported protocol version are " + manager.getSupportedVersionsAsString()); error.setDisconnect(true); throw error; diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompDecoder.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompDecoder.java index 453e466d96..cd2bc3be72 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompDecoder.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompDecoder.java @@ -27,66 +27,66 @@ public class StompDecoder { public static final boolean TRIM_LEADING_HEADER_VALUE_WHITESPACE = true; - public static final String COMMAND_ABORT = "ABORT"; + public static final String COMMAND_ABORT = Stomp.Commands.ABORT; public static final int COMMAND_ABORT_LENGTH = COMMAND_ABORT.length(); - public static final String COMMAND_ACK = "ACK"; + public static final String COMMAND_ACK = Stomp.Commands.ACK; public static final int COMMAND_ACK_LENGTH = COMMAND_ACK.length(); - public static final String COMMAND_NACK = "NACK"; + public static final String COMMAND_NACK = Stomp.Commands.NACK; public static final int COMMAND_NACK_LENGTH = COMMAND_NACK.length(); - public static final String COMMAND_BEGIN = "BEGIN"; + public static final String COMMAND_BEGIN = Stomp.Commands.BEGIN; public static final int COMMAND_BEGIN_LENGTH = COMMAND_BEGIN.length(); - public static final String COMMAND_COMMIT = "COMMIT"; + public static final String COMMAND_COMMIT = Stomp.Commands.COMMIT; public static final int COMMAND_COMMIT_LENGTH = COMMAND_COMMIT.length(); - public static final String COMMAND_CONNECT = "CONNECT"; + public static final String COMMAND_CONNECT = Stomp.Commands.CONNECT; public static final int COMMAND_CONNECT_LENGTH = COMMAND_CONNECT.length(); - public static final String COMMAND_DISCONNECT = "DISCONNECT"; + public static final String COMMAND_DISCONNECT = Stomp.Commands.DISCONNECT; public static final int COMMAND_DISCONNECT_LENGTH = COMMAND_DISCONNECT.length(); - public static final String COMMAND_SEND = "SEND"; + public static final String COMMAND_SEND = Stomp.Commands.SEND; public static final int COMMAND_SEND_LENGTH = COMMAND_SEND.length(); - public static final String COMMAND_STOMP = "STOMP"; + public static final String COMMAND_STOMP = Stomp.Commands.STOMP; public static final int COMMAND_STOMP_LENGTH = COMMAND_STOMP.length(); - public static final String COMMAND_SUBSCRIBE = "SUBSCRIBE"; + public static final String COMMAND_SUBSCRIBE = Stomp.Commands.SUBSCRIBE; public static final int COMMAND_SUBSCRIBE_LENGTH = COMMAND_SUBSCRIBE.length(); - public static final String COMMAND_UNSUBSCRIBE = "UNSUBSCRIBE"; + public static final String COMMAND_UNSUBSCRIBE = Stomp.Commands.UNSUBSCRIBE; public static final int COMMAND_UNSUBSCRIBE_LENGTH = COMMAND_UNSUBSCRIBE.length(); /** * * added by meddy, 27 april 2011, handle header parser for reply to websocket protocol *** */ - public static final String COMMAND_CONNECTED = "CONNECTED"; + public static final String COMMAND_CONNECTED = Stomp.Responses.CONNECTED; public static final int COMMAND_CONNECTED_LENGTH = COMMAND_CONNECTED.length(); - public static final String COMMAND_MESSAGE = "MESSAGE"; + public static final String COMMAND_MESSAGE = Stomp.Responses.MESSAGE; public static final int COMMAND_MESSAGE_LENGTH = COMMAND_MESSAGE.length(); - public static final String COMMAND_ERROR = "ERROR"; + public static final String COMMAND_ERROR = Stomp.Responses.ERROR; public static final int COMMAND_ERROR_LENGTH = COMMAND_ERROR.length(); - public static final String COMMAND_RECEIPT = "RECEIPT"; + public static final String COMMAND_RECEIPT = Stomp.Responses.RECEIPT; public static final int COMMAND_RECEIPT_LENGTH = COMMAND_RECEIPT.length(); /** @@ -131,10 +131,6 @@ public class StompDecoder public static final byte TAB = (byte) '\t'; - public static final String CONTENT_TYPE_HEADER_NAME = "content-type"; - - public static final String CONTENT_LENGTH_HEADER_NAME = "content-length"; - public byte[] workingBuffer = new byte[1024]; public int pos; @@ -346,7 +342,7 @@ public class StompDecoder headers.put(headerName, headerValue); - if (headerName.equals(CONTENT_LENGTH_HEADER_NAME)) + if (headerName.equals(Stomp.Headers.CONTENT_LENGTH)) { contentLength = Integer.parseInt(headerValue.toString()); } diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java index fd06f929e3..7728a3f4d2 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java @@ -379,7 +379,7 @@ class StompProtocolManager implements ProtocolManager, No public String getSupportedVersionsAsString() { - return "v1.0 v1.1 v1.2"; + return "v" + StompVersions.V1_0 + " v" + StompVersions.V1_1 + " v" + StompVersions.V1_2; } public String getVirtualHostName() diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v10/StompFrameHandlerV10.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v10/StompFrameHandlerV10.java index ee65243313..7cbf77157c 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v10/StompFrameHandlerV10.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v10/StompFrameHandlerV10.java @@ -24,6 +24,7 @@ import org.apache.activemq.artemis.core.protocol.stomp.Stomp; import org.apache.activemq.artemis.core.protocol.stomp.StompConnection; import org.apache.activemq.artemis.core.protocol.stomp.StompDecoder; import org.apache.activemq.artemis.core.protocol.stomp.StompFrame; +import org.apache.activemq.artemis.core.protocol.stomp.StompVersions; import org.apache.activemq.artemis.core.protocol.stomp.VersionedStompFrameHandler; import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; @@ -58,7 +59,7 @@ public class StompFrameHandlerV10 extends VersionedStompFrameHandler implements if (frame.hasHeader(Stomp.Headers.ACCEPT_VERSION)) { - response.addHeader(Stomp.Headers.Connected.VERSION, "1.0"); + response.addHeader(Stomp.Headers.Connected.VERSION, StompVersions.V1_0.toString()); } response.addHeader(Stomp.Headers.Connected.SESSION, connection.getID().toString()); diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameHandlerV11.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameHandlerV11.java index 86b40b0045..538427741c 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameHandlerV11.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameHandlerV11.java @@ -787,12 +787,12 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements headers.put(headerName, headerValue); - if (headerName.equals(CONTENT_LENGTH_HEADER_NAME)) + if (headerName.equals(Stomp.Headers.CONTENT_LENGTH)) { contentLength = Integer.parseInt(headerValue); } - if (headerName.equals(CONTENT_TYPE_HEADER_NAME)) + if (headerName.equals(Stomp.Headers.CONTENT_TYPE)) { contentType = headerValue; } diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java index 08f57d216c..ca9b6fe321 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java @@ -248,12 +248,12 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 implements FrameE headers.put(headerName, headerValue); } - if (headerName.equals(CONTENT_LENGTH_HEADER_NAME)) + if (headerName.equals(Stomp.Headers.CONTENT_LENGTH)) { contentLength = Integer.parseInt(headerValue); } - if (headerName.equals(CONTENT_TYPE_HEADER_NAME)) + if (headerName.equals(Stomp.Headers.CONTENT_TYPE)) { contentType = headerValue; }