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