activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r418749 [11/17] - in /incubator/activemq/trunk/activemq-cpp: ./ src/ src/main/ src/main/activemq/ src/main/activemq/concurrent/ src/main/activemq/connector/ src/main/activemq/connector/openwire/ src/main/activemq/connector/stomp/ src/main/a...
Date Mon, 03 Jul 2006 11:51:54 GMT
Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/IOTransportFactory.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/IOTransportFactory.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/IOTransportFactory.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/IOTransportFactory.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_IOTRANSPORTFACTORY_H_
+#define ACTIVEMQ_TRANSPORT_IOTRANSPORTFACTORY_H_
+
+#include <activemq/transport/IOTransport.h>
+#include <activemq/transport/TransportFactory.h>
+#include <activemq/transport/TransportFactoryMapRegistrar.h>
+
+namespace activemq{
+namespace transport{
+    
+    /**
+     * Manufactures IOTransports, which are objects that
+     * read from input streams and write to output streams.
+     */
+    class IOTransportFactory : public TransportFactory{
+    private:
+    
+        static TransportFactoryMapRegistrar registrar;
+        
+    public:
+        
+        virtual ~IOTransportFactory(){}
+        
+        /**
+         * Creates a Transport instance.
+         * @param properties The properties for the transport.
+         */
+        virtual Transport* createTransport( 
+            const activemq::util::Properties& properties )
+        {
+            return new IOTransport();
+        }
+
+        /**
+         * Returns a reference to this TransportFactory
+         * @returns TransportFactory Reference
+         */
+        static TransportFactory& getInstance(void);
+
+    };
+    
+}}
+
+#endif /*ACTIVEMQ_TRANSPORT_IOTRANSPORTFACTORY_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/Response.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/Response.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/Response.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/Response.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_RESPONSE_H_
+#define ACTIVEMQ_TRANSPORT_RESPONSE_H_
+
+#include <activemq/transport/Command.h>
+
+namespace activemq{
+namespace transport{
+  
+  class Response : public Command{
+  public:
+  
+        virtual ~Response(void) {}
+        
+        /**
+         * Gets the Correlation Id that is associated with this message
+         * @return the Correlation Id
+         */
+        virtual unsigned int getCorrelationId() const = 0;
+
+        /**
+         * Sets the Correlation Id if this Command
+         * @param Id
+         */
+        virtual void setCorrelationId( const unsigned int corrId ) = 0;
+        
+  };
+    
+}}
+
+#endif /*ACTIVEMQ_TRANSPORT_RESPONSE_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/ResponseCorrelator.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/ResponseCorrelator.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/ResponseCorrelator.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/ResponseCorrelator.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1 @@
+#include "ResponseCorrelator.h"

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/ResponseCorrelator.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/ResponseCorrelator.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/ResponseCorrelator.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/ResponseCorrelator.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,368 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_RESPONSECORRELATOR_H_
+#define ACTIVEMQ_TRANSPORT_RESPONSECORRELATOR_H_
+
+#include <activemq/transport/TransportFilter.h>
+#include <activemq/transport/FutureResponse.h>
+#include <activemq/transport/Command.h>
+#include <activemq/transport/ExceptionResponse.h>
+#include <activemq/concurrent/Mutex.h>
+#include <activemq/concurrent/Concurrent.h>
+#include <map>
+
+namespace activemq{
+namespace transport{
+  
+    /**
+     * This type of transport filter is responsible for correlating
+     * asynchronous responses with requests.  Non-response messages
+     * are simply sent directly to the CommandListener.  It owns
+     * the transport that it
+     */
+    class ResponseCorrelator : public TransportFilter 
+    {
+    private:        
+
+        /**
+         * The next command id for sent commands.
+         */
+        unsigned int nextCommandId;        
+        
+        /**
+         * Map of request ids to future response objects.
+         */
+        std::map<unsigned int, FutureResponse*> requestMap;
+        
+        /**
+         * Maximum amount of time in milliseconds to wait for a response.
+         */
+        unsigned long maxResponseWaitTime;
+        
+        /**
+         * Sync object for accessing the next command id variable.
+         */
+        concurrent::Mutex commandIdMutex;
+        
+        /**
+         * Sync object for accessing the request map.
+         */
+        concurrent::Mutex mapMutex;
+        
+        /**
+         * Flag to indicate the closed state.
+         */
+        bool closed;
+       
+    private:
+    
+        /**
+         * Returns the next available command id.
+         */
+        unsigned int getNextCommandId() throw (exceptions::ActiveMQException){
+            
+            try{
+                synchronized( &commandIdMutex ){
+                    return ++nextCommandId;
+                }
+                
+                // Should never get here, but some compilers aren't
+                // smart enough to figure out we'll never get here.
+                return 0;
+            }
+            AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+            AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+        }
+         
+    public:
+  
+        /**
+         * Constructor.
+         */
+        ResponseCorrelator( Transport* next, const bool own = true )
+        :
+            TransportFilter( next, own )
+        {            
+            nextCommandId = 0;
+            
+            // Default max response wait time to 3 seconds.
+            maxResponseWaitTime = 3000;
+            
+            // Start in the closed state. 
+            closed = true;
+        }
+        
+        /**
+         * Destructor - calls close().
+         */
+        virtual ~ResponseCorrelator(){
+            
+            // Close the transport and destroy it.
+            close();
+        
+            // Don't do anything with the future responses -
+            // they should be cleaned up by each requester.                        
+        }
+        
+        /**
+         * Gets the maximum wait time for a response in milliseconds.
+         */
+        virtual unsigned long getMaxResponseWaitTime() const{
+            return maxResponseWaitTime;
+        }           
+        
+        /**
+         * Sets the maximum wait time for a response in milliseconds.
+         */
+        virtual void setMaxResponseWaitTime( const unsigned long milliseconds ){
+            maxResponseWaitTime = milliseconds;
+        }
+        
+        /**
+         * Sends a one-way command.  Does not wait for any response from the
+         * broker.
+         * @param command the command to be sent.
+         * @throws CommandIOException if an exception occurs during writing of
+         * the command.
+         * @throws UnsupportedOperationException if this method is not implemented
+         * by this transport.
+         */
+        virtual void oneway( Command* command ) 
+            throw(CommandIOException, exceptions::UnsupportedOperationException)
+        {
+            
+            try{
+                command->setCommandId( getNextCommandId() );
+                command->setResponseRequired( false );
+                
+                if( closed || next == NULL ){
+                    throw CommandIOException( __FILE__, __LINE__,
+                        "transport already closed" );
+                }
+                
+                next->oneway( command );
+            }
+            AMQ_CATCH_RETHROW( exceptions::UnsupportedOperationException )
+            AMQ_CATCH_RETHROW( CommandIOException )
+            AMQ_CATCH_EXCEPTION_CONVERT( exceptions::ActiveMQException, CommandIOException )
+            AMQ_CATCHALL_THROW( CommandIOException )
+        }
+        
+        /**
+         * Sends the given request to the server and waits for the response.
+         * @param command The request to send.
+         * @return the response from the server.  This may be of type ExceptionResponse
+         * in the case of a distributed error that occurs at the broker.
+         * @throws CommandIOException if an error occurs with the request.
+         */
+        virtual Response* request( Command* command ) 
+            throw(CommandIOException, exceptions::UnsupportedOperationException)
+        {
+            
+            try{
+                command->setCommandId( getNextCommandId() );
+                command->setResponseRequired( true );
+                
+                // Add a future response object to the map indexed by this
+                // command id.
+                FutureResponse* futureResponse = 
+                   new FutureResponse();
+                  
+                synchronized( &mapMutex ){
+                    requestMap[command->getCommandId()] = futureResponse;
+                }                                
+                
+                // Wait to be notified of the response via the futureResponse
+                // object.
+                Response* response = NULL;
+                synchronized( futureResponse ){
+                    
+                    // Send the request.
+                    next->oneway( command );
+                    
+                    // Wait for the response to come in.
+                    futureResponse->wait( maxResponseWaitTime );                                       
+                    
+                    // Get the response.
+                    response = futureResponse->getResponse();                    
+                }                              
+                                
+                // Perform cleanup on the map.
+                synchronized( &mapMutex ){
+                    
+                    // We've done our waiting - get this thing out
+                    // of the map.
+                    requestMap.erase( command->getCommandId() );
+                    
+                    // Destroy the futureResponse.  It is safe to
+                    // do this now because the other thread only
+                    // accesses the futureResponse within a lock on
+                    // the map.
+                    delete futureResponse;
+                    futureResponse = NULL;
+                }
+                    
+                if( response == NULL ){                                        
+                    
+                    throw CommandIOException( __FILE__, __LINE__,
+                        "response from futureResponse was invalid" );
+                }
+                
+                return response;                
+            }
+            AMQ_CATCH_RETHROW( exceptions::UnsupportedOperationException )
+            AMQ_CATCH_RETHROW( CommandIOException )
+            AMQ_CATCH_EXCEPTION_CONVERT( exceptions::ActiveMQException, CommandIOException )
+            AMQ_CATCHALL_THROW( CommandIOException )
+        }
+        
+        /**
+         * This is called in the context of the nested transport's
+         * reading thread.  In the case of a response object,
+         * updates the request map and notifies those waiting on the
+         * response.  Non-response messages are just delegated to
+         * the command listener.
+         * @param command the received from the nested transport.
+         */
+        virtual void onCommand( Command* command ){
+            
+            // Let's see if the incoming command is a response.
+            Response* response = 
+               dynamic_cast<Response*>(command);
+               
+            if( response == NULL ){
+                
+                // It's a non-response - just notify the listener.
+                fire( command );
+                return;
+            }
+                
+            // It is a response - let's correlate ...
+            synchronized( &mapMutex ){
+                
+                // Look the future request up based on the correlation id.
+                std::map<unsigned int, FutureResponse*>::iterator iter =
+                    requestMap.find( response->getCorrelationId() );
+                if( iter == requestMap.end() ){
+                    
+                    // This is not terrible - just log it.
+                    printf("ResponseCorrelator::onCommand() - received unknown response for request: %d\n", 
+                        response->getCorrelationId() );
+                    return;
+                }
+                
+                // Get the future response (if it's in the map, it's not NULL).
+                FutureResponse* futureResponse = iter->second;
+                
+                // If it's an exception response, notify the exception listener.
+                ExceptionResponse* exResp = 
+                    dynamic_cast<ExceptionResponse*>(response);
+                if( exResp != NULL ){
+                    const BrokerError* error = exResp->getException();
+                    fire( *error );
+                }
+                
+                synchronized( futureResponse ){
+                    
+                    // Set the response property in the future response.
+                    futureResponse->setResponse( response );
+                    
+                    // Notify all waiting for this response.
+                    futureResponse->notifyAll();
+                }
+            }
+        }
+        
+        /**
+         * Assigns the command listener for non-response commands.
+         * @param listener the listener.
+         */
+        virtual void setCommandListener( CommandListener* listener ){
+            this->commandlistener = listener;
+        }
+        
+        /**
+         * Sets the observer of asynchronous exceptions from this transport.
+         * @param listener the listener of transport exceptions.
+         */
+        virtual void setTransportExceptionListener( 
+            TransportExceptionListener* listener )
+        {
+            this->exceptionListener = listener;
+        }
+        
+        /**
+         * Starts this transport object and creates the thread for
+         * polling on the input stream for commands.  If this object
+         * has been closed, throws an exception.  Before calling start,
+         * the caller must set the IO streams and the reader and writer
+         * objects.
+         * @throws CMSException if an error occurs or if this transport
+         * has already been closed.
+         */
+        virtual void start() throw( cms::CMSException ){
+            
+            /**
+             * We're already started.
+             */
+            if( !closed ){
+                return;
+            }
+            
+            if( commandlistener == NULL ){
+                throw exceptions::ActiveMQException( __FILE__, __LINE__,
+                    "commandListener is invalid" );
+            }
+            
+            if( exceptionListener == NULL ){
+                throw exceptions::ActiveMQException( __FILE__, __LINE__,
+                    "exceptionListener is invalid" );
+            }
+            
+            if( next == NULL ){
+                throw exceptions::ActiveMQException( __FILE__, __LINE__,
+                    "next transport is NULL" );
+            }
+            
+            // Start the delegate transport object.
+            next->start();
+            
+            // Mark it as open.
+            closed = false;
+        }
+        
+        /**
+         * Stops the polling thread and closes the streams.  This can
+         * be called explicitly, but is also called in the destructor. Once
+         * this object has been closed, it cannot be restarted.
+         * @throws CMSException if errors occur.
+         */
+        virtual void close() throw( cms::CMSException ){
+            
+            if( !closed && next != NULL ){
+                next->close();
+            }
+            
+            closed = true;
+        }
+        
+    };
+    
+}}
+
+#endif /*ACTIVEMQ_TRANSPORT_RESPONSECORRELATOR_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransport.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransport.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransport.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransport.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 "TcpTransport.h"
+
+#include <activemq/network/SocketFactory.h>
+#include <activemq/transport/IOTransport.h>
+#include <activemq/transport/TransportFactory.h>
+#include <activemq/transport/TransportFactoryMap.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::transport;
+using namespace activemq::network;
+using namespace activemq::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+TcpTransport::TcpTransport( const activemq::util::Properties& properties,
+                            Transport* next, 
+                            const bool own )
+ : TransportFilter( next, own )
+{
+    try
+    {
+        // Create the IO device we will be communicating over the
+        // wire with.  This may need to change if we add more types
+        // of sockets, such as SSL.  
+        socket = SocketFactory::createSocket(properties);
+
+        // Cast it to an IO transport so we can wire up the socket
+        // input and output streams.
+        IOTransport* ioTransport = dynamic_cast<IOTransport*>( next );
+        if( ioTransport == NULL ){
+            throw ActiveMQException( 
+                __FILE__, __LINE__, 
+                "TcpTransport::TcpTransport - "
+                "transport must be of type IOTransport");
+        }
+
+        // Give the IOTransport the streams from out TCP socket.        
+        ioTransport->setInputStream( socket->getInputStream() );
+        ioTransport->setOutputStream( socket->getOutputStream() );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+TcpTransport::~TcpTransport(void)
+{
+    try
+    {
+        socket->close();
+        delete socket;
+    }
+    AMQ_CATCH_NOTHROW( ActiveMQException )
+    AMQ_CATCHALL_NOTHROW( )
+}
+

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransport.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransport.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransport.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransport.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_TCPTRANSPORT_H_
+#define _ACTIVEMQ_TRANSPORT_TCPTRANSPORT_H_
+
+#include <activemq/transport/TransportFilter.h>
+#include <activemq/network/Socket.h>
+#include <activemq/util/Properties.h>
+
+namespace activemq{
+namespace transport{
+
+    /**
+     * Implements a TCP/IP based transport filter, this transport
+     * is meant to wrap an instance of an IOTransport.  The lower
+     * level transport should take care of manaing stream reads
+     * and writes.
+     */
+    class TcpTransport : public TransportFilter 
+    {
+    private:
+
+        /**
+         * Socket that this Transport Communicates with
+         */
+        network::Socket* socket;
+
+    public:
+
+    	TcpTransport( const activemq::util::Properties& properties,
+                      Transport* next, 
+                      const bool own = true );
+    	virtual ~TcpTransport(void);
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_TRANSPORT_TCPTRANSPORT_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransportFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransportFactory.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransportFactory.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransportFactory.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 "TcpTransportFactory.h"
+
+#include <activemq/transport/TcpTransport.h>
+#include <activemq/transport/ResponseCorrelator.h>
+
+using namespace activemq;
+using namespace activemq::transport;
+using namespace activemq::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+TransportFactory& TcpTransportFactory::getInstance(void)
+{
+    // Create the one and only instance of the registrar
+    static TransportFactoryMapRegistrar registrar(
+        "tcp", new TcpTransportFactory());
+        
+    return registrar.getFactory();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Transport* TcpTransportFactory::createTransport( 
+    const activemq::util::Properties& properties )
+        throw ( ActiveMQException )
+{
+    try
+    {
+        TransportFactory* factory = 
+            TransportFactoryMap::getInstance().lookup( "io" );
+    
+        if( factory == NULL ){
+            throw ActiveMQException( 
+                __FILE__, __LINE__, 
+                "TcpTransport::createTransport - "
+                "unknown transport factory");
+        }
+    
+        Transport* transport = new TcpTransport( 
+            properties, factory->createTransport( properties ) );
+
+        // Create a response correlator.  This will wrap around our 
+        // transport and manage its lifecycle - we don't need the 
+        // internal transport anymore, so we can reuse its pointer.
+        transport = new ResponseCorrelator( transport );
+        
+        return transport;
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransportFactory.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransportFactory.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransportFactory.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TcpTransportFactory.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_TCPTRANSPORTFACTORY_H_
+#define _ACTIVEMQ_TRANSPORT_TCPTRANSPORTFACTORY_H_
+
+#include <activemq/transport/TransportFactory.h>
+#include <activemq/transport/TransportFactoryMapRegistrar.h>
+#include <activemq/transport/IOTransportFactory.h>
+#include <activemq/exceptions/ActiveMQException.h>
+
+namespace activemq{
+namespace transport{
+    
+    class TcpTransportFactory : public TransportFactory
+    {
+    public:
+
+    	virtual ~TcpTransportFactory(void) {}
+
+        /**
+         * Creates a Transport instance.  
+         * @param properties The properties for the transport.
+         * @throws ActiveMQException
+         */
+        virtual Transport* createTransport( 
+            const activemq::util::Properties& properties )
+                throw ( exceptions::ActiveMQException );
+
+        /**
+         * Returns a reference to this TransportFactory
+         * @returns TransportFactory Reference
+         */
+        static TransportFactory& getInstance(void);
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_TRANSPORT_TCPTRANSPORTFACTORY_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/Transport.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/Transport.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/Transport.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/Transport.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_TRANSPORT_H_
+#define ACTIVEMQ_TRANSPORT_TRANSPORT_H_
+
+#include <activemq/io/InputStream.h>
+#include <activemq/io/OutputStream.h>
+#include <activemq/transport/CommandIOException.h>
+#include <activemq/exceptions/UnsupportedOperationException.h>
+#include <activemq/transport/Command.h>
+#include <activemq/transport/Response.h>
+#include <cms/Startable.h>
+#include <cms/Closeable.h>
+
+namespace activemq{
+namespace transport{
+  
+   // Forward declarations.
+   class CommandListener;
+   class CommandReader;
+   class CommandWriter;
+   class TransportExceptionListener;
+     
+   /**
+    * Interface for a transport layer for command objects.  Callers can
+    * send oneway messages or make synchronous requests.  Non-response
+    * messages will be delivered to the specified listener object upon
+    * receipt.
+    */
+   class Transport
+   :
+      public cms::Startable,
+      public cms::Closeable
+   {
+   public:
+     
+      virtual ~Transport(){}
+        
+      /**
+       * Sends a one-way command.  Does not wait for any response from the
+       * broker.
+       * @param command the command to be sent.
+       * @throws CommandIOException if an exception occurs during writing of
+       * the command.
+       * @throws UnsupportedOperationException if this method is not implemented
+       * by this transport.
+       */
+      virtual void oneway( Command* command ) 
+         throw(CommandIOException, 
+               exceptions::UnsupportedOperationException) = 0;
+  
+      /**
+       * Sends the given command to the broker and then waits for the response.
+       * @param command the command to be sent.
+       * @return the response from the broker.
+       * @throws CommandIOException if an exception occurs during the read of the
+       * command.
+       * @throws UnsupportedOperationException if this method is not implemented
+       * by this transport.
+       */
+      virtual Response* request( Command* command ) 
+        throw(CommandIOException, 
+              exceptions::UnsupportedOperationException) = 0;
+     
+      /**
+       * Assigns the command listener for non-response commands.
+       * @param listener the listener.
+       */
+      virtual void setCommandListener( CommandListener* listener ) = 0;
+     
+      /**
+       * Sets the command reader.
+       * @param reader the object that will be used for reading command objects.
+       */
+      virtual void setCommandReader( CommandReader* reader ) = 0;
+        
+      /**
+       * Sets the command writer.
+       * @param writer the object that will be used for writing command objects.
+       */
+      virtual void setCommandWriter( CommandWriter* writer ) = 0;
+     
+      /**
+       * Sets the observer of asynchronous exceptions from this transport.
+       * @param listener the listener of transport exceptions.
+       */
+      virtual void setTransportExceptionListener( 
+        TransportExceptionListener* listener ) = 0;
+   };
+    
+}}
+
+#endif /*ACTIVEMQ_TRANSPORT_TRANSPORT_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportExceptionListener.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportExceptionListener.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportExceptionListener.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportExceptionListener.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_TRANSPORTEXCEPTIONLISTENER_H_
+#define ACTIVEMQ_TRANSPORT_TRANSPORTEXCEPTIONLISTENER_H_
+
+#include <activemq/exceptions/ActiveMQException.h>
+
+namespace activemq{
+namespace transport{
+  
+   // Forward declarations.
+   class Transport;
+  
+   /**
+    * A listener of asynchronous exceptions from a command transport object.
+    */
+   class TransportExceptionListener{
+   public:
+        
+      virtual ~TransportExceptionListener(){}
+        
+      /**
+       * Event handler for an exception from a command transport.
+       * @param source The source of the exception
+       * @param ex The exception.
+       */
+      virtual void onTransportException( 
+         Transport* source, 
+         const exceptions::ActiveMQException& ex ) = 0;
+  };
+    
+}}
+
+#endif /*ACTIVEMQ_TRANSPORT_TRANSPORTEXCEPTIONLISTENER_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactory.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactory.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactory.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactory.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_TRANSPORTFACTORY_H_
+#define ACTIVEMQ_TRANSPORT_TRANSPORTFACTORY_H_
+
+#include <activemq/transport/IOTransport.h>
+#include <activemq/transport/ResponseCorrelator.h>
+#include <activemq/io/InputStream.h>
+#include <activemq/io/OutputStream.h>
+#include <activemq/exceptions/IllegalArgumentException.h>
+#include <activemq/util/Properties.h>
+
+namespace activemq{
+namespace transport{
+    
+    class TransportFactory{
+    public:
+        
+        virtual ~TransportFactory(void){}
+        
+        /**
+         * Creates a Transport instance.
+         * @param Properties Object that will hold transport values
+         */
+        virtual Transport* createTransport(
+            const activemq::util::Properties& properties ) = 0;
+
+    };
+    
+}}
+
+#endif /*ACTIVEMQ_TRANSPORT_TRANSPORTFACTORY_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactoryMap.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactoryMap.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactoryMap.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactoryMap.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 "TransportFactoryMap.h"
+
+using namespace activemq::transport;
+using namespace std;
+
+////////////////////////////////////////////////////////////////////////////////
+TransportFactoryMap& TransportFactoryMap::getInstance(void)
+{
+    // Static instance of this Map, create here so that one will
+    // always exist, the one and only Connector Map.      
+    static TransportFactoryMap instance;
+    
+    return instance;
+} 
+
+////////////////////////////////////////////////////////////////////////////////
+void TransportFactoryMap::registerTransportFactory( const string& name, 
+    TransportFactory* factory )
+{
+    factoryMap[name] = factory;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TransportFactoryMap::unregisterTransportFactory( const string& name ){
+    factoryMap.erase(name);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+TransportFactory* TransportFactoryMap::lookup( const string& name ){
+    
+    map<string, TransportFactory*>::const_iterator itr = 
+    factoryMap.find(name);
+
+    if(itr != factoryMap.end())
+    {
+        return itr->second;
+    }
+
+    // Didn't find it, return nothing, not a single thing.
+    return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+size_t TransportFactoryMap::getFactoryNames(vector<string>& factoryList){
+    map<string, TransportFactory*>::const_iterator itr =
+    factoryMap.begin();
+  
+    for(; itr != factoryMap.end(); ++itr)
+    {
+        factoryList.insert(factoryList.end(), itr->first);
+    }
+  
+    return factoryMap.size();
+}

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactoryMap.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactoryMap.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactoryMap.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactoryMap.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_TRANSPORTFACTORYMAP_H_
+#define ACTIVEMQ_TRANSPORT_TRANSPORTFACTORYMAP_H_
+
+#include <activemq/transport/TransportFactory.h>
+#include <map>
+#include <string>
+
+namespace activemq{
+namespace transport{
+  
+    /**
+     * The TransportFactoryMap contains keys that map to specific versions
+     * of the TransportFactory class which create a particular type of
+     * Transport.
+     */
+    class TransportFactoryMap{
+        
+    private:
+    
+        // Map of Factories
+        std::map<std::string, TransportFactory*> factoryMap;
+
+    private:
+   
+        // Hidden Contrustor, prevents instantiation
+        TransportFactoryMap() {};
+      
+        // Hidden Destructor.
+        virtual ~TransportFactoryMap() {};
+ 
+        // Hidden Copy Constructore
+        TransportFactoryMap(const TransportFactoryMap& factoryMap){};
+      
+        // Hidden Assignment operator
+        TransportFactoryMap& operator=(const TransportFactoryMap& factoryMap){ 
+            return *this;
+        }     
+        
+    public:
+        
+        /**
+         * Gets a singleton instance of this class.
+         */
+        static TransportFactoryMap& getInstance(void);
+      
+        /**
+         * Registers a new Transport Factory with this map
+         * @param name to associate the factory with
+         * @param factory to store.
+         */
+        void registerTransportFactory( const std::string& name, 
+            TransportFactory* factory );
+        
+        /**
+         * Unregisters a Transport Factory with this map
+         * @param name of the factory to remove
+         */
+        void unregisterTransportFactory( const std::string& name );
+        
+        /**
+         * Lookup the named factory in the Map
+         * @param the factory name to lookup
+         * @return the factory assciated with the name, or NULL
+         */
+        TransportFactory* lookup( const std::string& name );
+        
+        /**
+         * Fetch a list of factory names that this Map contains
+         * @param vector object to receive the list
+         * @returns count of factories.
+         */
+        std::size_t getFactoryNames(std::vector<std::string>& factoryList);
+        
+    };
+    
+}}
+
+#endif /*ACTIVEMQ_TRANSPORT_TRANSPORTFACTORYMAP_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactoryMapRegistrar.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactoryMapRegistrar.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactoryMapRegistrar.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFactoryMapRegistrar.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_TRANSPORTFACTORYMAPREGISTRAR_H_
+#define ACTIVEMQ_TRANSPORT_TRANSPORTFACTORYMAPREGISTRAR_H_
+
+#include <activemq/transport/TransportFactoryMap.h>
+
+namespace activemq{
+namespace transport{
+
+    /**
+     * Registers the passed in factory into the factory map, this class
+     * can manage the lifetime of the registered factory (default behaviour).
+     */
+    class TransportFactoryMapRegistrar
+    {
+    public:
+   
+        /** 
+         * Constructor for this class
+         * @param name of the factory to register
+         * @param the factory
+         * @param boolean indicating if this object manages the lifetime of 
+         *        the factory that is being registered.
+         */
+        TransportFactoryMapRegistrar(const std::string& name, 
+                                      TransportFactory*  factory,
+                                      bool               manageLifetime = true)
+        {       
+            // Register it in the map.
+            TransportFactoryMap::getInstance().
+                registerTransportFactory(name, factory);
+
+            // Store for later deletion            
+            this->factory        = factory;
+            this->manageLifetime = manageLifetime;
+            this->name           = name;
+        }
+      
+        virtual ~TransportFactoryMapRegistrar(void)
+        {
+            try
+            {
+                // UnRegister it in the map.
+                TransportFactoryMap::getInstance().
+                    unregisterTransportFactory(name);
+            
+                if(manageLifetime)
+                {
+                    delete factory;
+                }
+            }
+            catch(...) {}
+        }
+      
+        /**
+         * Return a reference to the factory object that is contained in this
+         * registrar.
+         * @return TransportFactory reference
+         */
+        virtual TransportFactory& getFactory(void) {
+            return *factory;
+        }
+      
+    private:
+      
+        std::string       name;
+        TransportFactory* factory;
+        bool              manageLifetime;
+
+    }; 
+      
+}}
+
+#endif /*ACTIVEMQ_TRANSPORT_TRANSPORTFACTORYMAPREGISTRAR_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFilter.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFilter.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFilter.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/transport/TransportFilter.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,230 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_TRANSPORTFILTER_H_
+#define ACTIVEMQ_TRANSPORT_TRANSPORTFILTER_H_
+
+#include <activemq/transport/Transport.h>
+#include <activemq/transport/CommandListener.h>
+#include <activemq/transport/Command.h>
+#include <activemq/transport/TransportExceptionListener.h>
+
+namespace activemq{
+namespace transport{
+  
+    /**
+     * A filter on the transport layer.  Transport
+     * filters implement the Transport interface and 
+     * optionally delegate calls to another Transport object.
+     */
+    class TransportFilter 
+    : 
+        public Transport,
+        public CommandListener,
+        public TransportExceptionListener
+    {
+    protected:        
+        
+        /**
+         * The transport that this filter wraps around.
+         */
+        Transport* next;
+        
+        /**
+         * Flag to indicate whether this object controls
+         * the lifetime of the next transport object.
+         */
+        bool own;
+        
+        /**
+         * Listener to incoming commands.
+         */
+        CommandListener* commandlistener;
+        
+        /**
+         * Listener of exceptions from this transport.
+         */
+        TransportExceptionListener* exceptionListener;
+        
+    protected:
+    
+        /**
+         * Notify the excpetion listener
+         */
+        void fire( const exceptions::ActiveMQException& ex ){
+
+            if( exceptionListener != NULL ){
+                
+                try{
+                    exceptionListener->onTransportException( this, ex );
+                }catch( ... ){}
+            }            
+        }
+        
+        /**
+         * Notify the command listener.
+         */
+        void fire( Command* command ){
+            
+            try{
+                if( commandlistener != NULL ){
+                    commandlistener->onCommand( command );
+                }
+            }catch( ... ){}
+        }
+        
+    public:
+  
+        /**
+         * Constructor.
+         */
+        TransportFilter( Transport* next, const bool own = true ){
+            
+            this->next = next;
+            this->own = own;
+            
+            commandlistener = NULL;
+            exceptionListener = NULL;
+                                    
+            // Observe the nested transport for events.
+            next->setCommandListener( this );
+            next->setTransportExceptionListener( this );
+        }
+        
+        /**
+         * Destructor - calls close().
+         */
+        virtual ~TransportFilter(){
+            
+            if( own ){
+                delete next;
+                next = NULL;
+            }
+            
+        }
+        
+        /**
+         * Event handler for the receipt of a command.
+         * @param command the received command object.
+         */
+        virtual void onCommand( Command* command ){
+            fire( command );
+        }
+        
+        /**
+         * Event handler for an exception from a command transport.
+         * @param source The source of the exception
+         * @param ex The exception.
+         */
+        virtual void onTransportException( Transport* source, const exceptions::ActiveMQException& ex ){
+            fire( ex );
+        }
+        
+        /**
+         * Sends a one-way command.  Does not wait for any response from the
+         * broker.
+         * @param command the command to be sent.
+         * @throws CommandIOException if an exception occurs during writing of
+         * the command.
+         * @throws UnsupportedOperationException if this method is not implemented
+         * by this transport.
+         */
+        virtual void oneway( Command* command ) throw(CommandIOException, exceptions::UnsupportedOperationException){
+            next->oneway( command );
+        }
+        
+        /**
+         * Not supported by this class - throws an exception.
+         * @throws UnsupportedOperationException.
+         */
+        virtual Response* request( Command* command ) throw(CommandIOException, exceptions::UnsupportedOperationException){
+            return next->request( command );
+        }
+        
+        /**
+         * Assigns the command listener for non-response commands.
+         * @param listener the listener.
+         */
+        virtual void setCommandListener( CommandListener* listener ){
+            this->commandlistener = listener;
+        }
+        
+        /**
+         * Sets the command reader.
+         * @param reader the object that will be used for reading command objects.
+         */
+        virtual void setCommandReader( CommandReader* reader ){
+            next->setCommandReader( reader );
+        }
+        
+        /**
+         * Sets the command writer.
+         * @param writer the object that will be used for writing command objects.
+         */
+        virtual void setCommandWriter( CommandWriter* writer ){
+            next->setCommandWriter( writer );
+        }
+      
+        /**
+         * Sets the observer of asynchronous exceptions from this transport.
+         * @param listener the listener of transport exceptions.
+         */
+        virtual void setTransportExceptionListener( TransportExceptionListener* listener ){
+            this->exceptionListener = listener;
+        }
+        
+        /**
+         * Starts this transport object and creates the thread for
+         * polling on the input stream for commands.  If this object
+         * has been closed, throws an exception.  Before calling start,
+         * the caller must set the IO streams and the reader and writer
+         * objects.
+         * @throws CMSException if an error occurs or if this transport
+         * has already been closed.
+         */
+        virtual void start() throw( cms::CMSException ){
+            
+            if( commandlistener == NULL ){
+                throw exceptions::ActiveMQException( __FILE__, __LINE__,
+                    "commandListener is invalid" );
+            }
+            
+            if( exceptionListener == NULL ){
+                throw exceptions::ActiveMQException( __FILE__, __LINE__,
+                    "exceptionListener is invalid" );
+            }
+            
+            // Start the delegate transport object.
+            next->start();
+        }
+        
+        /**
+         * Stops the polling thread and closes the streams.  This can
+         * be called explicitly, but is also called in the destructor. Once
+         * this object has been closed, it cannot be restarted.
+         * @throws CMSException if errors occur.
+         */
+        virtual void close() throw( cms::CMSException ){
+            
+            next->close();
+        }
+        
+    };
+    
+}}
+
+#endif /*ACTIVEMQ_TRANSPORT_TRANSPORTFILTER_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Boolean.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Boolean.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Boolean.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Boolean.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_UTIL_BOOLEAN_H_
+#define _ACTIVEMQ_UTIL_BOOLEAN_H_
+
+#include <activemq/util/Number.h>
+
+namespace activemq{
+namespace util{
+
+    class Boolean : Number
+    {
+    public:
+
+    	Boolean(void) {}
+    	virtual ~Boolean(void) {}
+
+        /**
+         * Parses the String passed and extracts an bool.
+         * @param String to parse
+         * @return bool value
+         */
+        static int parseBoolean(const std::string& value){
+            bool ret = 0;
+            std::istringstream istream(value);
+            istream.clear();
+            istream >> std::boolalpha >> ret;
+            return ret;
+        }
+        
+        /**
+         * Converts the bool to a String representation
+         * @param bool to convert
+         * @return string representation
+         */
+        static std::string toString(bool value){
+            std::ostringstream ostream;
+            ostream << std::boolalpha << value;
+            return ostream.str();
+        }
+
+    };
+
+}}
+
+#endif /*BOOLEAN_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Endian.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Endian.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Endian.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Endian.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_UTIL_ENDIAN_H
+#define ACTIVEMQ_UTIL_ENDIAN_H
+
+#ifdef unix
+#include <netinet/in.h>
+#else
+#include <Winsock2.h>
+#endif
+
+// First try - check __BYTE_ORDER macro
+#if !defined IFR_IS_BIG_ENDIAN && !defined IFR_IS_LITTLE_ENDIAN && !defined IFR_IS_DPD_ENDIAN
+# ifdef unix
+#  include <sys/param.h> // defines __BYTE_ORDER (or sometimes __LITTLE_ENDIAN or __BIG_ENDIAN or __PDP_ENDIAN)
+# endif
+# if defined (__GLIBC__)
+#  include <endian.h> // Can also define __BYTE_ORDER
+# endif
+# ifdef __BYTE_ORDER
+#  if __BYTE_ORDER == __LITTLE_ENDIAN
+#   define IFR_IS_LITTLE_ENDIAN
+#  elif __BYTE_ORDER == __BIG_ENDIAN
+#   define IFR_IS_BIG_ENDIAN
+#  elif __BYTE_ORDER == __PDP_ENDIAN
+#   define IFR_IS_PDP_ENDIAN
+#  endif
+# endif
+#endif
+
+// Second try - check __LITTLE_ENDIAN or __BIG_ENDIAN
+#if !defined IFR_IS_BIG_ENDIAN && !defined IFR_IS_LITTLE_ENDIAN && !defined IFR_IS_DPD_ENDIAN
+# if defined __LITTLE_ENDIAN
+#  define IFR_IS_LITTLE_ENDIAN
+# elif defined __BIG_ENDIAN
+#  define IFR_IS_BIG_ENDIAN
+# elif defined __PDP_ENDIAN
+#  define IFR_IS_PDP_ENDIAN
+# endif
+#endif
+
+// Last try - find out from well-known processor types using little endian
+#if !defined IFR_IS_BIG_ENDIAN && !defined IFR_IS_LITTLE_ENDIAN && !defined IFR_IS_DPD_ENDIAN
+# if defined (i386) || defined (__i386__) \
+  || defined (_M_IX86) || defined (vax) \
+  || defined (__alpha) || defined (__alpha__) \
+  || defined (__x86_64__) || defined (__ia64) \
+  || defined (__ia64__) || defined (__amd64__) \
+  || defined (_M_IX86) || defined (_M_IA64) \
+  || defined (_M_ALPHA)
+#  define IFR_IS_LITTLE_ENDIAN
+# else
+#  if defined (__sparc) || defined(__sparc__) \
+  || defined(_POWER) || defined(__powerpc__) \
+  || defined(__ppc__) || defined(__hppa) \
+  || defined(_MIPSEB) || defined(_POWER) \
+  || defined(__s390__)
+#   define IFR_IS_BIG_ENDIAN
+#  endif
+# endif
+#endif
+
+// Show error if we still don't know endianess
+#if !defined IFR_IS_BIG_ENDIAN && !defined IFR_IS_LITTLE_ENDIAN && !defined IFR_IS_DPD_ENDIAN
+#error "Could not determine endianess of your processor type"
+#endif
+
+// Use these if the compiler does not support _intXX
+#ifdef NEEDS_INT_DEFINED
+#define _int16 short
+#define _int32 int
+#define _int64 long long
+#endif
+
+// Check for uintXX types
+#ifndef uint8_t
+#define uint8_t unsigned char
+#endif
+#ifndef uint16_t
+#define uint16_t unsigned short
+#endif
+#ifndef uint32_t
+#define uint32_t unsigned int
+#endif
+#ifndef uint64_t
+#define uint64_t unsigned long long
+#endif
+
+// Macros and helpers for endian conversion
+namespace activemq{
+namespace util{
+	
+/*#ifdef IFR_IS_BIGENDIAN
+inline unsigned int       htoni   (unsigned int i)        { return i; }
+inline unsigned long long htonll  (unsigned long long ll) { return ll; }
+inline float              htonf   (float f)               { return f; }
+inline double             htond   (double d)              { return d; }
+inline unsigned int       ntohi   (unsigned int i)        { return i; }
+inline unsigned long long ntohll  (unsigned long long ll) { return ll; }
+inline float              ntohf   (float f)               { return f; }
+inline double             ntohd   (double d)              { return d; }
+#else // !IFR_IS_BIGENDIAN
+
+inline unsigned int htoni (unsigned int i) {
+  return ( i << 8  ) & 0xFF00 |
+	     ( i >> 8  ) & 0x00FF;
+}
+inline unsigned long long htonll (unsigned long long ll) {
+  return
+    ( ll << 56 ) & 0xFF00000000000000ULL |
+	( ll << 40 ) & 0x00FF000000000000ULL |
+	( ll << 24 ) & 0x0000FF0000000000ULL |
+	( ll << 8  ) & 0x000000FF00000000ULL |
+    ( ll >> 8  ) & 0x00000000FF000000ULL |
+	( ll >> 24 ) & 0x0000000000FF0000ULL |
+	( ll >> 40 ) & 0x000000000000FF00ULL |
+	( ll >> 56 ) & 0x00000000000000FFULL;
+}
+
+
+inline float htonf (float f) {
+  unsigned int i = htonl( *(unsigned int *)&f ) ;
+  return *(float *)&i ;
+}
+inline double htond (double d) {
+  unsigned long long ll = htonll( *(unsigned long long *)&d ) ;
+  return *(double *)&ll ;
+}
+inline unsigned int       ntohi   (unsigned int i)        { return htoni (i); }
+inline unsigned long long ntohll  (unsigned long long ll) { return htonll (ll); }
+inline float              ntohf   (float f)               { return htonf (f); }
+inline double             ntohd   (double d)              { return htond (d); }
+*/
+	class Endian{
+	public:
+	
+		static void byteSwap(unsigned char* data, int dataLength) {
+			
+			#ifdef IFR_IS_BIGENDIAN
+				return;
+			#endif
+			
+		    for (int i = 0; i<dataLength/2; i++) {
+				unsigned char temp = data[i];
+				data[i] = data[dataLength-1-i];
+				data[dataLength-1-i] = temp;
+		    }
+		}
+		
+		static uint8_t byteSwap( uint8_t value ){
+			byteSwap( (unsigned char*)&value, sizeof( value ) );
+			return value;
+		}
+		
+		static uint16_t byteSwap( uint16_t value ){
+			byteSwap( (unsigned char*)&value, sizeof( value ) );
+			return value;
+		}
+		
+		static uint32_t byteSwap( uint32_t value ){
+			byteSwap( (unsigned char*)&value, sizeof( value ) );
+			return value;
+		}
+		
+		static uint64_t byteSwap( uint64_t value ){
+			byteSwap( (unsigned char*)&value, sizeof( value ) );
+			return value;
+		}
+		
+		static float byteSwap( float value ){
+			byteSwap( (unsigned char*)&value, sizeof( value ) );
+			return value;
+		}
+		
+		static double byteSwap( double value ){
+			byteSwap( (unsigned char*)&value, sizeof( value ) );
+			return value;
+		}
+	};
+	
+//#endif // IFR_IS_BIGENDIAN
+
+}}
+
+#endif /*ACTIVEMQ_UTIL_ENDIAN_H*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,405 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 "Guid.h"
+#include <stdexcept>
+
+using namespace activemq::util;
+using namespace activemq::exceptions;
+using namespace std;
+
+////////////////////////////////////////////////////////////////////////////////
+Guid::Guid(void)
+{
+   // Clear internal uuid, would pass isNull
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      memset(&uuid, 0, sizeof(uuid_t));
+   #else
+      ::UuidCreateNil(&uuid);
+   #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid::Guid(const Guid& source)
+{
+   // Set this uuid to that of the source
+   *this = source;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid::Guid(const std::string& source)
+   throw ( IllegalArgumentException )
+{
+   if(source == "")
+   {
+      throw IllegalArgumentException(
+         __FILE__, __LINE__,
+         "GUID::fromBytes - Source was Empty");
+   }
+
+   // Set this uuid to that of the source
+   *this = source;   
+}
+   
+////////////////////////////////////////////////////////////////////////////////
+Guid::~Guid(void)
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::isNull(void) const
+{
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      // Check the uuid APIs is null method
+      return uuid_is_null(*(const_cast<uuid_t*>(&uuid))) == 1 ? true : false;
+   #else
+	   RPC_STATUS status;
+
+      BOOL result = ::UuidIsNil( const_cast<GUID*>( &uuid ), &status );
+
+	   return (result == TRUE) ? true : false;
+   #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Guid::setNull(void)
+{
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      // use the uuid function to clear
+      uuid_clear(uuid);
+   #else
+      ::UuidCreateNil(&uuid);
+   #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid& Guid::createGUID(void) throw( RuntimeException )
+{
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      // Use the uuid_generate method to create a new GUID
+      uuid_generate(uuid);
+   #else
+	   // Create a uuid with the Co Create GUID
+	   RPC_STATUS lhResult = ::UuidCreate( &uuid );
+
+	   if ( lhResult == RPC_S_UUID_NO_ADDRESS )
+	   {
+         throw RuntimeException(
+            __FILE__, __LINE__,
+            "GUIG::createGUID - Failed Creating GUID");
+	   }
+   #endif
+
+   return *this;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Guid::toString(void) const throw( RuntimeException )
+{
+   std::string uuid_str = "";
+
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      // Create storage for the string buffer
+      char buffer[36] = {0};
+      
+      // parse the uuid to the string
+      uuid_unparse(*(const_cast<uuid_t*>(&uuid)), buffer);
+      
+      // Store it in a string
+      uuid_str = buffer;
+   #else   
+	   // Convert the GUID object to a string.
+	   unsigned char* guidStr = 0;
+
+	   RPC_STATUS result = ::UuidToString(
+         const_cast<GUID*>(&uuid),
+		   &guidStr);
+
+	   if(result == RPC_S_OUT_OF_MEMORY)
+	   {
+         throw RuntimeException(
+            __FILE__, __LINE__, 
+            "GUIG::createGUID - Failed Creating GUID");
+	   }
+
+	   uuid_str = (char*)guidStr;
+
+	   // Dispose of the GUID string.
+	   ::RpcStringFree(&guidStr);
+   #endif
+
+   return uuid_str;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid::operator std::string() const
+{
+   return toString();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+const unsigned char* Guid::toBytes(void) const
+{
+   unsigned char* buffer = new unsigned char[getRawBytesSize()];
+   
+   // copy our buffer
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      uuid_copy(buffer, *(const_cast<uuid_t*>(&uuid)));
+   #else
+      memcpy(buffer, &uuid, getRawBytesSize());
+   #endif
+   
+   return &buffer[0]; 
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid& Guid::fromBytes(const unsigned char* bytes) 
+   throw ( IllegalArgumentException )
+{
+   if(bytes == NULL)
+   {
+      throw IllegalArgumentException(
+         __FILE__, __LINE__,
+         "GUID::fromBytes - bytes pointer was NULL");
+   }
+   
+   // Copy the data
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      memcpy(uuid, bytes, getRawBytesSize());
+   #else
+      memcpy(&uuid, bytes, getRawBytesSize());
+   #endif
+
+   return *this;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Guid::getRawBytesSize(void) const
+{
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      return sizeof(uuid_t);
+   #else
+      return sizeof(::GUID);
+   #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid::operator const unsigned char*() const
+{
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      return &uuid[0];
+   #else
+      return reinterpret_cast<const unsigned char*>(&uuid);
+   #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid& Guid::operator=(const Guid& source)
+   throw ( IllegalArgumentException )
+{
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      // Use the uuid method to copy
+      uuid_copy(uuid, *(const_cast<uuid_t*>(&source.uuid)));
+   #else
+      // Use mem copy
+      memcpy(&uuid, &source.uuid, getRawBytesSize());
+   #endif
+
+   return *this;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid& Guid::operator=(const std::string& source) 
+   throw ( IllegalArgumentException )
+{
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      // Parse a uuid from the passed in string
+      uuid_parse( const_cast<char*>(source.c_str()), uuid );
+   #else
+	   if ( source.empty() )
+	   {
+		   ::UuidCreateNil( &uuid );
+	   }
+	   else
+	   {
+		   RPC_STATUS hResult =
+			   ::UuidFromString( (unsigned char*)source.c_str(), &uuid );
+
+		   if ( hResult == RPC_S_INVALID_STRING_UUID )
+		   {
+            throw IllegalArgumentException(
+               __FILE__, __LINE__,
+               "GUID::fromBytes - Invalid GUID String");
+		   }
+	   }
+   #endif
+
+   return *this;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator==(const Guid& source) const
+{
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      // uuid_compare returns 0 for equal
+      return uuid_compare(
+               *(const_cast<uuid_t*>(&uuid)), 
+               *(const_cast<uuid_t*>(&source.uuid))) == 0 ? true : false;
+   #else
+	   RPC_STATUS status;
+
+	   BOOL result = ::UuidEqual(
+         const_cast<GUID*>( &uuid ),
+         const_cast<GUID*>( &source.uuid ),
+		   &status );
+
+	   return ( result == TRUE ) ? true : false;
+   #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator==(const std::string& source) const
+{
+   return *this == Guid(source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator!=(const Guid& source) const
+{
+   return !(*this == source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator!=(const std::string& source) const
+{
+   return !(*this == source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator<(const Guid& source) const
+{
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      // uuid_compare returns 0 for equal
+      return uuid_compare(
+               *(const_cast<uuid_t*>(&uuid)), 
+               *(const_cast<uuid_t*>(&source.uuid))) < 0 ? true : false;
+   #else
+      RPC_STATUS status;
+
+      int result = ::UuidCompare(
+         const_cast<GUID*>( &uuid ),
+         const_cast<GUID*>( &source.uuid ),
+		   &status );
+
+	   return ( result < 0 ) ? true : false;
+   #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator<(const std::string& source) const
+{
+   return *this < Guid(source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator<=(const Guid& source) const
+{
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      // uuid_compare returns 0 for equal
+      return uuid_compare(
+               *(const_cast<uuid_t*>(&uuid)), 
+               *(const_cast<uuid_t*>(&source.uuid))) <= 0 ? true : false;
+   #else
+      RPC_STATUS status;
+
+      int result = ::UuidCompare(
+         const_cast<GUID*>( &uuid ),
+         const_cast<GUID*>( &source.uuid ),
+		   &status );
+
+	   return ( result <= 0 ) ? true : false;
+   #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator<=(const std::string& source) const
+{
+   return *this <= Guid(source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator>(const Guid& source) const
+{
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      // uuid_compare returns 0 for equal
+      return uuid_compare(
+               *(const_cast<uuid_t*>(&uuid)), 
+               *(const_cast<uuid_t*>(&source.uuid))) > 0 ? true : false;
+   #else
+      RPC_STATUS status;
+
+      int result = ::UuidCompare(
+         const_cast<GUID*>( &uuid ),
+         const_cast<GUID*>( &source.uuid ),
+		   &status );
+
+	   return ( result > 0 ) ? true : false;
+   #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator>(const std::string& source) const
+{
+   return *this > Guid(source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator>=(const Guid& source) const
+{
+   #if defined( unix ) && !defined( __CYGWIN__ )
+      // uuid_compare returns 0 for equal
+      return uuid_compare(
+               *(const_cast<uuid_t*>(&uuid)), 
+               *(const_cast<uuid_t*>(&source.uuid))) >= 0 ? true : false;
+   #else
+      RPC_STATUS status;
+
+      int result = ::UuidCompare(
+         const_cast<GUID*>(&uuid),
+         const_cast<GUID*>(&source.uuid),
+		   &status);
+
+	   return (result >= 0) ? true : false;
+   #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator>=(const std::string& source) const
+{
+   return *this >= Guid(source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Guid::createGUIDString(void)
+{
+   return Guid().createGUID().toString();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+const unsigned char* createGUIDBytes(void)
+{
+   return Guid().createGUID().toBytes();
+}

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_UTIL_GUID_H
+#define ACTIVEMQ_UTIL_GUID_H
+
+#if defined( unix ) && !defined( __CYGWIN__ )
+   #include <uuid/uuid.h>
+#elif defined(_WIN32) || defined( __CYGWIN__ )
+	#include <objbase.h>
+   #include <rpcdce.h>
+#else // defined MACOSX
+	#include "uuid.h"
+#endif
+
+#include <activemq/exceptions/RuntimeException.h>
+#include <activemq/exceptions/IllegalArgumentException.h>
+
+#include <string>
+
+namespace activemq{
+namespace util{
+   
+   class Guid
+   {
+   public:
+
+      /**
+       * Constructor
+       */
+      Guid(void);
+
+      /**
+       * Copy Constructor
+       */
+      Guid(const Guid& source);
+
+      /**
+       * Constructor - Create a GUID from a String
+       */
+      Guid(const std::string& source)
+         throw ( exceptions::IllegalArgumentException );
+         
+      /**
+       * Destructor
+       */
+   	virtual ~Guid(void);
+
+      /**
+       * Determines if this GUID is null, if so it can be initialized with a 
+       * call to <code>createGUID</code>.
+       * @return true for Null GUID, false otherwise.
+       */
+      bool isNull(void) const;
+      
+      /**
+       * Clears the GUID's current value and sets it to a NULL GUID value
+       * will now pass <code>isNull</code>.
+       */
+      void setNull(void);
+
+      /**
+       * Generate a new GUID which will overwrite any current GUID value
+       * @return Reference to this object that now has a new GUID
+       */       
+      Guid& createGUID(void) throw( exceptions::RuntimeException );
+
+      /** 
+       * Converts the GUID to a string and returns that string
+       * @return a string with this GUID's stringified value
+       */
+      std::string toString(void) const throw( exceptions::RuntimeException );
+      
+      /** 
+       * Converts the GUID to a byte array and return a pointer to the
+       * new array, called takes ownership and must delete this array
+       * when done.  
+       * @return a byte array with the GUID byte value, size = 16
+       */
+      const unsigned char* toBytes(void) const;
+      
+      /**
+       * Initializes this GUID with the GUID specified in the bytes parameter
+       * @return reference to this object.
+       */
+      Guid& fromBytes(const unsigned char* bytes)    
+         throw ( exceptions::IllegalArgumentException );
+      
+      /**
+       * Returns the Size in Bytes of the Raw bytes representation of the
+       * GUID.
+       * @return size of the Raw bytes representation
+       */
+      int getRawBytesSize(void) const;
+
+      /**
+       * string type cast operator
+       * @returns string representation of this GUID
+       */
+      operator std::string() const;
+      
+      /**
+       * byte array cast operator, caller does not own this memeory
+       * @returns byte array with the GUID byte value representation
+       */
+      operator const unsigned char*() const;
+      
+      /**
+       * Assignment operators
+       * @return Reference to this GUID object
+       */
+      Guid& operator=(const Guid& source)          
+         throw ( exceptions::IllegalArgumentException );
+      Guid& operator=(const std::string& source)
+         throw ( exceptions::IllegalArgumentException );
+
+      /**
+       * Equality Comparison Operators
+       * @return true for equal. false otherwise
+       */
+      bool operator==(const Guid& source) const;
+      bool operator==(const std::string& source) const;
+      
+      /**
+       * Inequality Comparison Operators
+       * @return true for equal. false otherwise
+       */
+      bool operator!=(const Guid& source) const;
+      bool operator!=(const std::string& source) const;
+      
+      /**
+       * Less than operators
+       * @return true for equal. false otherwise
+       */
+      bool operator<(const Guid& source) const;
+      bool operator<(const std::string& source) const;
+      
+      /**
+       * Less than or equal to operators
+       * @return true for equal. false otherwise
+       */
+      bool operator<=(const Guid& source) const;
+      bool operator<=(const std::string& source) const;
+
+      /**
+       * Greater than operators
+       * @return true for equal. false otherwise
+       */
+      bool operator>(const Guid& source) const;
+      bool operator>(const std::string& source) const;
+
+      /**
+       * Greater than or equal to operators
+       * @return true for equal. false otherwise
+       */
+      bool operator>=(const Guid& source) const;
+      bool operator>=(const std::string& source) const;
+      
+   public:
+   
+      /**
+       * Static Guid Creation Method, creates a GUID and returns it as a string
+       * @return Guid string.
+       */
+      static std::string createGUIDString(void);
+      
+      /**
+       * Static Guid Create Method, create a GUID and returns the byte representation
+       * of the new GUID.
+       * @return Guid bytes array, size is 16
+       */
+      static const unsigned char* createGUIDBytes(void);
+   
+   private:
+   
+      // the uuid that this object represents.
+      #ifdef unix
+         uuid_t uuid;
+      #else
+         ::GUID uuid;
+      #endif
+         
+   };
+
+}}
+
+#endif /*ACTIVEMQ_UTIL_GUID_H*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Integer.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Integer.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Integer.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Integer.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_UTIL_INTEGER_H_
+#define _ACTIVEMQ_UTIL_INTEGER_H_
+
+#include <activemq/util/Number.h>
+
+namespace activemq{
+namespace util{
+
+    class Integer : public Number
+    {
+    public:
+
+    	Integer(void) {}
+    	virtual ~Integer(void) {}
+
+        /**
+         * Parses the String passed and extracts an int.
+         * @param String to parse
+         * @return int value
+         */
+        static int parseInt(const std::string& value){
+            int ret = 0;
+            std::istringstream istream(value);
+            istream.clear();
+            istream >> ret;
+            return ret;
+        }
+        
+        /**
+         * Converts the int to a String representation
+         * @param int to convert
+         * @return string representation
+         */
+        static std::string toString(int value){
+            std::ostringstream ostream;
+            ostream << value;
+            return ostream.str();
+        }
+        
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_UTIL_INTEGER_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Long.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Long.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Long.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Long.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_UTIL_LONG_H_
+#define _ACTIVEMQ_UTIL_LONG_H_
+
+#include <activemq/util/Number.h>
+
+namespace activemq{
+namespace util{
+
+    class Long : public Number
+    {
+    public:
+
+    	Long(void) {}
+    	virtual ~Long(void) {}
+
+        /**
+         * Parses the String passed and extracts an long.
+         * @param String to parse
+         * @return long value
+         */
+        static long parseLong(const std::string& value){
+            long ret = 0;
+            std::istringstream istream(value);
+            istream.clear();
+            istream >> ret;
+            return ret;
+        }
+        
+        /**
+         * Converts the long to a String representation
+         * @param long to convert
+         * @return string representation
+         */
+        static std::string toString(long value){
+            std::ostringstream ostream;
+            ostream << value;
+            return ostream.str();
+        }
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_UTIL_LONG_H_*/



Mime
View raw message