You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2007/11/11 17:52:54 UTC
svn commit: r593929 [4/7] - in /activemq/activemq-cpp/trunk/src:
main/activemq/connector/ main/activemq/connector/openwire/
main/activemq/connector/openwire/commands/
main/activemq/connector/openwire/marshal/
main/activemq/connector/openwire/utils/ mai...
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnector.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnector.cpp?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnector.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnector.cpp Sun Nov 11 08:52:45 2007
@@ -46,19 +46,20 @@
using namespace activemq::connector::stomp;
using namespace activemq::connector::stomp::commands;
-using namespace decaf::lang;
+using namespace decaf;
using namespace decaf::util;
+using namespace decaf::lang;
using namespace decaf::lang::exceptions;
-LOGDECAF_INITIALIZE(logger, StompConnector, "activemq.connector.stomp.StompConnector" )
+////////////////////////////////////////////////////////////////////////////////
+LOGDECAF_INITIALIZE( logger, StompConnector, "activemq.connector.stomp.StompConnector" )
////////////////////////////////////////////////////////////////////////////////
StompConnector::StompConnector( Transport* transport,
const decaf::util::Properties& properties )
- throw ( IllegalArgumentException )
-{
- if( transport == NULL )
- {
+ throw ( IllegalArgumentException ) {
+
+ if( transport == NULL ) {
throw IllegalArgumentException(
__FILE__, __LINE__,
"StompConnector::StompConnector - Transport cannot be NULL");
@@ -86,10 +87,10 @@
}
////////////////////////////////////////////////////////////////////////////////
-StompConnector::~StompConnector()
-{
- try
- {
+StompConnector::~StompConnector() {
+
+ try{
+
close();
delete transport;
@@ -100,10 +101,9 @@
}
////////////////////////////////////////////////////////////////////////////////
-void StompConnector::enforceConnected() throw ( ConnectorException )
-{
- if( state != CONNECTION_STATE_CONNECTED )
- {
+void StompConnector::enforceConnected() throw ( ConnectorException ) {
+
+ if( state != CONNECTION_STATE_CONNECTED ) {
throw StompConnectorException(
__FILE__, __LINE__,
"StompConnector::enforceConnected - Not Connected!" );
@@ -113,27 +113,24 @@
////////////////////////////////////////////////////////////////////////////////
void StompConnector::addCmdListener(
commands::CommandConstants::CommandId commandId,
- StompCommandListener* listener )
-{
+ StompCommandListener* listener ) {
cmdListenerMap.insert( make_pair( commandId, listener ) );
}
////////////////////////////////////////////////////////////////////////////////
void StompConnector::removeCmdListener(
- commands::CommandConstants::CommandId commandId )
-{
+ commands::CommandConstants::CommandId commandId ) {
cmdListenerMap.erase( commandId );
}
////////////////////////////////////////////////////////////////////////////////
-void StompConnector::start() throw( cms::CMSException )
-{
- try
- {
- synchronized( &mutex )
- {
- if( state == CONNECTION_STATE_CONNECTED )
- {
+void StompConnector::start() throw( cms::CMSException ) {
+
+ try{
+
+ synchronized( &mutex ) {
+
+ if( state == CONNECTION_STATE_CONNECTED ) {
throw ActiveMQException(
__FILE__, __LINE__,
"StompConnector::start - already started" );
@@ -147,14 +144,15 @@
}
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException );
}
////////////////////////////////////////////////////////////////////////////////
void StompConnector::close() throw( cms::CMSException ){
- try
- {
+ try{
+
if( state == CONNECTION_STATE_DISCONNECTED ){
return;
}
@@ -169,14 +167,15 @@
}
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException );
}
////////////////////////////////////////////////////////////////////////////////
-void StompConnector::connect()
-{
- try
- {
+void StompConnector::connect() {
+
+ try{
+
// Mark this connector as started.
state = CONNECTION_STATE_CONNECTING;
@@ -238,13 +237,14 @@
delete response;
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
-void StompConnector::disconnect()
-{
- try {
+void StompConnector::disconnect() {
+
+ try{
// Mark state as no longer connected.
state = CONNECTION_STATE_DISCONNECTED;
@@ -258,19 +258,21 @@
throw ex;
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException );
}
////////////////////////////////////////////////////////////////////////////////
SessionInfo* StompConnector::createSession(
cms::Session::AcknowledgeMode ackMode )
- throw( ConnectorException )
-{
+ throw( ConnectorException ) {
+
try {
enforceConnected();
return sessionManager->createSession( ackMode );
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
@@ -280,28 +282,30 @@
SessionInfo* session,
const std::string& selector,
bool noLocal )
- throw ( ConnectorException )
-{
- try
- {
+ throw ( ConnectorException ) {
+
+ try{
+
enforceConnected();
return sessionManager->createConsumer(
destination, session, selector, noLocal );
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
////////////////////////////////////////////////////////////////////////////////
void StompConnector::startConsumer(ConsumerInfo* consumer )
- throw ( ConnectorException )
-{
+ throw ( ConnectorException ) {
+
try {
enforceConnected();
return sessionManager->startConsumer(consumer);
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
@@ -312,16 +316,17 @@
const std::string& name,
const std::string& selector,
bool noLocal )
- throw ( ConnectorException )
-{
- try
- {
+ throw ( ConnectorException ) {
+
+ try{
+
enforceConnected();
return sessionManager->createDurableConsumer(
topic, session, name, selector, noLocal );
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
@@ -329,10 +334,10 @@
ProducerInfo* StompConnector::createProducer(
const cms::Destination* destination,
SessionInfo* session )
- throw ( ConnectorException )
-{
- try
- {
+ throw ( ConnectorException ) {
+
+ try{
+
enforceConnected();
ProducerInfo* producer = new StompProducerInfo( this );
@@ -344,40 +349,43 @@
return producer;
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
////////////////////////////////////////////////////////////////////////////////
cms::Topic* StompConnector::createTopic( const std::string& name,
SessionInfo* session AMQCPP_UNUSED)
- throw ( ConnectorException )
-{
+ throw ( ConnectorException ) {
+
try {
enforceConnected();
return new StompTopic( name );
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
////////////////////////////////////////////////////////////////////////////////
cms::Queue* StompConnector::createQueue( const std::string& name,
SessionInfo* session AMQCPP_UNUSED)
- throw ( ConnectorException )
-{
+ throw ( ConnectorException ) {
+
try {
enforceConnected();
return new StompQueue( name );
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
////////////////////////////////////////////////////////////////////////////////
cms::TemporaryTopic* StompConnector::createTemporaryTopic(
SessionInfo* session AMQCPP_UNUSED)
- throw ( ConnectorException, UnsupportedOperationException )
-{
+ throw ( ConnectorException, UnsupportedOperationException ) {
+
try {
throw UnsupportedOperationException(
__FILE__, __LINE__,
@@ -385,6 +393,7 @@
}
AMQ_CATCH_RETHROW( ConnectorException )
AMQ_CATCH_RETHROW( UnsupportedOperationException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
return NULL;
}
@@ -392,8 +401,8 @@
////////////////////////////////////////////////////////////////////////////////
cms::TemporaryQueue* StompConnector::createTemporaryQueue(
SessionInfo* session AMQCPP_UNUSED)
- throw ( ConnectorException, UnsupportedOperationException )
-{
+ throw ( ConnectorException, UnsupportedOperationException ) {
+
try {
throw UnsupportedOperationException(
__FILE__, __LINE__,
@@ -401,6 +410,7 @@
}
AMQ_CATCH_RETHROW( ConnectorException )
AMQ_CATCH_RETHROW( UnsupportedOperationException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
return NULL;
}
@@ -408,30 +418,28 @@
////////////////////////////////////////////////////////////////////////////////
void StompConnector::send( cms::Message* message,
ProducerInfo* producerInfo )
- throw ( ConnectorException )
-{
- try
- {
+ throw ( ConnectorException ) {
+
+ try{
+
enforceConnected();
const SessionInfo* session = producerInfo->getSessionInfo();
Command* command = dynamic_cast< transport::Command* >( message );
- if( command == NULL )
- {
+ if( command == NULL ) {
throw StompConnectorException(
__FILE__, __LINE__,
"StompConnector::send - "
"Message is not a valid stomp type.");
}
- if( session->getAckMode() == cms::Session::SESSION_TRANSACTED )
- {
+ if( session->getAckMode() == cms::Session::SESSION_TRANSACTED ) {
+
StompCommand* stompCommand =
dynamic_cast< StompCommand* >( message );
- if( stompCommand == NULL )
- {
+ if( stompCommand == NULL ) {
throw StompConnectorException(
__FILE__, __LINE__,
"StompConnector::send - "
@@ -452,16 +460,17 @@
ex.what() );
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
////////////////////////////////////////////////////////////////////////////////
void StompConnector::send( std::list<cms::Message*>& messages,
ProducerInfo* producerInfo )
- throw ( ConnectorException )
-{
- try
- {
+ throw ( ConnectorException ) {
+
+ try{
+
enforceConnected();
list< cms::Message* >::const_iterator itr = messages.begin();
@@ -471,6 +480,7 @@
}
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
@@ -479,8 +489,8 @@
const ConsumerInfo* consumer AMQCPP_UNUSED,
const cms::Message* message,
AckType ackType AMQCPP_UNUSED)
- throw ( ConnectorException )
-{
+ throw ( ConnectorException ) {
+
try {
enforceConnected();
@@ -508,16 +518,17 @@
ex.what() );
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
////////////////////////////////////////////////////////////////////////////////
TransactionInfo* StompConnector::startTransaction(
SessionInfo* session )
- throw ( ConnectorException )
-{
- try
- {
+ throw ( ConnectorException ) {
+
+ try{
+
enforceConnected();
TransactionInfo* transaction = new StompTransactionInfo( this );
@@ -541,6 +552,7 @@
ex.what() );
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
return NULL;
}
@@ -548,10 +560,10 @@
////////////////////////////////////////////////////////////////////////////////
void StompConnector::commit( TransactionInfo* transaction,
SessionInfo* session AMQCPP_UNUSED)
- throw ( ConnectorException )
-{
- try
- {
+ throw ( ConnectorException ) {
+
+ try {
+
enforceConnected();
CommitCommand cmd;
@@ -567,16 +579,17 @@
ex.what() );
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
////////////////////////////////////////////////////////////////////////////////
void StompConnector::rollback( TransactionInfo* transaction,
SessionInfo* session AMQCPP_UNUSED)
- throw ( ConnectorException )
-{
- try
- {
+ throw ( ConnectorException ) {
+
+ try {
+
enforceConnected();
AbortCommand cmd;
@@ -588,10 +601,10 @@
}
catch( CommandIOException& ex ){
transport->close();
- throw ConnectorException( __FILE__, __LINE__,
- ex.what() );
+ throw ConnectorException( __FILE__, __LINE__, ex.what() );
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
@@ -599,16 +612,15 @@
cms::Message* StompConnector::createMessage(
SessionInfo* session AMQCPP_UNUSED,
TransactionInfo* transaction )
- throw ( ConnectorException )
-{
- try
- {
+ throw ( ConnectorException ) {
+
+ try{
+
enforceConnected();
MessageCommand* cmd = new MessageCommand();
- if( transaction != NULL )
- {
+ if( transaction != NULL ) {
cmd->setTransactionId(
Long::toString( transaction->getTransactionId() ) );
}
@@ -616,6 +628,7 @@
return cmd;
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
@@ -623,16 +636,15 @@
cms::BytesMessage* StompConnector::createBytesMessage(
SessionInfo* session AMQCPP_UNUSED,
TransactionInfo* transaction )
- throw ( ConnectorException )
-{
- try
- {
+ throw ( ConnectorException ) {
+
+ try{
+
enforceConnected();
BytesMessageCommand* cmd = new BytesMessageCommand();
- if( transaction != NULL )
- {
+ if( transaction != NULL ) {
cmd->setTransactionId(
Long::toString( transaction->getTransactionId() ) );
}
@@ -640,6 +652,7 @@
return cmd;
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
@@ -647,16 +660,15 @@
cms::TextMessage* StompConnector::createTextMessage(
SessionInfo* session AMQCPP_UNUSED,
TransactionInfo* transaction )
- throw ( ConnectorException )
-{
- try
- {
+ throw ( ConnectorException ) {
+
+ try{
+
enforceConnected();
TextMessageCommand* cmd = new TextMessageCommand;
- if( transaction != NULL )
- {
+ if( transaction != NULL ) {
cmd->setTransactionId(
Long::toString( transaction->getTransactionId() ) );
}
@@ -664,6 +676,7 @@
return cmd;
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
@@ -671,48 +684,48 @@
cms::MapMessage* StompConnector::createMapMessage(
SessionInfo* session AMQCPP_UNUSED,
TransactionInfo* transaction AMQCPP_UNUSED )
- throw ( ConnectorException, UnsupportedOperationException )
-{
- try
- {
+ throw ( ConnectorException, UnsupportedOperationException ) {
+
+ try{
throw UnsupportedOperationException(
__FILE__, __LINE__,
"StompConnector::createMapMessage - No Stomp Support");
}
AMQ_CATCH_RETHROW( ConnectorException )
AMQ_CATCH_RETHROW( UnsupportedOperationException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
return NULL;
}
////////////////////////////////////////////////////////////////////////////////
void StompConnector::unsubscribe( const std::string& name AMQCPP_UNUSED )
- throw ( ConnectorException, UnsupportedOperationException )
-{
- try
- {
+ throw ( ConnectorException, UnsupportedOperationException ) {
+
+ try {
throw UnsupportedOperationException(
__FILE__, __LINE__,
"StompConnector::unsubscribe - No Stomp Support");
}
AMQ_CATCH_RETHROW( ConnectorException )
AMQ_CATCH_RETHROW( UnsupportedOperationException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
////////////////////////////////////////////////////////////////////////////////
void StompConnector::closeResource( ConnectorResource* resource )
- throw ( ConnectorException )
-{
- try
- {
+ throw ( ConnectorException ) {
+
+ try{
+
ConsumerInfo* consumer =
dynamic_cast<ConsumerInfo*>(resource);
SessionInfo* session =
dynamic_cast<SessionInfo*>(resource);
- if( consumer != NULL)
- {
+ if( consumer != NULL) {
+
try{
sessionManager->removeConsumer( consumer );
} catch( ConnectorException& ex ){
@@ -723,9 +736,9 @@
ex.setMark( __FILE__, __LINE__ );
throw ex;
}
- }
- else if( session != NULL)
- {
+
+ } else if( session != NULL ) {
+
try{
sessionManager->removeSession( session );
} catch( ConnectorException& ex ){
@@ -739,18 +752,18 @@
}
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
////////////////////////////////////////////////////////////////////////////////
-void StompConnector::onCommand( transport::Command* command )
-{
- try
- {
+void StompConnector::onCommand( transport::Command* command ) {
+
+ try{
+
StompCommand* stompCommand = dynamic_cast< StompCommand* >(command);
- if( stompCommand == NULL )
- {
+ if( stompCommand == NULL ) {
fire( ConnectorException(
__FILE__, __LINE__,
"StompConnector::onCommand - Recieved an unknown Command") );
@@ -759,8 +772,7 @@
CmdListenerMap::iterator itr =
cmdListenerMap.find( stompCommand->getStompCommandId() );
- if( itr == cmdListenerMap.end() )
- {
+ if( itr == cmdListenerMap.end() ) {
fire( ConnectorException(
__FILE__, __LINE__,
"StompConnector::onCommand - "
@@ -776,42 +788,44 @@
itr->second->onStompCommand( stompCommand );
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
////////////////////////////////////////////////////////////////////////////////
void StompConnector::onTransportException(
transport::Transport* source AMQCPP_UNUSED,
- const exceptions::ActiveMQException& ex )
-{
- try
- {
+ const decaf::lang::Exception& ex ) {
+
+ try{
+
// We're disconnected - the asynchronous error is expected.
if( state == CONNECTION_STATE_DISCONNECTED ){
return;
}
// We were not closing - log the stack trace.
- LOGDECAF_WARN(logger, ex.getStackTraceString() );
+ LOGDECAF_WARN( logger, ex.getStackTraceString() );
// Inform the user of the error.
- fire( ex );
+ ActiveMQException convert( ex );
+ fire( convert );
}
AMQ_CATCH_RETHROW( ConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
////////////////////////////////////////////////////////////////////////////////
void StompConnector::onStompCommand( commands::StompCommand* command )
- throw ( StompConnectorException )
-{
- try
- {
+ throw ( StompConnectorException ) {
+
+ try{
+
ErrorCommand* error =
dynamic_cast<ErrorCommand*>( command );
- if( error != NULL )
- {
+ if( error != NULL ) {
fire( StompConnectorException(
__FILE__, __LINE__,
( string( "StompConnector::onStompCommand - " ) +
@@ -825,5 +839,6 @@
delete command;
}
AMQ_CATCH_RETHROW( StompConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, StompConnectorException )
AMQ_CATCHALL_THROW( StompConnectorException );
}
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnector.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnector.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnector.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnector.h Sun Nov 11 08:52:45 2007
@@ -41,13 +41,11 @@
/**
* The connector implementation for the STOMP protocol.
*/
- class StompConnector
- :
+ class StompConnector :
public Connector,
public transport::CommandListener,
public transport::TransportExceptionListener,
- public StompCommandListener
- {
+ public StompCommandListener {
LOGDECAF_DECLARE( logger )
@@ -462,12 +460,10 @@
* @param listener listener the observer.
*/
virtual void setConsumerMessageListener(
- ConsumerMessageListener* listener )
- {
+ ConsumerMessageListener* listener ) {
this->messageListener = listener;
- if(sessionManager != NULL)
- {
+ if( sessionManager != NULL ) {
sessionManager->setConsumerMessageListener( listener );
}
}
@@ -477,8 +473,7 @@
* @param listener ExceptionListener the observer.
*/
virtual void setExceptionListener(
- cms::ExceptionListener* listener )
- {
+ cms::ExceptionListener* listener ) {
this->exceptionListener = listener;
}
@@ -500,7 +495,7 @@
*/
virtual void onTransportException(
transport::Transport* source,
- const exceptions::ActiveMQException& ex );
+ const decaf::lang::Exception& ex );
public: // StompCommandListener
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnectorException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnectorException.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnectorException.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnectorException.h Sun Nov 11 08:52:45 2007
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef ACTIVEMQ_CONNECTOR_STOMP_STOMPCONNECTOREXCEPTION_H_
-#define ACTIVEMQ_CONNECTOR_STOMP_STOMPCONNECTOREXCEPTION_H_
+#ifndef _ACTIVEMQ_CONNECTOR_STOMP_STOMPCONNECTOREXCEPTION_H_
+#define _ACTIVEMQ_CONNECTOR_STOMP_STOMPCONNECTOREXCEPTION_H_
#include <activemq/connector/ConnectorException.h>
@@ -26,22 +26,20 @@
/*
* Signals that an Connector exception of some sort has occurred.
*/
- class StompConnectorException : public connector::ConnectorException
- {
+ class StompConnectorException : public connector::ConnectorException {
public:
-
+
/**
* Default Constructor
*/
- StompConnectorException() throw(){}
+ StompConnectorException() throw() {}
/**
* Copy Constructor
* @param ex the exception to copy
*/
StompConnectorException( const exceptions::ActiveMQException& ex ) throw()
- : connector::ConnectorException()
- {
+ : connector::ConnectorException() {
*( ActiveMQException* )this = ex;
}
@@ -50,8 +48,7 @@
* @param ex the exception to copy, which is an instance of this type
*/
StompConnectorException( const StompConnectorException& ex ) throw()
- : connector::ConnectorException()
- {
+ : connector::ConnectorException() {
*( exceptions::ActiveMQException* )this = ex;
}
@@ -61,32 +58,32 @@
* @param lineNumber line where the exception occured
* @param msg the message that was generated
*/
- StompConnectorException( const char* file,
- const int lineNumber,
+ StompConnectorException( const char* file,
+ const int lineNumber,
const char* msg, ... ) throw()
- : connector::ConnectorException()
- {
+ : connector::ConnectorException() {
+
va_list vargs;
va_start( vargs, msg );
buildMessage( msg, vargs );
-
+
// Set the first mark for this exception.
setMark( file, lineNumber );
}
-
+
/**
* Clones this exception. This is useful for cases where you need
* to preserve the type of the original exception as well as the message.
* All subclasses should override.
*/
- virtual exceptions::ActiveMQException* clone() const{
+ virtual StompConnectorException* clone() const{
return new StompConnectorException( *this );
}
-
+
virtual ~StompConnectorException() throw() {}
};
}}}
-#endif /*ACTIVEMQ_CONNECTOR_STOMP_STOMPCONNECTOREXCEPTION_H_*/
+#endif /*_ACTIVEMQ_CONNECTOR_STOMP_STOMPCONNECTOREXCEPTION_H_*/
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnectorFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnectorFactory.cpp?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnectorFactory.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnectorFactory.cpp Sun Nov 11 08:52:45 2007
@@ -25,19 +25,21 @@
using namespace activemq::transport;
using namespace activemq::connector;
using namespace activemq::connector::stomp;
+using namespace decaf::lang;
+using namespace decaf::util;
+using namespace decaf::lang::exceptions;
////////////////////////////////////////////////////////////////////////////////
-Connector* StompConnectorFactory::createConnector(
+StompConnector* StompConnectorFactory::createConnector(
const decaf::util::Properties& properties,
- activemq::transport::Transport* transport )
-{
- return dynamic_cast<Connector*>(
- new StompConnector( transport, properties ) );
+ activemq::transport::Transport* transport ) {
+
+ return new StompConnector( transport, properties );
}
////////////////////////////////////////////////////////////////////////////////
-ConnectorFactory& StompConnectorFactory::getInstance(void)
-{
+ConnectorFactory& StompConnectorFactory::getInstance() {
+
// Create a static instance of the registrar and return a reference to
// its internal instance of this class.
static ConnectorFactoryMapRegistrar registrar(
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnectorFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnectorFactory.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnectorFactory.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConnectorFactory.h Sun Nov 11 08:52:45 2007
@@ -14,18 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef ACTIVEMQ_CONNECTOR_STOMP_STOMPCONNECTORFACTORY_H_
-#define ACTIVEMQ_CONNECTOR_STOMP_STOMPCONNECTORFACTORY_H_
+#ifndef _ACTIVEMQ_CONNECTOR_STOMP_STOMPCONNECTORFACTORY_H_
+#define _ACTIVEMQ_CONNECTOR_STOMP_STOMPCONNECTORFACTORY_H_
#include <activemq/connector/ConnectorFactory.h>
#include <activemq/connector/ConnectorFactoryMapRegistrar.h>
+#include <activemq/connector/stomp/StompConnector.h>
namespace activemq{
namespace connector{
namespace stomp{
- class StompConnectorFactory : public connector::ConnectorFactory
- {
+ class StompConnectorFactory : public connector::ConnectorFactory {
public:
virtual ~StompConnectorFactory(void) {}
@@ -36,7 +36,7 @@
* configured with
* @param transport the Transport instance this connector uses.
*/
- virtual Connector* createConnector(
+ virtual StompConnector* createConnector(
const decaf::util::Properties& properties,
activemq::transport::Transport* transport );
@@ -44,10 +44,10 @@
* Returns an instance of this Factory by reference
* @return StompConnectorFactory reference
*/
- static ConnectorFactory& getInstance(void);
+ static ConnectorFactory& getInstance();
};
}}}
-#endif /*ACTIVEMQ_CONNECTOR_STOMP_STOMPCONNECTORFACTORY_H_*/
+#endif /*_ACTIVEMQ_CONNECTOR_STOMP_STOMPCONNECTORFACTORY_H_*/
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConsumerInfo.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConsumerInfo.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConsumerInfo.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompConsumerInfo.h Sun Nov 11 08:52:45 2007
@@ -24,8 +24,7 @@
namespace connector{
namespace stomp{
- class StompConsumerInfo : public ConsumerInfo
- {
+ class StompConsumerInfo : public ConsumerInfo {
private:
// Message Selector for this Consumer
@@ -39,9 +38,10 @@
// Session Info - We do not own this
const SessionInfo* session;
-
+
+ // Consumer shouldn't get messages it publishes
bool noLocal;
-
+
// Subscription name for this consumer, "" for non-durables
std::string name;
@@ -66,7 +66,7 @@
noLocal = false;
}
- virtual ~StompConsumerInfo() {
+ virtual ~StompConsumerInfo() {
this->close();
delete destination;
}
@@ -134,19 +134,19 @@
virtual void setSessionInfo( const SessionInfo* session ) {
this->session = session;
}
-
+
virtual bool getNoLocal() const {
return noLocal;
}
-
+
virtual void setNoLocal( bool noLocal ) {
this->noLocal = noLocal;
}
-
+
virtual const std::string& getName() const {
return name;
}
-
+
virtual void setName( const std::string& name ) {
this->name = name;
}
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompDestination.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompDestination.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompDestination.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompDestination.h Sun Nov 11 08:52:45 2007
@@ -37,8 +37,7 @@
* one of Topic, Queue, TemporaryTopic, or TemporaryQueue.
*/
template <typename T>
- class StompDestination : public T
- {
+ class StompDestination : public T {
private:
// Params that are optional on the destination
@@ -67,8 +66,8 @@
*/
StompDestination( const std::string& dest,
cms::Destination::DestinationType destType ) {
- try
- {
+ try{
+
decaf::util::StringTokenizer tokenizer(dest, "?&");
std::vector<std::string> tokens;
@@ -76,8 +75,7 @@
this->destType = destType;
// Require that there at least one token, the dest
- if( tokenizer.countTokens() < 1 )
- {
+ if( tokenizer.countTokens() < 1 ) {
throw decaf::lang::exceptions::IllegalArgumentException(
__FILE__, __LINE__,
( std::string(
@@ -91,12 +89,11 @@
// Now get all the optional parameters and store them as properties
int count = tokenizer.toArray( tokens );
- for( int i = 0; i < count; ++i )
- {
+ for( int i = 0; i < count; ++i ) {
+
tokenizer.reset( tokens[i], "=" );
- if( tokenizer.countTokens() != 2 )
- {
+ if( tokenizer.countTokens() != 2 ) {
throw decaf::lang::exceptions::IllegalArgumentException(
__FILE__, __LINE__,
( std::string(
@@ -187,8 +184,8 @@
*/
virtual void copy( const cms::Destination& source ) {
- try
- {
+ try{
+
// This will throw an Bad Cast Exception if the destination
// isn't a compatible type
const StompDestination<T>& destination =
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompFrame.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompFrame.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompFrame.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompFrame.h Sun Nov 11 08:52:45 2007
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-#ifndef ACTIVEMQ_CONNECTOR_STOMP_STOMPFRAMEWRAPPER_H_
-#define ACTIVEMQ_CONNECTOR_STOMP_STOMPFRAMEWRAPPER_H_
+#ifndef _ACTIVEMQ_CONNECTOR_STOMP_STOMPFRAMEWRAPPER_H_
+#define _ACTIVEMQ_CONNECTOR_STOMP_STOMPFRAMEWRAPPER_H_
#include <string>
#include <string.h>
@@ -141,4 +141,4 @@
}}}
-#endif /*ACTIVEMQ_CONNECTOR_STOMP_STOMPFRAMEWRAPPER_H_*/
+#endif /*_ACTIVEMQ_CONNECTOR_STOMP_STOMPFRAMEWRAPPER_H_*/
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompProducerInfo.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompProducerInfo.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompProducerInfo.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompProducerInfo.h Sun Nov 11 08:52:45 2007
@@ -25,8 +25,7 @@
namespace connector{
namespace stomp{
- class StompProducerInfo : public ProducerInfo
- {
+ class StompProducerInfo : public ProducerInfo {
private:
// Are Message Ids Disabled
@@ -60,9 +59,9 @@
this->destination = NULL;
}
- virtual ~StompProducerInfo(void) {
+ virtual ~StompProducerInfo(void) {
this->close();
- delete destination;
+ delete destination;
}
/**
@@ -70,7 +69,7 @@
* sends its messages to.
* @return Destionation, owned by this object
*/
- virtual const cms::Destination* getDestination(void) const {
+ virtual const cms::Destination* getDestination() const {
return destination;
}
@@ -93,7 +92,7 @@
* Gets the ID that is assigned to this Producer
* @return value of the Producer Id.
*/
- virtual long long getProducerId(void) const {
+ virtual long long getProducerId() const {
return producerId;
}
@@ -109,7 +108,7 @@
* Gets the Session Info that this consumer is attached too
* @return SessionnInfo pointer
*/
- virtual const SessionInfo* getSessionInfo(void) const {
+ virtual const SessionInfo* getSessionInfo() const {
return session;
}
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompQueue.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompQueue.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompQueue.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompQueue.h Sun Nov 11 08:52:45 2007
@@ -26,22 +26,21 @@
namespace connector{
namespace stomp{
- class StompQueue : public StompDestination< cms::Queue >
- {
+ class StompQueue : public StompDestination< cms::Queue > {
public:
/**
* Copy Consturctor
* @param source CMS Dest to Copy, must be a compatible type
*/
- StompQueue( const cms::Destination* source ) :
+ StompQueue( const cms::Destination* source ) :
StompDestination< cms::Queue >( source ) {}
/**
* Custom Constructor
* @param name string destination name plus any params
*/
- StompQueue( const std::string& name ) :
+ StompQueue( const std::string& name ) :
StompDestination< cms::Queue >( name, cms::Destination::QUEUE )
{}
@@ -74,7 +73,7 @@
virtual std::string getPrefix() const {
return commands::CommandConstants::queuePrefix;
}
-
+
};
}}}
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.cpp?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.cpp Sun Nov 11 08:52:45 2007
@@ -28,6 +28,7 @@
using namespace activemq::connector;
using namespace activemq::connector::stomp;
using namespace activemq::transport;
+using namespace decaf;
using namespace decaf::util;
////////////////////////////////////////////////////////////////////////////////
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.h Sun Nov 11 08:52:45 2007
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-#ifndef ACTIVEMQ_CONNECTOR_STOMP_STOMPRESPONSEBUILDER_H_
-#define ACTIVEMQ_CONNECTOR_STOMP_STOMPRESPONSEBUILDER_H_
+#ifndef _ACTIVEMQ_CONNECTOR_STOMP_STOMPRESPONSEBUILDER_H_
+#define _ACTIVEMQ_CONNECTOR_STOMP_STOMPRESPONSEBUILDER_H_
#include <activemq/transport/MockTransport.h>
@@ -27,8 +27,8 @@
class StompResponseBuilder : public transport::MockTransport::ResponseBuilder{
public:
- StompResponseBuilder(){}
- virtual ~StompResponseBuilder(){}
+ StompResponseBuilder() {}
+ virtual ~StompResponseBuilder() {}
virtual transport::Response* buildResponse( const transport::Command* cmd );
virtual void buildIncomingCommands(
@@ -38,4 +38,4 @@
}}}
-#endif /*ACTIVEMQ_CONNECTOR_STOMP_STOMPRESPONSEBUILDER_H_*/
+#endif /*_ACTIVEMQ_CONNECTOR_STOMP_STOMPRESPONSEBUILDER_H_*/
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSelector.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSelector.cpp?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSelector.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSelector.cpp Sun Nov 11 08:52:45 2007
@@ -18,13 +18,15 @@
#include "StompSelector.h"
#include <activemq/util/Config.h>
-using namespace activemq::connector::stomp;
using namespace std;
+using namespace activemq;
+using namespace activemq::connector;
+using namespace activemq::connector::stomp;
////////////////////////////////////////////////////////////////////////////////
bool StompSelector::isSelected( const string& selector AMQCPP_UNUSED,
- cms::Message* msg AMQCPP_UNUSED)
-{
+ cms::Message* msg AMQCPP_UNUSED ) {
+
return true;
}
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSelector.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSelector.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSelector.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSelector.h Sun Nov 11 08:52:45 2007
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-#ifndef ACTIVEMQ_CONNECTOR_STOMP_STOMPSELECTOR_H_
-#define ACTIVEMQ_CONNECTOR_STOMP_STOMPSELECTOR_H_
+#ifndef _ACTIVEMQ_CONNECTOR_STOMP_STOMPSELECTOR_H_
+#define _ACTIVEMQ_CONNECTOR_STOMP_STOMPSELECTOR_H_
#include <cms/Message.h>
#include <string>
@@ -41,4 +41,4 @@
}}}
-#endif /*ACTIVEMQ_CONNECTOR_STOMP_STOMPSELECTOR_H_*/
+#endif /*_ACTIVEMQ_CONNECTOR_STOMP_STOMPSELECTOR_H_*/
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSessionInfo.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSessionInfo.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSessionInfo.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSessionInfo.h Sun Nov 11 08:52:45 2007
@@ -25,8 +25,7 @@
namespace connector{
namespace stomp{
- class StompSessionInfo : public SessionInfo
- {
+ class StompSessionInfo : public SessionInfo {
private:
// Acknowledge Mode of this Session
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSessionManager.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSessionManager.cpp?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSessionManager.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSessionManager.cpp Sun Nov 11 08:52:45 2007
@@ -46,80 +46,53 @@
////////////////////////////////////////////////////////////////////////////////
StompSessionManager::StompSessionManager( const std::string& connectionId,
Connector* connector,
- Transport* transport )
-{
- if( transport == NULL )
- {
+ Transport* transport ) {
+
+ if( transport == NULL ) {
throw NullPointerException(
__FILE__, __LINE__,
- "StompSessionManager::StompSessionManager" );
+ "StompSessionManager::StompSessionManager - Null param passed" );
}
this->transport = transport;
this->connector = connector;
this->connectionId = connectionId;
- this->nextSessionId = 0;
- this->nextConsumerId = 0;
this->messageListener = NULL;
}
////////////////////////////////////////////////////////////////////////////////
-StompSessionManager::~StompSessionManager(void)
-{
+StompSessionManager::~StompSessionManager() {
// NOTE - I am not cleaning out the ConsumerInfo objects in the
// map because it is really the job of the consumer to remove itself
// when it is destructed. If it doesn't then we would have problems,
- // but it's deleted after this object then we would
- // still have problems.
-}
-
-////////////////////////////////////////////////////////////////////////////////
-long long StompSessionManager::getNextSessionId(void)
-{
- synchronized( &mutex )
- {
- return nextSessionId++;
- }
-
- return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-long long StompSessionManager::getNextConsumerId(void)
-{
- synchronized( &mutex )
- {
- return nextConsumerId++;
- }
-
- return 0;
+ // but it's deleted after this object then we would still have problems.
}
////////////////////////////////////////////////////////////////////////////////
connector::SessionInfo* StompSessionManager::createSession(
cms::Session::AcknowledgeMode ackMode )
- throw ( exceptions::ActiveMQException )
-{
- try
- {
+ throw ( exceptions::ActiveMQException ) {
+
+ try{
+
SessionInfo* session = new StompSessionInfo( connector );
// Init data
session->setAckMode( ackMode );
session->setConnectionId( connectionId );
- session->setSessionId( getNextSessionId() );
+ session->setSessionId( this->nextSessionId.getNextSequenceId() );
return session;
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
void StompSessionManager::removeSession(
connector::SessionInfo* session AMQCPP_UNUSED)
- throw ( exceptions::ActiveMQException )
-{
+ throw ( exceptions::ActiveMQException ) {
// NO-op
}
@@ -129,10 +102,9 @@
SessionInfo* session,
const std::string& selector,
bool noLocal )
- throw( StompConnectorException )
-{
- try
- {
+ throw( StompConnectorException ) {
+
+ try{
// Delegate to the createDurableConsumer method, just pass the
// appropriate params so that a regular consumer is created on
// the broker side.
@@ -140,6 +112,7 @@
destination, session, "", selector, noLocal );
}
AMQ_CATCH_RETHROW( StompConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, StompConnectorException )
AMQ_CATCHALL_THROW( StompConnectorException )
}
@@ -157,7 +130,7 @@
// Initialize a new Consumer info Message
StompConsumerInfo* consumer = new StompConsumerInfo( connector );
- consumer->setConsumerId( getNextConsumerId() );
+ consumer->setConsumerId( this->nextConsumerId.getNextSequenceId() );
consumer->setDestination( destination );
consumer->setMessageSelector( selector );
consumer->setSessionInfo( session );
@@ -167,6 +140,7 @@
return consumer;
}
AMQ_CATCH_RETHROW( StompConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, StompConnectorException )
AMQ_CATCHALL_THROW( StompConnectorException )
}
@@ -178,7 +152,9 @@
StompConsumerInfo* stompConsumer = dynamic_cast<StompConsumerInfo*>(consumer);
if( stompConsumer == NULL ) {
- throw StompConnectorException(__FILE__, __LINE__,
+ throw StompConnectorException(
+ __FILE__, __LINE__,
+ "StompSessionManager::startConsumer - "
"ConsumerInfo is not of type created by this connector" );
}
@@ -239,6 +215,7 @@
}
}
AMQ_CATCH_RETHROW( StompConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, StompConnectorException )
AMQ_CATCHALL_THROW( StompConnectorException )
}
@@ -284,15 +261,16 @@
}
}
AMQ_CATCH_RETHROW( StompConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, StompConnectorException )
AMQ_CATCHALL_THROW( StompConnectorException )
}
////////////////////////////////////////////////////////////////////////////////
void StompSessionManager::onStompCommand( commands::StompCommand* command )
- throw ( StompConnectorException )
-{
- try
- {
+ throw ( StompConnectorException ) {
+
+ try{
+
cms::Message* message = dynamic_cast<cms::Message*>( command );
if( message == NULL ) {
@@ -328,8 +306,8 @@
if( StompSelector::isSelected(
consumerInfo->getMessageSelector(),
- message ) )
- {
+ message ) ) {
+
ActiveMQMessage* msg =
dynamic_cast<ActiveMQMessage*>( message );
messageListener->onConsumerMessage( consumerInfo, msg );
@@ -364,21 +342,21 @@
}
AMQ_CATCH_RETHROW( StompConnectorException )
AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, StompConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, StompConnectorException )
AMQ_CATCHALL_THROW( StompConnectorException )
}
////////////////////////////////////////////////////////////////////////////////
void StompSessionManager::setSubscribeOptions( const cms::Destination* dest,
SubscribeCommand& command )
- throw ( StompConnectorException )
-{
- try
- {
+ throw ( StompConnectorException ) {
+
+ try{
+
// Get the properties of this destination
const cms::CMSProperties& destProperties = dest->getCMSProperties();
- if( destProperties.isEmpty() )
- {
+ if( destProperties.isEmpty() ) {
// Nothing to do, so save some work and quit now.
return;
}
@@ -387,8 +365,7 @@
ActiveMQConstants::toString(
ActiveMQConstants::CONSUMER_NOLOCAL );
- if( destProperties.hasProperty( noLocalStr ) )
- {
+ if( destProperties.hasProperty( noLocalStr ) ) {
command.setNoLocal(
Boolean::parseBoolean(
destProperties.getProperty( noLocalStr ) ) );
@@ -398,8 +375,7 @@
ActiveMQConstants::toString(
ActiveMQConstants::CONSUMER_SELECTOR );
- if( destProperties.hasProperty( selectorStr ) )
- {
+ if( destProperties.hasProperty( selectorStr ) ) {
command.setMessageSelector(
destProperties.getProperty( selectorStr ) );
}
@@ -408,8 +384,7 @@
ActiveMQConstants::toString(
ActiveMQConstants::CONSUMER_PRIORITY );
- if( destProperties.hasProperty( priorityStr ) )
- {
+ if( destProperties.hasProperty( priorityStr ) ) {
command.setPriority(
Integer::parseInt(
destProperties.getProperty( priorityStr ) ) );
@@ -419,8 +394,7 @@
ActiveMQConstants::toString(
ActiveMQConstants::CONSUMER_DISPATCHASYNC );
- if( destProperties.hasProperty( dispatchAsyncStr ) )
- {
+ if( destProperties.hasProperty( dispatchAsyncStr ) ) {
command.setDispatchAsync(
Boolean::parseBoolean(
destProperties.getProperty( dispatchAsyncStr ) ) );
@@ -430,8 +404,7 @@
ActiveMQConstants::toString(
ActiveMQConstants::CONSUMER_EXCLUSIVE );
- if( destProperties.hasProperty( exclusiveStr ) )
- {
+ if( destProperties.hasProperty( exclusiveStr ) ) {
command.setExclusive(
Boolean::parseBoolean(
destProperties.getProperty( exclusiveStr ) ) );
@@ -441,8 +414,7 @@
ActiveMQConstants::toString(
ActiveMQConstants::CUNSUMER_MAXPENDINGMSGLIMIT );
- if( destProperties.hasProperty( maxPendingMsgLimitStr ) )
- {
+ if( destProperties.hasProperty( maxPendingMsgLimitStr ) ) {
command.setMaxPendingMsgLimit(
Integer::parseInt(
destProperties.getProperty( maxPendingMsgLimitStr ) ) );
@@ -452,8 +424,7 @@
ActiveMQConstants::toString(
ActiveMQConstants::CONSUMER_PREFECTCHSIZE );
- if( destProperties.hasProperty( prefetchSizeStr ) )
- {
+ if( destProperties.hasProperty( prefetchSizeStr ) ) {
command.setPrefetchSize(
Integer::parseInt(
destProperties.getProperty( prefetchSizeStr ) ) );
@@ -463,8 +434,7 @@
ActiveMQConstants::toString(
ActiveMQConstants::CONSUMER_RETROACTIVE );
- if( destProperties.hasProperty( retroactiveStr ) )
- {
+ if( destProperties.hasProperty( retroactiveStr ) ) {
command.setRetroactive(
Boolean::parseBoolean(
destProperties.getProperty( retroactiveStr ) ) );
@@ -472,5 +442,6 @@
}
AMQ_CATCH_RETHROW( StompConnectorException )
AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, StompConnectorException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, StompConnectorException )
AMQ_CATCHALL_THROW( StompConnectorException )
}
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSessionManager.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSessionManager.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSessionManager.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompSessionManager.h Sun Nov 11 08:52:45 2007
@@ -18,10 +18,12 @@
#ifndef _ACTIVEMQ_CONNECTOR_STOMP_STOMPSESSIONMANAGER_H_
#define _ACTIVEMQ_CONNECTOR_STOMP_STOMPSESSIONMANAGER_H_
+#include <decaf/util/concurrent/Mutex.h>
+
+#include <activemq/util/LongSequenceGenerator.h>
#include <activemq/connector/SessionInfo.h>
#include <activemq/connector/ConsumerInfo.h>
#include <activemq/transport/Transport.h>
-#include <decaf/util/concurrent/Mutex.h>
#include <activemq/connector/ConnectorException.h>
#include <activemq/connector/Connector.h>
#include <activemq/connector/stomp/StompCommandListener.h>
@@ -41,8 +43,7 @@
* so that a transactional session can manage the lifetime of the
* message.
*/
- class StompSessionManager : public StompCommandListener
- {
+ class StompSessionManager : public StompCommandListener {
private:
// Map Types
@@ -52,10 +53,10 @@
private:
// Next id to be used for a Session Id
- long long nextSessionId;
+ util::LongSequenceGenerator nextSessionId;
// Next id to be used for a Consumer Id
- long long nextConsumerId;
+ util::LongSequenceGenerator nextConsumerId;
// Mutex to protect ids.
decaf::util::concurrent::Mutex mutex;
@@ -169,8 +170,7 @@
* @param listener the observer.
*/
virtual void setConsumerMessageListener(
- ConsumerMessageListener* listener )
- {
+ ConsumerMessageListener* listener ) {
this->messageListener = listener;
}
@@ -195,20 +195,6 @@
virtual void setSubscribeOptions( const cms::Destination* destination,
commands::SubscribeCommand& command )
throw ( StompConnectorException );
-
- protected:
-
- /**
- * Gets the Next Session Id
- * @return unique session id
- */
- virtual long long getNextSessionId();
-
- /**
- * Gets the Next Session Id
- * @return unique session id
- */
- virtual long long getNextConsumerId();
};
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompTopic.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompTopic.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompTopic.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompTopic.h Sun Nov 11 08:52:45 2007
@@ -26,8 +26,7 @@
namespace connector{
namespace stomp{
- class StompTopic : public StompDestination<cms::Topic>
- {
+ class StompTopic : public StompDestination<cms::Topic> {
public:
/**
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompTransactionInfo.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompTransactionInfo.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompTransactionInfo.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompTransactionInfo.h Sun Nov 11 08:52:45 2007
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef ACTIVEMQ_CONNECTOR_STOMPTRANSACTIONINFO_H_
-#define ACTIVEMQ_CONNECTOR_STOMPTRANSACTIONINFO_H_
+#ifndef _ACTIVEMQ_CONNECTOR_STOMPTRANSACTIONINFO_H_
+#define _ACTIVEMQ_CONNECTOR_STOMPTRANSACTIONINFO_H_
#include <activemq/connector/TransactionInfo.h>
#include <activemq/connector/SessionInfo.h>
@@ -24,8 +24,7 @@
namespace connector{
namespace stomp{
- class StompTransactionInfo : public TransactionInfo
- {
+ class StompTransactionInfo : public TransactionInfo {
private:
// Transaction Id
@@ -89,4 +88,4 @@
}}}
-#endif /*ACTIVEMQ_CONNECTOR_STOMPTRANSACTIONINFO_H_*/
+#endif /*_ACTIVEMQ_CONNECTOR_STOMPTRANSACTIONINFO_H_*/
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/AbortCommand.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/AbortCommand.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/AbortCommand.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/AbortCommand.h Sun Nov 11 08:52:45 2007
@@ -31,18 +31,19 @@
* Represents the Stomp Abort Command which rolls back a
* transaction in progress.
*/
- class AbortCommand : public AbstractCommand< transport::Command >
- {
+ class AbortCommand : public AbstractCommand< transport::Command > {
public:
AbortCommand() :
AbstractCommand<transport::Command>() {
initialize( getFrame() );
}
+
AbortCommand( StompFrame* frame ) :
AbstractCommand<transport::Command>(frame) {
validate( getFrame() );
}
+
virtual ~AbortCommand(void) {}
/**
@@ -60,8 +61,7 @@
* frame with data appropriate for the command type.
* @param frame the Frame to init
*/
- virtual void initialize( StompFrame& frame )
- {
+ virtual void initialize( StompFrame& frame ) {
frame.setCommand( CommandConstants::toString(
CommandConstants::ABORT ) );
}
@@ -72,14 +72,14 @@
* @param frame the Frame to validate
* @returns true if frame is valid
*/
- virtual bool validate( const StompFrame& frame ) const
- {
+ virtual bool validate( const StompFrame& frame ) const {
+
if((frame.getCommand() ==
CommandConstants::toString( CommandConstants::ABORT ) ) &&
(frame.getProperties().hasProperty(
CommandConstants::toString(
- CommandConstants::HEADER_TRANSACTIONID ) ) ) )
- {
+ CommandConstants::HEADER_TRANSACTIONID ) ) ) ) {
+
return true;
}
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/AbstractCommand.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/AbstractCommand.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/AbstractCommand.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/AbstractCommand.h Sun Nov 11 08:52:45 2007
@@ -43,11 +43,8 @@
* more user-friendly interface to the frame content.
*/
template<typename T>
- class AbstractCommand
- :
- public StompCommand,
- public T
- {
+ class AbstractCommand : public StompCommand,
+ public T {
protected:
// Frame that contains the actual message
@@ -173,7 +170,7 @@
* require it.
* @param id Command Id
*/
- virtual void setCommandId( int id AMQCPP_UNUSED){
+ virtual void setCommandId( int id AMQCPP_UNUSED ){
/* do nothing */
}
@@ -204,7 +201,7 @@
virtual bool isResponseRequired() const {
return frame->getProperties().hasProperty(
CommandConstants::toString(
- CommandConstants::HEADER_REQUESTID) );
+ CommandConstants::HEADER_REQUESTID ) );
}
/**
@@ -226,7 +223,7 @@
virtual void setCorrelationId( int corrId ) {
setPropertyValue(
CommandConstants::toString(
- CommandConstants::HEADER_RESPONSEID),
+ CommandConstants::HEADER_RESPONSEID ),
decaf::lang::Integer::toString( corrId ) );
}
@@ -247,7 +244,7 @@
virtual void setTransactionId( const std::string& id ){
setPropertyValue(
CommandConstants::toString(
- CommandConstants::HEADER_TRANSACTIONID),
+ CommandConstants::HEADER_TRANSACTIONID ),
id );
}
@@ -268,15 +265,19 @@
* in a state that can be marshaled.
*/
virtual const StompFrame& marshal()
- throw (marshal::MarshalException)
- {
- if( frame == NULL || !validate( *frame ) ){
- throw marshal::MarshalException(
- __FILE__, __LINE__,
- "AbstractCommand::marshal() - frame invalid" );
- }
+ throw ( marshal::MarshalException ) {
+
+ try{
+ if( frame == NULL || !validate( *frame ) ){
+ throw marshal::MarshalException(
+ __FILE__, __LINE__,
+ "AbstractCommand::marshal() - frame invalid" );
+ }
- return getFrame();
+ return getFrame();
+ }
+ AMQ_CATCH_RETHROW( marshal::MarshalException )
+ AMQ_CATCHALL_THROW( marshal::MarshalException )
}
/**
@@ -319,14 +320,11 @@
* @param setContentLength true if the content length header should
* be set
*/
- virtual void setBytes( const unsigned char* bytes,
- std::size_t numBytes )
- {
+ virtual void setBytes( const unsigned char* bytes, std::size_t numBytes ) {
getFrame().setBody( bytes, numBytes );
}
- virtual void setBytes( const std::vector<unsigned char>& bytes )
- {
+ virtual void setBytes( const std::vector<unsigned char>& bytes ) {
getFrame().getBody() = bytes;
}
};
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/AckCommand.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/AckCommand.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/AckCommand.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/AckCommand.h Sun Nov 11 08:52:45 2007
@@ -35,18 +35,19 @@
* Optionally a Transaction Id can be set that indicates that the
* message acknowledgement should be part of a named transaction.
*/
- class AckCommand : public AbstractCommand< transport::Command >
- {
+ class AckCommand : public AbstractCommand< transport::Command > {
public:
AckCommand() :
AbstractCommand<transport::Command>() {
initialize( getFrame() );
}
+
AckCommand( StompFrame* frame ) :
AbstractCommand<transport::Command>( frame ) {
validate( getFrame() );
}
+
virtual ~AckCommand() {}
/**
@@ -85,8 +86,7 @@
* frame with data appropriate for the command type.
* @param frame Frame to init
*/
- virtual void initialize( StompFrame& frame )
- {
+ virtual void initialize( StompFrame& frame ) {
frame.setCommand( CommandConstants::toString(
CommandConstants::ACK ) );
}
@@ -97,8 +97,8 @@
* @param frame Frame to validate
* @returns true if frame is valid
*/
- virtual bool validate( const StompFrame& frame ) const
- {
+ virtual bool validate( const StompFrame& frame ) const {
+
// Make sure the message is an ACK message.
bool isAck = frame.getCommand() ==
CommandConstants::toString( CommandConstants::ACK );
@@ -108,8 +108,7 @@
CommandConstants::toString(
CommandConstants::HEADER_MESSAGEID ) );
- if( isAck && hasMessageId )
- {
+ if( isAck && hasMessageId ) {
return true;
}
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/BeginCommand.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/BeginCommand.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/BeginCommand.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/BeginCommand.h Sun Nov 11 08:52:45 2007
@@ -36,8 +36,7 @@
* A transaction Identifier is required and this id will be used
* for all sends, commits, aborts, or acks.
*/
- class BeginCommand : public AbstractCommand< transport::Command >
- {
+ class BeginCommand : public AbstractCommand< transport::Command > {
public:
BeginCommand() :
@@ -67,8 +66,7 @@
* frame with data appropriate for the command type.
* @param frame Frame to init
*/
- virtual void initialize( StompFrame& frame )
- {
+ virtual void initialize( StompFrame& frame ) {
frame.setCommand( CommandConstants::toString(
CommandConstants::BEGIN ) );
}
@@ -79,8 +77,8 @@
* @param frame Frame to validate
* @returns true if frame is valid
*/
- virtual bool validate( const StompFrame& frame ) const
- {
+ virtual bool validate( const StompFrame& frame ) const {
+
if((frame.getCommand() ==
CommandConstants::toString( CommandConstants::BEGIN )) &&
(frame.getProperties().hasProperty(