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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Jul 15 17:40:47 CDT 2011


branch "basecomponent" has been updated
       via  4348e46d2de214662f0d3dd4718d12d33a2e4abf (commit)
      from  99a16a762d9a30872f49d7d6e29756770245d2ec (commit)

Summary of changes:
 src/CMakeLists.txt                           |    2 +-
 src/{SipSessionGateway.cpp => Component.cpp} |   71 ++++++++++++--------------
 src/PJSipSessionModule.cpp                   |   44 +---------------
 3 files changed, 35 insertions(+), 82 deletions(-)
 rename src/{SipSessionGateway.cpp => Component.cpp} (89%)


- Log -----------------------------------------------------------------
commit 4348e46d2de214662f0d3dd4718d12d33a2e4abf
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Fri Jul 15 17:40:50 2011 -0500

    Changes for consistency.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f515361..eb4f032 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,7 +11,7 @@ include_directories(${API_INCLUDE_DIR})
 asterisk_scf_slice_include_directories(${API_SLICE_DIR})
 
 asterisk_scf_component_init(SipSessionManager)
-asterisk_scf_component_add_file(SipSessionManager SipSessionGateway.cpp)
+asterisk_scf_component_add_file(SipSessionManager Component.cpp)
 asterisk_scf_component_add_file(SipSessionManager SipReplicationContext.h)
 asterisk_scf_component_add_file(SipSessionManager SipSessionManagerEventPublisher.cpp)
 asterisk_scf_component_add_file(SipSessionManager SipSessionManagerEventPublisher.h)
diff --git a/src/SipSessionGateway.cpp b/src/Component.cpp
similarity index 89%
rename from src/SipSessionGateway.cpp
rename to src/Component.cpp
index 64ec9a5..b953591 100644
--- a/src/SipSessionGateway.cpp
+++ b/src/Component.cpp
@@ -53,7 +53,6 @@ using namespace AsteriskSCF::System::Component::V1;
 using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::SessionCommunications::V1;
 using namespace AsteriskSCF::System::Configuration::V1;
-using namespace AsteriskSCF::Component;
 using namespace AsteriskSCF::Replication;
 using namespace AsteriskSCF::Discovery;
 
@@ -70,21 +69,21 @@ namespace SipSessionManager
 /**
  * This private class initializes the startup and controls the shutdown of the component.
  */
-class SipSessionGateway : public Component
+class Component : public AsteriskSCF::Component::Component
 {
 public:
-    SipSessionGateway() 
-        : Component(lg, AsteriskSCF::SIP::V1::ComponentServiceDiscoveryCategory),
-          mListeningToReplicator(false)
+    Component() 
+        :  AsteriskSCF::Component::Component(lg, AsteriskSCF::SIP::V1::ComponentServiceDiscoveryCategory),
+           mListeningToReplicator(false)
     {
     }
 
-    ~SipSessionGateway()
+    ~Component()
     {
     }
 
 private:
-    // Required Component overrides
+    // Required base Component overrides
     virtual void createPrimaryServices();
     virtual void registerPrimaryServices();
     virtual void createReplicationStateListeners();
@@ -149,7 +148,7 @@ static const string ReplicaServiceId("SipChannelReplica");
 /**
  * Override of factory method to create our custom replication context. 
  */
-ReplicationContextPtr SipSessionGateway::createReplicationContext(ReplicationStateType state)
+ReplicationContextPtr Component::createReplicationContext(ReplicationStateType state)
 {
     SipReplicationContextPtr context(new SipReplicationContext(state));
     return context;
@@ -159,7 +158,7 @@ ReplicationContextPtr SipSessionGateway::createReplicationContext(ReplicationSta
  * Register this component's primary public interfaces with the Service Locator.
  * This enables other Asterisk SCF components to locate our interfaces.
  */
-void SipSessionGateway::registerPrimaryServices()
+void Component::registerPrimaryServices()
 {
     // This is a required override. As a gateway, this component doesn't expose 
     // any interfaces on it's primary service adapter. 
@@ -169,7 +168,7 @@ void SipSessionGateway::registerPrimaryServices()
  * Register this component's backplane interfaces with the Service Locator.
  * This enables other Asterisk SCF components to locate our interfaces.
  */
-void SipSessionGateway::registerBackplaneServices()
+void Component::registerBackplaneServices()
 {
     // Insure the default Component services are registered. 
     Component::registerBackplaneServices();
@@ -179,12 +178,12 @@ void SipSessionGateway::registerBackplaneServices()
         std::string serviceName = getCommunicator()->getProperties()->getPropertyWithDefault(
             getName() + ".Service", "default");
 
-        // Register our RoutingAdmin interface with the Service Locator.
+        // Register our configuration interface with the Service Locator.
         mConfigurationRegistration = wrapServiceForRegistration(mConfigurationServiceProxy, 
                                                                 ConfigurationDiscoveryCategory, 
                                                                 serviceName, 
                                                                 getName());
-        bool registered =  registerBackplaneService(mConfigurationRegistration);
+        bool registered =  manageBackplaneService(mConfigurationRegistration);
     }
     catch(const std::exception& e)
     {
@@ -196,7 +195,7 @@ void SipSessionGateway::registerBackplaneServices()
  * the endpoints that this channel manages can be accessed from any
  * Session Manager in the Asterisk SCF system.
  */
-void SipSessionGateway::registerWithRoutingService()
+void Component::registerWithRoutingService()
 {
     RegExSeq destinations;
 
@@ -210,7 +209,7 @@ void SipSessionGateway::registerWithRoutingService()
 /**
  * Deregister our own Endpoint Locator from the Routing SErvice.
  */
-void SipSessionGateway::deregisterFromRoutingService()
+void Component::deregisterFromRoutingService()
 {
     mRoutingServiceLocatorRegistry->removeEndpointLocator(mRoutingId);
 }
@@ -219,7 +218,7 @@ void SipSessionGateway::deregisterFromRoutingService()
  * Get a reference to the Routing Service interface that we care about, and cache it in the Data Model.
  * This will allow us to lookup endpoints anywhere in the Asterisk SCF system.
  */
-void SipSessionGateway::locateRoutingService()
+void Component::locateRoutingService()
 {
     ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
     genericparams->category = Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory;
@@ -235,7 +234,7 @@ void SipSessionGateway::locateRoutingService()
     mRoutingId = getCommunicator()->getProperties()->getPropertyWithDefault("Sip.RoutingDestinationId", "pjsip");
 }
 
-void SipSessionGateway::locateStateReplicator()
+void Component::locateStateReplicator()
 {
     if (getReplicationContext()->getState() == ACTIVE_STANDALONE)
     {
@@ -267,7 +266,7 @@ void SipSessionGateway::locateStateReplicator()
     }
 }
 
-void SipSessionGateway::listenToStateReplicators()
+void Component::listenToStateReplicators()
 {
     SipReplicationContextPtr sipReplicationContext = 
         static_pointer_cast<SipReplicationContext>(getReplicationContext());
@@ -288,10 +287,7 @@ void SipSessionGateway::listenToStateReplicators()
         // Are we in standby mode?
         if (sipReplicationContext->getState() == ACTIVE_IN_REPLICA_GROUP)
         {
-            SipStateReplicatorPrx oneWayStateReplicator = 
-                 SipStateReplicatorPrx::uncheckedCast(sipReplicationContext->getReplicator()->ice_oneway());
-
-            oneWayStateReplicator->addListener(mReplicatorListenerProxy);
+            sipReplicationContext->getReplicator()->addListener(mReplicatorListenerProxy);
             mListeningToReplicator = true;
         }
     }
@@ -307,7 +303,7 @@ void SipSessionGateway::listenToStateReplicators()
  * A component in active mode doesn't neeed to listen to
  * state replication data. 
  */
-void SipSessionGateway::stopListeningToStateReplicators()
+void Component::stopListeningToStateReplicators()
 {
     SipReplicationContextPtr sipReplicationContext = 
         static_pointer_cast<SipReplicationContext>(getReplicationContext());
@@ -319,10 +315,7 @@ void SipSessionGateway::stopListeningToStateReplicators()
 
     try
     {
-        SipStateReplicatorPrx oneWayStateReplicator = 
-                SipStateReplicatorPrx::uncheckedCast(sipReplicationContext->getReplicator()->ice_oneway());
-
-        oneWayStateReplicator->removeListener(mReplicatorListenerProxy);
+        sipReplicationContext->getReplicator()->removeListener(mReplicatorListenerProxy);
         mListeningToReplicator = false;
     }
     catch (const Ice::Exception& e)
@@ -336,7 +329,7 @@ void SipSessionGateway::stopListeningToStateReplicators()
  * Get a reference to the Session Routing Service interface that we care about, and cache it in the Data Model.
  * This will allow us to route sessions.
  */
-void SipSessionGateway::locateSessionRouter()
+void Component::locateSessionRouter()
 {
     ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
     genericparams->category = Routing::V1::SessionRouterDiscoveryCategory;
@@ -347,7 +340,7 @@ void SipSessionGateway::locateSessionRouter()
     mSessionRouter = pw;
 }
 
-void SipSessionGateway::configureEndpoints()
+void Component::configureEndpoints()
 {
     Ice::PropertiesPtr props = getCommunicator()->getProperties();
     Ice::StringSeq endpointNames = props->getPropertyAsList("Sip.Endpoints");
@@ -359,7 +352,7 @@ void SipSessionGateway::configureEndpoints()
     }
 }
 
-void SipSessionGateway::registerPJSipModules()
+void Component::registerPJSipModules()
 {
     SipReplicationContextPtr sipReplicationContext = 
         static_pointer_cast<SipReplicationContext>(getReplicationContext());
@@ -392,7 +385,7 @@ void SipSessionGateway::registerPJSipModules()
  * to initialize things before the base component does anything
  * else. 
  */
-void SipSessionGateway::onPreInitialize()
+void Component::onPreInitialize()
 {
     try
     {
@@ -420,7 +413,7 @@ void SipSessionGateway::onPreInitialize()
  * at times such as activation, or resumed, to allow us to
  * add our own proxies with remote services. 
  */
-void SipSessionGateway::registerWithRemoteServices() 
+void Component::registerWithRemoteServices() 
 {
     // Register our Endpoint Locator so that we can provide endpoints to the
     // Routing Service for the endpoints we manage.
@@ -432,7 +425,7 @@ void SipSessionGateway::registerWithRemoteServices()
  * at times such as standy, or paused, to allow us to
  * remove our own proxies from remote services. 
  */
-void SipSessionGateway::deregisterFromRemoteServices() 
+void Component::deregisterFromRemoteServices() 
 {
     deregisterFromRoutingService();
 }
@@ -442,7 +435,7 @@ void SipSessionGateway::deregisterFromRemoteServices()
  * to initialize things after the base component does common
  * initialization. 
  */
-void SipSessionGateway::onPostInitialize()
+void Component::onPostInitialize()
 {
     try
     {
@@ -460,7 +453,7 @@ void SipSessionGateway::onPostInitialize()
  * Create the objects that implement the main services this component provides 
  * the system.
  */
-void SipSessionGateway::createPrimaryServices()
+void Component::createPrimaryServices()
 {
     try
     {
@@ -491,7 +484,7 @@ void SipSessionGateway::createPrimaryServices()
     }
 }
 
-void SipSessionGateway::createBackplaneServices()
+void Component::createBackplaneServices()
 {
     // Include the base Component services. 
     Component::createBackplaneServices();
@@ -511,7 +504,7 @@ void SipSessionGateway::createBackplaneServices()
     }
 }
 
-void SipSessionGateway::createReplicationStateListeners()
+void Component::createReplicationStateListeners()
 {
     try
     {
@@ -530,7 +523,7 @@ void SipSessionGateway::createReplicationStateListeners()
     }
 }
 
-void SipSessionGateway::findRemoteServices() 
+void Component::findRemoteServices() 
 {
     // Locate the Session Router so we can REALLY do routing.
     locateSessionRouter();
@@ -542,7 +535,7 @@ void SipSessionGateway::findRemoteServices()
 /**
  * Notification from the component that we're stopping. 
  */
-void SipSessionGateway::onStop()
+void Component::onStop()
 {
     // Remove our endpoint locator from the routing service.
     deregisterFromRoutingService();
@@ -558,7 +551,7 @@ extern "C"
 {
 ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
 {
-    return new SipSessionGateway;
+    return new Component;
 }
 }
 
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index de4822c..80b3ae5 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -255,52 +255,12 @@ void PJSipSessionModule::replicateState(PJSipDialogModInfo *dlgInfo, PJSipTransa
     {
         if (setItems.size() != 0)
         {
-            Ice::ObjectPrx oneway;
-            try
-            {
-                oneway = mReplicationContext->getReplicator()->ice_oneway();
-            }
-            catch (const Ice::NoEndpointException&)
-            {
-                lg(Error) << "No endpoint for oneway invocation of setState() for state replication.";
-            }
-
-            AsteriskSCF::SIP::V1::SipStateReplicatorPrx oneWayStateReplicator = 
-                AsteriskSCF::SIP::V1::SipStateReplicatorPrx::uncheckedCast(oneway);
-
-            try
-            {
-                oneWayStateReplicator->setState(setItems);
-            }
-            catch (const Ice::TwowayOnlyException&)
-            {
-                lg(Error) << "setState() is not oneway.";
-            }
+            mReplicationContext->getReplicator().tryOneWay()->setState(setItems);
         }
 
         if (removeItems.size() != 0)
         {
-            Ice::ObjectPrx oneway;
-            try
-            {
-                oneway = mReplicationContext->getReplicator()->ice_oneway();
-            }
-            catch (const Ice::NoEndpointException&)
-            {
-                lg(Error) << "No endpoint for oneway invocation of removeState() for state replication.";
-            }
-
-            AsteriskSCF::SIP::V1::SipStateReplicatorPrx oneWayStateReplicator =
-                AsteriskSCF::SIP::V1::SipStateReplicatorPrx::uncheckedCast(oneway);
-
-            try
-            {
-                oneWayStateReplicator->removeState(removeItems);
-            }
-            catch (const Ice::TwowayOnlyException&)
-            {
-                lg(Error) << "removeState() is not oneway.";
-            }
+            mReplicationContext->getReplicator().tryOneWay()->removeState(removeItems);
         }
     }
 }

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list