Author: tabish
Date: Wed Jan 7 08:46:41 2009
New Revision: 732395
URL: http://svn.apache.org/viewvc?rev=732395&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-100
Some initial refactoring work that leads to V3 and addition of Failover.
Added:
activemq/activemq-cpp/trunk/src/main/activemq/library/
activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.cpp
(with props)
activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.h (with
props)
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatNegotiator.h
(with props)
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatRegistry.cpp
(with props)
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatRegistry.h
(with props)
activemq/activemq-cpp/trunk/src/test/activemq/wireformat/WireFormatRegistryTest.cpp
(with props)
activemq/activemq-cpp/trunk/src/test/activemq/wireformat/WireFormatRegistryTest.h
(with props)
Removed:
activemq/activemq-cpp/trunk/src/main/activemq/support/
Modified:
activemq/activemq-cpp/trunk/src/main/Makefile.am
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireConnector.cpp
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormat.cpp
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormat.h
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormatNegotiator.cpp
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormatNegotiator.h
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormat.h
activemq/activemq-cpp/trunk/src/test-benchmarks/main.cpp
activemq/activemq-cpp/trunk/src/test-integration/main.cpp
activemq/activemq-cpp/trunk/src/test/Makefile.am
activemq/activemq-cpp/trunk/src/test/main.cpp
activemq/activemq-cpp/trunk/src/test/testRegistry.cpp
Modified: activemq/activemq-cpp/trunk/src/main/Makefile.am
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/Makefile.am?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/main/Makefile.am Wed Jan 7 08:46:41 2009
@@ -16,6 +16,7 @@
# ---------------------------------------------------------------------------
cc_sources = \
+ activemq/library/ActiveMQCPP.cpp \
activemq/io/LoggingInputStream.cpp \
activemq/io/LoggingOutputStream.cpp \
activemq/exceptions/ActiveMQException.cpp \
@@ -40,7 +41,6 @@
activemq/core/ActiveMQProducer.cpp \
activemq/core/ActiveMQConnectionFactory.cpp \
activemq/core/ActiveMQSessionExecutor.cpp \
- activemq/support/InitDirector.cpp \
activemq/connector/stomp/StompSessionManager.cpp \
activemq/connector/stomp/commands/CommandConstants.cpp \
activemq/connector/stomp/StompCommandReader.cpp \
@@ -82,6 +82,7 @@
activemq/transport/filters/TcpTransportFactory.cpp \
activemq/transport/filters/LoggingTransport.cpp \
activemq/transport/filters/LoggingTransportFactory.cpp \
+ activemq/wireformat/WireFormatRegistry.cpp \
decaf/internal/DecafRuntime.cpp \
decaf/internal/AprPool.cpp \
decaf/internal/util/ByteArrayAdapter.cpp \
@@ -156,6 +157,7 @@
decaf/nio/ShortBuffer.cpp
h_sources = \
+ activemq/library/ActiveMQCPP.h \
activemq/core/ActiveMQProducer.h \
activemq/core/ActiveMQMessage.h \
activemq/core/ActiveMQConnectionData.h \
@@ -182,8 +184,6 @@
activemq/cmsutil/ResourceLifecycleManager.h \
activemq/cmsutil/SessionCallback.h \
activemq/cmsutil/SessionPool.h \
- activemq/support/LibraryInit.h \
- activemq/support/InitDirector.h \
activemq/io/LoggingInputStream.h \
activemq/io/LoggingOutputStream.h \
activemq/exceptions/ActiveMQException.h \
@@ -290,6 +290,10 @@
activemq/util/PrimitiveList.h \
activemq/util/URISupport.h \
activemq/util/MemoryUsage.h \
+ activemq/wireformat/WireFormat.h \
+ activemq/wireformat/WireFormatNegotiator.h \
+ activemq/wireformat/WireFormatFactory.h \
+ activemq/wireformat/WireFormatRegistry.h \
cms/DeliveryMode.h \
cms/TemporaryQueue.h \
cms/MapMessage.h \
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireConnector.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireConnector.cpp?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireConnector.cpp
(original)
+++
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireConnector.cpp
Wed Jan 7 08:46:41 2009
@@ -123,7 +123,7 @@
this->properties.copy( &properties );
this->wireFormat = dynamic_cast<OpenWireFormat*>(
wireFormatFactory.createWireFormat( properties ) );
- this->transport = new OpenWireFormatNegotiator( wireFormat, transport,
false );
+ this->transport = this->wireFormat->createNegotiator( transport );
// Observe the transport for events.
this->transport->setCommandListener( this );
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormat.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormat.cpp?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormat.cpp
(original)
+++
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormat.cpp
Wed Jan 7 08:46:41 2009
@@ -23,6 +23,7 @@
#include <decaf/util/UUID.h>
#include <decaf/lang/Math.h>
#include <decaf/io/ByteArrayOutputStream.h>
+#include <activemq/connector/openwire/OpenWireFormatNegotiator.h>
#include <activemq/connector/openwire/utils/BooleanStream.h>
#include <activemq/connector/openwire/commands/WireFormatInfo.h>
#include <activemq/connector/openwire/commands/DataStructure.h>
@@ -88,6 +89,17 @@
}
////////////////////////////////////////////////////////////////////////////////
+WireFormatNegotiator* OpenWireFormat::createNegotiator( transport::Transport*
transport )
+ throw( decaf::lang::exceptions::UnsupportedOperationException ) {
+
+ try{
+ return new OpenWireFormatNegotiator( this, transport, false );
+ }
+ AMQ_CATCH_RETHROW( UnsupportedOperationException )
+ AMQ_CATCHALL_THROW( UnsupportedOperationException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
void OpenWireFormat::destroyMarshalers() {
try {
for( size_t i = 0; i < dataMarshallers.size(); ++i ) {
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormat.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormat.h?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormat.h
(original)
+++
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormat.h
Wed Jan 7 08:46:41 2009
@@ -45,6 +45,23 @@
virtual ~OpenWireFormat();
/**
+ * Returns true if this WireFormat has a Negotiator that needs to wrap
the
+ * Transport that uses it.
+ * @returns true if the WireFormat provides a Negotiator.
+ */
+ virtual bool hasNegotiator() const {
+ return true;
+ }
+
+ /**
+ * If the Transport Provides a Negotiator this method will create and
return
+ * a news instance of the Negotiator.
+ * @returns new instance of a WireFormatNegotiator.
+ */
+ virtual wireformat::WireFormatNegotiator* createNegotiator(
transport::Transport* transport )
+ throw( decaf::lang::exceptions::UnsupportedOperationException );
+
+ /**
* Allows an external source to add marshallers to this object for
* types that may be marshalled or unmarhsalled.
* @param marshaller - the Marshaller to add to the collection.
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormatNegotiator.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormatNegotiator.cpp?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormatNegotiator.cpp
(original)
+++
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormatNegotiator.cpp
Wed Jan 7 08:46:41 2009
@@ -24,6 +24,7 @@
using namespace std;
using namespace activemq;
using namespace activemq::exceptions;
+using namespace activemq::wireformat;
using namespace activemq::transport;
using namespace activemq::connector;
using namespace activemq::connector::openwire;
@@ -35,7 +36,7 @@
OpenWireFormatNegotiator::OpenWireFormatNegotiator( OpenWireFormat*
openWireFormat,
Transport* next,
bool own ) :
- TransportFilter( next, own ),
+ WireFormatNegotiator( next, own ),
wireInfoSentDownLatch(1),
readyCountDownLatch(1)
{
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormatNegotiator.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormatNegotiator.h?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormatNegotiator.h
(original)
+++
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/OpenWireFormatNegotiator.h
Wed Jan 7 08:46:41 2009
@@ -22,6 +22,7 @@
#include <activemq/transport/TransportFilter.h>
#include <activemq/transport/Command.h>
#include <activemq/connector/openwire/OpenWireFormat.h>
+#include <activemq/wireformat/WireFormatNegotiator.h>
#include <decaf/util/concurrent/Mutex.h>
#include <decaf/util/concurrent/CountDownLatch.h>
#include <decaf/util/concurrent/Concurrent.h>
@@ -31,7 +32,7 @@
namespace connector{
namespace openwire{
- class AMQCPP_API OpenWireFormatNegotiator : public
transport::TransportFilter {
+ class AMQCPP_API OpenWireFormatNegotiator : public
wireformat::WireFormatNegotiator {
private:
/**
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp
(original)
+++
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp
Wed Jan 7 08:46:41 2009
@@ -24,7 +24,6 @@
#include <activemq/transport/TransportBuilder.h>
#include <activemq/core/ActiveMQConnection.h>
#include <activemq/core/ActiveMQConstants.h>
-#include <activemq/support/LibraryInit.h>
#include <memory>
using namespace std;
Added: activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.cpp?rev=732395&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.cpp
(added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.cpp Wed
Jan 7 08:46:41 2009
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ActiveMQCPP.h"
+
+#include <decaf/lang/Runtime.h>
+#include <activemq/wireformat/WireFormatRegistry.h>
+#include <activemq/connector/openwire/OpenWireFormatFactory.h>
+
+#include <activemq/transport/IOTransportFactory.h>
+#include <activemq/transport/mock/MockTransportFactory.h>
+#include <activemq/transport/filters/AsyncSendTransportFactory.h>
+#include <activemq/transport/filters/TcpTransportFactory.h>
+#include <activemq/transport/filters/LoggingTransportFactory.h>
+#include <activemq/transport/filters/ResponseCorrelatorFactory.h>
+#include <activemq/connector/stomp/StompConnectorFactory.h>
+#include <activemq/connector/openwire/OpenWireConnectorFactory.h>
+
+using namespace activemq;
+using namespace activemq::library;
+using namespace activemq::wireformat;
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQCPP::initializeLibrary() {
+
+ // Initialize the Decaf Library by requesting its runtime.
+ decaf::lang::Runtime::getRuntime();
+
+ connector::stomp::StompConnectorFactory::getInstance();
+ connector::openwire::OpenWireConnectorFactory::getInstance();
+ transport::filters::TcpTransportFactory::getInstance();
+ transport::filters::AsyncSendTransportFactory::getInstance();
+ transport::filters::LoggingTransportFactory::getInstance();
+ transport::filters::ResponseCorrelatorFactory::getInstance();
+ transport::IOTransportFactory::getInstance();
+ transport::mock::MockTransportFactory::getInstance();
+
+ // Register all WireFormats
+ ActiveMQCPP::registerWireFormats();
+
+ // Registr all Transports
+ ActiveMQCPP::registerTransports();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQCPP::shutdownLibrary() {
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQCPP::registerWireFormats() {
+
+ // Each of the internally implemented WireFormat's is registered here
+ // with the WireFormat Registry
+
+ WireFormatRegistry::getInstance().registerFactory(
+ "openwire", new connector::openwire::OpenWireFormatFactory() );
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQCPP::registerTransports() {
+
+}
Propchange:
activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.h?rev=732395&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.h (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.h Wed Jan
7 08:46:41 2009
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQ_LIBRARY_ACTIVEMQCPP_H_
+#define _ACTIVEMQ_LIBRARY_ACTIVEMQCPP_H_
+
+#include <activemq/util/Config.h>
+
+namespace activemq {
+namespace library {
+
+ class AMQCPP_API ActiveMQCPP {
+ protected:
+
+ ActiveMQCPP() {};
+ ActiveMQCPP( const ActiveMQCPP& );
+ ActiveMQCPP& operator= ( const ActiveMQCPP& );
+
+ public:
+
+ virtual ~ActiveMQCPP() {}
+
+ /**
+ * Initialize the ActiveMQ-CPP Library constructs, this method will
+ * init all the internal Registry objects and initialize the Decaf
+ * library.
+ */
+ static void initializeLibrary();
+
+ /**
+ * Shutdown the ActiveMQ-CPP Library, freeing any resources
+ * that could not be freed up to this point. All the user created
+ * ActiveMQ-CPP objects and Decaf Library objects should have been
+ * destroyed by the time this method is called.
+ */
+ static void shutdownLibrary();
+
+ private:
+
+ static void registerWireFormats();
+ static void registerTransports();
+
+ };
+
+}}
+
+#endif /* _ACTIVEMQ_LIBRARY_ACTIVEMQCPP_H_ */
Propchange: activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormat.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormat.h?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormat.h
(original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormat.h Wed
Jan 7 08:46:41 2009
@@ -24,10 +24,15 @@
#include <activemq/util/Config.h>
#include <activemq/transport/Command.h>
+#include <activemq/transport/Transport.h>
+
+#include <decaf/lang/exceptions/UnsupportedOperationException.h>
namespace activemq{
namespace wireformat{
+ class WireFormatNegotiator;
+
/**
* Provides a mechanism to marshal commands into and out of packets
* or into and out of streams, Channels and Datagrams.
@@ -69,6 +74,22 @@
*/
virtual int getVersion() const = 0;
+ /**
+ * Returns true if this WireFormat has a Negotiator that needs to wrap
the
+ * Transport that uses it.
+ * @returns true if the WireFormat provides a Negotiator.
+ */
+ virtual bool hasNegotiator() const = 0;
+
+ /**
+ * If the Transport Provides a Negotiator this method will create and
return
+ * a news instance of the Negotiator.
+ * @returns new instance of a WireFormatNegotiator.
+ * @throws UnsupportedOperationException if the WireFormat doesn't
have a Negotiator.
+ */
+ virtual WireFormatNegotiator* createNegotiator( transport::Transport*
transport )
+ throw( decaf::lang::exceptions::UnsupportedOperationException ) =
0;
+
};
}}
Added:
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatNegotiator.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatNegotiator.h?rev=732395&view=auto
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatNegotiator.h
(added)
+++
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatNegotiator.h
Wed Jan 7 08:46:41 2009
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQ_WIREFORMAT_WIREFORMATNEGOTIATOR_H_
+#define _ACTIVEMQ_WIREFORMAT_WIREFORMATNEGOTIATOR_H_
+
+#include <activemq/util/Config.h>
+#include <activemq/transport/TransportFilter.h>
+
+namespace activemq {
+namespace wireformat {
+
+ /**
+ * Defines a WireFormatNegotiator which allows a WireFormat to
+ */
+ class AMQCPP_API WireFormatNegotiator : public
activemq::transport::TransportFilter {
+ public:
+
+ /**
+ * Constructor.
+ * @param next - the next Transport in the chain
+ * @param own - true if this filter owns the next and should delete it
+ */
+ WireFormatNegotiator( Transport* next, const bool own = true ) :
+ transport::TransportFilter( next, own ) {}
+
+ virtual ~WireFormatNegotiator() {}
+
+ };
+
+}}
+
+#endif /* _ACTIVEMQ_WIREFORMAT_WIREFORMATNEGOTIATOR_H_ */
Propchange:
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatNegotiator.h
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatRegistry.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatRegistry.cpp?rev=732395&view=auto
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatRegistry.cpp
(added)
+++
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatRegistry.cpp
Wed Jan 7 08:46:41 2009
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "WireFormatRegistry.h"
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::wireformat;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+WireFormatRegistry::WireFormatRegistry() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+WireFormatRegistry::~WireFormatRegistry() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+const WireFormatFactory* WireFormatRegistry::findFactory( const std::string&
name ) const
+ throw( decaf::lang::exceptions::NoSuchElementException ) {
+
+ if( !this->registry.containsKey( name ) ) {
+ throw NoSuchElementException( __FILE__, __LINE__,
+ "No Matching Factory Registered for format := %s", name.c_str() );
+ }
+
+ return this->registry.getValue( name );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void WireFormatRegistry::registerFactory( const std::string& name,
WireFormatFactory* factory )
+ throw( decaf::lang::exceptions::IllegalArgumentException,
+ decaf::lang::exceptions::NullPointerException ) {
+
+ if( name == "" ) {
+ throw IllegalArgumentException( __FILE__, __LINE__,
+ "WireFormatFactory name cannot be the empty string" );
+ }
+
+ if( factory == NULL ) {
+ throw NullPointerException( __FILE__, __LINE__,
+ "Supplied WireFormatFactory pointer was NULL" );
+ }
+
+ this->registry.setValue( name, factory );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::vector<std::string> WireFormatRegistry::getWireFormatNames() const {
+ return this->registry.getKeys();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+WireFormatRegistry& WireFormatRegistry::getInstance() {
+ static WireFormatRegistry registry;
+ return registry;
+}
Propchange:
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatRegistry.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatRegistry.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatRegistry.h?rev=732395&view=auto
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatRegistry.h
(added)
+++
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatRegistry.h
Wed Jan 7 08:46:41 2009
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQ_WIREFORMAT_WIREFORMATREGISTRY_H_
+#define _ACTIVEMQ_WIREFORMAT_WIREFORMATREGISTRY_H_
+
+#include <activemq/util/Config.h>
+
+#include <string>
+#include <vector>
+#include <activemq/wireformat/WireFormatFactory.h>
+
+#include <decaf/util/Map.h>
+#include <decaf/lang/exceptions/NoSuchElementException.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/lang/exceptions/IllegalArgumentException.h>
+
+namespace activemq {
+namespace wireformat {
+
+ /**
+ * Registry of all WireFormat Factories that are available to the client
+ * at runtime. New WireFormat's must have a factory registered here before
+ * a connection attempt is made.
+ */
+ class AMQCPP_API WireFormatRegistry {
+ private:
+
+ decaf::util::Map<std::string, WireFormatFactory*> registry;
+
+ public:
+
+ WireFormatRegistry();
+
+ virtual ~WireFormatRegistry();
+
+ /**
+ * Gets a Registered WireFormatFactory from the Registry and returns it
+ * if there is not a registered format factory with the given name an
exception
+ * is thrown.
+ *
+ * @param name
+ * The name of the Factory to find in the Registry.
+ *
+ * @returns the Factory registered under the given name.
+ *
+ * @throws NoSuchElementException if no factory is registered with
that name.
+ */
+ const WireFormatFactory* findFactory( const std::string& name ) const
+ throw( decaf::lang::exceptions::NoSuchElementException );
+
+ /**
+ * Registers a new WireFormatFactory with this Registry. If a Factory
with the
+ * given name is already registered it is overwritten with the new
one. Once a
+ * factory is added to the Registry its lifetime is controlled by the
Registry, it
+ * will be deleted once the Registry has been deleted.
+ *
+ * @param name
+ * The name of the new Factory to register.
+ * @param factory
+ * The new Factory to add to the Registry.
+ *
+ * @throws IllegalArgumentException is name is the empty string.
+ * @throws NullPointerException if the Factory is Null.
+ */
+ void registerFactory( const std::string& name, WireFormatFactory*
factory )
+ throw( decaf::lang::exceptions::IllegalArgumentException,
+ decaf::lang::exceptions::NullPointerException );
+
+ /**
+ * Retrieves a list of the names of all the Registered WireFormat's in
this
+ * Registry.
+ *
+ * @returns stl vector of strings with all the WireFormat names
registered.
+ */
+ std::vector<std::string> getWireFormatNames() const;
+
+ /**
+ * Gets the single instance of the WireFormatRegistry
+ * @return reference to the single instance of this Registry
+ */
+ static WireFormatRegistry& getInstance();
+
+ };
+
+}}
+
+#endif /* _ACTIVEMQ_WIREFORMAT_WIREFORMATREGISTRY_H_ */
Propchange:
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/WireFormatRegistry.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/activemq-cpp/trunk/src/test-benchmarks/main.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-benchmarks/main.cpp?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-benchmarks/main.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test-benchmarks/main.cpp Wed Jan 7
08:46:41 2009
@@ -19,9 +19,13 @@
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/TestResult.h>
#include <activemq/util/Config.h>
+#include <activemq/library/ActiveMQCPP.h>
#include <iostream>
int main( int argc AMQCPP_UNUSED, char **argv AMQCPP_UNUSED ) {
+
+ activemq::library::ActiveMQCPP::initializeLibrary();
+
try {
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry =
@@ -38,10 +42,15 @@
std::cout << "Finished with the Benchmarks." << std::endl;
std::cout << "=====================================================\n";
+ activemq::library::ActiveMQCPP::shutdownLibrary();
+
return !wasSuccessful;
+
} catch(...) {
std::cout << "----------------------------------------" << std::endl;
std::cout << "- AN ERROR HAS OCCURED: -" << std::endl;
std::cout << "----------------------------------------" << std::endl;
+
+ activemq::library::ActiveMQCPP::shutdownLibrary();
}
}
Modified: activemq/activemq-cpp/trunk/src/test-integration/main.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/main.cpp?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/main.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test-integration/main.cpp Wed Jan 7
08:46:41 2009
@@ -20,28 +20,34 @@
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/TestResult.h>
#include <activemq/util/Config.h>
+#include <activemq/library/ActiveMQCPP.h>
#include <iostream>
-int main( int argc AMQCPP_UNUSED, char **argv AMQCPP_UNUSED)
-{
- try
- {
+int main( int argc AMQCPP_UNUSED, char **argv AMQCPP_UNUSED ) {
+
+ activemq::library::ActiveMQCPP::initializeLibrary();
+
+ try {
+
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry =
CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
-
+
// Shows a message as each test starts
CppUnit::BriefTestProgressListener listener;
runner.eventManager().addListener( &listener );
-
+
bool wasSuccessful = runner.run( "", false );
+ activemq::library::ActiveMQCPP::shutdownLibrary();
+
return !wasSuccessful;
}
catch(...) {
std::cout << "----------------------------------------" << std::endl;
std::cout << "- AN ERROR HAS OCCURED: -" << std::endl;
std::cout << "- Do you have a Broker Running? -" << std::endl;
- std::cout << "----------------------------------------" << std::endl;
+ std::cout << "----------------------------------------" << std::endl;
+ activemq::library::ActiveMQCPP::shutdownLibrary();
}
}
Modified: activemq/activemq-cpp/trunk/src/test/Makefile.am
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/Makefile.am?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/test/Makefile.am Wed Jan 7 08:46:41 2009
@@ -77,6 +77,7 @@
activemq/util/URISupportTest.cpp \
activemq/util/MemoryUsageTest.cpp \
activemq/util/LongSequenceGeneratorTest.cpp \
+ activemq/wireformat/WireFormatRegistryTest.cpp \
decaf/internal/util/ByteArrayAdapterTest.cpp \
decaf/internal/nio/ByteArrayPerspectiveTest.cpp \
decaf/internal/nio/ByteArrayBufferTest.cpp \
@@ -196,6 +197,7 @@
activemq/util/URISupportTest.h \
activemq/util/MemoryUsageTest.h \
activemq/util/LongSequenceGeneratorTest.h \
+ activemq/wireformat/WireFormatRegistryTest.h \
decaf/internal/util/ByteArrayAdapterTest.h \
decaf/internal/nio/ByteArrayPerspectiveTest.h \
decaf/internal/nio/ByteArrayBufferTest.h \
Added:
activemq/activemq-cpp/trunk/src/test/activemq/wireformat/WireFormatRegistryTest.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/wireformat/WireFormatRegistryTest.cpp?rev=732395&view=auto
==============================================================================
---
activemq/activemq-cpp/trunk/src/test/activemq/wireformat/WireFormatRegistryTest.cpp
(added)
+++
activemq/activemq-cpp/trunk/src/test/activemq/wireformat/WireFormatRegistryTest.cpp
Wed Jan 7 08:46:41 2009
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "WireFormatRegistryTest.h"
+
+#include <activemq/wireformat/WireFormatRegistry.h>
+
+#include <activemq/connector/openwire/OpenWireFormatFactory.h>
+
+using namespace activemq;
+using namespace activemq::wireformat;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+void WireFormatRegistryTest::test() {
+
+ connector::openwire::OpenWireFormatFactory factory;
+
+ WireFormatRegistry& registry = WireFormatRegistry::getInstance();
+
+ CPPUNIT_ASSERT( !registry.getWireFormatNames().empty() );
+
+ CPPUNIT_ASSERT_NO_THROW( registry.findFactory( "openwire" ) );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should have thrown an NoSuchElementException",
+ registry.findFactory(""),
+ NoSuchElementException );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should have thrown an NullPointerException",
+ registry.registerFactory( "test", NULL ),
+ NullPointerException );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should have thrown an IllegalArgumentException",
+ registry.registerFactory( "", &factory ),
+ IllegalArgumentException );
+
+}
Propchange:
activemq/activemq-cpp/trunk/src/test/activemq/wireformat/WireFormatRegistryTest.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/activemq-cpp/trunk/src/test/activemq/wireformat/WireFormatRegistryTest.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/wireformat/WireFormatRegistryTest.h?rev=732395&view=auto
==============================================================================
---
activemq/activemq-cpp/trunk/src/test/activemq/wireformat/WireFormatRegistryTest.h
(added)
+++
activemq/activemq-cpp/trunk/src/test/activemq/wireformat/WireFormatRegistryTest.h
Wed Jan 7 08:46:41 2009
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQ_WIREFORMAT_WIREFORMATREGISTRYTEST_H_
+#define _ACTIVEMQ_WIREFORMAT_WIREFORMATREGISTRYTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace activemq {
+namespace wireformat {
+
+ class WireFormatRegistryTest : public CppUnit::TestFixture {
+
+ CPPUNIT_TEST_SUITE( WireFormatRegistryTest );
+ CPPUNIT_TEST( test );
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+
+ WireFormatRegistryTest() {}
+ virtual ~WireFormatRegistryTest() {}
+
+ void test();
+
+ };
+
+}}
+
+#endif /* _ACTIVEMQ_WIREFORMAT_WIREFORMATREGISTRYTEST_H_ */
Propchange:
activemq/activemq-cpp/trunk/src/test/activemq/wireformat/WireFormatRegistryTest.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/activemq-cpp/trunk/src/test/main.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/main.cpp?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/main.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/main.cpp Wed Jan 7 08:46:41 2009
@@ -20,14 +20,15 @@
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/TestResult.h>
#include <activemq/util/Config.h>
+#include <activemq/library/ActiveMQCPP.h>
#include <decaf/lang/Runtime.h>
#include <decaf/lang/Integer.h>
#include <iostream>
int main( int argc, char **argv ) {
- // ensure that we start the runtime.
- decaf::lang::Runtime::getRuntime();
+ activemq::library::ActiveMQCPP::initializeLibrary();
+
bool wasSuccessful = false;
int iterations = 1;
@@ -51,6 +52,8 @@
wasSuccessful = runner.run( "", false );
}
+ activemq::library::ActiveMQCPP::shutdownLibrary();
+
return !wasSuccessful;
}
Modified: activemq/activemq-cpp/trunk/src/test/testRegistry.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/testRegistry.cpp?rev=732395&r1=732394&r2=732395&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/testRegistry.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/testRegistry.cpp Wed Jan 7 08:46:41
2009
@@ -154,6 +154,9 @@
#include <activemq/util/MemoryUsageTest.h>
CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::MemoryUsageTest );
+#include <activemq/wireformat/WireFormatRegistryTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::wireformat::WireFormatRegistryTest
);
+
#include <decaf/internal/util/ByteArrayAdapterTest.h>
CPPUNIT_TEST_SUITE_REGISTRATION( decaf::internal::util::ByteArrayAdapterTest );
#include <decaf/internal/nio/ByteArrayPerspectiveTest.h>