001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.activemq.transport.stomp;
018
019 import java.util.Locale;
020
021 public interface Stomp {
022 String NULL = "\u0000";
023 String NEWLINE = "\n";
024
025 byte BREAK = '\n';
026 byte COLON = ':';
027 byte ESCAPE = '\\';
028 byte[] ESCAPE_ESCAPE_SEQ = { 92, 92 };
029 byte[] COLON_ESCAPE_SEQ = { 92, 99 };
030 byte[] NEWLINE_ESCAPE_SEQ = { 92, 110 };
031
032 String COMMA = ",";
033 String V1_0 = "1.0";
034 String V1_1 = "1.1";
035 String V1_2 = "1.2";
036 String DEFAULT_HEART_BEAT = "0,0";
037 String DEFAULT_VERSION = "1.0";
038 String EMPTY = "";
039
040 String[] SUPPORTED_PROTOCOL_VERSIONS = {"1.2", "1.1", "1.0"};
041
042 String TEXT_PLAIN = "text/plain";
043 String TRUE = "true";
044 String FALSE = "false";
045 String END = "end";
046
047 public static interface Commands {
048 String STOMP = "STOMP";
049 String CONNECT = "CONNECT";
050 String SEND = "SEND";
051 String DISCONNECT = "DISCONNECT";
052 String SUBSCRIBE = "SUB";
053 String UNSUBSCRIBE = "UNSUB";
054
055 String BEGIN_TRANSACTION = "BEGIN";
056 String COMMIT_TRANSACTION = "COMMIT";
057 String ABORT_TRANSACTION = "ABORT";
058 String BEGIN = "BEGIN";
059 String COMMIT = "COMMIT";
060 String ABORT = "ABORT";
061 String ACK = "ACK";
062 String NACK = "NACK";
063 String KEEPALIVE = "KEEPALIVE";
064 }
065
066 public interface Responses {
067 String CONNECTED = "CONNECTED";
068 String ERROR = "ERROR";
069 String MESSAGE = "MESSAGE";
070 String RECEIPT = "RECEIPT";
071 }
072
073 public interface Headers {
074 String SEPERATOR = ":";
075 String RECEIPT_REQUESTED = "receipt";
076 String TRANSACTION = "transaction";
077 String CONTENT_LENGTH = "content-length";
078 String CONTENT_TYPE = "content-type";
079 String TRANSFORMATION = "transformation";
080 String TRANSFORMATION_ERROR = "transformation-error";
081
082 /**
083 * This header is used to instruct ActiveMQ to construct the message
084 * based with a specific type.
085 */
086 String AMQ_MESSAGE_TYPE = "amq-msg-type";
087
088 public interface Response {
089 String RECEIPT_ID = "receipt-id";
090 }
091
092 public interface Send {
093 String DESTINATION = "destination";
094 String CORRELATION_ID = "correlation-id";
095 String REPLY_TO = "reply-to";
096 String EXPIRATION_TIME = "expires";
097 String PRIORITY = "priority";
098 String TYPE = "type";
099 String PERSISTENT = "persistent";
100 }
101
102 public interface Message {
103 String MESSAGE_ID = "message-id";
104 String ACK_ID = "ack";
105 String DESTINATION = "destination";
106 String CORRELATION_ID = "correlation-id";
107 String EXPIRATION_TIME = "expires";
108 String REPLY_TO = "reply-to";
109 String PRORITY = "priority";
110 String REDELIVERED = "redelivered";
111 String TIMESTAMP = "timestamp";
112 String TYPE = "type";
113 String SUBSCRIPTION = "subscription";
114 String BROWSER = "browser";
115 String USERID = "JMSXUserID";
116 String ORIGINAL_DESTINATION = "original-destination";
117 String PERSISTENT = "persistent";
118 }
119
120 public interface Subscribe {
121 String DESTINATION = "destination";
122 String ACK_MODE = "ack";
123 String ID = "id";
124 String SELECTOR = "selector";
125 String BROWSER = "browser";
126
127 public interface AckModeValues {
128 String AUTO = "auto";
129 String CLIENT = "client";
130 String INDIVIDUAL = "client-individual";
131 }
132 }
133
134 public interface Unsubscribe {
135 String DESTINATION = "destination";
136 String ID = "id";
137 }
138
139 public interface Connect {
140 String LOGIN = "login";
141 String PASSCODE = "passcode";
142 String CLIENT_ID = "client-id";
143 String REQUEST_ID = "request-id";
144 String ACCEPT_VERSION = "accept-version";
145 String HOST = "host";
146 String HEART_BEAT = "heart-beat";
147 }
148
149 public interface Error {
150 String MESSAGE = "message";
151 }
152
153 public interface Connected {
154 String SESSION = "session";
155 String RESPONSE_ID = "response-id";
156 String SERVER = "server";
157 String VERSION = "version";
158 String HEART_BEAT = "heart-beat";
159 }
160
161 public interface Ack {
162 String MESSAGE_ID = "message-id";
163 String SUBSCRIPTION = "subscription";
164 String ACK_ID = "id";
165 }
166 }
167
168 public enum Transformations {
169 JMS_BYTE,
170 JMS_XML,
171 JMS_JSON,
172 JMS_OBJECT_XML,
173 JMS_OBJECT_JSON,
174 JMS_MAP_XML,
175 JMS_MAP_JSON,
176 JMS_ADVISORY_XML,
177 JMS_ADVISORY_JSON;
178
179 public String toString() {
180 return name().replaceAll("_", "-").toLowerCase(Locale.ENGLISH);
181 }
182
183 public static Transformations getValue(String value) {
184 return valueOf(value.replaceAll("-", "_").toUpperCase(Locale.ENGLISH));
185 }
186 }
187 }