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 2010/07/21 21:51:18 UTC
svn commit: r966386 - in /activemq/activemq-cpp/trunk/activemq-cpp/src:
main/activemq/commands/ main/activemq/core/ main/decaf/util/zip/
test-integration/activemq/test/ test/activemq/core/
Author: tabish
Date: Wed Jul 21 19:51:17 2010
New Revision: 966386
URL: http://svn.apache.org/viewvc?rev=966386&view=rev
Log:
implements: https://issues.apache.org/activemq/browse/AMQCPP-305
Also did some cleanup in the ActiveMQConnectionFactory code.
Adds new unit test to check that URI options are parsed and set on the Connection.
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/CmsTemplateTest.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQBytesMessage.cpp Wed Jul 21 19:51:17 2010
@@ -661,7 +661,9 @@ void ActiveMQBytesMessage::initializeWri
if( this->connection != NULL && this->connection->isUseCompression() ) {
this->compressed = true;
- os = new DeflaterOutputStream( os, true );
+ Deflater* deflator = new Deflater( this->connection->getCompressionLevel() );
+
+ os = new DeflaterOutputStream( os, deflator, true, true );
os = new ByteCounterOutputStream( &length, os, true );
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp Wed Jul 21 19:51:17 2010
@@ -109,7 +109,10 @@ void ActiveMQMapMessage::beforeMarshal(
if( this->connection != NULL && this->connection->isUseCompression() ) {
this->compressed = true;
- os = new DeflaterOutputStream( os, true );
+
+ Deflater* deflator = new Deflater( this->connection->getCompressionLevel() );
+
+ os = new DeflaterOutputStream( os, deflator, true, true );
}
DataOutputStream dataOut( os, true );
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp Wed Jul 21 19:51:17 2010
@@ -886,7 +886,10 @@ void ActiveMQStreamMessage::initializeWr
if( this->connection != NULL && this->connection->isUseCompression() ) {
this->compressed = true;
- os = new DeflaterOutputStream( os, true );
+
+ Deflater* deflator = new Deflater( this->connection->getCompressionLevel() );
+
+ os = new DeflaterOutputStream( os, deflator, true, true );
}
this->dataOut.reset( new DataOutputStream( os, true ) );
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp Wed Jul 21 19:51:17 2010
@@ -124,7 +124,8 @@ void ActiveMQTextMessage::beforeMarshal(
if( this->connection != NULL && this->connection->isUseCompression() ) {
this->compressed = true;
- os = new DeflaterOutputStream( os, true );
+ Deflater* deflator = new Deflater( this->connection->getCompressionLevel() );
+ os = new DeflaterOutputStream( os, deflator, true, true );
}
DataOutputStream dataOut( os, true );
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp Wed Jul 21 19:51:17 2010
@@ -105,6 +105,7 @@ namespace core{
bool alwaysSyncSend;
bool useAsyncSend;
bool useCompression;
+ int compressionLevel;
unsigned int sendTimeout;
unsigned int closeTimeout;
unsigned int producerWindowSize;
@@ -127,6 +128,7 @@ namespace core{
alwaysSyncSend( false ),
useAsyncSend( false ),
useCompression( false ),
+ compressionLevel( -1 ),
sendTimeout( 0 ),
closeTimeout( 15000 ),
producerWindowSize( 0 ),
@@ -1008,6 +1010,21 @@ void ActiveMQConnection::setUseCompressi
}
////////////////////////////////////////////////////////////////////////////////
+int ActiveMQConnection::getCompressionLevel() const {
+ return this->config->compressionLevel;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQConnection::setCompressionLevel( int value ) {
+
+ if( value < 0 ) {
+ this->config->compressionLevel = -1;
+ }
+
+ this->config->compressionLevel = Math::min( value, 9 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
unsigned int ActiveMQConnection::getSendTimeout() const {
return this->config->sendTimeout;
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h Wed Jul 21 19:51:17 2010
@@ -449,6 +449,24 @@ namespace core{
void setUseCompression( bool value );
/**
+ * Sets the Compression level used when Message body compression is enabled, a
+ * value of -1 causes the Compression Library to use the default setting which
+ * is a balance of speed and compression. The range of compression levels is
+ * [0..9] where 0 indicates best speed and 9 indicates best compression.
+ *
+ * @param value
+ * A signed int value that controls the compression level.
+ */
+ void setCompressionLevel( int value );
+
+ /**
+ * Gets the currently configured Compression level for Message bodies.
+ *
+ * @return the int value of the current compression level.
+ */
+ int getCompressionLevel() const;
+
+ /**
* Gets the assigned send timeout for this Connector
* @return the send timeout configured in the connection uri
*/
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp Wed Jul 21 19:51:17 2010
@@ -21,6 +21,7 @@
#include <decaf/lang/Boolean.h>
#include <decaf/lang/Integer.h>
#include <decaf/lang/Pointer.h>
+#include <decaf/lang/Math.h>
#include <decaf/lang/exceptions/NullPointerException.h>
#include <activemq/exceptions/ExceptionDefines.h>
#include <activemq/transport/TransportRegistry.h>
@@ -59,12 +60,13 @@ namespace core{
std::string password;
std::string clientId;
- std::string brokerURL;
+ URI brokerURI;
bool dispatchAsync;
bool alwaysSyncSend;
bool useAsyncSend;
bool useCompression;
+ int compressionLevel;
unsigned int sendTimeout;
unsigned int closeTimeout;
unsigned int producerWindowSize;
@@ -73,11 +75,12 @@ namespace core{
std::auto_ptr<PrefetchPolicy> defaultPrefetchPolicy;
std::auto_ptr<RedeliveryPolicy> defaultRedeliveryPolicy;
- FactorySettings() : brokerURL( ActiveMQConnectionFactory::DEFAULT_URI ),
+ FactorySettings() : brokerURI( ActiveMQConnectionFactory::DEFAULT_URI ),
dispatchAsync( true ),
alwaysSyncSend( false ),
useAsyncSend( false ),
useCompression( false ),
+ compressionLevel( -1 ),
sendTimeout( 0 ),
closeTimeout( 15000 ),
producerWindowSize( 0 ),
@@ -92,7 +95,7 @@ namespace core{
void updateConfiguration( const URI& uri ) {
- this->brokerURL = uri.toString();
+ this->brokerURI = uri;
this->properties->clear();
activemq::util::URISupport::parseQuery( uri.getQuery(), properties.get() );
@@ -112,6 +115,9 @@ namespace core{
core::ActiveMQConstants::toString(
core::ActiveMQConstants::CONNECTION_USECOMPRESSION ), "false" ) );
+ this->compressionLevel = decaf::lang::Integer::parseInt(
+ properties->getProperty( "connection.compressionLevel", "-1" ) );
+
this->dispatchAsync = Boolean::parseBoolean(
properties->getProperty(
core::ActiveMQConstants::toString(
@@ -167,9 +173,31 @@ ActiveMQConnectionFactory::ActiveMQConne
const std::string& username,
const std::string& password ) : settings( new FactorySettings() ) {
- settings->brokerURL = url;
- settings->username = username;
- settings->password = password;
+ this->setBrokerURI( URI( url ) );
+
+ // Store login data in the properties
+ if( !username.empty() ) {
+ this->settings->username = username;
+ }
+ if( !password.empty() ) {
+ this->settings->password = password;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ActiveMQConnectionFactory::ActiveMQConnectionFactory( const decaf::net::URI& uri,
+ const std::string& username,
+ const std::string& password ) : settings( new FactorySettings() ) {
+
+ this->setBrokerURI( uri );
+
+ // Store login data in the properties
+ if( !username.empty() ) {
+ this->settings->username = username;
+ }
+ if( !password.empty() ) {
+ this->settings->password = password;
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -183,14 +211,14 @@ ActiveMQConnectionFactory::~ActiveMQConn
////////////////////////////////////////////////////////////////////////////////
cms::Connection* ActiveMQConnectionFactory::createConnection() {
- return createConnection( settings->brokerURL, settings->username, settings->password, settings->clientId );
+ return doCreateConnection( settings->brokerURI, settings->username, settings->password, settings->clientId );
}
////////////////////////////////////////////////////////////////////////////////
cms::Connection* ActiveMQConnectionFactory::createConnection( const std::string& username,
const std::string& password ) {
- return createConnection( settings->brokerURL, username, password, settings->clientId );
+ return doCreateConnection( settings->brokerURI, username, password, settings->clientId );
}
////////////////////////////////////////////////////////////////////////////////
@@ -198,11 +226,11 @@ cms::Connection* ActiveMQConnectionFacto
const std::string& password,
const std::string& clientId ) {
- return createConnection( settings->brokerURL, username, password, clientId );
+ return doCreateConnection( settings->brokerURI, username, password, clientId );
}
////////////////////////////////////////////////////////////////////////////////
-cms::Connection* ActiveMQConnectionFactory::doCreateConnection( const std::string& url,
+cms::Connection* ActiveMQConnectionFactory::doCreateConnection( const decaf::net::URI& uri,
const std::string& username,
const std::string& password,
const std::string& clientId ) {
@@ -212,11 +240,7 @@ cms::Connection* ActiveMQConnectionFacto
try{
- // Try to convert the String URL into a valid URI
- URI uri( url );
-
- // Update configuration with new authentication info if any was provided.
- this->settings->updateConfiguration( uri );
+ this->setBrokerURI( uri );
// Store login data in the properties
if( !username.empty() ) {
@@ -276,14 +300,14 @@ cms::Connection* ActiveMQConnectionFacto
////////////////////////////////////////////////////////////////////////////////
cms::Connection* ActiveMQConnectionFactory::createConnection(
- const std::string& url,
+ const std::string& uri,
const std::string& username,
const std::string& password,
const std::string& clientId ) {
ActiveMQConnectionFactory factory;
- return factory.doCreateConnection( url, username, password, clientId );
+ return factory.doCreateConnection( URI( uri ), username, password, clientId );
}
////////////////////////////////////////////////////////////////////////////////
@@ -295,6 +319,7 @@ void ActiveMQConnectionFactory::configur
connection->setAlwaysSyncSend( this->settings->alwaysSyncSend );
connection->setUseAsyncSend( this->settings->useAsyncSend );
connection->setUseCompression( this->settings->useCompression );
+ connection->setCompressionLevel( this->settings->compressionLevel );
connection->setSendTimeout( this->settings->sendTimeout );
connection->setCloseTimeout( this->settings->closeTimeout );
connection->setProducerWindowSize( this->settings->producerWindowSize );
@@ -337,13 +362,20 @@ void ActiveMQConnectionFactory::setClien
}
////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConnectionFactory::setBrokerURL( const std::string& brokerURL ){
- settings->brokerURL = brokerURL;
+void ActiveMQConnectionFactory::setBrokerURI( const std::string& uri ) {
+ this->setBrokerURI( URI( uri ) );
}
////////////////////////////////////////////////////////////////////////////////
-const std::string& ActiveMQConnectionFactory::getBrokerURL() const {
- return settings->brokerURL;
+void ActiveMQConnectionFactory::setBrokerURI( const decaf::net::URI& uri ) {
+
+ // Update configuration with new authentication info if any was provided.
+ this->settings->updateConfiguration( uri );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+const decaf::net::URI& ActiveMQConnectionFactory::getBrokerURI() const {
+ return settings->brokerURI;
}
////////////////////////////////////////////////////////////////////////////////
@@ -417,6 +449,21 @@ void ActiveMQConnectionFactory::setUseCo
}
////////////////////////////////////////////////////////////////////////////////
+int ActiveMQConnectionFactory::getCompressionLevel() const {
+ return this->settings->compressionLevel;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQConnectionFactory::setCompressionLevel( int value ) {
+
+ if( value < 0 ) {
+ this->settings->compressionLevel = -1;
+ }
+
+ this->settings->compressionLevel = Math::min( value, 9 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
unsigned int ActiveMQConnectionFactory::getSendTimeout() const {
return this->settings->sendTimeout;
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h Wed Jul 21 19:51:17 2010
@@ -22,6 +22,8 @@
#include <cms/ConnectionFactory.h>
#include <cms/Connection.h>
+#include <decaf/net/URI.h>
+
namespace activemq{
namespace core{
@@ -55,6 +57,16 @@ namespace core{
const std::string& username = "",
const std::string& password = "" );
+ /**
+ * Constructor
+ * @param uri the URI of the Broker we are connecting to.
+ * @param username to authenticate with, defaults to ""
+ * @param password to authenticate with, defaults to ""
+ */
+ ActiveMQConnectionFactory( const decaf::net::URI& uri,
+ const std::string& username = "",
+ const std::string& password = "" );
+
virtual ~ActiveMQConnectionFactory() throw();
/**
@@ -143,18 +155,27 @@ namespace core{
void setClientId( const std::string& clientId );
/**
- * Sets the Broker URL that should be used when creating a new
- * connection instance
- * @param brokerURL string
+ * Sets the Broker URI that should be used when creating a new connection instance.
+ *
+ * @param brokerURI
+ * The string form of the Broker URI, this will be converted to a URI object.
+ */
+ void setBrokerURI( const std::string& uri );
+
+ /**
+ * Sets the Broker URI that should be used when creating a new connection instance.
+ *
+ * @param brokerURI
+ * The URI of the broker that this client will connect to.
*/
- void setBrokerURL( const std::string& brokerURL );
+ void setBrokerURI( const decaf::net::URI& uri );
/**
- * Gets the Broker URL that this factory will use when creating a new
+ * Gets the Broker URI that this factory will use when creating a new
* connection instance.
- * @return brokerURL string
+ * @return brokerURI string
*/
- const std::string& getBrokerURL() const;
+ const decaf::net::URI& getBrokerURI() const;
/**
* Set an CMS ExceptionListener that will be set on eat connection once it has been
@@ -264,6 +285,24 @@ namespace core{
void setUseCompression( bool value );
/**
+ * Sets the Compression level used when Message body compression is enabled, a
+ * value of -1 causes the Compression Library to use the default setting which
+ * is a balance of speed and compression. The range of compression levels is
+ * [0..9] where 0 indicates best speed and 9 indicates best compression.
+ *
+ * @param value
+ * A signed int value that controls the compression level.
+ */
+ void setCompressionLevel( int value );
+
+ /**
+ * Gets the currently configured Compression level for Message bodies.
+ *
+ * @return the int value of the current compression level.
+ */
+ int getCompressionLevel() const;
+
+ /**
* Gets the assigned send timeout for this Connector
* @return the send timeout configured in the connection uri
*/
@@ -311,20 +350,26 @@ namespace core{
* Creates a connection with the specified user identity. The
* connection is created in stopped mode. No messages will be
* delivered until the Connection.start method is explicitly called.
- * @param url the URL of the Broker we are connecting to.
- * @param username to authenticate with
- * @param password to authenticate with
- * @param clientId to assign to connection, defaults to ""
+ *
+ * @param uri
+ * The URI of the Broker we are connecting to.
+ * @param username
+ * The name of the user to authenticate with.
+ * @param password
+ * The password for the user to authenticate with.
+ * @param clientId
+ * The unique client id to assign to connection, defaults to "".
+ *
* @throw CMSException.
*/
- static cms::Connection* createConnection( const std::string& url,
+ static cms::Connection* createConnection( const std::string& uri,
const std::string& username,
const std::string& password,
const std::string& clientId = "" );
private:
- cms::Connection* doCreateConnection( const std::string& url,
+ cms::Connection* doCreateConnection( const decaf::net::URI& uri,
const std::string& username,
const std::string& password,
const std::string& clientId );
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp Wed Jul 21 19:51:17 2010
@@ -38,7 +38,7 @@ DeflaterOutputStream::DeflaterOutputStre
}
////////////////////////////////////////////////////////////////////////////////
-DeflaterOutputStream::DeflaterOutputStream( OutputStream* outputStream, Deflater* deflater, bool own )
+DeflaterOutputStream::DeflaterOutputStream( OutputStream* outputStream, Deflater* deflater, bool own, bool ownDeflater )
: FilterOutputStream( outputStream, own ) {
if( deflater == NULL ) {
@@ -47,14 +47,14 @@ DeflaterOutputStream::DeflaterOutputStre
}
this->deflater = deflater;
- this->ownDeflater = false;
+ this->ownDeflater = ownDeflater;
this->buf.resize( DEFAULT_BUFFER_SIZE );
this->isDone = false;
}
////////////////////////////////////////////////////////////////////////////////
DeflaterOutputStream::DeflaterOutputStream( OutputStream* outputStream, Deflater* deflater,
- int bufferSize, bool own )
+ int bufferSize, bool own, bool ownDeflater )
: FilterOutputStream( outputStream, own ) {
if( deflater == NULL ) {
@@ -68,7 +68,7 @@ DeflaterOutputStream::DeflaterOutputStre
}
this->deflater = deflater;
- this->ownDeflater = false;
+ this->ownDeflater = ownDeflater;
this->buf.resize( bufferSize );
this->isDone = false;
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h Wed Jul 21 19:51:17 2010
@@ -74,7 +74,8 @@ namespace zip {
/**
* Creates a new DeflateOutputStream with a user supplied Deflater and a default buffer size.
* When the user supplied a Deflater instance the DeflaterOutpotStream does not take ownership
- * of the Deflater pointer, the caller is still responsible for deleting the Deflater.
+ * of the Deflater pointer unless the ownDeflater parameter is set to true, the caller is still
+ * responsible for deleting the Deflater when ownDeflater is false.
*
* @param outputStream
* The OutputStream instance to wrap.
@@ -82,15 +83,19 @@ namespace zip {
* The user supplied Deflater to use for compression. (
* @param own
* Should this filter take ownership of the OutputStream pointer (default is false).
+ * @param ownDeflater
+ * Should the filter take ownership of the passed Deflater object (default is false).
*
* @throws NullPointerException if the Deflater given is NULL.
*/
- DeflaterOutputStream( decaf::io::OutputStream* outputStream, Deflater* deflater, bool own = false );
+ DeflaterOutputStream( decaf::io::OutputStream* outputStream, Deflater* deflater,
+ bool own = false, bool ownDeflater = false );
/**
* Creates a new DeflateOutputStream with a user supplied Deflater and specified buffer size.
* When the user supplied a Deflater instance the DeflaterOutpotStream does not take ownership
- * of the Deflater pointer, the caller is still responsible for deleting the Deflater.
+ * of the Deflater pointer unless the ownDeflater parameter is set to true, otherwise the caller
+ * is still responsible for deleting the Deflater.
*
* @param outputStream
* The OutputStream instance to wrap.
@@ -100,12 +105,14 @@ namespace zip {
* The size of the input buffer.
* @param own
* Should this filter take ownership of the OutputStream pointer (default is false).
+ * @param ownDeflater
+ * Should the filter take ownership of the passed Deflater object (default is false).
*
* @throws NullPointerException if the Deflater given is NULL.
* @throws IllegalArgumentException if bufferSize is 0.
*/
DeflaterOutputStream( decaf::io::OutputStream* outputStream, Deflater* deflater,
- int bufferSize, bool own = false );
+ int bufferSize, bool own = false, bool ownDeflater = false );
virtual ~DeflaterOutputStream();
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp Wed Jul 21 19:51:17 2010
@@ -41,7 +41,7 @@ InflaterInputStream::InflaterInputStream
}
////////////////////////////////////////////////////////////////////////////////
-InflaterInputStream::InflaterInputStream( InputStream* inputStream, Inflater* inflater, bool own )
+InflaterInputStream::InflaterInputStream( InputStream* inputStream, Inflater* inflater, bool own, bool ownInflater )
: FilterInputStream( inputStream, own ) {
if( inflater == NULL ) {
@@ -50,14 +50,14 @@ InflaterInputStream::InflaterInputStream
}
this->inflater = inflater;
- this->ownInflater = false;
+ this->ownInflater = ownInflater;
this->buff.resize( DEFAULT_BUFFER_SIZE );
this->atEOF = false;
}
////////////////////////////////////////////////////////////////////////////////
InflaterInputStream::InflaterInputStream( InputStream* inputStream, Inflater* inflater,
- int bufferSize, bool own )
+ int bufferSize, bool own, bool ownInflater )
: FilterInputStream( inputStream, own ) {
if( inflater == NULL ) {
@@ -71,7 +71,7 @@ InflaterInputStream::InflaterInputStream
}
this->inflater = inflater;
- this->ownInflater = false;
+ this->ownInflater = ownInflater;
this->buff.resize( bufferSize );
this->atEOF = false;
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h Wed Jul 21 19:51:17 2010
@@ -78,7 +78,8 @@ namespace zip {
/**
* Creates a new InflaterInputStream with a user supplied Inflater and a default buffer size.
* When the user supplied a Inflater instance the InflaterInputStream does not take ownership
- * of the Inflater pointer, the caller is still responsible for deleting the Inflater.
+ * of the Inflater pointer unless the ownInflater parameter is set to true, otherwise the
+ * caller is still responsible for deleting the Inflater.
*
* @param inputStream
* The InputStream instance to wrap.
@@ -86,15 +87,19 @@ namespace zip {
* The user supplied Inflater to use for decompression. (
* @param own
* Should this filter take ownership of the InputStream pointer (default is false).
+ * @param ownInflater
+ * Should the filter take ownership of the passed Inflater object (default is false).
*
* @throws NullPointerException if the Inflater given is NULL.
*/
- InflaterInputStream( decaf::io::InputStream* inputStream, Inflater* inflater, bool own = false );
+ InflaterInputStream( decaf::io::InputStream* inputStream, Inflater* inflater,
+ bool own = false, bool ownInflater = false );
/**
* Creates a new DeflateOutputStream with a user supplied Inflater and specified buffer size.
* When the user supplied a Inflater instance the InflaterInputStream does not take ownership
- * of the Inflater pointer, the caller is still responsible for deleting the Inflater.
+ * of the Inflater pointer unless the ownInflater parameter is set to true, otherwise the caller
+ * is still responsible for deleting the Inflater.
*
* @param inputStream
* The InputStream instance to wrap.
@@ -104,12 +109,14 @@ namespace zip {
* The size of the input buffer.
* @param own
* Should this filter take ownership of the InputStream pointer (default is false).
+ * @param ownInflater
+ * Should the filter take ownership of the passed Inflater object (default is false).
*
* @throws NullPointerException if the Inflater given is NULL.
* @throws IllegalArgumentException if the bufferSize value is zero.
*/
InflaterInputStream( decaf::io::InputStream* inputStream, Inflater* inflater,
- int bufferSize, bool own = false );
+ int bufferSize, bool own = false, bool ownInflater = false );
virtual ~InflaterInputStream();
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/CmsTemplateTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/CmsTemplateTest.cpp?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/CmsTemplateTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/CmsTemplateTest.cpp Wed Jul 21 19:51:17 2010
@@ -76,7 +76,7 @@ namespace test {
public:
Sender( const std::string& url, bool pubSub, const std::string& destName, int count ) {
- cf.setBrokerURL(url);
+ cf.setBrokerURI(url);
cmsTemplate.setConnectionFactory(&cf);
cmsTemplate.setPubSubDomain(pubSub);
cmsTemplate.setDefaultDestinationName(destName);
@@ -116,7 +116,7 @@ namespace test {
Receiver( const std::string& url, bool pubSub, const std::string& destName, int count )
: ready(1) {
- cf.setBrokerURL(url);
+ cf.setBrokerURI(url);
cmsTemplate.setConnectionFactory(&cf);
cmsTemplate.setPubSubDomain(pubSub);
cmsTemplate.setDefaultDestinationName(destName);
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp Wed Jul 21 19:51:17 2010
@@ -239,5 +239,48 @@ void ActiveMQConnectionFactoryTest::test
CPPUNIT_ASSERT( listener.isInterrupted() );
CPPUNIT_ASSERT( listener.isResumed() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQConnectionFactoryTest::testURIOptionsProcessing() {
+
+ try
+ {
+ std::string URI =
+ "mock://127.0.0.1:23232?connection.dispatchAsync=true&"
+ "connection.alwaysSyncSend=true&connection.useAsyncSend=true&"
+ "connection.useCompression=true&connection.compressionLevel=7&"
+ "connection.closeTimeout=10000";
+
+ ActiveMQConnectionFactory connectionFactory( URI );
+
+ CPPUNIT_ASSERT( connectionFactory.isDispatchAsync() == true );
+ CPPUNIT_ASSERT( connectionFactory.isAlwaysSyncSend() == true );
+ CPPUNIT_ASSERT( connectionFactory.isUseAsyncSend() == true );
+ CPPUNIT_ASSERT( connectionFactory.isUseCompression() == true );
+ CPPUNIT_ASSERT( connectionFactory.getCloseTimeout() == 10000 );
+ CPPUNIT_ASSERT( connectionFactory.getCompressionLevel() == 7 );
+
+ cms::Connection* connection =
+ connectionFactory.createConnection();
+
+ CPPUNIT_ASSERT( connection != NULL );
+
+ ActiveMQConnection* amqConnection = dynamic_cast<ActiveMQConnection*>( connection );
+
+ CPPUNIT_ASSERT( amqConnection->isDispatchAsync() == true );
+ CPPUNIT_ASSERT( amqConnection->isAlwaysSyncSend() == true );
+ CPPUNIT_ASSERT( amqConnection->isUseAsyncSend() == true );
+ CPPUNIT_ASSERT( amqConnection->isUseCompression() == true );
+ CPPUNIT_ASSERT( amqConnection->getCloseTimeout() == 10000 );
+ CPPUNIT_ASSERT( amqConnection->getCompressionLevel() == 7 );
+
+ delete connection;
+
+ return;
+ }
+ AMQ_CATCH_NOTHROW( exceptions::ActiveMQException )
+ AMQ_CATCHALL_NOTHROW( )
+ CPPUNIT_ASSERT( false );
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h?rev=966386&r1=966385&r2=966386&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h Wed Jul 21 19:51:17 2010
@@ -33,6 +33,7 @@ namespace core{
CPPUNIT_TEST( testCreateWithURIOptions );
CPPUNIT_TEST( testTransportListener );
CPPUNIT_TEST( testExceptionWithPortOutOfRange );
+ CPPUNIT_TEST( testURIOptionsProcessing );
CPPUNIT_TEST_SUITE_END();
public:
@@ -54,6 +55,7 @@ namespace core{
void testExceptionWithPortOutOfRange();
void testCreateWithURIOptions();
void testTransportListener();
+ void testURIOptionsProcessing();
};