You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by fi...@apache.org on 2012/08/02 17:33:41 UTC

svn commit: r1368543 [1/2] - in /incubator/etch/trunk/binding-cpp/runtime: include/common/ include/support/ include/transport/ include/util/ src/main/ src/main/common/ src/main/support/ src/main/transport/ src/main/util/ src/test/ src/test/support/ src...

Author: fitzner
Date: Thu Aug  2 15:33:40 2012
New Revision: 1368543

URL: http://svn.apache.org/viewvc?rev=1368543&view=rev
Log:
ETCH-147 EtchRuntime Implementation and updates for memory management

Change-Id: Ic9acda9427c2a44eaeffac1c5f01a01d9c276e67

Added:
    incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRuntime.h
    incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRuntime.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRuntimeTest.cpp
Modified:
    incubator/etch/trunk/binding-cpp/runtime/include/common/EtchString.h
    incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h
    incubator/etch/trunk/binding-cpp/runtime/include/support/EtchPlainMailbox.h
    incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerFactory.h
    incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchDefaultDeliveryService.h
    incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h
    incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpConnection.h
    incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h
    incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h
    incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransportFactory.h
    incubator/etch/trunk/binding-cpp/runtime/include/util/EtchResources.h
    incubator/etch/trunk/binding-cpp/runtime/include/util/EtchURL.h
    incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt
    incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchString.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchClientStack.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchPlainMailbox.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTransportFactory.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchResources.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchURL.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt
    incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchMessagizerTest.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPacketizerTest.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPlainMailboxManagerTest.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchTcpConnectionTest.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchTcpListenerTest.cpp

Modified: incubator/etch/trunk/binding-cpp/runtime/include/common/EtchString.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/common/EtchString.h?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/common/EtchString.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/common/EtchString.h Thu Aug  2 15:33:40 2012
@@ -94,7 +94,7 @@ public:
    * @return ETCH_OK if the substring has been successfully stored into the dest
    *         ETCH_EINVAL if there are errors in the indexing or buffer is NULL
    */
-  status_t substring(capu::uint32_t start, capu::uint32_t length, EtchString *dest);
+  status_t substring(capu::uint32_t start, capu::uint32_t length, EtchString *dest) const;
 
   /**
    * Returns the index of the first occurrence of a character within given string
@@ -102,7 +102,7 @@ public:
    * @return index index of first occurrence of character
    *         -1 if the character is not found
    */
-  capu::int32_t leftFind(const char c);
+  capu::int32_t leftFind(const char c) const;
 
   /**
    * Returns the index of last occurrence of a character within given string
@@ -110,7 +110,7 @@ public:
    * @return index index of last occurrence of character
    *         -1 if the character is not found
    */
-  capu::int32_t rightFind(const char c);
+  capu::int32_t rightFind(const char c) const;
 
   /**
    * Check two string is equal or not

Modified: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h Thu Aug  2 15:33:40 2012
@@ -23,32 +23,37 @@
 #define __ETCHDEFAULTSERVERFACTORY_H__
 
 
-#include "EtchServerFactory.h"
+#include "support/EtchServerFactory.h"
 
 /**
  * Default implementation of ServerFactory. Used by Etch generated Helper files
  * to provide listeners with backstop implementations of Session methods which
  * forward to user's implementation factory.
  */
-class EtchDefaultServerFactory : public EtchServerFactory
-{
+class EtchDefaultServerFactory
+  : public EtchServerFactory {
 public:
   /**
    * Constructs the DefaultServerFactory.
    * @param listener
    * @param implFactory
    */
-  EtchDefaultServerFactory( EtchTransport<EtchServerFactory>* listener, EtchSession* implFactory );
+  EtchDefaultServerFactory(EtchTransport<EtchServerFactory>* listener, EtchSession* implFactory);
+
+  /**
+   * Destructor
+   */
+  virtual ~EtchDefaultServerFactory();
 
   /**
    * @see EtchSession
    */
-  virtual status_t sessionQuery( capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result );
+  virtual status_t sessionQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result);
 
   /**
    * @see EtchSession
    */
-  virtual status_t sessionControl(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value );
+  virtual status_t sessionControl(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value);
 
   /**
    * @see EtchSession

Modified: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchPlainMailbox.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchPlainMailbox.h?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchPlainMailbox.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchPlainMailbox.h Thu Aug  2 15:33:40 2012
@@ -123,12 +123,11 @@ public:
   capu::bool_t isFull();
 
   /**
-   * 
-   * @return mailbox manager 
+   *
+   * @return mailbox manager
    */
   EtchMailboxManager* getMailboxManager();
 
-
 private:
   EtchMailboxManager* mMailboxManager;
   EtchMailbox::EtchNotify* mNotify;

Added: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRuntime.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRuntime.h?rev=1368543&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRuntime.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRuntime.h Thu Aug  2 15:33:40 2012
@@ -0,0 +1,102 @@
+/* $Id$
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __ETCHRUNTIME_H__
+#define __ETCHRUNTIME_H__
+
+#include "capu/os/Mutex.h"
+#include "capu/container/List.h"
+#include "common/EtchError.h"
+
+class EtchRuntime;
+
+class EtchRuntimeListener {
+public:
+
+  /**
+   * Called if the runtime changed its state
+   */
+  virtual status_t onRuntimeChanged(EtchRuntime* runtime) = 0;
+};
+
+/**
+ * EtchRuntime class
+ */
+class EtchRuntime {
+public:
+
+  /**
+   * Create a new instance of the EtchRuntime class
+   */
+  EtchRuntime();
+
+  /**
+   * Destructor
+   */
+  virtual ~EtchRuntime();
+
+  /**
+   * Unique runtime id
+   * @return unique runtime id
+   */
+  capu::uint64_t getId();
+
+  /**
+   * Current runtime state
+   * @return true if runtime was closed
+   */
+  capu::bool_t isClosed();
+
+  /**
+   * Register a runtime listener
+   */
+  status_t registerListener(EtchRuntimeListener* listener);
+
+  /**
+   * Unregister the runtime listener
+   */
+  status_t unregisterListener(EtchRuntimeListener* listener);
+
+  /**
+   * Starts the runtime
+   * @return ETCH_OK if runtime was successfully started
+   */
+  status_t start();
+
+  /**
+   * Shutdown the runtime
+   * @return ETCH_OK if runtime successfully ended
+   */
+  status_t shutdown();
+
+private:
+  static capu::uint64_t sId;
+  capu::uint64_t mId;
+  capu::bool_t mIsClosed;
+  capu::Mutex mMutex;
+  capu::List<EtchRuntimeListener*> mListeners;
+
+  /**
+   * Return the next id
+   */
+  static capu::uint64_t getNextId();
+
+  /**
+   * Fire onRuntimeChanged callback
+   */
+  status_t fireOnRuntimeChanged();
+};
+#endif /* ETCHRUNTIME_H */

Modified: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerFactory.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerFactory.h?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerFactory.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerFactory.h Thu Aug  2 15:33:40 2012
@@ -26,12 +26,13 @@
 #include "transport/EtchTransport.h"
 #include "transport/EtchTransportMessage.h"
 
+class EtchRuntime;
+
 /**
  * Interface to use for constructing new server instances by
  * TransportHelper.
  */
-class EtchServerFactory : public EtchSession, public EtchTransport<EtchSession>
-{
+class EtchServerFactory : public EtchSession, public EtchTransport<EtchSession> {
 public:
   /**
    * @param transport the TransportMessage to use with the new server instance.
@@ -39,14 +40,13 @@ public:
    * @param resources the resources to use for the new server instance.
    * @throws Exception
    */
-  virtual status_t newServer( EtchTransportMessage* transport, EtchString* uri,
-    EtchResources* resources ) = 0;
+  virtual status_t newServer(EtchTransportMessage* transport, const EtchString& uri, EtchResources* resources) = 0;
 
   /**
    * @param uri the uri to use to configure the new value factory.
    * @return a new instance of value factory for this connection.
    */
-  virtual status_t newValueFactory(EtchString* uri, EtchValueFactory *&vf) = 0;
+  virtual status_t newValueFactory(const EtchString& uri, EtchValueFactory *&vf) = 0;
 };
 
 #endif /* __ETCHSERVERFACTORY_H__ */

Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchDefaultDeliveryService.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchDefaultDeliveryService.h?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchDefaultDeliveryService.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchDefaultDeliveryService.h Thu Aug  2 15:33:40 2012
@@ -48,7 +48,7 @@ public:
    * @param transport the MailBoxManager implementation
    * @param uri as an EtchString object
    */
-  EtchDefaultDeliveryService(EtchMailboxManager* transport, EtchString uri);
+  EtchDefaultDeliveryService(EtchMailboxManager* transport, const EtchString& uri);
 
   /**
    * Constructor
@@ -57,6 +57,10 @@ public:
    */
   EtchDefaultDeliveryService(EtchMailboxManager* transport, EtchURL* uri);
 
+  /**
+   * Destructor
+   */
+  virtual ~EtchDefaultDeliveryService();
 
   /**
    * @return the transport interface

Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h Thu Aug  2 15:33:40 2012
@@ -34,13 +34,13 @@ public:
    * @param uri
    * @param resources
    */
-  EtchPlainMailboxManager(EtchTransportMessage* transport, EtchURL* url, EtchResources* resources);
+  EtchPlainMailboxManager(EtchTransportMessage* transport, const EtchString& url, EtchResources* resources);
 
   /**
    * Destructure
    */
   virtual ~EtchPlainMailboxManager();
-  
+
   /**
    * @return the transport.
    */
@@ -110,6 +110,4 @@ private:
   EtchIdGenerator mIdGen;
 };
 
-
-
 #endif

Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpConnection.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpConnection.h?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpConnection.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpConnection.h Thu Aug  2 15:33:40 2012
@@ -33,11 +33,11 @@
 #include "transport/EtchSessionData.h"
 #include "transport/EtchTcpOption.h"
 
+class EtchRuntime;
 
 /**
  * Implementation of connection which handles a tcp connection.
  */
-
 class EtchTcpConnection : public EtchConnection<EtchSessionData>, public EtchTransportData, public capu::Runnable {
 public:
 
@@ -47,7 +47,7 @@ public:
    * @param uri
    * @param resources
    */
-  EtchTcpConnection(EtchSocket* socket, EtchURL* uri);
+  EtchTcpConnection(EtchRuntime* runtime, EtchSocket* socket, EtchURL* uri);
 
   /**
    * Destructor
@@ -57,54 +57,54 @@ public:
   /**
    * @see TransportData
    */
-  virtual status_t transportControl(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value);
+  status_t transportControl(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value);
 
 
   /**
    * @see TransportData
    */
-  virtual status_t transportData(capu::SmartPointer<EtchWho> recipient, capu::SmartPointer<EtchFlexBuffer> buf);
+  status_t transportData(capu::SmartPointer<EtchWho> recipient, capu::SmartPointer<EtchFlexBuffer> buf);
 
   /**
    * @see TransportData
    */
-  virtual status_t transportNotify(capu::SmartPointer<EtchObject> event);
+  status_t transportNotify(capu::SmartPointer<EtchObject> event);
 
   /**
    * @see TransportData
    */
-  virtual status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result);
+  status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result);
 
   /**
    * @return Session
    */
-  virtual EtchSessionData* getSession();
+  EtchSessionData* getSession();
 
   /**
    * Sets session
    */
-  virtual void setSession(EtchSessionData* session);
+  void setSession(EtchSessionData* session);
 
 
   /**
    * @see EtchConnection
    */
-  virtual capu::bool_t isStarted();
+  capu::bool_t isStarted();
 
   /**
    * @see capu::thread
    */
-  virtual void run();
+  void run();
 
   /**
    * @see EtchConnection
    */
-  virtual status_t close();
+  status_t close();
 
   /**
    * @see EtchConnection
    */
-  virtual status_t setupSocket();
+  status_t setupSocket();
 
   /**
    * Sends some data to the remote end. If the connection is buffered, the
@@ -128,19 +128,12 @@ public:
   void setNumAttempts(capu::uint8_t numAttempts);
 
 private:
-  //PORT
-  capu::uint16_t mPort;
-
-  //HOST ADDR
   EtchString mHost;
-
-  //SOCKET
+  capu::uint16_t mPort;
   EtchSocket* mSocket;
-
-  //SOCKET OPTIONS
   EtchTcpOption mOptions;
-
   capu::uint8_t mNumAttempts;
+  EtchRuntime *mRuntime;
 
 protected:
 

Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h Thu Aug  2 15:33:40 2012
@@ -19,6 +19,7 @@
 
 #ifndef __ETCHTCPLISTENER_H__
 #define __ETCHTCPLISTENER_H__
+
 #include "common/EtchError.h"
 #include "common/EtchObject.h"
 #include "capu/util/SmartPointer.h"

Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h Thu Aug  2 15:33:40 2012
@@ -23,6 +23,7 @@
 #include "common/EtchString.h"
 #include "common/EtchConfig.h"
 #include "support/EtchServerFactory.h"
+#include "util/EtchResources.h"
 #include "transport/EtchTransportMessage.h"
 #include "transport/EtchTransportData.h"
 #include "transport/EtchTcpConnection.h"
@@ -32,20 +33,23 @@
 #include "transport/EtchTcpListener.h"
 #include "transport/EtchMessagizer.h"
 #include "transport/EtchTransportFactory.h"
-#include "util/EtchResources.h"
 
-class EtchTcpTransportFactory : public EtchTransportFactory {
+class EtchTcpTransportFactory
+ : public EtchTransportFactory {
 public:
+
   /**
    * Constructor
+   * @param runtime
    */
-  EtchTcpTransportFactory();
+  EtchTcpTransportFactory(EtchRuntime* runtime);
 
   /**
    * Constructor
+   * @param runtime
    * @param secure indicates whether the connection should be secured by SSL or not
    */
-  EtchTcpTransportFactory(capu::bool_t secure);
+  EtchTcpTransportFactory(EtchRuntime* runtime, capu::bool_t secure);
 
   /**
    * Destructor
@@ -65,19 +69,20 @@ public:
 private:
   static const EtchString SOCKET;
   const capu::bool_t mIsSecure;
-
+  EtchRuntime* mRuntime;
 
   class MySessionListener : public EtchTransport<EtchServerFactory>, public EtchSessionListener<EtchSocket> {
   public:
 
     /**
      * Creates a new Session Listener
+     * @param runtime
      * @param transport
      * @param uri
      * @param resources
      */
-    MySessionListener(EtchTransport<EtchSessionListener<EtchSocket> > *transport,
-                      EtchString uri, EtchResources* resources, capu::bool_t secure);
+    MySessionListener(EtchRuntime* runtime, EtchTransport<EtchSessionListener<EtchSocket> > *transport,
+            EtchString uri, EtchResources* resources, capu::bool_t secure);
 
      /**
       * Destructor
@@ -134,12 +139,11 @@ private:
     EtchString mUri;
     EtchResources* mResources;
     EtchServerFactory* mSession;
+    EtchRuntime* mRuntime;
     capu::bool_t mIsSecure;
-
   };
 
 };
 
-
 #endif
 

Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransportFactory.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransportFactory.h?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransportFactory.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransportFactory.h Thu Aug  2 15:33:40 2012
@@ -34,6 +34,7 @@
  */
 class EtchTransportFactory {
 public:
+
   /**
    * Query term on the transport uri which defines a set of filters which
    * process messages as they move up and down the transport stack. Filter
@@ -51,7 +52,7 @@ public:
    * @return ETCH_ENOT_EXIST if the required transport method is not available or not implememted
              ETCH_OK otherwise
    */
-  static status_t getTransport(EtchString uri, EtchResources* resources, EtchTransportMessage*& result);
+  static status_t getTransport(EtchRuntime* runtime, EtchString uri, EtchResources* resources, EtchTransportMessage*& result);
 
   /**
    * Constructs a new Transport Listener which is used to construct
@@ -62,7 +63,7 @@ public:
    * @return ETCH_ENOT_EXIST if the required listener is not available or not implememted
              ETCH_OK otherwise
    */
-  static status_t getListener(EtchString uri, EtchResources* resources, EtchTransport<EtchServerFactory>*& result);
+  static status_t getListener(EtchRuntime* runtime, EtchString uri, EtchResources* resources, EtchTransport<EtchServerFactory>*& result);
 
 
 protected:
@@ -109,15 +110,24 @@ protected:
 
 private:
 
+  /**
+   * Adds any message filters specified on the uri. They are added in order
+   * from transport to session. The first filter is the session for Messagizer,
+   * the second is the session for the first, etc. The last filter added is
+   * returned, and becomes the TransportMessage for what follows.
+   * @param transport
+   * @param uri
+   * @param resources
+   * @param filter the newly added filter
+   * @return status
+   */
   status_t addFilter(EtchTransportMessage* transport, EtchString* name, EtchURL* uri, EtchResources* resources, EtchTransportMessage*& filter);
+
   /**
    * Gets the named transport factory.
    * @param name the name of a configured transport factory.
    * @param the named transport factory.
-   * @return ETCH_ENOT_EXIST if the requested transportfactory does not exist
-             ETCH_OK otherwise
    */
-  static status_t getTransportFactory(const EtchString& name, EtchTransportFactory*& result);
-
+   static status_t getTransportFactory(EtchRuntime* runtime, const EtchString& name, EtchTransportFactory*& result);
 };
 #endif /* __ETCHTRANSPORTFACTORY_H__ */

Modified: incubator/etch/trunk/binding-cpp/runtime/include/util/EtchResources.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/util/EtchResources.h?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/util/EtchResources.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/util/EtchResources.h Thu Aug  2 15:33:40 2012
@@ -48,7 +48,7 @@ public:
    * @return true if this Resources has the key
    *         false otherwise.
    */
-  capu::bool_t containsKey(EtchString& key);
+  capu::bool_t containsKey(const EtchString& key);
 
   /**
    * Returns the named resource from this Resources
@@ -57,7 +57,7 @@ public:
    * @return a pointer to the object with given key
    *         if there is no element with given key return a NULL pointer
    */
-  status_t get(EtchString& key, EtchObject*& result);
+  status_t get(const EtchString& key, EtchObject*& result);
 
   /**
    * Puts the named resource into this Resources.
@@ -66,7 +66,7 @@ public:
    * @return a pointer to the overwritten element
    *         if there is no existing element with same key returns a NULL pointer
    */
-  status_t put(EtchString& key, EtchObject *value, EtchObject*& result);
+  status_t put(const EtchString& key, EtchObject *value, EtchObject*& result);
 
   /**
    * Removes the named resource from this Resources only.
@@ -74,7 +74,7 @@ public:
    * @return a pointer to the removed element
    *         if there is no element with given key return a NULL pointer
    */
-  status_t remove(EtchString& key, EtchObject*& result);
+  status_t remove(const EtchString& key, EtchObject*& result);
 
   /**
    * @return related EtchResources

Modified: incubator/etch/trunk/binding-cpp/runtime/include/util/EtchURL.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/util/EtchURL.h?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/util/EtchURL.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/util/EtchURL.h Thu Aug  2 15:33:40 2012
@@ -44,7 +44,7 @@ public:
    * Constructs a url from a string.
    * @param urlStr
    */
-  EtchURL(EtchString& urlStr);
+  EtchURL(const EtchString& urlStr);
 
   /**
    * Deconstructor
@@ -61,7 +61,7 @@ public:
    *
    * @param scheme the scheme to set which may be null but not blank.
    */
-  void setScheme(EtchString& scheme);
+  void setScheme(const EtchString& scheme);
 
   /**
    * Sets the scheme.
@@ -93,7 +93,7 @@ public:
    *
    * @param user the user to set which may be null but not blank.
    */
-  void setUser(EtchString& user);
+  void setUser(const EtchString& user);
 
   //////////////
   // PASSWORD //
@@ -109,7 +109,7 @@ public:
    *
    * @param password the password to set which may be null but not blank.
    */
-  void setPassword(EtchString& password);
+  void setPassword(const EtchString& password);
 
   //////////
   // HOST //
@@ -125,7 +125,7 @@ public:
    *
    * @param host the host to set which may be null but not blank.
    */
-  void setHost(EtchString& host);
+  void setHost(const EtchString& host);
 
   //////////
   // PORT //
@@ -162,7 +162,7 @@ public:
    *
    * @param uri the uri to set which may be null or blank.
    */
-  void setUri(EtchString& uri);
+  void setUri(const EtchString& uri);
 
   ////////////
   // PARAMS //
@@ -280,19 +280,19 @@ private:
   EtchList<EtchString> params;
   EtchHashTable<EtchString, EtchString> terms;
 
-  status_t parse(EtchString* s);
+  status_t parse(const EtchString* s);
 
-  status_t parseHost(EtchString* s);
+  status_t parseHost(const EtchString* s);
 
-  status_t parseUserPassword(EtchString* s);
+  status_t parseUserPassword(const EtchString* s);
 
-  status_t parseHostPort(EtchString* s);
+  status_t parseHostPort(const EtchString* s);
 
-  status_t parseParams(EtchString* s);
+  status_t parseParams(const EtchString* s);
 
-  status_t parseTerms(EtchString* s);
+  status_t parseTerms(const EtchString* s);
 
-  status_t parseTerm(EtchString *s);
+  status_t parseTerm(const EtchString *s);
 
 };
 

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt Thu Aug  2 15:33:40 2012
@@ -1,18 +1,18 @@
 #
-# Licensed to the Apache Software Foundation (ASF) under one or more 
-# contributor license agreements. See the NOTICE file distributed with  
-# this work for additional information regarding copyright ownership. 
-# The ASF licenses this file to you under the Apache License, Version  
-# 2.0 (the "License"); you may not use this file except in compliance  
-# with the License. You may obtain a copy of the License at 
-# 
-# http://www.apache.org/licenses/LICENSE-2.0 
-# 
-# Unless required by applicable law or agreed to in writing, software 
-# distributed under the License is distributed on an "AS IS" BASIS, 
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version
+# 2.0 (the "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and 
-# limitations under the License. 
+# See the License for the specific language governing permissions and
+# limitations under the License.
 #
 
 # set include dirs
@@ -58,6 +58,10 @@ SET(MAIN_INCLUDES
     ${PROJECT_SOURCE_DIR}/include/transport/EtchTransportData.h
     ${PROJECT_SOURCE_DIR}/include/transport/EtchTransportMessage.h
     ${PROJECT_SOURCE_DIR}/include/transport/EtchTransportPacket.h
+    ${PROJECT_SOURCE_DIR}/include/transport/EtchTransportFactory.h 
+    ${PROJECT_SOURCE_DIR}/include/transport/EtchMessagizer.h
+    ${PROJECT_SOURCE_DIR}/include/transport/EtchFormat.h
+    ${PROJECT_SOURCE_DIR}/include/transport/EtchTcpTransportFactory.h
     ${PROJECT_SOURCE_DIR}/include/common/EtchTypes.h
     ${PROJECT_SOURCE_DIR}/include/common/EtchException.h
     ${PROJECT_SOURCE_DIR}/include/common/EtchAuthenticationException.h
@@ -110,8 +114,7 @@ SET(MAIN_INCLUDES
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchBinaryTaggedData.h
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchBinaryTaggedDataInput.h
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchBinaryTaggedDataOutput.h
-    ${PROJECT_SOURCE_DIR}/include/transport/EtchMessagizer.h
-    ${PROJECT_SOURCE_DIR}/include/transport/EtchFormat.h
+    ${PROJECT_SOURCE_DIR}/include/support/EtchRuntime.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchAsyncResultBase.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchDefaultServerFactory.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchDeliveryService.h
@@ -125,12 +128,11 @@ SET(MAIN_INCLUDES
     ${PROJECT_SOURCE_DIR}/include/support/EtchServerFactory.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchStubHelper.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchStubBase.h
-    ${PROJECT_SOURCE_DIR}/include/transport/EtchTransportFactory.h
-    ${PROJECT_SOURCE_DIR}/include/transport/EtchTcpTransportFactory.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchTransportHelper.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchPlainMailbox.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchMonitor.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchStack.h
+    ${PROJECT_SOURCE_DIR}/include/support/EtchRuntime.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchServerStack.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchClientStack.h
     ${PROJECT_SOURCE_DIR}/include/util/EtchUtil.h
@@ -216,6 +218,7 @@ SET(MAIN_SOURCES
     support/EtchRemoteBase.cpp
     support/EtchTransportHelper.cpp
     support/EtchMonitor.cpp
+    support/EtchRuntime.cpp
     support/EtchServerStack.cpp
     support/EtchClientStack.cpp
     util/EtchCircularQueue.cpp

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchString.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchString.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchString.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchString.cpp Thu Aug  2 15:33:40 2012
@@ -201,7 +201,7 @@ capu::bool_t EtchString::equals(const Et
   return false;
 }
 
-capu::int32_t EtchString::rightFind(const char c) {
+capu::int32_t EtchString::rightFind(const char c) const {
   if (mEncoding == ENCODING_UTF8) {
     //utf8
     //TODO: Implementation needed
@@ -217,13 +217,13 @@ capu::int32_t EtchString::rightFind(cons
   return index;
 }
 
-capu::int32_t EtchString::leftFind(const char c) {
+capu::int32_t EtchString::leftFind(const char c) const {
   if (mEncoding == ENCODING_UTF8) {
     //utf8
     //TODO: Implementation needed
     return -1;
   }
-  const char * str = this->c_str();
+  const char * str = c_str();
   capu::int32_t index = -1;
   char* ch = strchr((char*) str, c);
   //NOT FOUND
@@ -233,7 +233,7 @@ capu::int32_t EtchString::leftFind(const
   return index;
 }
 
-status_t EtchString::substring(capu::uint32_t start, capu::uint32_t length, EtchString * dest) {
+status_t EtchString::substring(capu::uint32_t start, capu::uint32_t length, EtchString * dest) const {
   if (mEncoding == ENCODING_UTF8) {
     //utf8
     //TODO: Implementation needed

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchClientStack.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchClientStack.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchClientStack.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchClientStack.cpp Thu Aug  2 15:33:40 2012
@@ -17,7 +17,6 @@
 
 #include "support/EtchClientStack.h"
 
-
 EtchClientStack::EtchClientStack(EtchRemoteBase* rb, EtchSessionMessage *helper, EtchResources *res, EtchValueFactory* vf)
 : mRemoteBase(rb), mStubHelper(helper),mResources(res), mVf(vf) {
 }

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp Thu Aug  2 15:33:40 2012
@@ -37,7 +37,13 @@ EtchDefaultServerFactory::EtchDefaultSer
     }
 }
 
-status_t EtchDefaultServerFactory::sessionQuery( capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result ) {
+EtchDefaultServerFactory::~EtchDefaultServerFactory() {
+  if(mListener != NULL) {
+    delete mListener;
+  }
+}
+
+status_t EtchDefaultServerFactory::sessionQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
   if(mSession != NULL) {
     return mSession->sessionQuery(query, result);
   }
@@ -55,7 +61,7 @@ status_t EtchDefaultServerFactory::sessi
   if(mSession != NULL) {
     return mSession->sessionNotify( event );
   }
-  return ETCH_OK;
+  return ETCH_UNSUPP_OP;
 }
 
 EtchSession* EtchDefaultServerFactory::getSession() {
@@ -63,21 +69,23 @@ EtchSession* EtchDefaultServerFactory::g
 }
 
 void EtchDefaultServerFactory::setSession( EtchSession* session ) {
-  mSession = session;
+  if(session != NULL) {
+    this->mSession = session;
+  }
 }
 
 status_t EtchDefaultServerFactory::transportControl( capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value ) {
   if(mListener == NULL) {
     return ETCH_ERANGE;
   }
-  return mListener->transportControl( control, value );;
+  return mListener->transportControl(control, value);;
 }
 
 status_t EtchDefaultServerFactory::transportNotify( capu::SmartPointer<EtchObject> event ) {
   if(mListener == NULL) {
     return ETCH_ERANGE;
   }
-  return mListener->transportNotify( event );
+  return mListener->transportNotify(event);
 }
 
 status_t EtchDefaultServerFactory::transportQuery( capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result ) {

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchPlainMailbox.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchPlainMailbox.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchPlainMailbox.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchPlainMailbox.cpp Thu Aug  2 15:33:40 2012
@@ -22,7 +22,6 @@ EtchPlainMailbox::EtchPlainMailbox(EtchM
 }
 
 EtchPlainMailbox::~EtchPlainMailbox() {
-  // TODO: Validate dynamic 
   while (!mQueue.isEmpty()) {
     EtchMailbox::EtchElement* element = NULL;
     if(ETCH_OK == mQueue.get(&element)) {
@@ -42,8 +41,11 @@ EtchLong EtchPlainMailbox::getMessageId(
 status_t EtchPlainMailbox::message(capu::SmartPointer<EtchWho> sender, capu::SmartPointer<EtchMessage> msg) {
   status_t status;
   EtchMailbox::EtchElement* element = new EtchMailbox::EtchElement(sender, msg);
-  
+
+  mMutex.lock();
   status = mQueue.put(element, -1);
+  mMutex.unlock();
+
   if(status == ETCH_OK) {
      fireNotify();
      return ETCH_OK;
@@ -55,7 +57,8 @@ status_t EtchPlainMailbox::message(capu:
 }
 
 void EtchPlainMailbox::fireNotify() {
-  EtchMailbox::EtchNotify* n;
+
+  EtchMailbox::EtchNotify *n;
   EtchObject* s;
   capu::bool_t c;
 
@@ -63,16 +66,17 @@ void EtchPlainMailbox::fireNotify() {
   n = mNotify;
   s = mState;
   c = mQueue.isClosed();
-  mMutex.unlock();
 
   if (n != NULL) {
     n->mailboxStatus(this, s, c);
   }
+  // TODO: check if the unlock must be so late
+  mMutex.unlock();
 }
 
 status_t EtchPlainMailbox::read(EtchMailbox::EtchElement*& result) {
   status_t status = mQueue.get(&result);
-  if (ETCH_OK == status) {
+  if(ETCH_OK == status) {
     return ETCH_OK;
   }
   // TODO: logging
@@ -124,13 +128,16 @@ status_t EtchPlainMailbox::unregisterNot
 }
 
 capu::bool_t EtchPlainMailbox::isEmpty() {
-  return mQueue.isEmpty();
+  capu::bool_t res = mQueue.isEmpty();
+  return res;
 }
 
 capu::bool_t EtchPlainMailbox::isClosed() {
-  return mQueue.isClosed();
+  capu::bool_t res = mQueue.isClosed();
+  return res;
 }
 
 capu::bool_t EtchPlainMailbox::isFull() {
-  return mQueue.isFull();
-}
\ No newline at end of file
+  capu::bool_t res = mQueue.isFull();
+  return res;
+}

Added: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRuntime.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRuntime.cpp?rev=1368543&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRuntime.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRuntime.cpp Thu Aug  2 15:33:40 2012
@@ -0,0 +1,94 @@
+/* $Id$
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "common/EtchError.h"
+#include "common/EtchRuntimeException.h"
+#include "support/EtchRuntime.h"
+#include "support/EtchTransportHelper.h"
+
+EtchRuntime::EtchRuntime() 
+  : mIsClosed(false){
+  mMutex.lock();
+  mId = getNextId();
+  mMutex.unlock();
+}
+
+EtchRuntime::~EtchRuntime() {
+}
+
+capu::uint64_t EtchRuntime::getId() {
+  return mId;
+}
+
+capu::bool_t EtchRuntime::isClosed() {
+  return mIsClosed;
+}
+
+status_t EtchRuntime::registerListener(EtchRuntimeListener* listener) {
+  if(listener == NULL) {
+    return ETCH_EINVAL;
+  }
+  
+  mMutex.lock();
+  mListeners.add(listener);
+  mMutex.unlock();
+  return ETCH_OK;
+}
+
+status_t EtchRuntime::unregisterListener(EtchRuntimeListener* listener) {
+  status_t status;
+  mMutex.lock();
+  capu::int_t index = mListeners.find(listener);
+  if(index != -1) {
+    mListeners.removeAt(index);
+    status = ETCH_OK;
+  } else {
+    status = ETCH_ERROR;
+  }
+  mMutex.unlock();
+  return status;
+}
+
+status_t EtchRuntime::start() {
+  return ETCH_OK;
+}
+
+status_t EtchRuntime::shutdown() {
+  if(!mIsClosed) {
+    mIsClosed = true;
+    fireOnRuntimeChanged();
+  }
+  return ETCH_OK;
+}
+
+status_t EtchRuntime::fireOnRuntimeChanged() {
+  mMutex.lock();
+
+  capu::List<EtchRuntimeListener*>::Iterator iter = mListeners.begin();
+  while(iter.hasNext()) {
+    EtchRuntimeListener* listener = NULL;
+    iter.next(&listener);
+    listener->onRuntimeChanged(this);
+  }
+  mMutex.unlock();
+  return ETCH_OK;
+}
+
+capu::uint64_t EtchRuntime::getNextId() {
+  static capu::uint64_t sId = 0;
+  return sId++;
+}

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp Thu Aug  2 15:33:40 2012
@@ -22,12 +22,21 @@
 
 const EtchString EtchDefaultDeliveryService::DISABLE_TIMEOUT("DefaultDeliveryService.disableTimeout");
 
-EtchDefaultDeliveryService::EtchDefaultDeliveryService(EtchMailboxManager* transport, EtchString uri)
+/**
+ * @param transport
+ * @param uri
+ * @param resources
+ */
+EtchDefaultDeliveryService::EtchDefaultDeliveryService(EtchMailboxManager* transport, const EtchString& uri)
 : mTransport(transport), mStatus(EtchString("session status"), EtchString("")) {
   EtchURL url(uri);
   init(&url);
 }
 
+/**
+ * @param transport
+ * @param uri
+ */
 EtchDefaultDeliveryService::EtchDefaultDeliveryService(EtchMailboxManager* transport, EtchURL* uri)
 : mTransport(transport), mStatus(EtchString("session status"), EtchString("")) {
   init(uri);
@@ -53,6 +62,15 @@ void EtchDefaultDeliveryService::init(Et
   }
 }
 
+EtchDefaultDeliveryService::~EtchDefaultDeliveryService() {
+  if(mTransport != NULL) {
+    delete mTransport;
+  }
+}
+
+/**
+ * @return the transport.
+ */
 const EtchMailboxManager* EtchDefaultDeliveryService::getTransport() {
   return mTransport;
 }
@@ -135,12 +153,12 @@ status_t EtchDefaultDeliveryService::beg
 }
 
 status_t EtchDefaultDeliveryService::endcall(EtchMailbox* mb, EtchType* responseType, capu::SmartPointer<EtchObject>& result) {
-  EtchMailbox::EtchElement* mbe = NULL;
 
   //get timeout
   capu::uint32_t timeout = mDisableTimeout ? 0 : responseType->getTimeout();
 
   //get message from mailbox
+  EtchMailbox::EtchElement* mbe = NULL;
   status_t res = mb->read(mbe, timeout);
   if (res != ETCH_OK) {
     mb->closeRead();
@@ -183,4 +201,4 @@ status_t EtchDefaultDeliveryService::wai
 
 status_t EtchDefaultDeliveryService::waitDown(capu::int32_t maxDelay) {
   return mStatus.waitUntilEq((EtchString &) DOWN, maxDelay);
-}
\ No newline at end of file
+}

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp Thu Aug  2 15:33:40 2012
@@ -42,7 +42,8 @@ EtchMessagizer::EtchMessagizer(EtchTrans
 }
 
 EtchMessagizer::~EtchMessagizer() {
-  mTransport->setSession(NULL);
+  if(mTransport != NULL)
+    delete mTransport;
   if (mTdi != NULL)
     delete mTdi;
   if (mTdo != NULL)
@@ -93,8 +94,7 @@ status_t EtchMessagizer::sessionPacket(c
     return result;
   }
   result = mSession->sessionMessage(sender, message);
-  if (result != ETCH_OK)
-  {
+  if (result != ETCH_OK) {
     EtchString errmsg("Unwanted Message");
     mSession->sessionNotify(new EtchException(errmsg, ETCH_UNWANTED_MESSAGE, EtchException::EXCPTYPE_BUILTIN));
   }
@@ -109,6 +109,12 @@ status_t EtchMessagizer::transportMessag
 
   // packetize the message.
   // leave space for the packet header
+  result = msgBuf->setLength(mTransport->getHeaderSize());
+  if (result != ETCH_OK) {
+    mutex.unlock();
+    return result;
+  }
+
   result = msgBuf->setIndex(mTransport->getHeaderSize());
   if (result != ETCH_OK) {
     mutex.unlock();
@@ -127,4 +133,4 @@ status_t EtchMessagizer::transportMessag
   }
   mutex.unlock();
   return ETCH_OK;
-}
\ No newline at end of file
+}

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp Thu Aug  2 15:33:40 2012
@@ -31,7 +31,7 @@ EtchPacketizer::EtchPacketizer(EtchTrans
 
   if (mTransport != NULL)
     mTransport->setSession(this);
-  
+
   EtchURL url(uri.c_str());
   EtchString value;
   url.getTerms().get((EtchString&) EtchPacketizer::MAX_PKT_SIZE_TERM, &value);
@@ -65,7 +65,8 @@ EtchPacketizer::EtchPacketizer(EtchTrans
 }
 
 EtchPacketizer::~EtchPacketizer() {
-  mTransport->setSession(NULL);
+  if(mTransport != NULL)
+    delete mTransport;
 }
 
 capu::int32_t EtchPacketizer::getHeaderSize() {
@@ -114,8 +115,8 @@ status_t EtchPacketizer::transportPacket
     return ETCH_ERANGE;
 
   capu::uint32_t index = buf->getIndex();
-  buf->put((capu::int8_t*) & EtchPacketizer::SIG, sizeof (EtchPacketizer::SIG));
-  buf->put((capu::int8_t*) & pktSize, sizeof (pktSize));
+  buf->putInt(EtchPacketizer::SIG);
+  buf->putInt(pktSize);
   buf->setIndex(index);
   return mTransport->transportData(recipient, buf);
 }
@@ -228,7 +229,7 @@ status_t EtchPacketizer::processHeader(E
   if (pktSize > mMaxPktSize) {
     return ETCH_ERROR;
   }
-  
+
   return ETCH_OK;
 }
 

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp Thu Aug  2 15:33:40 2012
@@ -17,19 +17,21 @@
  */
 #include "transport/EtchPlainMailboxManager.h"
 
-EtchPlainMailboxManager::EtchPlainMailboxManager(EtchTransportMessage* transport, EtchURL* url, EtchResources* resources)
-: mSession(NULL), mTransport(transport) {
+EtchPlainMailboxManager::EtchPlainMailboxManager(EtchTransportMessage* transport, const EtchString& uri, EtchResources* resources)
+: mSession(NULL), mTransport(transport), mUp(false) {
   mTransport->setSession(this);
 }
 
 EtchPlainMailboxManager::~EtchPlainMailboxManager() {
   EtchHashTable<EtchLong, EtchMailbox*>::Iterator it = mMailboxes.begin();
   EtchHashTable<EtchLong, EtchMailbox*>::Pair p;
+  // TODO check thread safety
   while (it.hasNext()) {
     it.next(&p);
     p.second->closeDelivery();
     delete p.second;
   }
+  delete mTransport;
 }
 
 EtchTransportMessage* EtchPlainMailboxManager::getTransport() {
@@ -138,11 +140,25 @@ status_t EtchPlainMailboxManager::transp
 }
 
 status_t EtchPlainMailboxManager::sessionQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
-  return mSession->sessionQuery(query, result);
+  status_t status;
+  if(mSession != NULL) {
+    status = mSession->sessionQuery(query, result);
+  } else {
+    // TODO: add log message
+    status = ETCH_ERROR;
+  }
+  return status;
 }
 
 status_t EtchPlainMailboxManager::sessionControl(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value) {
-  return mSession->sessionControl(control, value);
+  status_t status;
+  if(mSession != NULL) {
+    status = mSession->sessionControl(control, value);
+  } else {
+    // TODO: add log message
+    status = ETCH_ERROR;
+  }
+  return status;
 }
 
 status_t EtchPlainMailboxManager::sessionNotify(capu::SmartPointer<EtchObject> event) {
@@ -151,14 +167,23 @@ status_t EtchPlainMailboxManager::sessio
   } else
   if(event->equals(&EtchSession::DOWN)) {
     mUp = false;
+    // TODO check thread safety
     EtchHashTable<EtchLong, EtchMailbox*>::Iterator it = mMailboxes.begin();
     EtchHashTable<EtchLong, EtchMailbox*>::Pair p;
     while (it.hasNext()) {
       it.next(&p);
       p.second->closeDelivery();
+      delete p.second;
     }
   }
-  return mSession->sessionNotify(event);
+  status_t status;
+  if(mSession != NULL) {
+    status = mSession->sessionNotify(event);
+  } else {
+    // TODO: add log message
+    status = ETCH_ERROR;
+  }
+  return status;
 }
 
 status_t EtchPlainMailboxManager::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp Thu Aug  2 15:33:40 2012
@@ -18,7 +18,8 @@
 
 #include "transport/EtchTcpConnection.h"
 
-EtchTcpConnection::EtchTcpConnection(EtchSocket* socket, EtchURL* uri) : mOptions(uri) {
+EtchTcpConnection::EtchTcpConnection(EtchRuntime* runtime, EtchSocket* socket, EtchURL* uri)
+: mRuntime(runtime), mOptions(uri) {
   if ((socket == NULL) && (uri != NULL)) {
     mHost = uri->getHost();
     mPort = uri->getPort();
@@ -39,6 +40,13 @@ EtchTcpConnection::~EtchTcpConnection() 
     mThread->join();
     delete mThread;
   }
+
+  if (mSocket != NULL) {
+    mSocket->close();
+    delete mSocket;
+    mSocket = NULL;
+    mIsStarted = false;
+  }
 }
 
 status_t EtchTcpConnection::send(capu::int8_t* buf, capu::uint32_t off, capu::uint32_t len) {
@@ -153,8 +161,6 @@ status_t EtchTcpConnection::transportCon
   }
 
   if (control->equals(&EtchTcpConnection::START_AND_WAIT_UP)) {
-    if (mIsStarted)
-      return ETCH_OK;
     mMutex.lock();
     if (mIsStarted) {
       mMutex.unlock();
@@ -164,9 +170,8 @@ status_t EtchTcpConnection::transportCon
     mMutex.unlock();
     mThread = new capu::Thread(this);
     mThread->start();
-    
-
     return waitUp(((EtchInt32*) value.get())->get());
+
   }
 
   if (control->equals(&EtchTcpConnection::STOP)) {
@@ -176,6 +181,7 @@ status_t EtchTcpConnection::transportCon
       return ETCH_OK;
     }
     mIsStarted = false;
+
     mMutex.unlock();
     close();
     return ETCH_OK;
@@ -202,7 +208,6 @@ status_t EtchTcpConnection::transportCon
     }
     mIsStarted = false;
     mMutex.unlock();
-
     close();
     return ETCH_OK;
   }

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp Thu Aug  2 15:33:40 2012
@@ -19,35 +19,38 @@
 
 const EtchString EtchTcpTransportFactory::SOCKET("TcpTransportFactory.socket");
 
-EtchTcpTransportFactory::EtchTcpTransportFactory()
-: mIsSecure(false) {
-
+EtchTcpTransportFactory::EtchTcpTransportFactory(EtchRuntime* runtime)
+: mRuntime(runtime)
+, mIsSecure(false) {
 }
 
-EtchTcpTransportFactory::EtchTcpTransportFactory(capu::bool_t secure)
-: mIsSecure(secure) {
+EtchTcpTransportFactory::EtchTcpTransportFactory(EtchRuntime* runtime, capu::bool_t secure)
+: mRuntime(runtime)
+, mIsSecure(secure) {
 
 }
 
 EtchTcpTransportFactory::~EtchTcpTransportFactory() {
-
 }
 
 status_t EtchTcpTransportFactory::newTransport(EtchString uri, EtchResources* resources, EtchTransportMessage*& result) {
   EtchURL u(uri);
 
+  status_t status;
   EtchObject* socket = NULL;
-  if (resources->get((EtchString &) SOCKET, socket) != ETCH_OK) {
-    return ETCH_ENOT_EXIST;
+  status = resources->get((EtchString &) SOCKET, socket);
+  if(status != ETCH_OK) {
+    return ETCH_ENOT_EXIST;;
   }
 
   EtchTransportData *c = NULL;
 
   if (mIsSecure) {
     //TODO : secure communication via ssl sockets
-    return ETCH_ENOT_EXIST;
+    return ETCH_EUNIMPL;
   } else {
-    c = new EtchTcpConnection((EtchSocket*) socket, &u);
+    // TODO add runtime
+    c = new EtchTcpConnection(NULL, (EtchSocket*) socket, &u);
   }
 
   EtchTransportPacket* p = new EtchPacketizer(c, &u);
@@ -57,6 +60,7 @@ status_t EtchTcpTransportFactory::newTra
   //TODO: ADD FILTERS HERE
 
   EtchObject* obj = NULL;
+  // TODO check why the string must be copied
   EtchString tmp(EtchTransport<EtchSocket>::VALUE_FACTORY);
   if (resources->get(tmp, obj) != ETCH_OK) {
     c->setSession(NULL);
@@ -80,29 +84,33 @@ status_t EtchTcpTransportFactory::newLis
   EtchTransport<EtchSessionListener<EtchSocket> > *l = NULL;
   if (mIsSecure) {
     //TODO secure communication
-    return ETCH_ENOT_EXIST;
+    return ETCH_EUNIMPL;
   } else {
     l = new EtchTcpListener(&u);
   }
 
-  result = new MySessionListener(l, uri, resources, mIsSecure);
+  result = new MySessionListener(mRuntime, l, uri, resources, mIsSecure);
   if (result == NULL) {
-    return ETCH_ENOT_EXIST;
+    return ETCH_ERROR;
   }
   return ETCH_OK;
 }
 
-EtchTcpTransportFactory::MySessionListener::MySessionListener(EtchTransport<EtchSessionListener<EtchSocket> > *transport, EtchString uri, EtchResources* resources, capu::bool_t secure)
-: mTransport(transport), mUri(uri), mResources(resources), mIsSecure(secure) {
-  if (transport != NULL) {
-    transport->setSession(this);
-  }
+EtchTcpTransportFactory::MySessionListener::MySessionListener(EtchRuntime* runtime, EtchTransport<EtchSessionListener<EtchSocket> > *transport, EtchString uri, EtchResources* resources, capu::bool_t secure)
+: mRuntime(runtime), mTransport(transport), mUri(uri), mResources(resources), mIsSecure(secure) {
+  transport->setSession(this);
 }
 
 EtchServerFactory* EtchTcpTransportFactory::MySessionListener::getSession() {
   return mSession;
 }
 
+EtchTcpTransportFactory::MySessionListener::~MySessionListener() {
+  if(mTransport != NULL) {
+    delete mTransport;
+  }
+}
+
 void EtchTcpTransportFactory::MySessionListener::setSession(EtchServerFactory* session) {
   mSession = session;
 }
@@ -137,27 +145,59 @@ status_t EtchTcpTransportFactory::MySess
   }
 
   EtchResources *res = new EtchResources(mResources);
+
+  // put socket to the resources
   EtchObject *obj = NULL;
   if (res->put((EtchString &) SOCKET, connection, obj) != ETCH_OK) {
     delete res;
     return ETCH_ERROR;
   }
 
+  // create value vatory and put it to the resources
   EtchValueFactory* vf = NULL;
-  if (mSession->newValueFactory(&mUri, vf) != ETCH_OK) {
+  if(mSession->newValueFactory(mUri, vf) != ETCH_OK) {
     delete res;
     return ETCH_ERROR;
   }
-  if (res->put((EtchString &) VALUE_FACTORY, vf, obj)) {
+  if(res->put(EtchTransport<EtchSocket>::VALUE_FACTORY, vf, obj) != ETCH_OK)
+  {
+    delete vf;
     delete res;
     return ETCH_ERROR;
   }
 
-  EtchTransportMessage *t = NULL;
-  if (getTransport(mUri, res, t) != ETCH_OK) {
-    delete res;
-    return ETCH_ERROR;
+  EtchURL u = EtchURL(mUri);
+
+  EtchObject* socket = NULL;
+  if (res->get(SOCKET, socket) != ETCH_OK) {
+    return ETCH_ENOT_EXIST;
+  }
+  // TODO check if we should register a new stack to the runtime
+  
+  EtchTransportData *c = NULL;
+  if (mIsSecure) {
+    //TODO : secure communication via ssl sockets
+    return ETCH_EUNIMPL;
+  } else {
+    c = new EtchTcpConnection(mRuntime, (EtchSocket*) socket, &u);
   }
 
-  return mSession->newServer(t, &mUri, res);
-}
\ No newline at end of file
+  EtchTransportPacket* p = new EtchPacketizer(c, &u);
+
+  EtchTransportMessage* m = new EtchMessagizer(p, &u, res);
+
+  //TODO: ADD FILTERS HERE
+
+  if (res->get(EtchTransport<EtchSocket>::VALUE_FACTORY, obj) != ETCH_OK) {
+    c->setSession(NULL);
+    p->setSession(NULL);
+    m->setSession(NULL);
+    delete c;
+    delete p;
+    delete m;
+    return ETCH_ENOT_EXIST;
+  }
+  vf->lockDynamicTypes();
+
+  return mSession->newServer(m, mUri, res);
+}

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTransportFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTransportFactory.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTransportFactory.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTransportFactory.cpp Thu Aug  2 15:33:40 2012
@@ -20,10 +20,10 @@
 
 #include "transport/EtchTransportFactory.h"
 #include "transport/EtchTcpTransportFactory.h"
+#include "support/EtchRuntime.h"
 
 const EtchString EtchTransportFactory::FILTER("filter");
 
-
 EtchTransportFactory::~EtchTransportFactory() {
 
 }
@@ -38,37 +38,35 @@ status_t EtchTransportFactory::addFilter
   return ETCH_EUNIMPL;
 }
 
-status_t EtchTransportFactory::getTransport(EtchString uri, EtchResources* resources, EtchTransportMessage*& result) {
+status_t EtchTransportFactory::getTransport(EtchRuntime* runtime, EtchString uri, EtchResources* resources, EtchTransportMessage*& result) {
   EtchURL u(uri);
   EtchTransportFactory* f = NULL;
-  if (getTransportFactory(u.getScheme(), f) != ETCH_OK) {
-    return ETCH_ENOT_EXIST;
-  }
-  if (f == NULL) {
+  if (getTransportFactory(runtime, u.getScheme(), f) != ETCH_OK) {
     return ETCH_ENOT_EXIST;
   }
-  return f->newTransport(uri, resources, result);
+  status_t _result = f->newTransport(uri, resources, result);
+  // TODO check lifecyle here
+  delete f;
+  return _result;
 }
 
-status_t EtchTransportFactory::getListener(EtchString uri, EtchResources* resources, EtchTransport<EtchServerFactory>*& result) {
+status_t EtchTransportFactory::getListener(EtchRuntime* runtime, EtchString uri, EtchResources* resources, EtchTransport<EtchServerFactory>*& result) {
   EtchURL u(uri);
   EtchTransportFactory* f = NULL;
-  if (getTransportFactory(u.getScheme(), f) != ETCH_OK) {
+  if (getTransportFactory(runtime, u.getScheme(), f) != ETCH_OK) {
     return ETCH_ENOT_EXIST;
   }
-  if (f == NULL) {
-    return ETCH_ENOT_EXIST;
-  }
-  return f->newListener(uri, resources, result);
+
+  status_t ret = f->newListener(uri, resources, result);
+  delete f;
+  return ret;
 }
 
-status_t EtchTransportFactory::getTransportFactory(const EtchString& name, EtchTransportFactory*& result) {
+status_t EtchTransportFactory::getTransportFactory(EtchRuntime* runtime, const EtchString& name, EtchTransportFactory*& result) {
   EtchString tmp("tcp");
   if (name.equals(&tmp)) {
-    result = new EtchTcpTransportFactory();
+    result = new EtchTcpTransportFactory(runtime);
     return ETCH_OK;
   }
-  //TODO: result = new EtchUdpTransprtFactory();
   return ETCH_ENOT_EXIST;
-
 }

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchResources.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchResources.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchResources.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchResources.cpp Thu Aug  2 15:33:40 2012
@@ -25,14 +25,12 @@ EtchResources::EtchResources()
 
 EtchResources::EtchResources(EtchResources * related)
 : mRelated(related) {
-
 }
 
 EtchResources::~EtchResources() {
-
 }
 
-capu::bool_t EtchResources::containsKey(EtchString& key) {
+capu::bool_t EtchResources::containsKey(const EtchString& key) {
   EtchObject* ptr = NULL;
   if (res.get(key, &ptr) == ETCH_OK)
     return true;
@@ -47,7 +45,7 @@ capu::bool_t EtchResources::containsKey(
   }
 }
 
-status_t EtchResources::get(EtchString& key, EtchObject*& result) {
+status_t EtchResources::get(const EtchString& key, EtchObject*& result) {
   if (res.get(key, &result) != ETCH_OK) {
 
     if (mRelated == NULL)
@@ -59,11 +57,11 @@ status_t EtchResources::get(EtchString& 
   return ETCH_OK;
 }
 
-status_t EtchResources::put(EtchString& key, EtchObject* value, EtchObject*& result) {
+status_t EtchResources::put(const EtchString& key, EtchObject* value, EtchObject*& result) {
   return res.put(key, value, &result);
 }
 
-status_t EtchResources::remove(EtchString& key, EtchObject*& result) {
+status_t EtchResources::remove(const EtchString& key, EtchObject*& result) {
 
   return res.remove(key, &result);
 }

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchURL.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchURL.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchURL.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchURL.cpp Thu Aug  2 15:33:40 2012
@@ -39,7 +39,7 @@ EtchURL::EtchURL(const char* urlStr) {
   }
 }
 
-EtchURL::EtchURL(EtchString& urlStr) {
+EtchURL::EtchURL(const EtchString& urlStr) {
   if (urlStr.c_str() == NULL) {
     //already initialized
   } else if (urlStr.length() > 0) {
@@ -60,7 +60,7 @@ EtchURL::~EtchURL() {
   terms.clear();
 }
 
-status_t EtchURL::parse(EtchString* s) {
+status_t EtchURL::parse(const EtchString* s) {
   if (s == NULL)
     return ETCH_EINVAL;
   // s is scheme:[//[user[:password]@]host[:port]/]uri[;params][?terms][#fragment]
@@ -177,7 +177,7 @@ status_t EtchURL::parse(EtchString* s) {
   return ETCH_OK;
 }
 
-status_t EtchURL::parseHost(EtchString* s) {
+status_t EtchURL::parseHost(const EtchString* s) {
   if (s == NULL) {
     return ETCH_EINVAL;
   }
@@ -197,7 +197,7 @@ status_t EtchURL::parseHost(EtchString* 
   return ETCH_OK;
 }
 
-status_t EtchURL::parseUserPassword(EtchString* s) {
+status_t EtchURL::parseUserPassword(const EtchString* s) {
   if (s == NULL) {
     return ETCH_EINVAL;
   }
@@ -219,7 +219,7 @@ status_t EtchURL::parseUserPassword(Etch
   return ETCH_OK;
 }
 
-status_t EtchURL::parseHostPort(EtchString* s) {
+status_t EtchURL::parseHostPort(const EtchString* s) {
   if (s == NULL) {
     return ETCH_EINVAL;
   }
@@ -242,7 +242,7 @@ status_t EtchURL::parseHostPort(EtchStri
   return ETCH_OK;
 }
 
-status_t EtchURL::parseParams(EtchString* s) {
+status_t EtchURL::parseParams(const EtchString* s) {
   // s is param[;param]*
   if (s == NULL) {
     return ETCH_EINVAL;
@@ -265,7 +265,7 @@ status_t EtchURL::parseParams(EtchString
   return ETCH_OK;
 }
 
-status_t EtchURL::parseTerms(EtchString* s) {
+status_t EtchURL::parseTerms(const EtchString* s) {
   if (s == NULL) {
     return ETCH_EINVAL;
   }
@@ -286,7 +286,7 @@ status_t EtchURL::parseTerms(EtchString*
   return parseTerm(&_s);
 }
 
-status_t EtchURL::parseTerm(EtchString * s) {
+status_t EtchURL::parseTerm(const EtchString * s) {
   if (s == NULL) {
     return ETCH_EINVAL;
   }
@@ -308,7 +308,7 @@ EtchString& EtchURL::getScheme() {
   return scheme;
 }
 
-void EtchURL::setScheme(EtchString& scheme) {
+void EtchURL::setScheme(const EtchString& scheme) {
   this->scheme.set(scheme.c_str());
 }
 
@@ -324,7 +324,7 @@ EtchString& EtchURL::getUser() {
   return user;
 }
 
-void EtchURL::setUser(EtchString& user) {
+void EtchURL::setUser(const EtchString& user) {
   this->user.set(user.c_str());
 }
 
@@ -332,7 +332,7 @@ EtchString& EtchURL::getPassword() {
   return password;
 }
 
-void EtchURL::setPassword(EtchString& password) {
+void EtchURL::setPassword(const EtchString& password) {
   this->password.set(password.c_str());
 }
 
@@ -340,7 +340,7 @@ EtchString& EtchURL::getHost() {
   return host;
 }
 
-void EtchURL::setHost(EtchString& host) {
+void EtchURL::setHost(const EtchString& host) {
   this->host.set(host.c_str());
 }
 
@@ -348,7 +348,7 @@ capu::uint16_t EtchURL::getPort() {
   return port;
 }
 
-void EtchURL::setPort(capu::uint16_t port) {
+void EtchURL::setPort(const capu::uint16_t port) {
   this->port = port;
 }
 
@@ -356,7 +356,7 @@ EtchString& EtchURL::getUri() {
   return uri;
 }
 
-void EtchURL::setUri(EtchString& uri) {
+void EtchURL::setUri(const EtchString& uri) {
   this->uri.set(uri.c_str());
 }
 

Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt Thu Aug  2 15:33:40 2012
@@ -50,6 +50,7 @@ add_executable (etch-cpp-test
     util/EtchURLTest.cpp
     util/EtchResourcesTest.cpp
     util/EtchUtilTest.cpp
+    util/EtchCircularQueueTest.cpp
     transport/EtchFlexBufferTest.cpp
     transport/EtchTcpConnectionTest.cpp
     transport/EtchTcpListenerTest.cpp
@@ -90,8 +91,7 @@ add_executable (etch-cpp-test
     support/EtchPlainMailboxTest.cpp
     support/EtchMonitorTest.cpp
     support/EtchRemoteBaseTest.cpp
-    util/EtchCircularQueueTest.cpp
-    util/EtchUtilTest.cpp
+    support/EtchRuntimeTest.cpp
     ${GTEST}/src/gtest-all.cc
     ${GMOCK}/src/gmock-all.cc
     main.cpp

Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp Thu Aug  2 15:33:40 2012
@@ -75,6 +75,7 @@ public:
   EtchTypeMap types;
   EtchClass2TypeMap class2type;
   EtchDefaultValueFactory * factory;
+
   /**
    * Constructs the MyValueFactory.
    * @param uri
@@ -94,14 +95,14 @@ public:
 
 TEST(EtchRemoteBaseTest, constructorTest) {
   MockSession2 session;
-  MockTransport2 transport;
+  MockTransport2 *transport = new MockTransport2();
   MockDefaultValueFactory2 *factory;
   EtchString uri("tcp://127.0.0.1:4001");
   factory = new MockDefaultValueFactory2(uri);
   //created value factory
   EtchURL u(uri);
   EtchPlainMailboxManager * manager = NULL;
-  manager = new EtchPlainMailboxManager(&transport, &u, NULL);
+  manager = new EtchPlainMailboxManager(transport, NULL, NULL);
   EtchDeliveryService * service = NULL;
   service = new EtchDefaultDeliveryService(manager, &u);
   EtchRemoteBase * remote = NULL;
@@ -112,14 +113,13 @@ TEST(EtchRemoteBaseTest, constructorTest
   service->setSession(&session);
 
   delete remote;
-  delete manager;
   delete service;
   delete factory;
 }
 
 TEST(EtchRemoteBaseTest, newMessageTest) {
   MockSession2 session;
-  MockTransport2 transport;
+  MockTransport2 *transport = new MockTransport2();
   MockDefaultValueFactory2 *factory;
   EtchString uri("tcp://127.0.0.1:4001");
   factory = new MockDefaultValueFactory2(uri);
@@ -127,7 +127,7 @@ TEST(EtchRemoteBaseTest, newMessageTest)
   EtchURL u(uri);
 
   EtchPlainMailboxManager * manager = NULL;
-  manager = new EtchPlainMailboxManager(&transport, &u, NULL);
+  manager = new EtchPlainMailboxManager(transport, NULL, NULL);
   EtchDeliveryService * service = NULL;
   service = new EtchDefaultDeliveryService(manager, &u);
   EtchRemoteBase * remote = NULL;
@@ -151,14 +151,13 @@ TEST(EtchRemoteBaseTest, newMessageTest)
   EXPECT_TRUE(factory->factory == msg->getValueFactory());
 
   delete remote;
-  delete manager;
   delete service;
   delete factory;
 }
 
 TEST(EtchRemoteBaseTest, sendTest) {
   MockSession2 session;
-  MockTransport2 transport;
+  MockTransport2 *transport = new MockTransport2();
   MockDefaultValueFactory2 *factory;
   EtchString uri("tcp://127.0.0.1:4001");
   factory = new MockDefaultValueFactory2(uri);
@@ -166,7 +165,7 @@ TEST(EtchRemoteBaseTest, sendTest) {
   EtchURL u(uri);
 
   EtchPlainMailboxManager * manager = NULL;
-  manager = new EtchPlainMailboxManager(&transport, &u, NULL);
+  manager = new EtchPlainMailboxManager(transport, NULL, NULL);
   EtchDeliveryService * service = NULL;
   service = new EtchDefaultDeliveryService(manager, &u);
   EtchRemoteBase * remote = NULL;
@@ -194,14 +193,13 @@ TEST(EtchRemoteBaseTest, sendTest) {
 
   factory->types.clear();
   delete remote;
-  delete manager;
   delete service;
   delete factory;
 }
 
 TEST(EtchRemoteBaseTest, beginCallTest) {
   MockSession2 session;
-  MockTransport2 transport;
+  MockTransport2 *transport = new MockTransport2();
   MockDefaultValueFactory2 *factory;
   EtchString uri("tcp://127.0.0.1:4001");
   factory = new MockDefaultValueFactory2(uri);
@@ -209,7 +207,7 @@ TEST(EtchRemoteBaseTest, beginCallTest) 
   EtchURL u(uri);
 
   EtchPlainMailboxManager * manager = NULL;
-  manager = new EtchPlainMailboxManager(&transport, &u, NULL);
+  manager = new EtchPlainMailboxManager(transport, NULL, NULL);
   EtchDeliveryService * service = NULL;
   service = new EtchDefaultDeliveryService(manager, &u);
   EtchRemoteBase * remote = NULL;
@@ -242,14 +240,13 @@ TEST(EtchRemoteBaseTest, beginCallTest) 
 
   factory->types.clear();
   delete remote;
-  delete manager;
   delete service;
   delete factory;
 }
 
 TEST(EtchRemoteBaseTest, endCallTest) {
   MockSession2 session;
-  MockTransport2 transport;
+  MockTransport2 *transport = new MockTransport2();
   MockDefaultValueFactory2 *factory;
   EtchString uri("tcp://127.0.0.1:4001");
   factory = new MockDefaultValueFactory2(uri);
@@ -257,7 +254,7 @@ TEST(EtchRemoteBaseTest, endCallTest) {
   EtchURL u(uri);
 
   EtchPlainMailboxManager * manager = NULL;
-  manager = new EtchPlainMailboxManager(&transport, &u, NULL);
+  manager = new EtchPlainMailboxManager(transport, NULL, NULL);
   EtchDeliveryService * service = NULL;
   service = new EtchDefaultDeliveryService(manager, &u);
   EtchRemoteBase * remote = NULL;
@@ -303,7 +300,7 @@ TEST(EtchRemoteBaseTest, endCallTest) {
   capu::SmartPointer<EtchObject> old;
   EtchField field = replyType->getResponseField();
   replyMessage->put(field, data, &old);
-  //call the sessionMessage of mailbox manager as if it is called from messagizer to deliver data from 
+  //call the sessionMessage of mailbox manager as if it is called from messagizer to deliver data from
   EXPECT_TRUE(ETCH_OK == manager->sessionMessage(NULL, replymess));
   capu::SmartPointer<EtchObject> result;
   EXPECT_TRUE(remote->endcall(mail, replyType, result) == ETCH_OK);
@@ -313,7 +310,6 @@ TEST(EtchRemoteBaseTest, endCallTest) {
   factory->types.clear();
   delete mail;
   delete remote;
-  delete manager;
   delete service;
   delete factory;
-}
\ No newline at end of file
+}

Added: incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRuntimeTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRuntimeTest.cpp?rev=1368543&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRuntimeTest.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRuntimeTest.cpp Thu Aug  2 15:33:40 2012
@@ -0,0 +1,82 @@
+/* $Id$
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "support/EtchRuntime.h"
+
+TEST(EtchRuntime, Default) {
+  EtchRuntime* runtime = new EtchRuntime();
+  delete runtime;
+}
+
+TEST(EtchRuntime, getId) {
+  EtchRuntime* runtime = new EtchRuntime();
+  capu::uint64_t id = runtime->getId();
+  delete runtime;
+}
+
+TEST(EtchRuntime, isClosed) {
+  EtchRuntime* runtime = new EtchRuntime();
+  ASSERT_EQ(false, runtime->isClosed());
+  runtime->shutdown();
+  ASSERT_EQ(true, runtime->isClosed());
+  delete runtime;
+}
+
+class EtchRuntimeTestListener : public EtchRuntimeListener {
+public:
+  /**
+   * Constructor
+   */
+  EtchRuntimeTestListener() 
+    : mId(0) {
+  }
+
+  /**
+   * @see EtchRuntimeListener
+   */
+  status_t onRuntimeChanged(EtchRuntime* runtime) {
+    mId++;
+    return ETCH_OK;
+  }
+public:
+  capu::uint8_t mId;
+};
+
+TEST(EtchRuntime, registerListener) {
+  status_t status;
+  EtchRuntime* runtime = new EtchRuntime();
+  
+  status = runtime->registerListener(NULL);
+  ASSERT_EQ(ETCH_EINVAL, status);
+
+  EtchRuntimeTestListener listener;
+  status = runtime->registerListener(&listener);
+  ASSERT_EQ(ETCH_OK, status);
+
+  // a shutdown leads to a runtime change
+  runtime->shutdown();
+
+  status = runtime->unregisterListener(&listener);
+  ASSERT_EQ(ETCH_OK, status);
+
+  // check if callback was fired
+  ASSERT_EQ(1, listener.mId);
+
+  delete runtime;
+}

Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp?rev=1368543&r1=1368542&r2=1368543&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp Thu Aug  2 15:33:40 2012
@@ -28,6 +28,19 @@
 class MockSession1 : public EtchSessionMessage {
 public:
 
+  MockSession1(EtchTransportMessage* transport) 
+    : mTransport(transport) {
+    if(mTransport != NULL) {
+      mTransport->setSession(this);
+    }
+  }
+
+  virtual ~MockSession1() {
+    if(mTransport != NULL) {
+      delete mTransport;
+    }
+  }
+
   status_t sessionMessage(capu::SmartPointer<EtchWho> receipent, capu::SmartPointer<EtchMessage> buf) {
     return ETCH_OK;
   }
@@ -43,19 +56,20 @@ public:
   status_t sessionNotify(capu::SmartPointer<EtchObject> event) {
     return ETCH_OK;
   }
+private:
+  EtchTransportMessage* mTransport;
 };
 
 class MockTransport1 : public EtchTransportMessage {
 public:
 
-  status_t transportMessage(capu::SmartPointer<EtchWho> recipient, capu::SmartPointer<EtchMessage> message) {
+    status_t transportMessage(capu::SmartPointer<EtchWho> recipient, capu::SmartPointer<EtchMessage> message) {
     return ETCH_OK;
   }
 
   MOCK_METHOD0(getSession, EtchSessionMessage* ());
 
   void setSession(EtchSessionMessage* session) {
-
   }
 
   status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {
@@ -78,13 +92,13 @@ public:
   EtchDefaultValueFactory * factory;
   /**
    * Constructs the MyValueFactory.
-   * @param uriString
+   * @param uri
    */
 public:
 
-  MockDefaultValueFactory1(EtchString uriString) {
-    EtchDefaultValueFactory::Init(&types, &class2type);
-    factory = new EtchDefaultValueFactory(uriString, &types, &class2type);
+  MockDefaultValueFactory1(EtchString uri) {
+  EtchDefaultValueFactory::Init(&types, &class2type);
+  factory = new EtchDefaultValueFactory(uri, &types, &class2type);
   }
 
   ~MockDefaultValueFactory1() {
@@ -94,38 +108,28 @@ public:
 };
 
 TEST(EtchDeliveryServiceTest, constructorTest) {
-  MockTransport1 transport;
-  MockSession1 session;
-  MockDefaultValueFactory1 *factory;
-  EtchString uriString("tcp://127.0.0.1:4001");
-  factory = new MockDefaultValueFactory1(uriString);
-  //created value factory
-  EtchURL uri(uriString);
-  EtchPlainMailboxManager *manager = new EtchPlainMailboxManager(&transport, &uri, NULL);
-  EtchDefaultDeliveryService *service = new EtchDefaultDeliveryService(manager, uriString);
-  EtchDefaultDeliveryService *service2 = new EtchDefaultDeliveryService(manager, &uri);
-
-  EXPECT_TRUE(service != NULL);
-  manager->setSession(service);
-  service->setSession(&session);
-
-  EXPECT_TRUE(service2 != NULL);
-  manager->setSession(service2);
-  service2->setSession(&session);
-
-  delete manager;
-  delete service;
-  delete service2;
-  delete factory;
+
+  EtchString uri("tcp://127.0.0.1:4001");
+
+// create mock layer for transport
+  MockTransport1* transport = new MockTransport1();
+
+  EtchPlainMailboxManager* mailboxManager = new EtchPlainMailboxManager(transport, uri, NULL);
+  EtchDefaultDeliveryService* deliveryService = new EtchDefaultDeliveryService(mailboxManager, uri);
+
+  // create mock layer for session
+  MockSession1* session = new MockSession1(deliveryService);
+
+  delete session;
 }
 
 TEST(EtchDeliveryServiceTest, beginCallTest) {
-  EtchString uriString("tcp://127.0.0.1:4001");
-  EtchURL uri(uriString);
-  MockDefaultValueFactory1 *factory = new MockDefaultValueFactory1(uriString);
+  EtchString uri("tcp://127.0.0.1:4001");
 
+  // create value factory
+  MockDefaultValueFactory1* factory = new MockDefaultValueFactory1(uri);
   //set type and corresponding validator
-  EtchType * type;
+  EtchType * type = NULL;
   capu::SmartPointer<EtchValidator> val = NULL;
   EtchValidatorLong::Get(0, val);
 
@@ -139,44 +143,45 @@ TEST(EtchDeliveryServiceTest, beginCallT
   EXPECT_TRUE(ETCH_OK != message->getMessageId(id));
   EXPECT_TRUE(ETCH_OK != message->getInReplyToMessageId(id));
 
-  //create transport and session layers
-  MockTransport1 transport;
-  MockSession1 session;
-
-  //create mailbox manager
-  EtchPlainMailboxManager * manager = new EtchPlainMailboxManager(&transport, &uri, NULL);
-
-  //create delivery service and set respective transport and session intefaces
-  EtchDefaultDeliveryService * service = new EtchDefaultDeliveryService(manager, &uri);
-  manager->setSession(service);
-  service->setSession(&session);
+  // create mock layer for transport
+  MockTransport1* transport = new MockTransport1();
+
+  EtchPlainMailboxManager* mailboxManager = new EtchPlainMailboxManager(transport, uri, NULL);
+  EtchDefaultDeliveryService* deliveryService = new EtchDefaultDeliveryService(mailboxManager, uri);
+
+  // create mock layer for session
+  MockSession1* session = new MockSession1(deliveryService);
 
   //put the stack up
-  manager->sessionNotify(new EtchString(EtchSession::UP));
+  mailboxManager->sessionNotify(new EtchString(EtchSession::UP));
 
   //test begincall
   EtchMailbox *mail = NULL;
-  EXPECT_TRUE(ETCH_OK == service->begincall(message, mail));
-  EXPECT_EQ(1, manager->count());
+  EXPECT_TRUE(ETCH_OK == deliveryService->begincall(message, mail));
+  EXPECT_EQ(1, mailboxManager->count());
   EXPECT_TRUE(ETCH_OK == message->getMessageId(id));
   EXPECT_TRUE(ETCH_OK != message->getInReplyToMessageId(id));
 
-  EXPECT_TRUE(ETCH_OK == manager->getMailbox(id, mail));
-
+  EXPECT_TRUE(ETCH_OK == mailboxManager->getMailbox(id, mail));
   message->clear();
-  delete service;
-  delete manager;
+
+  //put the stack down
+  mailboxManager->sessionNotify(new EtchString(EtchSession::DOWN));
+
+  delete session;
   delete factory;
 }
 
 TEST(EtchDeliveryServiceTest, endCallTest) {
-  EtchString uriString("tcp://127.0.0.1:4001");
-  EtchURL uri(uriString);
-  MockDefaultValueFactory1 *factory = new MockDefaultValueFactory1(uriString);
+  status_t status;
+  EtchString uri("tcp://127.0.0.1:4001");
+
+  // create value factory
+  MockDefaultValueFactory1* factory = new MockDefaultValueFactory1(uri);
 
   //set type and return type and the corresponding validators
-  EtchType * type;
-  EtchType * replyType;
+  EtchType * type = NULL;
+  EtchType * replyType = NULL;
   capu::SmartPointer<EtchValidator> val = NULL;
   EtchValidatorLong::Get(0, val);
 
@@ -194,52 +199,49 @@ TEST(EtchDeliveryServiceTest, endCallTes
   EXPECT_TRUE(ETCH_OK != message->getMessageId(id));
   EXPECT_TRUE(ETCH_OK != message->getInReplyToMessageId(id));
 
-  MockTransport1 transport;
-  MockSession1 session;
+  // create mock layer for transport
+  MockTransport1* transport = new MockTransport1();
+
+  EtchPlainMailboxManager* mailboxManager = new EtchPlainMailboxManager(transport, uri, NULL);
+  EtchDefaultDeliveryService* deliveryService = new EtchDefaultDeliveryService(mailboxManager, uri);
+
+  // create mock layer for session
+  MockSession1* session = new MockSession1(deliveryService);
 
-  //mailbox manager
-  EtchPlainMailboxManager *manager = new EtchPlainMailboxManager(&transport, &uri, NULL);
-  //delivery service
-  EtchDefaultDeliveryService *service = new EtchDefaultDeliveryService(manager, &uri);
-
-  manager->setSession(service);
-  service->setSession(&session);
-  manager->sessionNotify(new EtchString(EtchSession::UP));
+  //put the stack up
+  mailboxManager->sessionNotify(new EtchString(EtchSession::UP));
 
   //performed the call
   EtchMailbox *mail;
-  EXPECT_TRUE(ETCH_OK == service->begincall(message, mail));
-  EXPECT_EQ(1, manager->count());
+  EXPECT_TRUE(ETCH_OK == deliveryService->begincall(message, mail));
+  EXPECT_EQ(1, mailboxManager->count());
   EXPECT_TRUE(ETCH_OK == message->getMessageId(id));
   EXPECT_TRUE(ETCH_OK != message->getInReplyToMessageId(id));
-  EXPECT_TRUE(ETCH_OK == manager->getMailbox(id, mail));
-  capu::SmartPointer<EtchObject> result;
+  EXPECT_TRUE(ETCH_OK == mailboxManager->getMailbox(id, mail));
 
+  //create a reply message
   //simulate the response
   capu::SmartPointer<EtchMessage> replymessage;
-
-  //create a reply message
   message->createReplyMessage(replyType, replymessage);
   EXPECT_TRUE(ETCH_OK == replymessage->getInReplyToMessageId(id));
-  capu::SmartPointer<EtchMessage> replymess = replymessage;
   capu::SmartPointer<EtchObject> data = new EtchLong(123);
   capu::SmartPointer<EtchObject> old;
   EtchField field = replyType->getResponseField();
   replymessage->put(field, data, &old);
 
-  //call the sessionMessage of mailbox manager as if it is called from messagizer to deliver data from 
-  EXPECT_TRUE(ETCH_OK == manager->sessionMessage(NULL, replymess));
+  //call the sessionMessage of mailbox manager as if it is called from messagizer to deliver data from
+  status = mailboxManager->sessionMessage(NULL, replymessage);
+  EXPECT_EQ(ETCH_OK, status);
 
   //wait for the response
-  EXPECT_TRUE(ETCH_OK == service->endcall(mail, replyType, result));
-
+  capu::SmartPointer<EtchObject> result;
+  status = deliveryService->endcall(mail, replyType, result);
+  EXPECT_EQ(ETCH_OK, status);
+  delete mail;
+  
   //check the result
   EXPECT_TRUE(result->equals(data.get()));
 
-  replymessage->clear();
-  message->clear();
-  delete mail;
-  delete service;
-  delete manager;
+  delete session;
   delete factory;
-}
\ No newline at end of file
+}