[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Oct 18 09:14:48 CDT 2010


branch "master" has been updated
       via  faaece515a3fe152bedc86bd9473f3e2015d6f13 (commit)
       via  53c9d86dd0d9c453a3d964ce5e3b267db149fb93 (commit)
       via  82f9b3bb6bd11f9c85f0547e4e4cf5389957b12f (commit)
       via  667705c067cdc9d5e60d62382261b8254f3795c6 (commit)
       via  e1939555cd28ea8a983577e93b706fcf6fb4d74d (commit)
       via  ab018f2970ce0d2ab2d84ff428fd4e9dbf43c773 (commit)
       via  8d239079a95dc61b81ab7d5086effbb9e963128b (commit)
       via  e2569300dfffe470d54233c8489616e4dabcbb10 (commit)
       via  4c8146f1979db9d9ce5cba49d68e929bcc2f6725 (commit)
       via  7328f734fbdcab017d4efd3b1566539f40b5edfe (commit)
       via  3aa33a7e9517fb5040f1298e2b0d0b15b20414f6 (commit)
       via  dc271816bc72243938f975a3f638ba9daf042ee3 (commit)
       via  274a899619560fa09942d703e60669c88734c722 (commit)
       via  5b3c6bf967f37f6fc638d598208365b62b22aa1d (commit)
       via  0d15966ba2f8d073cd23f737fc92a483efbba6e8 (commit)
      from  0033e7aa459ad12bcb2ada572ef5c72da42f6a1f (commit)

Summary of changes:
 src/CMakeLists.txt                     |    3 +-
 src/PJSipManager.cpp                   |    4 +-
 src/PJSipManager.h                     |    5 +-
 src/PJSipSessionModule.h               |    9 +-
 src/PJSipSessionModuleConstruction.cpp |    4 +-
 src/ProxyWrapper.cpp                   |   20 ++++
 src/ProxyWrapper.h                     |  154 ++++++++++++++++++++++++++++++++
 src/SipChannelServiceApp.cpp           |   22 +++---
 8 files changed, 199 insertions(+), 22 deletions(-)
 create mode 100644 src/ProxyWrapper.cpp
 create mode 100644 src/ProxyWrapper.h


- Log -----------------------------------------------------------------
commit faaece515a3fe152bedc86bd9473f3e2015d6f13
Merge: 53c9d86 0033e7a
Author: Mark Michelson <mmichelson at digium.com>
Date:   Mon Oct 18 08:45:24 2010 -0500

    Merge branch 'master' into hiphop

diff --cc src/CMakeLists.txt
index 4565229,5b77b71..ea86332
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@@ -73,16 -73,15 +73,16 @@@ asterisk_scf_component_add_slice(SipSta
  #code from the SIP component. This statement is not the most
  #permanent of changes and assumes the directories are
  #structured in the way that gitall structures them.
 -include_directories(../../statereplicator/src)
 +include_directories(${utils_dir}/StateReplicator/src)
 +include_directories(${utils_dir}/ProxyWrapper/src)
  
- hydra_component_add_file(SipStateReplicator SipStateReplicatorApp.cpp)
- hydra_component_add_file(SipStateReplicator SipStateReplicator.h)
- #hydra_component_add_file(SipStateReplicator SipStateReplicator.cpp)
+ asterisk_scf_component_add_file(SipStateReplicator SipStateReplicatorApp.cpp)
+ asterisk_scf_component_add_file(SipStateReplicator SipStateReplicator.h)
+ #asterisk_scf_component_add_file(SipStateReplicator SipStateReplicator.cpp)
  
- hydra_component_add_ice_libraries(SipStateReplicator IceStorm)
+ asterisk_scf_component_add_ice_libraries(SipStateReplicator IceStorm)
  
- hydra_component_build_icebox(SipStateReplicator)
+ asterisk_scf_component_build_icebox(SipStateReplicator)
  target_link_libraries(SipStateReplicator logging-client)
  
- #hydra_component_install(SipStateReplicator RUNTIME bin "Sip State Replicator" SipStateReplicator)
+ #asterisk_scf_component_install(SipStateReplicator RUNTIME bin "Sip State Replicator" SipStateReplicator)

commit 53c9d86dd0d9c453a3d964ce5e3b267db149fb93
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Oct 14 18:12:28 2010 -0500

    Make changes to use the ice-util-c++ stuff.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bccb165..4565229 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -16,8 +16,6 @@ hydra_component_add_slice(SipChannelService ReplicaIf)
 hydra_component_add_slice(SipChannelService SipIf)
 
 hydra_component_add_file(SipChannelService SipChannelServiceApp.cpp)
-hydra_component_add_file(SipChannelService ProxyWrapper.cpp)
-hydra_component_add_file(SipChannelService ProxyWrapper.h)
 hydra_component_add_file(SipChannelService SipChannelServiceEventPublisher.cpp)
 hydra_component_add_file(SipChannelService SipChannelServiceEventPublisher.h)
 hydra_component_add_file(SipChannelService SipChannelServiceEndpointLocator.cpp)
@@ -75,7 +73,8 @@ hydra_component_add_slice(SipStateReplicator MediaRTPIf)
 #code from the SIP component. This statement is not the most
 #permanent of changes and assumes the directories are
 #structured in the way that gitall structures them.
-include_directories(../../statereplicator/src)
+include_directories(${utils_dir}/StateReplicator/src)
+include_directories(${utils_dir}/ProxyWrapper/src)
 
 hydra_component_add_file(SipStateReplicator SipStateReplicatorApp.cpp)
 hydra_component_add_file(SipStateReplicator SipStateReplicator.h)

commit 82f9b3bb6bd11f9c85f0547e4e4cf5389957b12f
Merge: 667705c 62d6bb3
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Oct 14 18:11:55 2010 -0500

    Merge branch 'master' of git.asterisk.org:asterisk-scf/integration/sip into hiphop
    
    Conflicts:
    	src/SipChannelServiceApp.cpp

diff --cc src/SipChannelServiceApp.cpp
index 611bbbe,6a831bc..1f79e0d
--- a/src/SipChannelServiceApp.cpp
+++ b/src/SipChannelServiceApp.cpp
@@@ -359,15 -360,8 +360,8 @@@ void SipChannelService::locateStateRepl
  
     try
     {
 -      Ice::ObjectPrx objectPrx = mServiceLocator->locate(replicatorParams);
 -      mStateReplicator = SIP::V1::SipStateReplicatorPrx::checkedCast(objectPrx);
 +      ProxyWrapper<SipStateReplicatorPrx> pw(mServiceLocator, replicatorParams);
 +      mStateReplicator = pw;
- 
-       // Are we a listener?
-       if (mCommunicator->getProperties()->getPropertyWithDefault("Sip.StateReplicatorListener", "no") == "yes")
-       {
-          mStateReplicator->addListener(mReplicatorListenerProxy);
-          mReplicaService->standby();
-       }
     }
     catch (...)
     {

commit 667705c067cdc9d5e60d62382261b8254f3795c6
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Oct 14 14:31:56 2010 -0500

    Add comment explaining the class and detailing some ideas for future
    improvements.

diff --git a/src/ProxyWrapper.h b/src/ProxyWrapper.h
index d4bff96..6bc7e0c 100644
--- a/src/ProxyWrapper.h
+++ b/src/ProxyWrapper.h
@@ -20,6 +20,29 @@ namespace SipChannelService
 /**
  * A wrapper for an Ice Proxy.
  * The Template parameter P is the proxy we're wrapping
+ *
+ * The main feature of using a proxy wrapper at this stage is that
+ * it provides the ability to detect if we could find a given proxy
+ * at initialization. If we did not, then the first time we try to
+ * invoke a proxy operation, then we will attempt to acquire a proxy
+ * a second time via the service locator.
+ *
+ * An improvement that would be nice would be to make the recovery
+ * more general purpose. There are a couple of ways to try this.
+ *
+ * 1. Always ice_ping as the first operation of the -> operator
+ * overload. This way we can be sure that the servant we are trying
+ * to talk to is still reachable. If it's not, then we may be able to
+ * ask the service locator for a new proxy and proceed. The advantage 
+ * to this method is that we only ping proxies when we need them. The
+ * disadvantage is that we add an extra RPC for each proxy operation.
+ *
+ * 2. Have a background thread that periodically ice_pings all wrapped
+ * proxies. This thread can be responsible for alerting a proxy wrapper
+ * to try to get a new proxy if one is unreachable. The advantage here is
+ * that for RPC-heavy operations, we're not doubling the amount of RPCs
+ * by pinging every time. The disadvantage is that we could be needlessly
+ * pinging servants for essentially dormant services.
  */
 template <class P>
 class ProxyWrapper
@@ -108,7 +131,7 @@ private:
 			return true;
 		}
 
-		// Try again to initialize. 
+		// Try again to initialize.
 		initialize();
 		return mInitialized;
 	}

commit e1939555cd28ea8a983577e93b706fcf6fb4d74d
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Oct 14 11:49:00 2010 -0500

    Remove unneeded forward declaration of nonexistent class.

diff --git a/src/ProxyWrapper.h b/src/ProxyWrapper.h
index 7f5b5d1..d4bff96 100644
--- a/src/ProxyWrapper.h
+++ b/src/ProxyWrapper.h
@@ -16,8 +16,6 @@ namespace AsteriskSCF
 {
 namespace SipChannelService
 {
-template<class P>
-class ProxyWrapperPriv;
 
 /**
  * A wrapper for an Ice Proxy.

commit ab018f2970ce0d2ab2d84ff428fd4e9dbf43c773
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Oct 14 10:34:58 2010 -0500

    Fix up spacing issues.

diff --git a/src/ProxyWrapper.h b/src/ProxyWrapper.h
index 828724e..7f5b5d1 100644
--- a/src/ProxyWrapper.h
+++ b/src/ProxyWrapper.h
@@ -27,108 +27,106 @@ template <class P>
 class ProxyWrapper
 {
 public:
-   
-   ProxyWrapper() : mServiceLocator(0), mLocatorParams(0), mInitialized(false) {}
-
-   ProxyWrapper(const ProxyWrapper &pw)
-   {
-      copy(pw);
-   }
-
-   ProxyWrapper(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& locator,
-         AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr params)
-      :  mServiceLocator(locator), mLocatorParams(params), mInitialized(false)
-   {
-      initialize();
-   }
-
-   P& operator->()
-   {
-      assert(mServiceLocator && mLocatorParams);
-
-      if (!verifyInitialized())
-      {
-         throw "No access to Proxy";
-      }
-
-      return mProxy;
-   }
-
-   ProxyWrapper operator=(const ProxyWrapper &pw)
-   {
-      // Boo to self-assignment
-      if (this == &pw)
-	  {
-	     return *this;
-	  }
-      copy(pw);
-      return *this;
-   }
-
-   operator void*() const
-   {
-      return mProxy ? (void *)1 : 0;
-   }
-
-   bool isInitialized()
-   {
-      return mInitialized;
-   }
+	ProxyWrapper() : mServiceLocator(0), mLocatorParams(0), mInitialized(false) {}
+
+	ProxyWrapper(const ProxyWrapper &pw)
+	{
+		copy(pw);
+	}
+
+	ProxyWrapper(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& locator,
+			AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr params)
+			:  mServiceLocator(locator), mLocatorParams(params), mInitialized(false)
+	{
+		initialize();
+	}
+
+	P& operator->()
+	{
+		assert(mServiceLocator && mLocatorParams);
+		
+		if (!verifyInitialized())
+		{
+			throw "No access to Proxy";
+		}
+
+		return mProxy;
+	}
+	
+	ProxyWrapper operator=(const ProxyWrapper &pw)
+	{
+		// Boo to self-assignment
+		if (this == &pw)
+		{
+			return *this;
+		}
+		copy(pw);
+		return *this;
+	}
+	
+	operator void*() const
+	{
+		return mProxy ? (void *)1 : 0;
+	}
+	
+	bool isInitialized()
+	{
+		return mInitialized;
+	}
 
 private:
-   /**
-    * Initialization. Primarily involves acquring access to specific IceStorm topic. 
-    */
-   void initialize()
-   {
-      try
-      {
-         // Use the locator to find the Proxy
-         Ice::ObjectPrx bridgeManagerObject = mServiceLocator->locate(mLocatorParams);
-         mProxy = P::checkedCast(bridgeManagerObject);
-      }
-      catch (const Ice::Exception &e)
-      {
-         std::cout << "Exception locating " << mLocatorParams->category << ": " << e.what() << std::endl; 
-         return;
-      }
-
-      if (mProxy == 0)
-      {
-         std::cout << "Unable to locate " << mLocatorParams->category << std::endl;
-      }
-
-      mInitialized = true;
-   }
-
-   /**
-    * Utiltity to check for initialization state. 
-    */
-   bool verifyInitialized()
-   {
-      if (mInitialized)
-      {
-         return true;
-      }
-
-      // Try again to initialize. 
-      initialize();
-
-      return mInitialized;
-   }
-
-   void copy(const ProxyWrapper &pw)
-   {
-      mServiceLocator = pw.mServiceLocator;
-      mLocatorParams = pw.mLocatorParams;
-      mProxy = pw.mProxy;
-      mInitialized = pw.mInitialized;
-   }
-
-   P mProxy;
-   AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
-   AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr mLocatorParams;
-   bool mInitialized;
+	/**
+	 * Initialization. Primarily involves acquring access to specific IceStorm topic. 
+	 */
+	void initialize()
+	{
+		try
+		{
+			// Use the locator to find the Proxy
+			Ice::ObjectPrx bridgeManagerObject = mServiceLocator->locate(mLocatorParams);
+			mProxy = P::checkedCast(bridgeManagerObject);
+		}
+		catch (const Ice::Exception &e)
+		{
+			std::cout << "Exception locating " << mLocatorParams->category << ": " << e.what() << std::endl; 
+			return;
+		}
+
+		if (mProxy == 0)
+		{
+			std::cout << "Unable to locate " << mLocatorParams->category << std::endl;
+		}
+
+		mInitialized = true;
+	}
+
+	/**
+	 * Utiltity to check for initialization state. 
+	 */
+	bool verifyInitialized()
+	{
+		if (mInitialized)
+		{
+			return true;
+		}
+
+		// Try again to initialize. 
+		initialize();
+		return mInitialized;
+	}
+
+	void copy(const ProxyWrapper &pw)
+	{
+		mServiceLocator = pw.mServiceLocator;
+		mLocatorParams = pw.mLocatorParams;
+		mProxy = pw.mProxy;
+		mInitialized = pw.mInitialized;
+	}
+
+	P mProxy;
+	AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
+	AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr mLocatorParams;
+	bool mInitialized;
 };
 
 }; // end SipChannelService

commit 8d239079a95dc61b81ab7d5086effbb9e963128b
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Oct 14 10:23:51 2010 -0500

    Add some safeguards into the ProxyWrapper class.
    
    * Short-circuit the self-assignment case. It's actually not a huge
      deal at the moment if someone had tried self-assignment, but this
      saves some potential future headaches as this class grows.
    
    * Assert that we have a service locator and service locator params
      in places that depend on their presence. This likely would have
      been caught as exceptions within the verifyInitialized() method,
      but absence of these items indicates a programming error and not
      an uncontrollable external circumstance.

diff --git a/src/ProxyWrapper.h b/src/ProxyWrapper.h
index 746b198..828724e 100644
--- a/src/ProxyWrapper.h
+++ b/src/ProxyWrapper.h
@@ -44,6 +44,8 @@ public:
 
    P& operator->()
    {
+      assert(mServiceLocator && mLocatorParams);
+
       if (!verifyInitialized())
       {
          throw "No access to Proxy";
@@ -54,6 +56,11 @@ public:
 
    ProxyWrapper operator=(const ProxyWrapper &pw)
    {
+      // Boo to self-assignment
+      if (this == &pw)
+	  {
+	     return *this;
+	  }
       copy(pw);
       return *this;
    }

commit e2569300dfffe470d54233c8489616e4dabcbb10
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Oct 13 17:39:35 2010 -0500

    Use ProxyWrapper for the state replicator proxy.

diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 9700b86..fc614a9 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -66,7 +66,7 @@ void PJSipManager::registerSessionModule(pjsip_endpoint *endpt,
    boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
    ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
    AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
-   AsteriskSCF::SIP::V1::SipStateReplicatorPrx stateReplicator,
+   ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
    AsteriskSCF::System::Component::V1::ReplicaPtr replica
    )
 {
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index 0e10b73..b2e27c8 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -62,7 +62,7 @@ public:
 		boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
 		ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
 		AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
-		AsteriskSCF::SIP::V1::SipStateReplicatorPrx stateReplicator,
+		ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
 		AsteriskSCF::System::Component::V1::ReplicaPtr replica
 	);
 
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index c9e95c7..13feb8b 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -47,7 +47,7 @@ public:
 	PJSipSessionModule(pjsip_endpoint *endpt, boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
 		ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
 		AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
-		AsteriskSCF::SIP::V1::SipStateReplicatorPrx stateReplicator,
+		ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
 		AsteriskSCF::System::Component::V1::ReplicaPtr replica);
 	pj_status_t load(pjsip_endpoint *endpoint);
 	pj_status_t start();
@@ -79,7 +79,7 @@ private:
 	boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
 	ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> mSessionRouter;
 	AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
-	AsteriskSCF::SIP::V1::SipStateReplicatorPrx mStateReplicator;
+	ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> mStateReplicator;
 	AsteriskSCF::System::Component::V1::ReplicaPtr mReplica;
 };
 
diff --git a/src/PJSipSessionModuleConstruction.cpp b/src/PJSipSessionModuleConstruction.cpp
index 85ed440..701e2b8 100644
--- a/src/PJSipSessionModuleConstruction.cpp
+++ b/src/PJSipSessionModuleConstruction.cpp
@@ -85,7 +85,7 @@ PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
 		boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
 		ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
 		AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
-		AsteriskSCF::SIP::V1::SipStateReplicatorPrx stateReplicator,
+		ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
 		AsteriskSCF::System::Component::V1::ReplicaPtr replica)
 	: mName("Session Module"), mEndpointFactory(endpointFactoryPtr),
 	  mSessionRouter(sessionRouter), mServiceLocator(serviceLocator),
diff --git a/src/ProxyWrapper.h b/src/ProxyWrapper.h
index 363acda..746b198 100644
--- a/src/ProxyWrapper.h
+++ b/src/ProxyWrapper.h
@@ -58,6 +58,11 @@ public:
       return *this;
    }
 
+   operator void*() const
+   {
+      return mProxy ? (void *)1 : 0;
+   }
+
    bool isInitialized()
    {
       return mInitialized;
diff --git a/src/SipChannelServiceApp.cpp b/src/SipChannelServiceApp.cpp
index 84783d7..611bbbe 100644
--- a/src/SipChannelServiceApp.cpp
+++ b/src/SipChannelServiceApp.cpp
@@ -105,7 +105,7 @@ private:
    SipStateReplicatorListenerPrx mReplicatorListenerProxy;
    boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
    ServiceLocatorPrx mServiceLocator;
-   SipStateReplicatorPrx mStateReplicator;
+   ProxyWrapper<SipStateReplicatorPrx> mStateReplicator;
    ProxyWrapper<SessionRouterPrx> mSessionRouter;
    ProxyWrapper<LocatorRegistryPrx> mRoutingServiceLocatorRegistry;
    boost::shared_ptr<SipChannelServiceEventPublisher> mEventPublisher;
@@ -359,8 +359,8 @@ void SipChannelService::locateStateReplicator()
 
    try
    {
-      Ice::ObjectPrx objectPrx = mServiceLocator->locate(replicatorParams);
-      mStateReplicator = SIP::V1::SipStateReplicatorPrx::checkedCast(objectPrx);
+      ProxyWrapper<SipStateReplicatorPrx> pw(mServiceLocator, replicatorParams);
+      mStateReplicator = pw;
 
       // Are we a listener?
       if (mCommunicator->getProperties()->getPropertyWithDefault("Sip.StateReplicatorListener", "no") == "yes")

commit 4c8146f1979db9d9ce5cba49d68e929bcc2f6725
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Oct 13 16:49:17 2010 -0500

    Use the proxy wrapper for the session router.

diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index f6d02b6..9700b86 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -64,7 +64,7 @@ PJSipManager::PJSipManager(Ice::PropertiesPtr props)
 
 void PJSipManager::registerSessionModule(pjsip_endpoint *endpt,
    boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
-   AsteriskSCF::SessionCommunications::V1::SessionRouterPrx sessionRouter,
+   ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
    AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
    AsteriskSCF::SIP::V1::SipStateReplicatorPrx stateReplicator,
    AsteriskSCF::System::Component::V1::ReplicaPtr replica
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index 15c27cf..0e10b73 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -18,6 +18,7 @@
 #include <boost/shared_ptr.hpp>
 #include "PJSipSessionModule.h"
 #include "PJSipLoggingModule.h"
+#include "ProxyWrapper.h"
 
 namespace AsteriskSCF
 {
@@ -59,7 +60,7 @@ public:
 	 */
 	void registerSessionModule(pjsip_endpoint *endpt,
 		boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
-		AsteriskSCF::SessionCommunications::V1::SessionRouterPrx sessionRouter,
+		ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
 		AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
 		AsteriskSCF::SIP::V1::SipStateReplicatorPrx stateReplicator,
 		AsteriskSCF::System::Component::V1::ReplicaPtr replica
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index 0c4a97a..c9e95c7 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -16,6 +16,7 @@
 #include "SipSession.h"
 #include "PJSipModule.h"
 #include "ReplicaIf.h"
+#include "ProxyWrapper.h"
 
 namespace AsteriskSCF
 {
@@ -44,7 +45,7 @@ class PJSipSessionModule : public PJSipModule
 {
 public:
 	PJSipSessionModule(pjsip_endpoint *endpt, boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
-		AsteriskSCF::SessionCommunications::V1::SessionRouterPrx sessionRouter,
+		ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
 		AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
 		AsteriskSCF::SIP::V1::SipStateReplicatorPrx stateReplicator,
 		AsteriskSCF::System::Component::V1::ReplicaPtr replica);
@@ -76,7 +77,7 @@ private:
 	pjsip_ua_init_param mUaParam;
 	const std::string mName;
 	boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
-	AsteriskSCF::SessionCommunications::V1::SessionRouterPrx mSessionRouter;
+	ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> mSessionRouter;
 	AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
 	AsteriskSCF::SIP::V1::SipStateReplicatorPrx mStateReplicator;
 	AsteriskSCF::System::Component::V1::ReplicaPtr mReplica;
diff --git a/src/PJSipSessionModuleConstruction.cpp b/src/PJSipSessionModuleConstruction.cpp
index d1c8eb3..85ed440 100644
--- a/src/PJSipSessionModuleConstruction.cpp
+++ b/src/PJSipSessionModuleConstruction.cpp
@@ -83,7 +83,7 @@ static pjsip_dialog *uaOnDialogForked(pjsip_dialog *first_set, pjsip_rx_data *rd
 
 PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
 		boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
-		AsteriskSCF::SessionCommunications::V1::SessionRouterPrx sessionRouter,
+		ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
 		AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
 		AsteriskSCF::SIP::V1::SipStateReplicatorPrx stateReplicator,
 		AsteriskSCF::System::Component::V1::ReplicaPtr replica)
diff --git a/src/ProxyWrapper.h b/src/ProxyWrapper.h
index f1a16e7..363acda 100644
--- a/src/ProxyWrapper.h
+++ b/src/ProxyWrapper.h
@@ -30,6 +30,11 @@ public:
    
    ProxyWrapper() : mServiceLocator(0), mLocatorParams(0), mInitialized(false) {}
 
+   ProxyWrapper(const ProxyWrapper &pw)
+   {
+      copy(pw);
+   }
+
    ProxyWrapper(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& locator,
          AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr params)
       :  mServiceLocator(locator), mLocatorParams(params), mInitialized(false)
@@ -47,12 +52,9 @@ public:
       return mProxy;
    }
 
-   ProxyWrapper operator=(ProxyWrapper &pw)
+   ProxyWrapper operator=(const ProxyWrapper &pw)
    {
-      mServiceLocator = pw.mServiceLocator;
-      mLocatorParams = pw.mLocatorParams;
-      mProxy = pw.mProxy;
-      mInitialized = pw.mInitialized;
+      copy(pw);
       return *this;
    }
 
@@ -103,6 +105,14 @@ private:
       return mInitialized;
    }
 
+   void copy(const ProxyWrapper &pw)
+   {
+      mServiceLocator = pw.mServiceLocator;
+      mLocatorParams = pw.mLocatorParams;
+      mProxy = pw.mProxy;
+      mInitialized = pw.mInitialized;
+   }
+
    P mProxy;
    AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
    AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr mLocatorParams;
diff --git a/src/SipChannelServiceApp.cpp b/src/SipChannelServiceApp.cpp
index 5c58eb1..84783d7 100644
--- a/src/SipChannelServiceApp.cpp
+++ b/src/SipChannelServiceApp.cpp
@@ -39,7 +39,7 @@ using namespace AsteriskSCF::Core::Routing::V1;
 using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::System::Component::V1;
 using namespace AsteriskSCF::System::Logging;
-using namespace AsteriskSCF::SessionCommunications;
+using namespace AsteriskSCF::SessionCommunications::V1;
 
 namespace
 {
@@ -106,9 +106,8 @@ private:
    boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
    ServiceLocatorPrx mServiceLocator;
    SipStateReplicatorPrx mStateReplicator;
-   AsteriskSCF::SessionCommunications::V1::SessionRouterPrx mSessionRouter;
+   ProxyWrapper<SessionRouterPrx> mSessionRouter;
    ProxyWrapper<LocatorRegistryPrx> mRoutingServiceLocatorRegistry;
-   Bridging::V1::BridgeManagerPrx mBridgeManager;
    boost::shared_ptr<SipChannelServiceEventPublisher> mEventPublisher;
    Routing::V1::EndpointLocatorPtr mEndpointLocator;
 };
@@ -390,8 +389,8 @@ void SipChannelService::locateSessionRouter()
    ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
    genericparams->category = Routing::V1::SessionRouterDiscoveryCategory;
 
-   Ice::ObjectPrx objectPrx = mServiceLocator->locate(genericparams);
-   mSessionRouter = AsteriskSCF::SessionCommunications::V1::SessionRouterPrx::checkedCast(objectPrx);
+   ProxyWrapper<SessionRouterPrx> pw(mServiceLocator, genericparams);
+   mSessionRouter = pw;
 }
 
 /**

commit 7328f734fbdcab017d4efd3b1566539f40b5edfe
Merge: 3aa33a7 fa9a1e0
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Oct 13 16:28:08 2010 -0500

    Merge branch 'master' into hiphop
    
    Conflicts:
    	src/SipChannelServiceApp.cpp


commit 3aa33a7e9517fb5040f1298e2b0d0b15b20414f6
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Oct 13 16:09:22 2010 -0500

    Change from using a pointer to a ProxyWrapper to just using it itself.

diff --git a/src/ProxyWrapper.h b/src/ProxyWrapper.h
index b383c17..f1a16e7 100644
--- a/src/ProxyWrapper.h
+++ b/src/ProxyWrapper.h
@@ -27,6 +27,9 @@ template <class P>
 class ProxyWrapper
 {
 public:
+   
+   ProxyWrapper() : mServiceLocator(0), mLocatorParams(0), mInitialized(false) {}
+
    ProxyWrapper(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& locator,
          AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr params)
       :  mServiceLocator(locator), mLocatorParams(params), mInitialized(false)
@@ -44,6 +47,15 @@ public:
       return mProxy;
    }
 
+   ProxyWrapper operator=(ProxyWrapper &pw)
+   {
+      mServiceLocator = pw.mServiceLocator;
+      mLocatorParams = pw.mLocatorParams;
+      mProxy = pw.mProxy;
+      mInitialized = pw.mInitialized;
+      return *this;
+   }
+
    bool isInitialized()
    {
       return mInitialized;
diff --git a/src/SipChannelServiceApp.cpp b/src/SipChannelServiceApp.cpp
index 5b74dd7..27803ba 100644
--- a/src/SipChannelServiceApp.cpp
+++ b/src/SipChannelServiceApp.cpp
@@ -109,7 +109,7 @@ private:
    ServiceLocatorPrx mServiceLocator;
    SipStateReplicatorPrx mStateReplicator;
    AsteriskSCF::SessionCommunications::V1::SessionRouterPrx mSessionRouter;
-   ProxyWrapper<LocatorRegistryPrx> *mRoutingServiceLocatorRegistry;
+   ProxyWrapper<LocatorRegistryPrx> mRoutingServiceLocatorRegistry;
    Bridging::V1::BridgeManagerPrx mBridgeManager;
    boost::shared_ptr<SipChannelServiceEventPublisher> mEventPublisher;
    Routing::V1::EndpointLocatorPtr mEndpointLocator;
@@ -320,7 +320,7 @@ void SipChannelService::registerWithRoutingService()
    mEndpointFactory->generateRoutingDestinations(destinations);
 
    EndpointLocatorPrx locator = EndpointLocatorPrx::uncheckedCast(mGlobalAdapter->createDirectProxy(mCommunicator->stringToIdentity(EndpointLocatorObjectId)));
-   (*mRoutingServiceLocatorRegistry)->addEndpointLocator("pjsip", destinations, locator);
+   mRoutingServiceLocatorRegistry->addEndpointLocator("pjsip", destinations, locator);
 }
 
 /**
@@ -328,7 +328,7 @@ void SipChannelService::registerWithRoutingService()
  */
 void SipChannelService::deregisterFromRoutingService()
 {
-   (*mRoutingServiceLocatorRegistry)->removeEndpointLocator("pjsip");
+   mRoutingServiceLocatorRegistry->removeEndpointLocator("pjsip");
 }
 
 /**
@@ -345,7 +345,8 @@ void SipChannelService::locateRoutingService()
    ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
    genericparams->category = Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory;
 
-   mRoutingServiceLocatorRegistry = new ProxyWrapper<Routing::V1::LocatorRegistryPrx>(mServiceLocator, genericparams);
+   ProxyWrapper<LocatorRegistryPrx> pw(mServiceLocator, genericparams);
+   mRoutingServiceLocatorRegistry = pw;
 }
 
 void SipChannelService::locateStateReplicator()

commit dc271816bc72243938f975a3f638ba9daf042ee3
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Oct 13 13:53:07 2010 -0500

    First use of a ProxyWrapper in code. It works!

diff --git a/src/SipChannelServiceApp.cpp b/src/SipChannelServiceApp.cpp
index 7f160a5..5b74dd7 100644
--- a/src/SipChannelServiceApp.cpp
+++ b/src/SipChannelServiceApp.cpp
@@ -31,6 +31,7 @@
 #include "PJSipManager.h"
 #include "SipSession.h"
 #include "SipStateReplicator.h"
+#include "ProxyWrapper.h"
 
 using namespace std;
 using namespace AsteriskSCF::SipChannelService;
@@ -108,7 +109,7 @@ private:
    ServiceLocatorPrx mServiceLocator;
    SipStateReplicatorPrx mStateReplicator;
    AsteriskSCF::SessionCommunications::V1::SessionRouterPrx mSessionRouter;
-   Routing::V1::LocatorRegistryPrx mRoutingServiceLocatorRegistry;
+   ProxyWrapper<LocatorRegistryPrx> *mRoutingServiceLocatorRegistry;
    Bridging::V1::BridgeManagerPrx mBridgeManager;
    boost::shared_ptr<SipChannelServiceEventPublisher> mEventPublisher;
    Routing::V1::EndpointLocatorPtr mEndpointLocator;
@@ -319,7 +320,7 @@ void SipChannelService::registerWithRoutingService()
    mEndpointFactory->generateRoutingDestinations(destinations);
 
    EndpointLocatorPrx locator = EndpointLocatorPrx::uncheckedCast(mGlobalAdapter->createDirectProxy(mCommunicator->stringToIdentity(EndpointLocatorObjectId)));
-   mRoutingServiceLocatorRegistry->addEndpointLocator("pjsip", destinations, locator);
+   (*mRoutingServiceLocatorRegistry)->addEndpointLocator("pjsip", destinations, locator);
 }
 
 /**
@@ -327,7 +328,7 @@ void SipChannelService::registerWithRoutingService()
  */
 void SipChannelService::deregisterFromRoutingService()
 {
-   mRoutingServiceLocatorRegistry->removeEndpointLocator("pjsip");
+   (*mRoutingServiceLocatorRegistry)->removeEndpointLocator("pjsip");
 }
 
 /**
@@ -344,9 +345,7 @@ void SipChannelService::locateRoutingService()
    ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
    genericparams->category = Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory;
 
-   Ice::ObjectPrx objectPrx = mServiceLocator->locate(genericparams);
-   mRoutingServiceLocatorRegistry = Routing::V1::LocatorRegistryPrx::checkedCast(objectPrx);
-
+   mRoutingServiceLocatorRegistry = new ProxyWrapper<Routing::V1::LocatorRegistryPrx>(mServiceLocator, genericparams);
 }
 
 void SipChannelService::locateStateReplicator()

commit 274a899619560fa09942d703e60669c88734c722
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Oct 13 13:52:17 2010 -0500

    Move all logic from ProxyWrapper.cpp to ProxyWrapper.h because templates make Bambi cry.

diff --git a/src/ProxyWrapper.cpp b/src/ProxyWrapper.cpp
index 1517e37..df206ad 100644
--- a/src/ProxyWrapper.cpp
+++ b/src/ProxyWrapper.cpp
@@ -5,118 +5,16 @@
  *
  * All rights reserved.
  */
-#include <Ice/Ice.h>
-#include <IceStorm/IceStorm.h>
 
-#include "Core/Discovery/ServiceLocatorIf.h"
 #include "ProxyWrapper.h"
 
-using namespace ::std;
-using namespace AsteriskSCF::Core::Discovery::V1;
-
 namespace AsteriskSCF
 {
 namespace SipChannelService
 {
-
-/**
- * The private implementation of ProxyWrapper. 
+ /*
+ * This .cpp is a temporary solution to get a CMakeProject that consists only of header files. 
  */
-template <class P>
-class ProxyWrapperPriv
-{
-public:
-   ProxyWrapperPriv(const ServiceLocatorPrx& locator, ServiceLocatorParamsPtr params)
-      :  mServiceLocator(locator), mLocatorParams(params), mInitialized(false)
-   {
-      initialize();
-   }
-
-   /**
-    * Initialization. Primarily involves acquring access to specific IceStorm topic. 
-    */
-   void initialize()
-   {
-      try
-      {
-         // Use the locator to find the Proxy
-         Ice::ObjectPrx bridgeManagerObject = mServiceLocator->locate(mLocatorParams);
-         mProxy = P::checkedCast(bridgeManagerObject);
-      }
-      catch (const Ice::Exception &e)
-      {
-         cout << "Exception locating " << mLocatorParams->category << ": " << e.what() << endl; 
-         return;
-      }
-
-      if (mProxy == 0)
-      {
-         cout << "Unable to locate " << mLocatorParams->category << endl;
-      }
-
-      mInitialized = true;
-   }
 
-   /**
-    * Utiltity to check for initialization state. 
-    */
-   bool verifyInitialized()
-   {
-      if (mInitialized)
-      {
-         return true;
-      }
-
-      // Try again to initialize. 
-      initialize();
-
-      return mInitialized;
-   }
-
-   bool isInitialized()
-   {
-      return mInitialized;
-   }
-
-public:
-   P mProxy;
-
-private:
-   ServiceLocatorPrx mServiceLocator;
-   ServiceLocatorParamsPtr mLocatorParams;
-   bool mInitialized;
 };
-
-/**
- * Class constructor. 
- */
-template <class P>
-ProxyWrapper<P>::ProxyWrapper(const ServiceLocatorPrx& locator, ServiceLocatorParamsPtr params) 
-      : mImpl(new ProxyWrapperPriv<P>(locator, params))
-{
-}
-
-/**
- * Provide acess to the actual proxy.
- */
-template <class P>
-const P& ProxyWrapper<P>::operator->() const
-{
-   if (!mImpl->verifyInitialized())
-   {
-      throw "No access to Proxy";
-   }
-
-   return mImpl->mProxy;
-}
-
-template <class P>
-bool ProxyWrapper<P>::isInitialized()
-{
-   return mImpl->isInitialized();
-}
-
-
-}; // end SipChannelService
-}; // end AsteriskSCF
-
+};
diff --git a/src/ProxyWrapper.h b/src/ProxyWrapper.h
index 514cf1e..b383c17 100644
--- a/src/ProxyWrapper.h
+++ b/src/ProxyWrapper.h
@@ -28,16 +28,74 @@ class ProxyWrapper
 {
 public:
    ProxyWrapper(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& locator,
-         AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr params);
+         AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr params)
+      :  mServiceLocator(locator), mLocatorParams(params), mInitialized(false)
+   {
+      initialize();
+   }
 
-   const P& operator->() const ;
-   bool isInitialized();
+   P& operator->()
+   {
+      if (!verifyInitialized())
+      {
+         throw "No access to Proxy";
+      }
+
+      return mProxy;
+   }
+
+   bool isInitialized()
+   {
+      return mInitialized;
+   }
 
 private:
-   boost::shared_ptr<ProxyWrapperPriv<P> > mImpl; // pimpl idiom applied. 
-};
+   /**
+    * Initialization. Primarily involves acquring access to specific IceStorm topic. 
+    */
+   void initialize()
+   {
+      try
+      {
+         // Use the locator to find the Proxy
+         Ice::ObjectPrx bridgeManagerObject = mServiceLocator->locate(mLocatorParams);
+         mProxy = P::checkedCast(bridgeManagerObject);
+      }
+      catch (const Ice::Exception &e)
+      {
+         std::cout << "Exception locating " << mLocatorParams->category << ": " << e.what() << std::endl; 
+         return;
+      }
+
+      if (mProxy == 0)
+      {
+         std::cout << "Unable to locate " << mLocatorParams->category << std::endl;
+      }
+
+      mInitialized = true;
+   }
 
-typedef boost::shared_ptr<ProxyWrapper> ProxyWrapperPtr;
+   /**
+    * Utiltity to check for initialization state. 
+    */
+   bool verifyInitialized()
+   {
+      if (mInitialized)
+      {
+         return true;
+      }
+
+      // Try again to initialize. 
+      initialize();
+
+      return mInitialized;
+   }
+
+   P mProxy;
+   AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
+   AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr mLocatorParams;
+   bool mInitialized;
+};
 
 }; // end SipChannelService
 }; // end AsteriskSCF

commit 5b3c6bf967f37f6fc638d598208365b62b22aa1d
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Oct 13 10:50:41 2010 -0500

    Fix incorrect namespace on proxy wrapper.

diff --git a/src/ProxyWrapper.cpp b/src/ProxyWrapper.cpp
index d8fa2a3..1517e37 100644
--- a/src/ProxyWrapper.cpp
+++ b/src/ProxyWrapper.cpp
@@ -16,7 +16,7 @@ using namespace AsteriskSCF::Core::Discovery::V1;
 
 namespace AsteriskSCF
 {
-namespace BasicRoutingService
+namespace SipChannelService
 {
 
 /**
@@ -117,6 +117,6 @@ bool ProxyWrapper<P>::isInitialized()
 }
 
 
-}; // end BasicRoutingService
+}; // end SipChannelService
 }; // end AsteriskSCF
 
diff --git a/src/ProxyWrapper.h b/src/ProxyWrapper.h
index cb24825..514cf1e 100644
--- a/src/ProxyWrapper.h
+++ b/src/ProxyWrapper.h
@@ -14,7 +14,7 @@
 
 namespace AsteriskSCF
 {
-namespace BasicRoutingService
+namespace SipChannelService
 {
 template<class P>
 class ProxyWrapperPriv;
@@ -39,5 +39,5 @@ private:
 
 typedef boost::shared_ptr<ProxyWrapper> ProxyWrapperPtr;
 
-}; // end BasicRoutingService
+}; // end SipChannelService
 }; // end AsteriskSCF

commit 0d15966ba2f8d073cd23f737fc92a483efbba6e8
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Oct 12 17:39:14 2010 -0500

    Create a simple proxy wrapper.
    
    This will help facilitate some robustness. If we don't initially get
    a proxy to things such as a state replicator or a routing service,
    it's not a biggie because when the time comes to get one of them, we'll
    just try to get one again automatically. It's not fool- or idiot-proof,
    but it's better than what's there currently.
    
    For now, this is being developed solely in the sip repo, but it would
    probably make a great deal of sense to move this into either its own
    repo or some other Ice utility repo later so that all Asterisk SCF
    components can use what's here.
    
    Also, this is pretty rudimentary for now. I haven't actually attempted
    using this, and that will be seen in my next set of changes. There will
    likely be a template specialization for service locator proxies, or perhaps
    some other sort of something-or-other for it.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 891d062..2b53311 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -17,6 +17,8 @@ hydra_component_add_slice(SipChannelService ReplicaIf)
 hydra_component_add_slice(SipChannelService SipIf)
 
 hydra_component_add_file(SipChannelService SipChannelServiceApp.cpp)
+hydra_component_add_file(SipChannelService ProxyWrapper.cpp)
+hydra_component_add_file(SipChannelService ProxyWrapper.h)
 hydra_component_add_file(SipChannelService SipChannelServiceEventPublisher.cpp)
 hydra_component_add_file(SipChannelService SipChannelServiceEventPublisher.h)
 hydra_component_add_file(SipChannelService SipChannelServiceEndpointLocator.cpp)
diff --git a/src/ProxyWrapper.cpp b/src/ProxyWrapper.cpp
new file mode 100644
index 0000000..d8fa2a3
--- /dev/null
+++ b/src/ProxyWrapper.cpp
@@ -0,0 +1,122 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+#include <Ice/Ice.h>
+#include <IceStorm/IceStorm.h>
+
+#include "Core/Discovery/ServiceLocatorIf.h"
+#include "ProxyWrapper.h"
+
+using namespace ::std;
+using namespace AsteriskSCF::Core::Discovery::V1;
+
+namespace AsteriskSCF
+{
+namespace BasicRoutingService
+{
+
+/**
+ * The private implementation of ProxyWrapper. 
+ */
+template <class P>
+class ProxyWrapperPriv
+{
+public:
+   ProxyWrapperPriv(const ServiceLocatorPrx& locator, ServiceLocatorParamsPtr params)
+      :  mServiceLocator(locator), mLocatorParams(params), mInitialized(false)
+   {
+      initialize();
+   }
+
+   /**
+    * Initialization. Primarily involves acquring access to specific IceStorm topic. 
+    */
+   void initialize()
+   {
+      try
+      {
+         // Use the locator to find the Proxy
+         Ice::ObjectPrx bridgeManagerObject = mServiceLocator->locate(mLocatorParams);
+         mProxy = P::checkedCast(bridgeManagerObject);
+      }
+      catch (const Ice::Exception &e)
+      {
+         cout << "Exception locating " << mLocatorParams->category << ": " << e.what() << endl; 
+         return;
+      }
+
+      if (mProxy == 0)
+      {
+         cout << "Unable to locate " << mLocatorParams->category << endl;
+      }
+
+      mInitialized = true;
+   }
+
+   /**
+    * Utiltity to check for initialization state. 
+    */
+   bool verifyInitialized()
+   {
+      if (mInitialized)
+      {
+         return true;
+      }
+
+      // Try again to initialize. 
+      initialize();
+
+      return mInitialized;
+   }
+
+   bool isInitialized()
+   {
+      return mInitialized;
+   }
+
+public:
+   P mProxy;
+
+private:
+   ServiceLocatorPrx mServiceLocator;
+   ServiceLocatorParamsPtr mLocatorParams;
+   bool mInitialized;
+};
+
+/**
+ * Class constructor. 
+ */
+template <class P>
+ProxyWrapper<P>::ProxyWrapper(const ServiceLocatorPrx& locator, ServiceLocatorParamsPtr params) 
+      : mImpl(new ProxyWrapperPriv<P>(locator, params))
+{
+}
+
+/**
+ * Provide acess to the actual proxy.
+ */
+template <class P>
+const P& ProxyWrapper<P>::operator->() const
+{
+   if (!mImpl->verifyInitialized())
+   {
+      throw "No access to Proxy";
+   }
+
+   return mImpl->mProxy;
+}
+
+template <class P>
+bool ProxyWrapper<P>::isInitialized()
+{
+   return mImpl->isInitialized();
+}
+
+
+}; // end BasicRoutingService
+}; // end AsteriskSCF
+
diff --git a/src/ProxyWrapper.h b/src/ProxyWrapper.h
new file mode 100644
index 0000000..cb24825
--- /dev/null
+++ b/src/ProxyWrapper.h
@@ -0,0 +1,43 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+#pragma once
+
+#include <Ice/Ice.h>
+#include <boost/shared_ptr.hpp>
+
+#include "Core/Discovery/ServiceLocatorIf.h"
+
+namespace AsteriskSCF
+{
+namespace BasicRoutingService
+{
+template<class P>
+class ProxyWrapperPriv;
+
+/**
+ * A wrapper for an Ice Proxy.
+ * The Template parameter P is the proxy we're wrapping
+ */
+template <class P>
+class ProxyWrapper
+{
+public:
+   ProxyWrapper(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& locator,
+         AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr params);
+
+   const P& operator->() const ;
+   bool isInitialized();
+
+private:
+   boost::shared_ptr<ProxyWrapperPriv<P> > mImpl; // pimpl idiom applied. 
+};
+
+typedef boost::shared_ptr<ProxyWrapper> ProxyWrapperPtr;
+
+}; // end BasicRoutingService
+}; // end AsteriskSCF

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list