00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _ACTIVEMQ_WIREFORMAT_STOMP_STOMPWIREFORMAT_H_ 00019 #define _ACTIVEMQ_WIREFORMAT_STOMP_STOMPWIREFORMAT_H_ 00020 00021 #include <activemq/util/Config.h> 00022 #include <activemq/wireformat/WireFormat.h> 00023 #include <activemq/wireformat/stomp/StompFrame.h> 00024 #include <decaf/util/concurrent/atomic/AtomicBoolean.h> 00025 #include <decaf/io/IOException.h> 00026 #include <decaf/lang/Pointer.h> 00027 00028 namespace activemq { 00029 namespace wireformat { 00030 namespace stomp { 00031 00032 using decaf::lang::Pointer; 00033 using activemq::commands::Command; 00034 00035 class StompHelper; 00036 class StompWireformatProperties; 00037 00038 class AMQCPP_API StompWireFormat : public WireFormat { 00039 private: 00040 00044 StompHelper* helper; 00045 00046 // Stored after we connect to use when validating that a durable subscribe 00047 // and unsubscribe are set to use the client Id. 00048 std::string clientId; 00049 00050 // Indicates when we are in the doUnmarshal call 00051 decaf::util::concurrent::atomic::AtomicBoolean receiving; 00052 00053 // Internal structure for holding class internal data that can change without 00054 // affecting binary compatibility. 00055 StompWireformatProperties* properties; 00056 00057 private: 00058 00059 StompWireFormat(const StompWireFormat&); 00060 StompWireFormat& operator=(const StompWireFormat&); 00061 00062 public: 00063 00064 StompWireFormat(); 00065 00066 virtual ~StompWireFormat(); 00067 00068 public: 00069 00083 virtual void marshal(const Pointer<commands::Command> command, 00084 const activemq::transport::Transport* transport, 00085 decaf::io::DataOutputStream* out); 00086 00097 virtual Pointer<commands::Command> unmarshal(const activemq::transport::Transport* transport, 00098 decaf::io::DataInputStream* in); 00099 00104 virtual void setVersion(int version AMQCPP_UNUSED) {} 00105 00110 virtual int getVersion() const { 00111 return 1; 00112 } 00113 00119 std::string getTopicPrefix() const; 00120 00127 void setTopicPrefix(const std::string& prefix); 00128 00134 std::string getQueuePrefix() const; 00135 00142 void setQueuePrefix(const std::string& prefix); 00143 00149 std::string getTempTopicPrefix() const; 00150 00157 void setTempTopicPrefix(const std::string& prefix); 00158 00164 std::string getTempQueuePrefix() const; 00165 00172 void setTempQueuePrefix(const std::string& prefix); 00173 00179 virtual bool inReceive() const { 00180 return this->receiving.get(); 00181 } 00182 00188 virtual bool hasNegotiator() const { 00189 return false; 00190 } 00191 00198 virtual Pointer<transport::Transport> createNegotiator( 00199 const Pointer<transport::Transport> transport); 00200 00201 private: 00202 00203 Pointer<Command> unmarshalMessage(const Pointer<StompFrame> frame); 00204 Pointer<Command> unmarshalReceipt(const Pointer<StompFrame> frame); 00205 Pointer<Command> unmarshalConnected(const Pointer<StompFrame> frame); 00206 Pointer<Command> unmarshalError(const Pointer<StompFrame> frame); 00207 00208 Pointer<StompFrame> marshalMessage(const Pointer<Command> command); 00209 Pointer<StompFrame> marshalAck(const Pointer<Command> command); 00210 Pointer<StompFrame> marshalConnectionInfo(const Pointer<Command> command); 00211 Pointer<StompFrame> marshalTransactionInfo(const Pointer<Command> command); 00212 Pointer<StompFrame> marshalShutdownInfo(const Pointer<Command> command); 00213 Pointer<StompFrame> marshalRemoveInfo(const Pointer<Command> command); 00214 Pointer<StompFrame> marshalConsumerInfo(const Pointer<Command> command); 00215 Pointer<StompFrame> marshalRemoveSubscriptionInfo(const Pointer<Command> command); 00216 00217 }; 00218 00219 }}} 00220 00221 #endif /* _ACTIVEMQ_WIREFORMAT_STOMP_STOMPWIREFORMAT_H_ */
1.6.1