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.fusesource.hawtdispatch.example.stomp;
018
019 import org.fusesource.hawtbuf.AsciiBuffer;
020 import org.fusesource.hawtbuf.Buffer;
021
022
023 public interface Stomp {
024
025 Buffer EMPTY_BUFFER = new Buffer(0);
026 byte NULL = 0;
027 Buffer NULL_BUFFER = new Buffer(new byte[]{NULL});
028 byte NEWLINE = '\n';
029 Buffer NEWLINE_BUFFER = new Buffer(new byte[]{NEWLINE});
030 Buffer END_OF_FRAME_BUFFER = new Buffer(new byte[]{NULL, NEWLINE});
031
032 AsciiBuffer TRUE = new AsciiBuffer("true");
033 AsciiBuffer FALSE = new AsciiBuffer("false");
034
035 public static interface Commands {
036 AsciiBuffer CONNECT = new AsciiBuffer("CONNECT");
037 AsciiBuffer SEND = new AsciiBuffer("SEND");
038 AsciiBuffer DISCONNECT = new AsciiBuffer("DISCONNECT");
039 AsciiBuffer SUBSCRIBE = new AsciiBuffer("SUBSCRIBE");
040 AsciiBuffer UNSUBSCRIBE = new AsciiBuffer("UNSUBSCRIBE");
041
042 AsciiBuffer BEGIN_TRANSACTION = new AsciiBuffer("BEGIN");
043 AsciiBuffer COMMIT_TRANSACTION = new AsciiBuffer("COMMIT");
044 AsciiBuffer ABORT_TRANSACTION = new AsciiBuffer("ABORT");
045 AsciiBuffer BEGIN = new AsciiBuffer("BEGIN");
046 AsciiBuffer COMMIT = new AsciiBuffer("COMMIT");
047 AsciiBuffer ABORT = new AsciiBuffer("ABORT");
048 AsciiBuffer ACK = new AsciiBuffer("ACK");
049 }
050
051 public interface Responses {
052 AsciiBuffer CONNECTED = new AsciiBuffer("CONNECTED");
053 AsciiBuffer ERROR = new AsciiBuffer("ERROR");
054 AsciiBuffer MESSAGE = new AsciiBuffer("MESSAGE");
055 AsciiBuffer RECEIPT = new AsciiBuffer("RECEIPT");
056 }
057
058 public interface Headers {
059 byte SEPERATOR = ':';
060 Buffer SEPERATOR_BUFFER = new Buffer(new byte[]{SEPERATOR});
061
062 AsciiBuffer RECEIPT_REQUESTED = new AsciiBuffer("receipt");
063 AsciiBuffer TRANSACTION = new AsciiBuffer("transaction");
064 AsciiBuffer CONTENT_LENGTH = new AsciiBuffer("content-length");
065 AsciiBuffer TRANSFORMATION = new AsciiBuffer("transformation");
066 AsciiBuffer TRANSFORMATION_ERROR = new AsciiBuffer("transformation-error");
067
068 public interface Response {
069 AsciiBuffer RECEIPT_ID = new AsciiBuffer("receipt-id");
070 }
071
072 public interface Send {
073 AsciiBuffer DESTINATION = new AsciiBuffer("destination");
074 AsciiBuffer CORRELATION_ID = new AsciiBuffer("correlation-id");
075 AsciiBuffer REPLY_TO = new AsciiBuffer("reply-to");
076 AsciiBuffer EXPIRATION_TIME = new AsciiBuffer("expires");
077 AsciiBuffer PRIORITY = new AsciiBuffer("priority");
078 AsciiBuffer TYPE = new AsciiBuffer("type");
079 AsciiBuffer PERSISTENT = new AsciiBuffer("persistent");
080 }
081
082 public interface Message {
083 AsciiBuffer MESSAGE_ID = new AsciiBuffer("message-id");
084 AsciiBuffer DESTINATION = new AsciiBuffer("destination");
085 AsciiBuffer CORRELATION_ID = new AsciiBuffer("correlation-id");
086 AsciiBuffer EXPIRATION_TIME = new AsciiBuffer("expires");
087 AsciiBuffer REPLY_TO = new AsciiBuffer("reply-to");
088 AsciiBuffer PRORITY = new AsciiBuffer("priority");
089 AsciiBuffer REDELIVERED = new AsciiBuffer("redelivered");
090 AsciiBuffer TIMESTAMP = new AsciiBuffer("timestamp");
091 AsciiBuffer TYPE = new AsciiBuffer("type");
092 AsciiBuffer SUBSCRIPTION = new AsciiBuffer("subscription");
093 }
094
095 public interface Subscribe {
096 AsciiBuffer DESTINATION = new AsciiBuffer("destination");
097 AsciiBuffer ACK_MODE = new AsciiBuffer("ack");
098 AsciiBuffer ID = new AsciiBuffer("id");
099 AsciiBuffer SELECTOR = new AsciiBuffer("selector");
100
101 public interface AckModeValues {
102 AsciiBuffer AUTO = new AsciiBuffer("auto");
103 AsciiBuffer CLIENT = new AsciiBuffer("client");
104 AsciiBuffer INDIVIDUAL = new AsciiBuffer("client-individual");
105 }
106 }
107
108 public interface Unsubscribe {
109 AsciiBuffer DESTINATION = new AsciiBuffer("destination");
110 AsciiBuffer ID = new AsciiBuffer("id");
111 }
112
113 public interface Connect {
114 AsciiBuffer LOGIN = new AsciiBuffer("login");
115 AsciiBuffer PASSCODE = new AsciiBuffer("passcode");
116 AsciiBuffer CLIENT_ID = new AsciiBuffer("client-id");
117 AsciiBuffer REQUEST_ID = new AsciiBuffer("request-id");
118 }
119
120 public interface Error {
121 AsciiBuffer MESSAGE = new AsciiBuffer("message");
122 }
123
124 public interface Connected {
125 AsciiBuffer SESSION = new AsciiBuffer("session");
126 AsciiBuffer RESPONSE_ID = new AsciiBuffer("response-id");
127 }
128
129 public interface Ack {
130 AsciiBuffer MESSAGE_ID = new AsciiBuffer("message-id");
131 }
132 }
133
134 public enum Transformations {
135 JMS_BYTE, JMS_OBJECT_XML, JMS_OBJECT_JSON, JMS_MAP_XML, JMS_MAP_JSON;
136
137 public String toString() {
138 return name().replaceAll("_", "-").toLowerCase();
139 }
140
141 public static Transformations getValue(String value) {
142 return valueOf(value.replaceAll("-", "_").toUpperCase());
143 }
144 }
145 }