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 2009/01/09 19:49:20 UTC
svn commit: r733111 [1/2] - in /activemq/activemq-cpp/trunk/src: main/
main/activemq/core/ main/activemq/library/ main/activemq/transport/
main/activemq/transport/correlator/ main/activemq/transport/logging/
main/activemq/transport/mock/ main/activemq/...
Author: tabish
Date: Fri Jan 9 10:49:19 2009
New Revision: 733111
URL: http://svn.apache.org/viewvc?rev=733111&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/transport/AbstractTransportFactory.cpp (with props)
activemq/activemq-cpp/trunk/src/main/activemq/transport/AbstractTransportFactory.h (with props)
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/openwire/
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormat.cpp (with props)
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormat.h (with props)
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormatFactory.cpp (with props)
activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormatFactory.h (with props)
activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportRegistryTest.cpp (with props)
activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportRegistryTest.h (with props)
activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/
activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp (with props)
activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.h (with props)
Removed:
activemq/activemq-cpp/trunk/src/main/activemq/transport/IOTransportFactory.cpp
activemq/activemq-cpp/trunk/src/main/activemq/transport/IOTransportFactory.h
activemq/activemq-cpp/trunk/src/main/activemq/transport/TransportBuilder.cpp
activemq/activemq-cpp/trunk/src/main/activemq/transport/TransportBuilder.h
activemq/activemq-cpp/trunk/src/main/activemq/transport/correlator/ResponseCorrelatorFactory.cpp
activemq/activemq-cpp/trunk/src/main/activemq/transport/correlator/ResponseCorrelatorFactory.h
activemq/activemq-cpp/trunk/src/main/activemq/transport/logging/LoggingTransportFactory.cpp
activemq/activemq-cpp/trunk/src/main/activemq/transport/logging/LoggingTransportFactory.h
Modified:
activemq/activemq-cpp/trunk/src/main/Makefile.am
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp
activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.cpp
activemq/activemq-cpp/trunk/src/main/activemq/transport/TransportFactory.h
activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransport.h
activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransportFactory.cpp
activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransportFactory.h
activemq/activemq-cpp/trunk/src/main/activemq/transport/tcp/TcpTransportFactory.cpp
activemq/activemq-cpp/trunk/src/main/activemq/transport/tcp/TcpTransportFactory.h
activemq/activemq-cpp/trunk/src/test/Makefile.am
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompConnectorTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompSessionManagerTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/core/ActiveMQConnectionTest.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=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/main/Makefile.am Fri Jan 9 10:49:19 2009
@@ -67,20 +67,19 @@
activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp \
activemq/connector/ConnectorFactoryMap.cpp \
activemq/connector/BaseConnectorResource.cpp \
- activemq/transport/TransportBuilder.cpp \
activemq/transport/TransportFilter.cpp \
activemq/transport/TransportRegistry.cpp \
- activemq/transport/IOTransportFactory.cpp \
+ activemq/transport/AbstractTransportFactory.cpp \
activemq/transport/IOTransport.cpp \
activemq/transport/mock/MockTransport.cpp \
activemq/transport/mock/MockTransportFactory.cpp \
activemq/transport/correlator/ResponseCorrelator.cpp \
- activemq/transport/correlator/ResponseCorrelatorFactory.cpp \
activemq/transport/tcp/TcpTransport.cpp \
activemq/transport/tcp/TcpTransportFactory.cpp \
activemq/transport/logging/LoggingTransport.cpp \
- activemq/transport/logging/LoggingTransportFactory.cpp \
activemq/wireformat/WireFormatRegistry.cpp \
+ activemq/wireformat/stomp/StompWireFormat.cpp \
+ activemq/wireformat/stomp/StompWireFormatFactory.cpp \
decaf/internal/DecafRuntime.cpp \
decaf/internal/AprPool.cpp \
decaf/internal/util/ByteArrayAdapter.cpp \
@@ -254,29 +253,26 @@
activemq/connector/ConnectorFactoryMapRegistrar.h \
activemq/connector/ProducerInfo.h \
activemq/connector/ConsumerInfo.h \
- activemq/transport/TransportBuilder.h \
activemq/transport/Transport.h \
activemq/transport/TransportFilter.h \
activemq/transport/TransportFactory.h \
+ activemq/transport/AbstractTransportFactory.h \
activemq/transport/TransportExceptionListener.h \
- activemq/transport/TransportRegistry.cpp \
+ activemq/transport/TransportRegistry.h \
activemq/transport/Response.h \
activemq/transport/Command.h \
activemq/transport/CommandListener.h \
activemq/transport/CommandReader.h \
activemq/transport/CommandWriter.h \
activemq/transport/CommandIOException.h \
- activemq/transport/IOTransportFactory.h \
activemq/transport/IOTransport.h \
activemq/transport/mock/MockTransport.h \
activemq/transport/mock/MockTransportFactory.h \
activemq/transport/correlator/FutureResponse.h \
activemq/transport/correlator/ResponseCorrelator.h \
- activemq/transport/correlator/ResponseCorrelatorFactory.h \
activemq/transport/tcp/TcpTransport.h \
activemq/transport/tcp/TcpTransportFactory.h \
activemq/transport/logging/LoggingTransport.h \
- activemq/transport/logging/LoggingTransportFactory.h \
activemq/util/Config.h \
activemq/util/ActiveMQProperties.h \
activemq/util/LongSequenceGenerator.h \
@@ -289,6 +285,8 @@
activemq/wireformat/WireFormatNegotiator.h \
activemq/wireformat/WireFormatFactory.h \
activemq/wireformat/WireFormatRegistry.h \
+ activemq/wireformat/stomp/StompWireFormat.h \
+ activemq/wireformat/stomp/StompWireFormatFactory.h \
cms/DeliveryMode.h \
cms/TemporaryQueue.h \
cms/MapMessage.h \
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=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp Fri Jan 9 10:49:19 2009
@@ -16,14 +16,16 @@
*/
#include "ActiveMQConnectionFactory.h"
+#include <decaf/net/URI.h>
#include <decaf/util/UUID.h>
#include <decaf/util/Properties.h>
#include <decaf/lang/exceptions/NullPointerException.h>
#include <activemq/exceptions/ExceptionDefines.h>
#include <activemq/connector/ConnectorFactoryMap.h>
-#include <activemq/transport/TransportBuilder.h>
+#include <activemq/transport/TransportRegistry.h>
#include <activemq/core/ActiveMQConnection.h>
#include <activemq/core/ActiveMQConstants.h>
+#include <activemq/util/URISupport.h>
#include <memory>
using namespace std;
@@ -32,6 +34,8 @@
using namespace activemq::connector;
using namespace activemq::exceptions;
using namespace activemq::transport;
+using namespace decaf;
+using namespace decaf::net;
using namespace decaf::util;
using namespace decaf::lang::exceptions;
@@ -102,7 +106,6 @@
auto_ptr<ActiveMQConnectionData> connectionData;
auto_ptr<ActiveMQConnection> connection;
std::string clientIdLocal = clientId;
- TransportBuilder transportBuilder;
try{
@@ -111,6 +114,12 @@
clientIdLocal = UUID::randomUUID().toString();
}
+ // Try to convert the String URL into a valid URI
+ URI uri( url );
+
+ // Parse out properties so they can be passed to the Connectors.
+ activemq::util::URISupport::parseQuery( uri.getQuery(), properties.get() );
+
// Store login data in the properties
properties->setProperty(
ActiveMQConstants::toString(
@@ -123,7 +132,8 @@
ActiveMQConstants::PARAM_CLIENTID ), clientIdLocal );
// Use the TransportBuilder to get our Transport
- transport.reset( transportBuilder.buildTransport( url, *properties ) );
+ transport.reset(
+ TransportRegistry::getInstance().findFactory( uri.getScheme() )->create( url ) );
if( transport.get() == NULL ){
throw ActiveMQException(
Modified: 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=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/library/ActiveMQCPP.cpp Fri Jan 9 10:49:19 2009
@@ -20,13 +20,12 @@
#include <decaf/lang/Runtime.h>
#include <activemq/wireformat/WireFormatRegistry.h>
#include <activemq/transport/TransportRegistry.h>
+
+#include <activemq/wireformat/stomp/StompWireFormatFactory.h>
#include <activemq/connector/openwire/OpenWireFormatFactory.h>
-#include <activemq/transport/IOTransportFactory.h>
#include <activemq/transport/mock/MockTransportFactory.h>
#include <activemq/transport/tcp/TcpTransportFactory.h>
-#include <activemq/transport/logging/LoggingTransportFactory.h>
-#include <activemq/transport/correlator/ResponseCorrelatorFactory.h>
#include <activemq/connector/stomp/StompConnectorFactory.h>
#include <activemq/connector/openwire/OpenWireConnectorFactory.h>
@@ -34,8 +33,6 @@
using namespace activemq::library;
using namespace activemq::transport;
using namespace activemq::transport::tcp;
-using namespace activemq::transport::correlator;
-using namespace activemq::transport::logging;
using namespace activemq::transport::mock;
using namespace activemq::wireformat;
@@ -68,6 +65,8 @@
WireFormatRegistry::getInstance().registerFactory(
"openwire", new connector::openwire::OpenWireFormatFactory() );
+ WireFormatRegistry::getInstance().registerFactory(
+ "stomp", new wireformat::stomp::StompWireFormatFactory() );
}
@@ -80,12 +79,6 @@
TransportRegistry::getInstance().registerFactory(
"tcp", new TcpTransportFactory() );
TransportRegistry::getInstance().registerFactory(
- "transport.logging.LoggingTransport", new LoggingTransportFactory() );
- TransportRegistry::getInstance().registerFactory(
- "transport.correlator.ResponseCorrelator", new ResponseCorrelatorFactory() );
- TransportRegistry::getInstance().registerFactory(
- "transport.IOTransport", new IOTransportFactory() );
- TransportRegistry::getInstance().registerFactory(
"mock", new MockTransportFactory() );
}
Added: activemq/activemq-cpp/trunk/src/main/activemq/transport/AbstractTransportFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/AbstractTransportFactory.cpp?rev=733111&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/transport/AbstractTransportFactory.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/transport/AbstractTransportFactory.cpp Fri Jan 9 10:49:19 2009
@@ -0,0 +1,121 @@
+/*
+ * 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 "AbstractTransportFactory.h"
+
+#include <memory>
+#include <string>
+#include <activemq/wireformat/WireFormat.h>
+#include <activemq/wireformat/WireFormatRegistry.h>
+#include <activemq/util/URISupport.h>
+#include <activemq/transport/correlator/ResponseCorrelator.h>
+#include <activemq/transport/logging/LoggingTransport.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::transport;
+using namespace activemq::transport::correlator;
+using namespace activemq::transport::logging;
+using namespace activemq::wireformat;
+using namespace activemq::exceptions;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+using namespace decaf::net;
+using namespace decaf::util;
+
+////////////////////////////////////////////////////////////////////////////////
+Transport* AbstractTransportFactory::create( const decaf::net::URI& location )
+ throw ( exceptions::ActiveMQException ) {
+
+ try{
+
+ Properties properties =
+ activemq::util::URISupport::parseQuery( location.getQuery() );
+
+ WireFormat* wireFormat = this->createWireFormat( properties );
+
+ return this->doCreate( location, wireFormat, properties );
+ }
+ AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
+ AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Transport* AbstractTransportFactory::createComposite( const decaf::net::URI& location )
+ throw ( exceptions::ActiveMQException ) {
+
+ try{
+ Properties properties =
+ activemq::util::URISupport::parseQuery( location.getQuery() );
+
+ WireFormat* wireFormat = this->createWireFormat( properties );
+
+ return doCreateComposite( location, wireFormat, properties );
+ }
+ AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
+ AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Transport* AbstractTransportFactory::doCreate( const decaf::net::URI& location,
+ WireFormat* wireFormat,
+ const decaf::util::Properties& properties )
+ throw ( exceptions::ActiveMQException ) {
+
+ try{
+
+ // Create the initial Transport, then wrap it in the normal Filters
+ Transport* transport = doCreateComposite(
+ location, wireFormat, properties );
+
+ // Create the Transport for response correlator
+ transport = new ResponseCorrelator( transport );
+
+ // If command tracing was enabled, wrap the transport with a logging transport.
+ if( properties.getProperty( "transport.commandTracingEnabled", "false" ) == "true" ) {
+ // Create the Transport for response correlator
+ transport = new LoggingTransport( transport );
+ }
+
+ return transport;
+ }
+ AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
+ AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+WireFormat* AbstractTransportFactory::createWireFormat(
+ const decaf::util::Properties& properties )
+ throw( decaf::lang::exceptions::NoSuchElementException ) {
+
+ try{
+
+ std::string wireFormat = properties.getProperty( "wireFormat", "openwire" );
+
+ WireFormatFactory* factory =
+ WireFormatRegistry::getInstance().findFactory( wireFormat );
+
+ return factory->createWireFormat( properties );
+ }
+ AMQ_CATCH_RETHROW( NoSuchElementException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, NoSuchElementException )
+ AMQ_CATCHALL_THROW( NoSuchElementException )
+}
Propchange: activemq/activemq-cpp/trunk/src/main/activemq/transport/AbstractTransportFactory.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/src/main/activemq/transport/AbstractTransportFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/AbstractTransportFactory.h?rev=733111&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/transport/AbstractTransportFactory.h (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/transport/AbstractTransportFactory.h Fri Jan 9 10:49:19 2009
@@ -0,0 +1,108 @@
+/*
+ * 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_TRANSPORT_ABSTRACTTRANSPORTFACTORY_H_
+#define _ACTIVEMQ_TRANSPORT_ABSTRACTTRANSPORTFACTORY_H_
+
+#include <activemq/util/Config.h>
+#include <activemq/transport/Transport.h>
+#include <activemq/transport/TransportFactory.h>
+#include <activemq/wireformat/WireFormat.h>
+#include <decaf/lang/exceptions/NoSuchElementException.h>
+#include <decaf/util/Properties.h>
+
+namespace activemq {
+namespace transport {
+
+ /**
+ * Abstract implementation of the TransportFactory interface, providing
+ * the base functionality that's common to most of the TransportFactory
+ * instances.
+ *
+ * @since 3.0
+ */
+ class AMQCPP_API AbstractTransportFactory : public TransportFactory {
+ public:
+
+ virtual ~AbstractTransportFactory() {}
+
+ /**
+ * Creates a fully configured Transport instance which could be a chain
+ * of filters and transports.
+ * @param location - URI location to connect to plus any properties to assign.
+ * @throws ActiveMQexception if an error occurs
+ */
+ virtual Transport* create( const decaf::net::URI& location )
+ throw ( exceptions::ActiveMQException );
+
+ /**
+ * Creates a slimed down Transport instance which can be used in composite
+ * transport instances.
+ * @param location - URI location to connect to plus any properties to assign.
+ * @throws ActiveMQexception if an error occurs
+ */
+ virtual Transport* createComposite( const decaf::net::URI& location )
+ throw ( exceptions::ActiveMQException );
+
+ protected:
+
+ /**
+ * Creates a fully configured Transport instance which could be a chain
+ * of filters and transports.
+ * @param location - URI location to connect to.
+ * @param wireformat - the assigned WireFormat for the new Transport.
+ * @param properties - Properties to apply to the transport.
+ * @throws ActiveMQexception if an error occurs
+ */
+ virtual Transport* doCreate( const decaf::net::URI& location,
+ wireformat::WireFormat* wireFormat,
+ const decaf::util::Properties& properties )
+ throw ( exceptions::ActiveMQException );
+
+ /**
+ * Creates a slimed down Transport instance which can be used in composite
+ * transport instances.
+ * @param location - URI location to connect to.
+ * @param wireformat - the assigned WireFormat for the new Transport.
+ * @param properties - Properties to apply to the transport.
+ * @throws ActiveMQexception if an error occurs
+ */
+ virtual Transport* doCreateComposite( const decaf::net::URI& location,
+ wireformat::WireFormat* wireFormat,
+ const decaf::util::Properties& properties )
+ throw ( exceptions::ActiveMQException ) = 0;
+
+ /**
+ * Creates the WireFormat that is configured for this Transport and returns it.
+ * The default WireFormat is Openwire.
+ *
+ * @param properties
+ * The properties that were configured on the URI.
+ *
+ * @returns a pointer to a WireFormat instance that the caller then owns.
+ *
+ * @throws NoSuchElementException if the configured WireFormat is not found.
+ */
+ virtual wireformat::WireFormat* createWireFormat(
+ const decaf::util::Properties& properties )
+ throw( decaf::lang::exceptions::NoSuchElementException );
+
+ };
+
+}}
+
+#endif /* _ACTIVEMQ_TRANSPORT_ABSTRACTTRANSPORTFACTORY_H_ */
Propchange: activemq/activemq-cpp/trunk/src/main/activemq/transport/AbstractTransportFactory.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/TransportFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/TransportFactory.h?rev=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/transport/TransportFactory.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/transport/TransportFactory.h Fri Jan 9 10:49:19 2009
@@ -20,36 +20,46 @@
#include <activemq/util/Config.h>
#include <activemq/exceptions/ActiveMQException.h>
+#include <activemq/transport/Transport.h>
+#include <decaf/net/URI.h>
#include <decaf/util/Properties.h>
namespace activemq{
namespace transport{
- class Transport;
-
/**
* Defines the interface for Factories that create Transports or
- * TransportFilters. Since Transports can be chained, the create
- * method takes a pointer to the next transport in the list, and
- * wether the newly create transport owns the next and should delete
- * it on its own destruction.
+ * TransportFilters.
+ * <p>
+ * The factory should be able to create either a completely configured
+ * Transport meaning that it has all the appropriate filters wrapping it,
+ * or it should be able to create a slimed down version that is used in
+ * composite transports like Failover or Fanout.
+ *
+ * @since 3.0
*/
- class AMQCPP_API TransportFactory{
+ class AMQCPP_API TransportFactory {
public:
virtual ~TransportFactory() {}
/**
- * Creates a Transport instance.
- * @param properties - Object that will hold transport config values
- * @param next - the next transport in the chain, or NULL
- * @param own - does the new Transport own the next
+ * Creates a fully configured Transport instance which could be a chain
+ * of filters and transports.
+ * @param location - URI location to connect to plus any properties to assign.
+ * @throws ActiveMQexception if an error occurs
+ */
+ virtual Transport* create( const decaf::net::URI& location )
+ throw ( exceptions::ActiveMQException ) = 0;
+
+ /**
+ * Creates a slimed down Transport instance which can be used in composite
+ * transport instances.
+ * @param location - URI location to connect to plus any properties to assign.
* @throws ActiveMQexception if an error occurs
*/
- virtual Transport* createTransport(
- const decaf::util::Properties& properties,
- Transport* next = NULL,
- bool own = true ) throw ( exceptions::ActiveMQException ) = 0;
+ virtual Transport* createComposite( const decaf::net::URI& location )
+ throw ( exceptions::ActiveMQException ) = 0;
};
Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransport.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransport.h?rev=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransport.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransport.h Fri Jan 9 10:49:19 2009
@@ -186,8 +186,7 @@
public:
- MockTransport( ResponseBuilder* responseBuilder ,
- bool own = false );
+ MockTransport( ResponseBuilder* responseBuilder, bool own = false );
virtual ~MockTransport();
Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransportFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransportFactory.cpp?rev=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransportFactory.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransportFactory.cpp Fri Jan 9 10:49:19 2009
@@ -20,27 +20,22 @@
#include <activemq/connector/openwire/OpenWireResponseBuilder.h>
#include <activemq/transport/Transport.h>
#include <activemq/transport/mock/MockTransport.h>
-#include <activemq/transport/mock/MockTransportFactory.h>
using namespace activemq;
using namespace activemq::transport;
using namespace activemq::transport::mock;
using namespace activemq::exceptions;
+using namespace decaf;
using namespace decaf::util;
using namespace decaf::lang;
////////////////////////////////////////////////////////////////////////////////
-Transport* MockTransportFactory::createTransport(
- const decaf::util::Properties& properties,
- Transport* next,
- bool own ) throw ( activemq::exceptions::ActiveMQException ) {
-
- try{
-
- // We don't use the next here, so clean it up now.
- if( own == true ) {
- delete next;
- }
+Transport* MockTransportFactory::doCreateComposite( const decaf::net::URI& location,
+ wireformat::WireFormat* wireFormat,
+ const decaf::util::Properties& properties )
+ throw ( exceptions::ActiveMQException ) {
+
+ try {
std::string wireFormat =
properties.getProperty( "wireFormat", "stomp" );
Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransportFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransportFactory.h?rev=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransportFactory.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/transport/mock/MockTransportFactory.h Fri Jan 9 10:49:19 2009
@@ -19,7 +19,7 @@
#define _ACTIVEMQ_TRANSPORT_MOCK_MOCKTRANSPORTFACTORY_H_
#include <activemq/util/Config.h>
-#include <activemq/transport/TransportFactory.h>
+#include <activemq/transport/AbstractTransportFactory.h>
namespace activemq{
namespace transport{
@@ -29,19 +29,25 @@
* Manufactures MockTransports, which are objects that
* read from input streams and write to output streams.
*/
- class AMQCPP_API MockTransportFactory : public TransportFactory{
+ class AMQCPP_API MockTransportFactory : public AbstractTransportFactory {
public:
virtual ~MockTransportFactory() {}
+ protected:
+
/**
- * Creates a Transport instance.
- * @param properties The properties for the transport.
+ * Creates a slimed down Transport instance which can be used in composite
+ * transport instances.
+ * @param location - URI location to connect to.
+ * @param wireformat - the assigned WireFormat for the new Transport.
+ * @param properties - Properties to apply to the transport.
+ * @throws ActiveMQexception if an error occurs
*/
- virtual Transport* createTransport(
- const decaf::util::Properties& properties,
- Transport* next = NULL,
- bool own = true ) throw ( exceptions::ActiveMQException );
+ virtual Transport* doCreateComposite( const decaf::net::URI& location,
+ wireformat::WireFormat* wireFormat,
+ const decaf::util::Properties& properties )
+ throw ( exceptions::ActiveMQException );
};
Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/tcp/TcpTransportFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/tcp/TcpTransportFactory.cpp?rev=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/transport/tcp/TcpTransportFactory.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/transport/tcp/TcpTransportFactory.cpp Fri Jan 9 10:49:19 2009
@@ -17,6 +17,7 @@
#include "TcpTransportFactory.h"
+#include <activemq/transport/IOTransport.h>
#include <activemq/transport/tcp/TcpTransport.h>
using namespace activemq;
@@ -26,13 +27,13 @@
using namespace decaf::lang;
////////////////////////////////////////////////////////////////////////////////
-Transport* TcpTransportFactory::createTransport(
- const decaf::util::Properties& properties,
- Transport* next,
- bool own ) throw ( ActiveMQException ) {
+Transport* TcpTransportFactory::doCreateComposite( const decaf::net::URI& location,
+ wireformat::WireFormat* wireFormat,
+ const decaf::util::Properties& properties )
+ throw ( exceptions::ActiveMQException ) {
try {
- return new TcpTransport( properties, next, own );
+ return new TcpTransport( properties, new IOTransport() );
}
AMQ_CATCH_RETHROW( ActiveMQException )
AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/tcp/TcpTransportFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/tcp/TcpTransportFactory.h?rev=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/transport/tcp/TcpTransportFactory.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/transport/tcp/TcpTransportFactory.h Fri Jan 9 10:49:19 2009
@@ -19,8 +19,7 @@
#define _ACTIVEMQ_TRANSPORT_TCP_TCPTRANSPORTFACTORY_H_
#include <activemq/util/Config.h>
-#include <activemq/transport/TransportFactory.h>
-#include <activemq/transport/IOTransportFactory.h>
+#include <activemq/transport/AbstractTransportFactory.h>
#include <activemq/exceptions/ActiveMQException.h>
namespace activemq{
@@ -30,22 +29,25 @@
/**
* Factory Responsible for creating the TcpTransport.
*/
- class AMQCPP_API TcpTransportFactory : public TransportFactory {
+ class AMQCPP_API TcpTransportFactory : public AbstractTransportFactory {
public:
virtual ~TcpTransportFactory() {}
+ protected:
+
/**
- * Creates a Transport instance.
- * @param properties - Object that will hold transport config values
- * @param next - the next transport in the chain, or NULL
- * @param own - does the new Transport own the next
- * @throws ActiveMQException if an error occurs.
+ * Creates a slimed down Transport instance which can be used in composite
+ * transport instances.
+ * @param location - URI location to connect to.
+ * @param wireformat - the assigned WireFormat for the new Transport.
+ * @param properties - Properties to apply to the transport.
+ * @throws ActiveMQexception if an error occurs
*/
- virtual Transport* createTransport(
- const decaf::util::Properties& properties,
- Transport* next,
- bool own ) throw ( exceptions::ActiveMQException );
+ virtual Transport* doCreateComposite( const decaf::net::URI& location,
+ wireformat::WireFormat* wireFormat,
+ const decaf::util::Properties& properties )
+ throw ( exceptions::ActiveMQException );
};
Added: activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormat.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormat.cpp?rev=733111&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormat.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormat.cpp Fri Jan 9 10:49:19 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 "StompWireFormat.h"
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::wireformat;
+using namespace activemq::wireformat::stomp;
+using namespace decaf;
+using namespace decaf::io;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+StompWireFormat::StompWireFormat() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+StompWireFormat::~StompWireFormat() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StompWireFormat::marshal( transport::Command* command, decaf::io::DataOutputStream* out )
+ throw ( decaf::io::IOException ) {
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+transport::Command* StompWireFormat::unmarshal( decaf::io::DataInputStream* in )
+ throw ( decaf::io::IOException ) {
+
+ return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+WireFormatNegotiator* StompWireFormat::createNegotiator( transport::Transport* transport )
+ throw( decaf::lang::exceptions::UnsupportedOperationException ) {
+
+ throw UnsupportedOperationException( __FILE__, __LINE__,
+ "No Negotiator is required to use this WireFormat." );
+}
Propchange: activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormat.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormat.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormat.h?rev=733111&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormat.h (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormat.h Fri Jan 9 10:49:19 2009
@@ -0,0 +1,88 @@
+/*
+ * 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_STOMP_STOMPWIREFORMAT_H_
+#define _ACTIVEMQ_WIREFORMAT_STOMP_STOMPWIREFORMAT_H_
+
+#include <activemq/util/Config.h>
+#include <activemq/wireformat/WireFormat.h>
+
+namespace activemq {
+namespace wireformat {
+namespace stomp {
+
+ class AMQCPP_API StompWireFormat : public WireFormat {
+ public:
+
+ StompWireFormat();
+ virtual ~StompWireFormat();
+
+ /**
+ * Stream based marshaling
+ * @param command - The Command to Marshal
+ * @param out - the output stream to write the command to.
+ * @throws IOException
+ */
+ virtual void marshal( transport::Command* command, decaf::io::DataOutputStream* out )
+ throw ( decaf::io::IOException );
+
+ /**
+ * Packet based un-marshaling
+ * @param in - the input stream to read the command from.
+ * @returns the newly marshaled Command, caller owns the pointer
+ * @throws IOException
+ */
+ virtual transport::Command* unmarshal( decaf::io::DataInputStream* in )
+ throw ( decaf::io::IOException );
+
+ /**
+ * Set the Version
+ * @param the version of the wire format
+ */
+ virtual void setVersion( int version ) {}
+
+ /**
+ * Get the Version
+ * @return the version of the wire format
+ */
+ virtual int getVersion() const {
+ return 1;
+ }
+
+ /**
+ * 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 false;
+ }
+
+ /**
+ * 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 );
+
+ };
+
+}}}
+
+#endif /* _ACTIVEMQ_WIREFORMAT_STOMP_STOMPWIREFORMAT_H_ */
Propchange: activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormat.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormatFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormatFactory.cpp?rev=733111&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormatFactory.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormatFactory.cpp Fri Jan 9 10:49:19 2009
@@ -0,0 +1,38 @@
+/*
+ * 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 "StompWireFormatFactory.h"
+
+#include <activemq/exceptions/ActiveMQException.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::wireformat;
+using namespace activemq::wireformat::stomp;
+using namespace activemq::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+StompWireFormat* StompWireFormatFactory::createWireFormat(
+ const decaf::util::Properties& properties )
+ throw ( decaf::lang::exceptions::IllegalStateException ) {
+
+ try{
+ return new StompWireFormat();
+ }
+ AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCHALL_THROW( ActiveMQException )
+}
Propchange: activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormatFactory.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormatFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormatFactory.h?rev=733111&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormatFactory.h (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormatFactory.h Fri Jan 9 10:49:19 2009
@@ -0,0 +1,50 @@
+/*
+ * 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_STOMP_STOMPWIREFORMATFACTORY_H_
+#define _ACTIVEMQ_WIREFORMAT_STOMP_STOMPWIREFORMATFACTORY_H_
+
+#include <activemq/util/Config.h>
+#include <activemq/wireformat/WireFormatFactory.h>
+#include <activemq/wireformat/stomp/StompWireFormat.h>
+
+namespace activemq {
+namespace wireformat {
+namespace stomp {
+
+ /**
+ * Factory used to create the Stomp Wire Format instance.
+ */
+ class StompWireFormatFactory : public WireFormatFactory {
+ public:
+
+ StompWireFormatFactory() {}
+ virtual ~StompWireFormatFactory() {}
+
+ /**
+ * Creates a new WireFormat Object passing it a set of
+ * properties from which it can obtain any optional settings
+ * @param properties - the Properties for this WireFormat
+ */
+ virtual StompWireFormat* createWireFormat( const decaf::util::Properties& properties )
+ throw ( decaf::lang::exceptions::IllegalStateException );
+
+ };
+
+}}}
+
+#endif /* _ACTIVEMQ_WIREFORMAT_STOMP_STOMPWIREFORMATFACTORY_H_ */
Propchange: activemq/activemq-cpp/trunk/src/main/activemq/wireformat/stomp/StompWireFormatFactory.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/activemq-cpp/trunk/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/Makefile.am?rev=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/test/Makefile.am Fri Jan 9 10:49:19 2009
@@ -67,8 +67,10 @@
activemq/cmsutil/SessionPoolTest.cpp \
activemq/cmsutil/CmsTemplateTest.cpp \
activemq/exceptions/ActiveMQExceptionTest.cpp \
+ activemq/transport/TransportRegistryTest.cpp \
activemq/transport/IOTransportTest.cpp \
activemq/transport/correlator/ResponseCorrelatorTest.cpp \
+ activemq/transport/mock/MockTransportFactoryTest.cpp \
activemq/util/PrimitiveValueNodeTest.cpp \
activemq/util/PrimitiveListTest.cpp \
activemq/util/PrimitiveMapTest.cpp \
@@ -185,8 +187,10 @@
activemq/cmsutil/SessionPoolTest.h \
activemq/cmsutil/CmsTemplateTest.h \
activemq/exceptions/ActiveMQExceptionTest.h \
+ activemq/transport/TransportRegistryTest.h \
activemq/transport/IOTransportTest.h \
activemq/transport/correlator/ResponseCorrelatorTest.h \
+ activemq/transport/mock/MockTransportFactoryTest.h \
activemq/util/PrimitiveValueNodeTest.h \
activemq/util/PrimitiveListTest.h \
activemq/util/PrimitiveMapTest.h \
Modified: activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompConnectorTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompConnectorTest.cpp?rev=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompConnectorTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompConnectorTest.cpp Fri Jan 9 10:49:19 2009
@@ -288,6 +288,8 @@
properties.setProperty( "wireFormat", "stomp" );
properties.setProperty( "client-id", connectionId );
+ decaf::net::URI uri( "mock://mock?wireFormat=stomp" );
+
transport::TransportFactory* factory =
transport::TransportRegistry::getInstance().findFactory( "mock" );
if( factory == NULL ){
@@ -296,7 +298,7 @@
// Create the transport->
this->transport =
- dynamic_cast<MockTransport*>( factory->createTransport( properties ) );
+ dynamic_cast<MockTransport*>( factory->create( uri ) );
if( transport == NULL ){
CPPUNIT_ASSERT( false );
}
Modified: activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompSessionManagerTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompSessionManagerTest.cpp?rev=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompSessionManagerTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompSessionManagerTest.cpp Fri Jan 9 10:49:19 2009
@@ -336,6 +336,8 @@
properties.setProperty( "wireFormat", "stomp" );
properties.setProperty( "client-id", connectionId );
+ decaf::net::URI uri( "mock://mock?wireFormat=stomp" );
+
transport::TransportFactory* factory =
transport::TransportRegistry::getInstance().findFactory( "mock" );
if( factory == NULL ){
@@ -344,7 +346,7 @@
// Create the transport.
this->transport =
- dynamic_cast<MockTransport*>( factory->createTransport( properties ) );
+ dynamic_cast<MockTransport*>( factory->create( uri ) );
if( transport == NULL ){
CPPUNIT_ASSERT( false );
}
Modified: activemq/activemq-cpp/trunk/src/test/activemq/core/ActiveMQConnectionTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/core/ActiveMQConnectionTest.cpp?rev=733111&r1=733110&r2=733111&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/core/ActiveMQConnectionTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/core/ActiveMQConnectionTest.cpp Fri Jan 9 10:49:19 2009
@@ -58,6 +58,7 @@
// Default to Stomp
properties->setProperty( "wireFormat", "stomp" );
+ decaf::net::URI uri( "mock://mock?wireFormat=stomp" );
transport::TransportFactory* factory =
transport::TransportRegistry::getInstance().findFactory( "mock" );
@@ -66,7 +67,7 @@
}
// Create the transport.
- transport = factory->createTransport( *properties );
+ transport = factory->create( uri );
if( transport == NULL ){
CPPUNIT_ASSERT( false );
}
@@ -196,6 +197,7 @@
// Default to Stomp
properties->setProperty( "wireFormat", "stomp" );
+ decaf::net::URI uri( "mock://mock?wireFormat=stomp" );
transport::TransportFactory* factory =
transport::TransportRegistry::getInstance().findFactory( "mock" );
@@ -204,7 +206,7 @@
}
// Create the transport.
- transport = factory->createTransport( *properties );
+ transport = factory->create( uri );
if( transport == NULL ){
CPPUNIT_ASSERT( false );
}
@@ -253,6 +255,7 @@
// Default to Stomp
properties->setProperty( "wireFormat", "openwire" );
+ decaf::net::URI uri( "mock://mock?wireFormat=stomp" );
transport::TransportFactory* factory =
transport::TransportRegistry::getInstance().findFactory( "mock" );
@@ -261,7 +264,7 @@
}
// Create the transport.
- transport = factory->createTransport( *properties );
+ transport = factory->create( uri );
if( transport == NULL ){
CPPUNIT_ASSERT( false );
}
Added: activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportRegistryTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportRegistryTest.cpp?rev=733111&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportRegistryTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportRegistryTest.cpp Fri Jan 9 10:49:19 2009
@@ -0,0 +1,55 @@
+/*
+ * 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 "TransportRegistryTest.h"
+
+#include <activemq/transport/TransportRegistry.h>
+#include <activemq/transport/mock/MockTransportFactory.h>
+
+using namespace activemq;
+using namespace activemq::transport;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+void TransportRegistryTest::test() {
+
+ transport::mock::MockTransportFactory factory;
+
+ TransportRegistry& registry = TransportRegistry::getInstance();
+
+ CPPUNIT_ASSERT( !registry.getTransportNames().empty() );
+
+ CPPUNIT_ASSERT_NO_THROW( registry.findFactory( "mock" ) );
+
+ 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/transport/TransportRegistryTest.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportRegistryTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportRegistryTest.h?rev=733111&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportRegistryTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportRegistryTest.h Fri Jan 9 10:49:19 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_TRANSPORT_TRANSPORTREGISTRYTEST_H_
+#define _ACTIVEMQ_TRANSPORT_TRANSPORTREGISTRYTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace activemq {
+namespace transport {
+
+ class TransportRegistryTest : public CppUnit::TestFixture {
+
+ CPPUNIT_TEST_SUITE( TransportRegistryTest );
+ CPPUNIT_TEST( test );
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+
+ TransportRegistryTest() {}
+ virtual ~TransportRegistryTest() {}
+
+ void test();
+
+ };
+
+}}
+
+#endif /* _ACTIVEMQ_TRANSPORT_TRANSPORTREGISTRYTEST_H_ */
Propchange: activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportRegistryTest.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp?rev=733111&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp Fri Jan 9 10:49:19 2009
@@ -0,0 +1,49 @@
+/*
+ * 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 "MockTransportFactoryTest.h"
+
+#include <activemq/transport/mock/MockTransportFactory.h>
+#include <activemq/transport/mock/MockTransport.h>
+#include <decaf/net/URI.h>
+#include <memory>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::transport;
+using namespace activemq::transport::mock;
+using namespace decaf;
+using namespace decaf::net;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+void MockTransportFactoryTest::test() {
+
+ URI uri( "mock://mock?wireformat=openwire" );
+
+ MockTransportFactory factory;
+
+ auto_ptr<Transport> transport( factory.create( uri ) );
+
+ CPPUNIT_ASSERT( transport.get() != NULL );
+
+ transport.reset( factory.createComposite( uri ) );
+
+ CPPUNIT_ASSERT( transport.get() != NULL );
+
+}
Propchange: activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.h?rev=733111&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.h Fri Jan 9 10:49:19 2009
@@ -0,0 +1,45 @@
+/*
+ * 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_TRANSPORT_MOCK_MOCKTRANSPORTFACTORYTEST_H_
+#define _ACTIVEMQ_TRANSPORT_MOCK_MOCKTRANSPORTFACTORYTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace activemq {
+namespace transport {
+namespace mock {
+
+ class MockTransportFactoryTest : public CppUnit::TestFixture {
+
+ CPPUNIT_TEST_SUITE( MockTransportFactoryTest );
+ CPPUNIT_TEST( test );
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+
+ MockTransportFactoryTest() {}
+ virtual ~MockTransportFactoryTest() {}
+
+ void test();
+
+ };
+
+}}}
+
+#endif /* _ACTIVEMQ_TRANSPORT_MOCK_MOCKTRANSPORTFACTORYTEST_H_ */
Propchange: activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.h
------------------------------------------------------------------------------
svn:eol-style = native