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 DEFAULT_HEART_BEAT = "0,0";
036 String DEFAULT_VERSION = "1.0";
037 String EMPTY = "";
038
039 String[] SUPPORTED_PROTOCOL_VERSIONS = {"1.1", "1.0"};
040
041 String TEXT_PLAIN = "text/plain";
042 String TRUE = "true";
043 String FALSE = "false";
044 String END = "end";
045
046 public static interface Commands {
047 String STOMP = "STOMP";
048 String CONNECT = "CONNECT";
049 String SEND = "SEND";
050 String DISCONNECT = "DISCONNECT";
051 String SUBSCRIBE = "SUB";
052 String UNSUBSCRIBE = "UNSUB";
053
054 String BEGIN_TRANSACTION = "BEGIN";
055 String COMMIT_TRANSACTION = "COMMIT";
056 String ABORT_TRANSACTION = "ABORT";
057 String BEGIN = "BEGIN";
058 String COMMIT = "COMMIT";
059 String ABORT = "ABORT";
060 String ACK = "ACK";
061 String NACK = "NACK";
062 String KEEPALIVE = "KEEPALIVE";
063 }
064
065 public interface Responses {
066 String CONNECTED = "CONNECTED";
067 String ERROR = "ERROR";
068 String MESSAGE = "MESSAGE";
069 String RECEIPT = "RECEIPT";
070 }
071
072 public interface Headers {
073 String SEPERATOR = ":";
074 String RECEIPT_REQUESTED = "receipt";
075 String TRANSACTION = "transaction";
076 String CONTENT_LENGTH = "content-length";
077 String CONTENT_TYPE = "content-type";
078 String TRANSFORMATION = "transformation";
079 String TRANSFORMATION_ERROR = "transformation-error";
080
081 /**
082 * This header is used to instruct ActiveMQ to construct the message
083 * based with a specific type.
084 */
085 String AMQ_MESSAGE_TYPE = "amq-msg-type";
086
087 public interface Response {
088 String RECEIPT_ID = "receipt-id";
089 }
090
091 public interface Send {
092 String DESTINATION = "destination";
093 String CORRELATION_ID = "correlation-id";
094 String REPLY_TO = "reply-to";
095 String EXPIRATION_TIME = "expires";
096 String PRIORITY = "priority";
097 String TYPE = "type";
098 String PERSISTENT = "persistent";
099 }
100
101 public interface Message {
102 String MESSAGE_ID = "message-id";
103 String DESTINATION = "destination";
104 String CORRELATION_ID = "correlation-id";
105 String EXPIRATION_TIME = "expires";
106 String REPLY_TO = "reply-to";
107 String PRORITY = "priority";
108 String REDELIVERED = "redelivered";
109 String TIMESTAMP = "timestamp";
110 String TYPE = "type";
111 String SUBSCRIPTION = "subscription";
112 String BROWSER = "browser";
113 String USERID = "JMSXUserID";
114 String ORIGINAL_DESTINATION = "original-destination";
115 String PERSISTENT = "persistent";
116 }
117
118 public interface Subscribe {
119 String DESTINATION = "destination";
120 String ACK_MODE = "ack";
121 String ID = "id";
122 String SELECTOR = "selector";
123 String BROWSER = "browser";
124
125 public interface AckModeValues {
126 String AUTO = "auto";
127 String CLIENT = "client";
128 String INDIVIDUAL = "client-individual";
129 }
130 }
131
132 public interface Unsubscribe {
133 String DESTINATION = "destination";
134 String ID = "id";
135 }
136
137 public interface Connect {
138 String LOGIN = "login";
139 String PASSCODE = "passcode";
140 String CLIENT_ID = "client-id";
141 String REQUEST_ID = "request-id";
142 String ACCEPT_VERSION = "accept-version";
143 String HOST = "host";
144 String HEART_BEAT = "heart-beat";
145 }
146
147 public interface Error {
148 String MESSAGE = "message";
149 }
150
151 public interface Connected {
152 String SESSION = "session";
153 String RESPONSE_ID = "response-id";
154 String SERVER = "server";
155 String VERSION = "version";
156 String HEART_BEAT = "heart-beat";
157 }
158
159 public interface Ack {
160 String MESSAGE_ID = "message-id";
161 String SUBSCRIPTION = "subscription";
162 }
163 }
164
165 public enum Transformations {
166 JMS_BYTE,
167 JMS_XML,
168 JMS_JSON,
169 JMS_OBJECT_XML,
170 JMS_OBJECT_JSON,
171 JMS_MAP_XML,
172 JMS_MAP_JSON,
173 JMS_ADVISORY_XML,
174 JMS_ADVISORY_JSON;
175
176 public String toString() {
177 return name().replaceAll("_", "-").toLowerCase(Locale.ENGLISH);
178 }
179
180 public static Transformations getValue(String value) {
181 return valueOf(value.replaceAll("-", "_").toUpperCase(Locale.ENGLISH));
182 }
183 }
184 }