[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
Tue Oct 26 12:44:02 CDT 2010


branch "master" has been updated
       via  71d76ebdbb7c6a5566990cd5f6bffdc46cbbcd80 (commit)
      from  423ca559403af8b3e55620e1d691541c457b5458 (commit)

Summary of changes:
 src/PJSipManager.cpp                   |    4 +-
 src/PJSipManager.h                     |    4 +-
 src/PJSipSessionModule.h               |    8 +-
 src/PJSipSessionModuleConstruction.cpp |    4 +-
 src/ProxyWrapper.cpp                   |   20 ----
 src/ProxyWrapper.h                     |  154 --------------------------------
 src/SipSessionManagerApp.cpp           |   13 ++--
 7 files changed, 17 insertions(+), 190 deletions(-)
 delete mode 100644 src/ProxyWrapper.cpp
 delete mode 100644 src/ProxyWrapper.h


- Log -----------------------------------------------------------------
commit 71d76ebdbb7c6a5566990cd5f6bffdc46cbbcd80
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Oct 26 13:41:39 2010 -0400

    Use the ice-utils-c++ ProxyWrapper template instead of including one with the SIP component.

diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 4554e70..083911e 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -72,9 +72,9 @@ PJSipManager::PJSipManager(Ice::PropertiesPtr props)
 
 void PJSipManager::registerSessionModule(pjsip_endpoint *endpt,
    boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
-   ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
+   AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
    AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
-   ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
+   AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
    AsteriskSCF::System::Component::V1::ReplicaPtr replica
    )
 {
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index da115c1..b9d1e5a 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -68,9 +68,9 @@ public:
 	 */
 	void registerSessionModule(pjsip_endpoint *endpt,
 		boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
-		ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
+		AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
 		AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
-		ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
+		AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
 		AsteriskSCF::System::Component::V1::ReplicaPtr replica
 	);
 
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index c10cbf2..6e41d6b 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -57,9 +57,9 @@ class PJSipSessionModule : public PJSipModule
 {
 public:
 	PJSipSessionModule(pjsip_endpoint *endpt, boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
-		ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
+		AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
 		AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
-		ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
+		AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
 		AsteriskSCF::System::Component::V1::ReplicaPtr replica);
 	pj_status_t load(pjsip_endpoint *endpoint);
 	pj_status_t start();
@@ -89,9 +89,9 @@ private:
 	pjsip_ua_init_param mUaParam;
 	const std::string mName;
 	boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
-	ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> mSessionRouter;
+	AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> mSessionRouter;
 	AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
-	ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> mStateReplicator;
+	AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> mStateReplicator;
 	AsteriskSCF::System::Component::V1::ReplicaPtr mReplica;
 };
 
diff --git a/src/PJSipSessionModuleConstruction.cpp b/src/PJSipSessionModuleConstruction.cpp
index 63dd7ed..847ef3f 100644
--- a/src/PJSipSessionModuleConstruction.cpp
+++ b/src/PJSipSessionModuleConstruction.cpp
@@ -91,9 +91,9 @@ static pjsip_dialog *uaOnDialogForked(pjsip_dialog *first_set, pjsip_rx_data *rd
 
 PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
 		boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
-		ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
+		AsteriskSCF::ProxyWrapper::ProxyWrapper<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
 		AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
-		ProxyWrapper<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
+		AsteriskSCF::ProxyWrapper::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.cpp b/src/ProxyWrapper.cpp
deleted file mode 100644
index df206ad..0000000
--- a/src/ProxyWrapper.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Asterisk Scalable Communications Framework
- *
- * Copyright (C) 2010 -- Digium, Inc.
- *
- * All rights reserved.
- */
-
-#include "ProxyWrapper.h"
-
-namespace AsteriskSCF
-{
-namespace SipChannelService
-{
- /*
- * This .cpp is a temporary solution to get a CMakeProject that consists only of header files. 
- */
-
-};
-};
diff --git a/src/ProxyWrapper.h b/src/ProxyWrapper.h
deleted file mode 100644
index 05f69b5..0000000
--- a/src/ProxyWrapper.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * 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 SipSessionManager
-{
-
-/**
- * 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
-{
-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;
-	}
-
-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;
-};
-
-}; // end SipSessionManager
-}; // end AsteriskSCF
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 5a56fd4..f915761 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -48,6 +48,7 @@ using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::System::Component::V1;
 using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::SessionCommunications::V1;
+using namespace AsteriskSCF::ProxyWrapper;
 
 namespace
 {
@@ -114,9 +115,9 @@ private:
    SipStateReplicatorListenerPrx mReplicatorListenerProxy;
    boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
    ServiceLocatorPrx mServiceLocator;
-   ProxyWrapper<SipStateReplicatorPrx> mStateReplicator;
-   ProxyWrapper<SessionRouterPrx> mSessionRouter;
-   ProxyWrapper<LocatorRegistryPrx> mRoutingServiceLocatorRegistry;
+   AsteriskSCF::ProxyWrapper::ProxyWrapper<SipStateReplicatorPrx> mStateReplicator;
+   AsteriskSCF::ProxyWrapper::ProxyWrapper<SessionRouterPrx> mSessionRouter;
+   AsteriskSCF::ProxyWrapper::ProxyWrapper<LocatorRegistryPrx> mRoutingServiceLocatorRegistry;
    boost::shared_ptr<SipSessionManagerEventPublisher> mEventPublisher;
    Routing::V1::EndpointLocatorPtr mEndpointLocator;
 };
@@ -353,7 +354,7 @@ void SipSessionManager::locateRoutingService()
    ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
    genericparams->category = Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory;
 
-   ProxyWrapper<LocatorRegistryPrx> pw(mServiceLocator, genericparams);
+   AsteriskSCF::ProxyWrapper::ProxyWrapper<LocatorRegistryPrx> pw(mServiceLocator, genericparams);
    mRoutingServiceLocatorRegistry = pw;
 }
 
@@ -370,7 +371,7 @@ void SipSessionManager::locateStateReplicator()
 
    try
    {
-      ProxyWrapper<SipStateReplicatorPrx> pw(mServiceLocator, replicatorParams);
+	   AsteriskSCF::ProxyWrapper::ProxyWrapper<SipStateReplicatorPrx> pw(mServiceLocator, replicatorParams);
       mStateReplicator = pw;
    }
    catch (...)
@@ -407,7 +408,7 @@ void SipSessionManager::locateSessionRouter()
    ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
    genericparams->category = Routing::V1::SessionRouterDiscoveryCategory;
 
-   ProxyWrapper<SessionRouterPrx> pw(mServiceLocator, genericparams);
+   AsteriskSCF::ProxyWrapper::ProxyWrapper<SessionRouterPrx> pw(mServiceLocator, genericparams);
    mSessionRouter = pw;
 }
 

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list