[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
Tue Jul 19 17:01:59 CDT 2011


branch "basecomponent" has been updated
       via  340787c1e9b33985381a868d0a9cb4ff59c1f767 (commit)
      from  4348e46d2de214662f0d3dd4718d12d33a2e4abf (commit)

Summary of changes:
 config/SipConfigurator.py   |    3 +-
 src/Component.cpp           |   93 ++++++++++++++++++++++--------------------
 src/SipReplicationContext.h |    2 +-
 3 files changed, 52 insertions(+), 46 deletions(-)


- Log -----------------------------------------------------------------
commit 340787c1e9b33985381a868d0a9cb4ff59c1f767
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Jul 19 17:01:35 2011 -0500

    Changes driven by testing.

diff --git a/config/SipConfigurator.py b/config/SipConfigurator.py
index 980cded..adb4c0f 100755
--- a/config/SipConfigurator.py
+++ b/config/SipConfigurator.py
@@ -170,8 +170,9 @@ class SipSectionVisitors(Configurator.SectionVisitors):
             self.visit_endpoint(config, section)
 
 # In order to do service locator based lookup we need to pass in a params object
-serviceLocatorParams = AsteriskSCF.SIP.V1.SipConfigurationParams()
+serviceLocatorParams = AsteriskSCF.Core.Discovery.V1.ServiceLocatorParams()
 serviceLocatorParams.category = AsteriskSCF.SIP.V1.ConfigurationDiscoveryCategory
+serviceLocatorParams.service = 'default' 
 
 # Make a configurator application and let it run
 app = Configurator.ConfiguratorApp('Sip.config', SipSectionVisitors(), None, serviceLocatorParams)
diff --git a/src/Component.cpp b/src/Component.cpp
index b953591..ce6c95c 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -85,7 +85,7 @@ public:
 private:
     // Required base Component overrides
     virtual void createPrimaryServices();
-    virtual void registerPrimaryServices();
+    virtual void preparePrimaryServicesForDiscovery();
     virtual void createReplicationStateListeners();
     virtual void stopListeningToStateReplicators();
     virtual void listenToStateReplicators();
@@ -96,19 +96,19 @@ private:
     virtual void onPostInitialize();
     virtual void onStop();
 
-    // Other overrides
+    // Other base Component overrides
     virtual void createBackplaneServices();
-    virtual void registerBackplaneServices();
+    virtual void prepareBackplaneServicesForDiscovery();
     virtual ReplicationContextPtr createReplicationContext(ReplicationStateType state);
-    virtual void deregisterFromRemoteServices();    
+    virtual void unregisterFromRemoteServices();    
     virtual void registerWithRemoteServices();
 
     // Our own implementation operations. 
     void registerWithRoutingService();
-    void deregisterFromRoutingService();
+    void unregisterFromRoutingService();
 
     void registerWithServiceLocator();
-    void deregisterFromServiceLocator();
+    void unregisterFromServiceLocator();
     void locateRoutingService();
     void locateSessionRouter();
     void locateStateReplicator();
@@ -158,61 +158,37 @@ ReplicationContextPtr Component::createReplicationContext(ReplicationStateType s
  * Register this component's primary public interfaces with the Service Locator.
  * This enables other Asterisk SCF components to locate our interfaces.
  */
-void Component::registerPrimaryServices()
+void Component::preparePrimaryServicesForDiscovery()
 {
     // This is a required override. As a gateway, this component doesn't expose 
     // any interfaces on it's primary service adapter. 
 }
 
 /**
- * Register this component's backplane interfaces with the Service Locator.
- * This enables other Asterisk SCF components to locate our interfaces.
+ * Prepare this component's backplane interfaces for discovery via the Service Locator.
  */
-void Component::registerBackplaneServices()
+void Component::prepareBackplaneServicesForDiscovery()
 {
-    // Insure the default Component services are registered. 
-    Component::registerBackplaneServices();
+    // Insure the default Component services are prepped. 
+    AsteriskSCF::Component::Component::prepareBackplaneServicesForDiscovery();
 
     try
     {
         std::string serviceName = getCommunicator()->getProperties()->getPropertyWithDefault(
             getName() + ".Service", "default");
 
-        // Register our configuration interface with the Service Locator.
+        // Wrap our configuration interface for the Service Locator.
         mConfigurationRegistration = wrapServiceForRegistration(mConfigurationServiceProxy, 
                                                                 ConfigurationDiscoveryCategory, 
                                                                 serviceName, 
                                                                 getName());
-        bool registered =  manageBackplaneService(mConfigurationRegistration);
+        manageBackplaneService(mConfigurationRegistration);
     }
     catch(const std::exception& e)
     {
         lg(Error) << "Exception in " << getName() << ", " << BOOST_CURRENT_FUNCTION <<  " : " << e.what();
     }
 }
-/**
- * Register our own Endpoint Locator with the Routing Service so that
- * the endpoints that this channel manages can be accessed from any
- * Session Manager in the Asterisk SCF system.
- */
-void Component::registerWithRoutingService()
-{
-    RegExSeq destinations;
-
-    mEndpointFactory->generateRoutingDestinations(destinations);
-
-    EndpointLocatorPrx locator = EndpointLocatorPrx::uncheckedCast(
-        getServiceAdapter()->createDirectProxy(getCommunicator()->stringToIdentity(EndpointLocatorObjectId)));
-    mRoutingServiceLocatorRegistry->addEndpointLocator(mRoutingId, destinations, locator);
-}
-
-/**
- * Deregister our own Endpoint Locator from the Routing SErvice.
- */
-void Component::deregisterFromRoutingService()
-{
-    mRoutingServiceLocatorRegistry->removeEndpointLocator(mRoutingId);
-}
 
 /**
  * Get a reference to the Routing Service interface that we care about, and cache it in the Data Model.
@@ -224,8 +200,6 @@ void Component::locateRoutingService()
     genericparams->category = Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory;
     genericparams->service =
         getCommunicator()->getProperties()->getPropertyWithDefault("Sip.RoutingService", "default");
-    genericparams->id =
-        getCommunicator()->getProperties()->getPropertyWithDefault("Sip.RoutingId", "");
 
     AsteriskSCF::Discovery::SmartProxy<LocatorRegistryPrx> pw(getServiceLocator(), genericparams, lg);
     mRoutingServiceLocatorRegistry = pw;
@@ -285,7 +259,7 @@ void Component::listenToStateReplicators()
     try
     {
         // Are we in standby mode?
-        if (sipReplicationContext->getState() == ACTIVE_IN_REPLICA_GROUP)
+        if (sipReplicationContext->getState() == STANDBY_IN_REPLICA_GROUP)
         {
             sipReplicationContext->getReplicator()->addListener(mReplicatorListenerProxy);
             mListeningToReplicator = true;
@@ -409,6 +383,37 @@ void Component::onPreInitialize()
 }
 
 /**
+ * Register our own Endpoint Locator with the Routing Service so that
+ * the endpoints that this channel manages can be accessed from any
+ * Session Manager in the Asterisk SCF system.
+ */
+void Component::registerWithRoutingService()
+{
+    try
+    {
+        RegExSeq destinations;
+
+        mEndpointFactory->generateRoutingDestinations(destinations);
+
+        EndpointLocatorPrx locator = EndpointLocatorPrx::uncheckedCast(
+            getServiceAdapter()->createDirectProxy(getCommunicator()->stringToIdentity(EndpointLocatorObjectId)));
+        mRoutingServiceLocatorRegistry->addEndpointLocator(mRoutingId, destinations, locator);
+    }
+    catch(const std::exception& e)
+    {
+        lg(Error) << "Exception in " << getName() << ", " << BOOST_CURRENT_FUNCTION <<  " : " << e.what();
+    }
+}
+
+/**
+ * Unregister our own Endpoint Locator from the Routing SErvice.
+ */
+void Component::unregisterFromRoutingService()
+{
+    mRoutingServiceLocatorRegistry->removeEndpointLocator(mRoutingId);
+}
+
+/**
  * This operation is called by the base Component class
  * at times such as activation, or resumed, to allow us to
  * add our own proxies with remote services. 
@@ -425,9 +430,9 @@ void Component::registerWithRemoteServices()
  * at times such as standy, or paused, to allow us to
  * remove our own proxies from remote services. 
  */
-void Component::deregisterFromRemoteServices() 
+void Component::unregisterFromRemoteServices() 
 {
-    deregisterFromRoutingService();
+    unregisterFromRoutingService();
 }
 
 /**
@@ -487,7 +492,7 @@ void Component::createPrimaryServices()
 void Component::createBackplaneServices()
 {
     // Include the base Component services. 
-    Component::createBackplaneServices();
+    AsteriskSCF::Component::Component::createBackplaneServices();
 
     try
     {
@@ -538,7 +543,7 @@ void Component::findRemoteServices()
 void Component::onStop()
 {
     // Remove our endpoint locator from the routing service.
-    deregisterFromRoutingService();
+    unregisterFromRoutingService();
 
     //
     // TODO: This is probably a mistake. Many things access the PJSipManager instance and will continue
diff --git a/src/SipReplicationContext.h b/src/SipReplicationContext.h
index 53de8cf..bf2021d 100644
--- a/src/SipReplicationContext.h
+++ b/src/SipReplicationContext.h
@@ -44,7 +44,7 @@ public:
      virtual bool isReplicating() 
      {
          // If the base context says we aren't replicating, we aren't. 
-         if (!ReplicationContext::isReplicating())
+         if (ReplicationContext::isReplicating() == false)
          {
              return false;
          }

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list