[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "component-interface" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue May 10 12:57:22 CDT 2011


branch "component-interface" has been updated
       via  35e0fa0627a8a4008c8976cc3c29c91aee08a635 (commit)
       via  8d8ffceda105c8bfcbaf47f87f264c23e7cfe62a (commit)
       via  17925fcd79f9294bba57bffd11cdcf95a3e590dc (commit)
      from  82f2598d09ccf1f05bb7ec3da66324694434bde0 (commit)

Summary of changes:
 config/bridging.conf            |    2 +-
 config/test_bridging.conf       |    2 +-
 src/BridgeReplicatorService.cpp |    4 +-
 src/Service.cpp                 |  103 +++++++++++++++++++++++++++++++++++++-
 src/ServiceUtil.h               |   19 ++++++-
 5 files changed, 120 insertions(+), 10 deletions(-)


- Log -----------------------------------------------------------------
commit 35e0fa0627a8a4008c8976cc3c29c91aee08a635
Author: Fred Anderson <fanderson at digium.com>
Date:   Tue May 10 12:56:50 2011 -0500

    Changes to support component interface

diff --git a/config/bridging.conf b/config/bridging.conf
index 7ba3738..ff8b524 100644
--- a/config/bridging.conf
+++ b/config/bridging.conf
@@ -4,7 +4,7 @@
 BridgeManager.BridgeService.Endpoints=default
 
 # A proxy to the service locator management service
-ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -p 4422
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422
 LocatorService.Proxy=LocatorService:tcp -p 4411
 
 # A proxy to the IceStorm topic manager
diff --git a/config/test_bridging.conf b/config/test_bridging.conf
index e88f751..d3bceda 100644
--- a/config/test_bridging.conf
+++ b/config/test_bridging.conf
@@ -104,7 +104,7 @@ ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
 # The proxies that clients use to access the Service Locator facilities.
 #
 LocatorService.Proxy=LocatorService:default -p 4411
-ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -p 4422
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422
 
 #
 # The IceBox entries for loading the services.
diff --git a/src/BridgeReplicatorService.cpp b/src/BridgeReplicatorService.cpp
index eefdd13..4110425 100644
--- a/src/BridgeReplicatorService.cpp
+++ b/src/BridgeReplicatorService.cpp
@@ -117,11 +117,11 @@ void BridgeReplicatorApp::start(const string& name, const Ice::CommunicatorPtr&
     getLoggerFactory().setLogOutput(iceLogger->getLogger());
 
 
-    string property = communicator->getProperties()->getProperty("ServiceLocatorManagementProxy");
+    string property = communicator->getProperties()->getProperty("LocatorServiceManagement.Proxy");
     if(property.size() == 0)
     {
         throw IceBox::FailureException(__FILE__, __LINE__,
-                "Configuration error: Unable to locate property `ServiceLocatorManagementProxy'");
+                "Configuration error: Unable to locate property `LocatorServiceManagement.Proxy'");
     }
     
     //
diff --git a/src/Service.cpp b/src/Service.cpp
index 6da1038..034bd7d 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -38,11 +38,6 @@ using namespace std;
 
 namespace
 {
-Logger lg = getLoggerFactory().getLogger("AsteriskSCF.BridgeService");
-}
-
-namespace
-{
 
 class ReplicaControl : virtual public Replica
 {
@@ -100,46 +95,35 @@ private:
 
 typedef IceUtil::Handle<ReplicaControl> ReplicaControlPtr;
 
-
 class BridgingApp : public IceBox::Service
 {
 public:
     BridgingApp();
-    ~BridgingApp();
 
 public:
     void start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args);
     void stop();
     void suspend();
     void resume();
-    void shutdown();
 
 private:
-    ServiceManagementPrx mComponentServiceManagement;
-    ServiceLocatorManagementPrx mServiceLocatorManagement;
-    BridgeManagerPrx mBridgeManagerPrx;
-    std::string mServiceLocatorManagementProperty;
-    std::string mAdapterName;
-    bool mInitialized;
-    bool mRunning;
-    std::string mAppName;
-    Ice::CommunicatorPtr mCommunicator;
     /**
      * A proxy to the service locator manager for the bridge manager service.
      */
     IceUtil::Handle<LocatorRegistrationWrapper<BridgeManagerPrx> > mLocator;
-    ServiceLocatorPrx mSLocator;
+    /**
+     * A proxy to the service locator manager for the component service.
+     */
+    IceUtil::Handle<LocatorRegistrationWrapper<ComponentServicePrx> > mCompLocator;
     Ice::ObjectAdapterPtr mAdapter;
     Ice::ObjectAdapterPtr mInfrastructureAdapter;
     IceUtil::Handle<RegisterThread<BridgeManagerPrx> > mRegisterThread;
+    IceUtil::Handle<RegisterThread<ComponentServicePrx> > mCompRegisterThread;
     ReplicaControlPtr mReplicaControl;
     ComponentServicePtr mComponentService;
-
-    void initialize();
-    void setCategory(const ServiceManagementPrx& serviceManagement, const std::string& category);
-    void registerWithServiceLocator();
 };
 
+static const std::string ComponentServiceId("BridgeComponent");
 
 /**
  * This class provides implementation for the ComponentService interface.
@@ -173,32 +157,213 @@ private:
     BridgingApp& mApp;
 };
 
-static const std::string ComponentServiceId("BridgeComponent");
 
-BridgingApp::BridgingApp() : mInitialized(false), mRunning(false)
+BridgingApp::BridgingApp()
 {
 }
 
 
-BridgingApp::~BridgingApp()
+void BridgingApp::start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq&)
 {
-    mComponentService = 0;
-}
+    Logger logger = getLoggerFactory().getLogger("AsteriskSCF.BridgeService");
+    logger(Debug) << "Launching AsteriskSCF Session-Oriented Bridging Service." ;
 
+    //
+    // It is standard practice to base the adapter name on the configured
+    // service instance name.
+    //
+    std::string adapterName;
+    if (name.size() == 0)
+    {
+        adapterName = "BridgeService";
+    }
+    else
+    {
+        adapterName = name + ".BridgeService";
+    }
 
-void BridgingApp::start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq&)
-{
-    lg(Debug) << "Launching AsteriskSCF Session-Oriented Bridging Service." ;
 
-    mCommunicator = communicator;
-    mAppName = name;
+    //
+    // Check on the threadpool properties, make sure that they are compatible with the requirements of this 
+    // service. This could be moved into a helper method, but it is somehow more clear for seeing what
+    // is going on during initialization to leave it here.
+    //
+    // TODO: Are there any other properties that need to be double-checked before proceeding?
+    //
+    Ice::Int defaultPoolSize = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0);
+    if (communicator->getProperties()->getPropertyAsIntWithDefault(adapterName + ".ThreadPool.Size", 0) < 4)
+    {
+        if (defaultPoolSize < 4)
+        {
+            logger(Info) << "Configured thread pool size for " << adapterName + " is too small, defaulting to 4";
+            communicator->getProperties()->setProperty(adapterName + ".ThreadPool.Size", "4");
+        }
+    }
+    if (communicator->getProperties()->getPropertyAsIntWithDefault(adapterName + "Internal.ThreadPool.Size", 0) < 4)
+    {
+        if (defaultPoolSize < 4)
+        {
+            logger(Info) << "Configured thread pool size for " << adapterName + "Internal is too small, defaulting to 4";
+            communicator->getProperties()->setProperty(adapterName + "Internal.ThreadPool.Size", "4");
+        }
+    }
+    defaultPoolSize = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.ThreadPool.Client.Size", 0);
+    if (defaultPoolSize < 4)
+    {
+        logger(Warning) << "Client thread pool size is too small. It should be set to 4 or greater";
+    }
+
+    
+    //
+    // TODO: All adapter ids should be globally unique. This would allow replicas to be identified.
+    // How this might be useful is that it might be used as a replicated state item to identify
+    // which adapter is currently the primary in a group of replicas.
+    //
+    mAdapter = communicator->createObjectAdapterWithEndpoints(adapterName, 
+        communicator->getProperties()->getPropertyWithDefault(adapterName + ".Endpoints", "default"));
+
+    //
+    // We do not activate the main object adapter until most everything is initialized. The infrastructure
+    // adapter is for internally accessed objects or for supporting things that will be externally
+    // accessible until later so activating it now is fine.
+    //
+    mInfrastructureAdapter = communicator->createObjectAdapterWithEndpoints(adapterName + "Internal",
+        communicator->getProperties()->getPropertyWithDefault(adapterName + "Internal.Endpoints", "default"));
+    mInfrastructureAdapter->activate();
+
+    //
+    // Configure the AsteriskSCF logger.
+    // TODO: check whether this works right if we've already created the logger object.
+    //
+    ConfiguredIceLoggerPtr iceLogger = createIceLogger(mAdapter);
+    if (iceLogger)
+    {
+        getLoggerFactory().setLogOutput(iceLogger->getLogger());
+    }
+
+    //
+    // While this property is checked early in this method, it is not used until later on.
+    // This is to avoid several initialization steps if the final steps of initialization
+    // cannot be performed.
+    //
+    std::string serviceLocatorManagementProperty = communicator->getProperties()->getProperty("LocatorServiceManagement.Proxy");
+    if (serviceLocatorManagementProperty.empty())
+    {
+        throw IceBox::FailureException(__FILE__, __LINE__, 
+            "Configuration error: Unable to locate property `LocatorServiceManagement.Proxy'");
+    }
+
+    string locatorPropertyString = communicator->getProperties()->getProperty("LocatorService.Proxy");
+    if (locatorPropertyString.empty())
+    {
+        throw IceBox::FailureException(__FILE__, __LINE__,
+            "Configuration error: Unable to locate property `LocatorService.Proxy`");
+    }
+    
+    ServiceLocatorPrx locator = ServiceLocatorPrx::checkedCast(communicator->stringToProxy(locatorPropertyString));
+       
+    BridgeStateReplicatorParamsPtr searchParams = new BridgeStateReplicatorParams;
+    searchParams->category = StateReplicatorDiscoveryCategory;
+    searchParams->name = communicator->getProperties()->getPropertyWithDefault("Bridge.StateReplicatorName", "default");
+  
+    ReplicatorSmartPrx replicator;
+    try
+    {
+        replicator = ReplicatorSmartPrx(locator, searchParams, logger);
+    }
+    catch (const std::exception& ex)
+    {
+        logger(Error) << "Bridge state replicator lookup failed. Continuing without replication. " << ex.what();
+    }
+   
+    std::string managerName = 
+        communicator->getProperties()->getPropertyWithDefault(name + ".ManagerId", "BridgeManager");
+
+    //
+    // It's very important that uncheckedCast's be used here as there are no guarantees
+    // that the object adapter is activated yet. If it is not, then this can hang.
+    //
+    BridgeManagerServantPtr manager = createBridgeManager(mAdapter, managerName, replicator, logger);
+    BridgeManagerPrx bridgeManagerPrx = BridgeManagerPrx::uncheckedCast(mAdapter->add(manager, 
+          mAdapter->getCommunicator()->stringToIdentity(managerName)));
+    assert(bridgeManagerPrx != 0);
+    if (bridgeManagerPrx == 0)
+    {
+        throw IceBox::FailureException(__FILE__, __LINE__, "Unable to instantiate bridge manager object");
+    }
+
+    //
+    // Configure replication connections.
+    //
+    ReplicatorListenerPtr replicaListener = createStateListener(logger, manager);
+    ReplicatorListenerPrx listenerPrx = ReplicatorListenerPrx::uncheckedCast(mInfrastructureAdapter->addWithUUID(replicaListener));
+
+    string replicaId = 
+        mAdapter->getCommunicator()->getProperties()->getPropertyWithDefault(
+            adapterName + ".ReplicaId", "BridgeReplica");
+    mReplicaControl = new ReplicaControl(mInfrastructureAdapter, manager, replicaId);
+    ReplicaPrx replicaControlPrx =
+        ReplicaPrx::uncheckedCast(mInfrastructureAdapter->add(mReplicaControl, communicator->stringToIdentity(replicaId)));
+
+    bool onStandby = false;
+    if (replicator)
+    {
+        onStandby = communicator->getProperties()->getPropertyWithDefault(name + ".StateReplicatorListener", "no") == "yes";
+    }
+    if (onStandby)
+    {
+        replicator->addListener(listenerPrx);
+        replicaControlPrx->standby();
+    }
+    else
+    {
+        manager->activate();
+    }
+
+    bool registered = false;
+    try
+    {
+        ServiceLocatorParamsPtr parameters(new ServiceLocatorParams);
+        parameters->category = BridgeServiceDiscoveryCategory;
+        mLocator = 
+            new LocatorRegistrationWrapper<BridgeManagerPrx>(communicator, serviceLocatorManagementProperty, bridgeManagerPrx, 
+               adapterName, parameters);
+        registered = mLocator->registerService();
+    }
+    catch (const Ice::Exception&)
+    {
+    }
+    if (!registered)
+    {
+        mRegisterThread = new RegisterThread<BridgeManagerPrx>(mLocator);
+        mRegisterThread->start();
+    }
+
+    // Create and publish the ComponentService interface.
+    mComponentService = new ComponentServiceImpl(*this);
+    mInfrastructureAdapter->add(mComponentService, communicator->stringToIdentity(ComponentServiceId));
+
+    ComponentServicePrx componentPrx = ComponentServicePrx::uncheckedCast(mInfrastructureAdapter->addWithUUID(mComponentService));
 
-    if (!mInitialized)
+    registered = false;
+    try
+    {
+        ServiceLocatorParamsPtr parameters(new ServiceLocatorParams);
+        parameters->category = ComponentServiceDiscoveryCategory;
+        mCompLocator = 
+            new LocatorRegistrationWrapper<ComponentServicePrx>(communicator, serviceLocatorManagementProperty, componentPrx,
+                    adapterName,parameters);
+        registered = mCompLocator->registerService();
+    }
+    catch (const Ice::Exception&)
+    {
+    }
+    if (!registered)
     {
-        initialize();
+        mCompRegisterThread = new RegisterThread<ComponentServicePrx>(mCompLocator);
+        mCompRegisterThread->start();
     }
-    registerWithServiceLocator();
-    mRunning = true;
+
     //
     // TODO: We need to know whether or not to activate!
     //
@@ -212,9 +377,12 @@ void BridgingApp::stop()
     {
         mRegisterThread->stop();
     }
+    if (mCompRegisterThread)
+    {
+        mCompRegisterThread->stop();
+    }
     try
     {
-        mComponentServiceManagement->unregister();
         mLocator->unregister();
     }
     catch (const Ice::Exception&)
@@ -222,6 +390,13 @@ void BridgingApp::stop()
     }
     try
     {
+        mCompLocator->unregister();
+    }
+    catch (const Ice::Exception&)
+    {
+    }
+    try
+    {
         Ice::CommunicatorPtr comm = mAdapter->getCommunicator();
         comm->shutdown();
         mAdapter->waitForDeactivate();
@@ -232,239 +407,18 @@ void BridgingApp::stop()
     {
         // TODO: log
     }
-    mRunning = false;
 }
 
 
 void BridgingApp::suspend()
 {
-    stop();
+    mCompLocator->serviceManagement()->suspend();
 }
 
 
 void BridgingApp::resume()
 {
-    if (!mRunning)
-    {
-        mAdapter->activate();
-        registerWithServiceLocator();
-    }
-    mRunning = true;
-}
-
-
-/**
- * Helper function to add some parameters to one of our registered interfaces in the ServiceLocator, so that
- * other components can look up our interfaces.
- */
-void BridgingApp::setCategory(const ServiceManagementPrx& serviceManagement, const std::string& category)
-{
-    // Add category as a parameter to enable other components look this component up.
-    ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams;
-    genericparams->category = category;
-    serviceManagement->addLocatorParams(genericparams, "");
-}
-
-
-void BridgingApp::initialize()
-{
-    printf("GOT HERE\n");
-    if (!mInitialized)
-    {
-        //
-        // It is standard practice to base the adapter name on the configured
-        // service instance name.
-        //
-        if (mAppName.size() == 0)
-        {
-            mAdapterName = "BridgeService";
-        }
-        else
-        {
-            mAdapterName = mAppName + ".BridgeService";
-        }
-        //
-        // Check on the threadpool properties, make sure that they are compatible with the requirements of this 
-        // service. This could be moved into a helper method, but it is somehow more clear for seeing what
-        // is going on during initialization to leave it here.
-        //
-        // TODO: Are there any other properties that need to be double-checked before proceeding?
-        //
-        Ice::Int defaultPoolSize = mCommunicator->getProperties()->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0);
-        if (mCommunicator->getProperties()->getPropertyAsIntWithDefault(mAdapterName + ".ThreadPool.Size", 0) < 4)
-        {
-            if (defaultPoolSize < 4)
-            {
-                lg(Info) << "Configured thread pool size for " << mAdapterName + " is too small, defaulting to 4";
-                mCommunicator->getProperties()->setProperty(mAdapterName + ".ThreadPool.Size", "4");
-            }
-        }
-        if (mCommunicator->getProperties()->getPropertyAsIntWithDefault(mAdapterName + "Internal.ThreadPool.Size", 0) < 4)
-        {
-            if (defaultPoolSize < 4)
-            {
-                lg(Info) << "Configured thread pool size for " << mAdapterName + "Internal is too small, defaulting to 4";
-                mCommunicator->getProperties()->setProperty(mAdapterName + "Internal.ThreadPool.Size", "4");
-            }
-        }
-        defaultPoolSize = mCommunicator->getProperties()->getPropertyAsIntWithDefault("Ice.ThreadPool.Client.Size", 0);
-        if (defaultPoolSize < 4)
-        {
-            lg(Warning) << "Client thread pool size is too small. It should be set to 4 or greater";
-        }
-
-        
-        //
-        // TODO: All adapter ids should be globally unique. This would allow replicas to be identified.
-        // How this might be useful is that it might be used as a replicated state item to identify
-        // which adapter is currently the primary in a group of replicas.
-        //
-        mAdapter = mCommunicator->createObjectAdapterWithEndpoints(mAdapterName, 
-            mCommunicator->getProperties()->getPropertyWithDefault(mAdapterName + ".Endpoints", "default"));
-        //
-        // We do not activate the main object adapter until most everything is initialized. The infrastructure
-        // adapter is for internally accessed objects or for supporting things that will be externally
-        // accessible until later so activating it now is fine.
-        //
-        mInfrastructureAdapter = mCommunicator->createObjectAdapterWithEndpoints(mAdapterName + "Internal",
-            mCommunicator->getProperties()->getPropertyWithDefault(mAdapterName + "Internal.Endpoints", "default"));
-        mInfrastructureAdapter->activate();
-
-        //
-        // Configure the AsteriskSCF lg.
-        // TODO: check whether this works right if we've already created the lg object.
-        //
-        ConfiguredIceLoggerPtr iceLogger = createIceLogger(mAdapter);
-        if (iceLogger)
-        {
-            getLoggerFactory().setLogOutput(iceLogger->getLogger());
-        }
-
-        mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("LocatorServiceManagement.Proxy"));
-
-        if (mServiceLocatorManagement == 0)
-        {
-            lg(Error) << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. This component can't be found until this is corrected.";
-            return;
-        }
-
-        //
-        // While this property is checked early in this method, it is not used until later on.
-        // This is to avoid several initialization steps if the final steps of initialization
-        // cannot be performed.
-        //
-        mServiceLocatorManagementProperty = mCommunicator->getProperties()->getProperty("ServiceLocatorManagementProxy");
-        if (mServiceLocatorManagementProperty.empty())
-        {
-            throw IceBox::FailureException(__FILE__, __LINE__, 
-                "Configuration error: Unable to locate property `ServiceLocatorManagementProxy'");
-        }
-
-        std::string locatorPropertyString = mCommunicator->getProperties()->getProperty("LocatorService.Proxy");
-        if (locatorPropertyString.empty())
-        {
-            throw IceBox::FailureException(__FILE__, __LINE__,
-                "Configuration error: Unable to locate property `LocatorService.Proxy`");
-        }
-        
-        mSLocator = ServiceLocatorPrx::checkedCast(mCommunicator->stringToProxy(locatorPropertyString));
-
-        printf("one\n");
-        // Register the ComponentService interface with the Service Locator.
-        Ice::ObjectPrx componentServiceObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(ComponentServiceId));
-        ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
-        std::string componentServiceGuid("BridgeService"); 
-        mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
-        printf("two\n");
-
-        setCategory(mComponentServiceManagement,AsteriskSCF::SessionCommunications::V1::BridgeServiceDiscoveryCategory);
-           
-        BridgeStateReplicatorParamsPtr searchParams = new BridgeStateReplicatorParams;
-        searchParams->category = StateReplicatorDiscoveryCategory;
-        searchParams->name = mCommunicator->getProperties()->getPropertyWithDefault("Bridge.StateReplicatorName", "default");
-      
-        ReplicatorSmartPrx replicator;
-        printf("three\n");
-        try
-        {
-            replicator = ReplicatorSmartPrx(mSLocator, searchParams, lg);
-        }
-        catch (const std::exception& ex)
-        {
-            lg(Error) << "Bridge state replicator lookup failed. Continuing without replication. " << ex.what();
-        }
-       
-        std::string managerName = 
-            mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".ManagerId", "BridgeManager");
-        printf("four\n");
-
-        //
-        // It's very important that uncheckedCast's be used here as there are no guarantees
-        // that the object adapter is activated yet. If it is not, then this can hang.
-        //
-        BridgeManagerServantPtr manager = createBridgeManager(mAdapter, managerName, replicator, lg);
-        mBridgeManagerPrx = BridgeManagerPrx::uncheckedCast(mAdapter->add(manager,mAdapter->getCommunicator()->stringToIdentity(managerName)));
-        assert(mBridgeManagerPrx != 0);
-        if (mBridgeManagerPrx == 0)
-        {
-            throw IceBox::FailureException(__FILE__, __LINE__, "Unable to instantiate bridge manager object");
-        }
-
-        //
-        // Configure replication connections.
-        //
-        ReplicatorListenerPtr replicaListener = createStateListener(lg, manager);
-        ReplicatorListenerPrx listenerPrx = ReplicatorListenerPrx::uncheckedCast(mInfrastructureAdapter->addWithUUID(replicaListener));
-
-        string replicaId = 
-            mAdapter->getCommunicator()->getProperties()->getPropertyWithDefault(
-                mAdapterName + ".ReplicaId", "BridgeReplica");
-        mReplicaControl = new ReplicaControl(mInfrastructureAdapter, manager, replicaId);
-        ReplicaPrx replicaControlPrx =
-            ReplicaPrx::uncheckedCast(mInfrastructureAdapter->add(mReplicaControl, mCommunicator->stringToIdentity(replicaId)));
-
-        printf("five\n");
-        bool onStandby = false;
-        if (replicator)
-        {
-            onStandby = mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".StateReplicatorListener", "no") == "yes";
-        }
-        if (onStandby)
-        {
-            replicator->addListener(listenerPrx);
-            replicaControlPrx->standby();
-        }
-        else
-        {
-            manager->activate();
-        }
-        printf("six\n");
-        mInitialized = true;
-    }
-}
-
-
-void BridgingApp::registerWithServiceLocator()
-{
-    bool registered = false;
-
-    try
-    {
-        ServiceLocatorParamsPtr parameters(new ServiceLocatorParams);
-        parameters->category = BridgeServiceDiscoveryCategory;
-        mLocator = 
-            new LocatorRegistrationWrapper<BridgeManagerPrx>(mCommunicator, mServiceLocatorManagementProperty, mBridgeManagerPrx, 
-               mAdapterName, parameters);
-        registered = mLocator->registerService();
-    }
-    catch (const Ice::Exception&)
-    {
-    }
-    if (!registered)
-    {
-        mRegisterThread = new RegisterThread<BridgeManagerPrx>(mLocator);
-        mRegisterThread->start();
-    }
+    mCompLocator->serviceManagement()->unsuspend();
 }
 
 }
diff --git a/src/ServiceUtil.h b/src/ServiceUtil.h
index 17f6b1e..dea5ccd 100644
--- a/src/ServiceUtil.h
+++ b/src/ServiceUtil.h
@@ -44,13 +44,13 @@ public:
 
     bool registerService()
     {
-        AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx management = 
+        mServiceLocatorManagement = 
             AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx::checkedCast(mCommunicator->stringToProxy(mProxyString));
-        if(management)
+        if(mServiceLocatorManagement)
         {
             IceUtil::Mutex::Lock lock(mLock);
             mServiceManagement = 
-                AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx::uncheckedCast(management->addService(mService, mName));
+                AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(mService, mName));
             if(mServiceManagement)
             {
                 mServiceManagement->addLocatorParams(mParameters, "");
@@ -72,6 +72,16 @@ public:
         mServiceManagement->unregister();
     }
 
+    AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx serviceLocatorManagement()
+    {
+        return mServiceLocatorManagement;
+    }
+
+    AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx serviceManagement()
+    {
+        return mServiceManagement;
+    }
+
 private:
 
     //
@@ -85,7 +95,10 @@ private:
     std::string mName;
     AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr mParameters;
     AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx mServiceManagement;
+    AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx mServiceLocatorManagement;
 };
+
+
 //
 // This thread takes care of registering the bridge if the service discovery components are unavailable during startup.
 //

commit 8d8ffceda105c8bfcbaf47f87f264c23e7cfe62a
Author: Fred Anderson <fanderson at digium.com>
Date:   Tue May 10 06:00:31 2011 -0500

    Tweak

diff --git a/src/Service.cpp b/src/Service.cpp
index 51b353c..6da1038 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -112,6 +112,7 @@ public:
     void stop();
     void suspend();
     void resume();
+    void shutdown();
 
 private:
     ServiceManagementPrx mComponentServiceManagement;
@@ -267,6 +268,7 @@ void BridgingApp::setCategory(const ServiceManagementPrx& serviceManagement, con
 
 void BridgingApp::initialize()
 {
+    printf("GOT HERE\n");
     if (!mInitialized)
     {
         //
@@ -367,11 +369,13 @@ void BridgingApp::initialize()
         
         mSLocator = ServiceLocatorPrx::checkedCast(mCommunicator->stringToProxy(locatorPropertyString));
 
+        printf("one\n");
         // Register the ComponentService interface with the Service Locator.
         Ice::ObjectPrx componentServiceObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(ComponentServiceId));
         ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
         std::string componentServiceGuid("BridgeService"); 
         mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
+        printf("two\n");
 
         setCategory(mComponentServiceManagement,AsteriskSCF::SessionCommunications::V1::BridgeServiceDiscoveryCategory);
            
@@ -380,6 +384,7 @@ void BridgingApp::initialize()
         searchParams->name = mCommunicator->getProperties()->getPropertyWithDefault("Bridge.StateReplicatorName", "default");
       
         ReplicatorSmartPrx replicator;
+        printf("three\n");
         try
         {
             replicator = ReplicatorSmartPrx(mSLocator, searchParams, lg);
@@ -391,6 +396,7 @@ void BridgingApp::initialize()
        
         std::string managerName = 
             mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".ManagerId", "BridgeManager");
+        printf("four\n");
 
         //
         // It's very important that uncheckedCast's be used here as there are no guarantees
@@ -417,6 +423,7 @@ void BridgingApp::initialize()
         ReplicaPrx replicaControlPrx =
             ReplicaPrx::uncheckedCast(mInfrastructureAdapter->add(mReplicaControl, mCommunicator->stringToIdentity(replicaId)));
 
+        printf("five\n");
         bool onStandby = false;
         if (replicator)
         {
@@ -431,6 +438,7 @@ void BridgingApp::initialize()
         {
             manager->activate();
         }
+        printf("six\n");
         mInitialized = true;
     }
 }

commit 17925fcd79f9294bba57bffd11cdcf95a3e590dc
Author: Fred Anderson <fanderson at digium.com>
Date:   Mon May 9 14:16:05 2011 -0500

    Adding component interface

diff --git a/src/Service.cpp b/src/Service.cpp
index fd3fcd6..51b353c 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -38,6 +38,11 @@ using namespace std;
 
 namespace
 {
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.BridgeService");
+}
+
+namespace
+{
 
 class ReplicaControl : virtual public Replica
 {
@@ -92,212 +97,114 @@ private:
     BridgeManagerServantPtr mManager;
     string mReplicaId;
 };
+
 typedef IceUtil::Handle<ReplicaControl> ReplicaControlPtr;
 
+
 class BridgingApp : public IceBox::Service
 {
 public:
     BridgingApp();
+    ~BridgingApp();
 
-protected:
+public:
     void start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args);
     void stop();
+    void suspend();
+    void resume();
 
 private:
+    ServiceManagementPrx mComponentServiceManagement;
+    ServiceLocatorManagementPrx mServiceLocatorManagement;
+    BridgeManagerPrx mBridgeManagerPrx;
+    std::string mServiceLocatorManagementProperty;
+    std::string mAdapterName;
+    bool mInitialized;
+    bool mRunning;
+    std::string mAppName;
+    Ice::CommunicatorPtr mCommunicator;
     /**
      * A proxy to the service locator manager for the bridge manager service.
      */
     IceUtil::Handle<LocatorRegistrationWrapper<BridgeManagerPrx> > mLocator;
+    ServiceLocatorPrx mSLocator;
     Ice::ObjectAdapterPtr mAdapter;
     Ice::ObjectAdapterPtr mInfrastructureAdapter;
     IceUtil::Handle<RegisterThread<BridgeManagerPrx> > mRegisterThread;
     ReplicaControlPtr mReplicaControl;
+    ComponentServicePtr mComponentService;
+
+    void initialize();
+    void setCategory(const ServiceManagementPrx& serviceManagement, const std::string& category);
+    void registerWithServiceLocator();
 };
 
-BridgingApp::BridgingApp()
-{
-}
 
-void BridgingApp::start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq&)
+/**
+ * This class provides implementation for the ComponentService interface.
+ * Every Asterisk SCF component is expected to expose the ComponentService interface.
+ */
+class ComponentServiceImpl : public ComponentService
 {
-    Logger logger = getLoggerFactory().getLogger("AsteriskSCF.BridgeService");
-    logger(Debug) << "Launching AsteriskSCF Session-Oriented Bridging Service." ;
-
-    //
-    // It is standard practice to base the adapter name on the configured
-    // service instance name.
-    //
-    std::string adapterName;
-    if (name.size() == 0)
-    {
-        adapterName = "BridgeService";
-    }
-    else
+public:
+    ComponentServiceImpl(BridgingApp &app) :
+        mApp(app)
     {
-        adapterName = name + ".BridgeService";
     }
 
-    //
-    // Check on the threadpool properties, make sure that they are compatible with the requirements of this 
-    // service. This could be moved into a helper method, but it is somehow more clear for seeing what
-    // is going on during initialization to leave it here.
-    //
-    // TODO: Are there any other properties that need to be double-checked before proceeding?
-    //
-    Ice::Int defaultPoolSize = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0);
-    if (communicator->getProperties()->getPropertyAsIntWithDefault(adapterName + ".ThreadPool.Size", 0) < 4)
+public: // Overrides of the ComponentService interface.
+    void suspend(const Ice::Current&)
     {
-        if (defaultPoolSize < 4)
-        {
-            logger(Info) << "Configured thread pool size for " << adapterName + " is too small, defaulting to 4";
-            communicator->getProperties()->setProperty(adapterName + ".ThreadPool.Size", "4");
-        }
+        mApp.suspend();
     }
-    if (communicator->getProperties()->getPropertyAsIntWithDefault(adapterName + "Internal.ThreadPool.Size", 0) < 4)
+
+    void resume(const Ice::Current&)
     {
-        if (defaultPoolSize < 4)
-        {
-            logger(Info) << "Configured thread pool size for " << adapterName + "Internal is too small, defaulting to 4";
-            communicator->getProperties()->setProperty(adapterName + "Internal.ThreadPool.Size", "4");
-        }
+        mApp.resume();
     }
-    defaultPoolSize = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.ThreadPool.Client.Size", 0);
-    if (defaultPoolSize < 4)
+
+    void shutdown(const Ice::Current&)
     {
-        logger(Warning) << "Client thread pool size is too small. It should be set to 4 or greater";
+        mApp.stop();
     }
 
-    
-    //
-    // TODO: All adapter ids should be globally unique. This would allow replicas to be identified.
-    // How this might be useful is that it might be used as a replicated state item to identify
-    // which adapter is currently the primary in a group of replicas.
-    //
-    mAdapter = communicator->createObjectAdapterWithEndpoints(adapterName, 
-        communicator->getProperties()->getPropertyWithDefault(adapterName + ".Endpoints", "default"));
+private:
+    BridgingApp& mApp;
+};
 
-    //
-    // We do not activate the main object adapter until most everything is initialized. The infrastructure
-    // adapter is for internally accessed objects or for supporting things that will be externally
-    // accessible until later so activating it now is fine.
-    //
-    mInfrastructureAdapter = communicator->createObjectAdapterWithEndpoints(adapterName + "Internal",
-        communicator->getProperties()->getPropertyWithDefault(adapterName + "Internal.Endpoints", "default"));
-    mInfrastructureAdapter->activate();
+static const std::string ComponentServiceId("BridgeComponent");
 
-    //
-    // Configure the AsteriskSCF logger.
-    // TODO: check whether this works right if we've already created the logger object.
-    //
-    ConfiguredIceLoggerPtr iceLogger = createIceLogger(mAdapter);
-    if (iceLogger)
-    {
-        getLoggerFactory().setLogOutput(iceLogger->getLogger());
-    }
+BridgingApp::BridgingApp() : mInitialized(false), mRunning(false)
+{
+}
 
-    //
-    // While this property is checked early in this method, it is not used until later on.
-    // This is to avoid several initialization steps if the final steps of initialization
-    // cannot be performed.
-    //
-    std::string serviceLocatorManagementProperty = communicator->getProperties()->getProperty("ServiceLocatorManagementProxy");
-    if (serviceLocatorManagementProperty.empty())
-    {
-        throw IceBox::FailureException(__FILE__, __LINE__, 
-            "Configuration error: Unable to locate property `ServiceLocatorManagementProxy'");
-    }
 
-    string locatorPropertyString = communicator->getProperties()->getProperty("LocatorService.Proxy");
-    if (locatorPropertyString.empty())
-    {
-        throw IceBox::FailureException(__FILE__, __LINE__,
-            "Configuration error: Unable to locate property `LocatorService.Proxy`");
-    }
-    
-    ServiceLocatorPrx locator = ServiceLocatorPrx::checkedCast(communicator->stringToProxy(locatorPropertyString));
-       
-    BridgeStateReplicatorParamsPtr searchParams = new BridgeStateReplicatorParams;
-    searchParams->category = StateReplicatorDiscoveryCategory;
-    searchParams->name = communicator->getProperties()->getPropertyWithDefault("Bridge.StateReplicatorName", "default");
-  
-    ReplicatorSmartPrx replicator;
-    try
-    {
-        replicator = ReplicatorSmartPrx(locator, searchParams, logger);
-    }
-    catch (const std::exception& ex)
-    {
-        logger(Error) << "Bridge state replicator lookup failed. Continuing without replication. " << ex.what();
-    }
-   
-    std::string managerName = 
-        communicator->getProperties()->getPropertyWithDefault(name + ".ManagerId", "BridgeManager");
+BridgingApp::~BridgingApp()
+{
+    mComponentService = 0;
+}
 
-    //
-    // It's very important that uncheckedCast's be used here as there are no guarantees
-    // that the object adapter is activated yet. If it is not, then this can hang.
-    //
-    BridgeManagerServantPtr manager = createBridgeManager(mAdapter, managerName, replicator, logger);
-    BridgeManagerPrx bridgeManagerPrx = BridgeManagerPrx::uncheckedCast(mAdapter->add(manager, 
-          mAdapter->getCommunicator()->stringToIdentity(managerName)));
-    assert(bridgeManagerPrx != 0);
-    if (bridgeManagerPrx == 0)
-    {
-        throw IceBox::FailureException(__FILE__, __LINE__, "Unable to instantiate bridge manager object");
-    }
 
-    //
-    // Configure replication connections.
-    //
-    ReplicatorListenerPtr replicaListener = createStateListener(logger, manager);
-    ReplicatorListenerPrx listenerPrx = ReplicatorListenerPrx::uncheckedCast(mInfrastructureAdapter->addWithUUID(replicaListener));
-
-    string replicaId = 
-        mAdapter->getCommunicator()->getProperties()->getPropertyWithDefault(
-            adapterName + ".ReplicaId", "BridgeReplica");
-    mReplicaControl = new ReplicaControl(mInfrastructureAdapter, manager, replicaId);
-    ReplicaPrx replicaControlPrx =
-        ReplicaPrx::uncheckedCast(mInfrastructureAdapter->add(mReplicaControl, communicator->stringToIdentity(replicaId)));
-
-    bool onStandby = false;
-    if (replicator)
-    {
-        onStandby = communicator->getProperties()->getPropertyWithDefault(name + ".StateReplicatorListener", "no") == "yes";
-    }
-    if (onStandby)
-    {
-        replicator->addListener(listenerPrx);
-        replicaControlPrx->standby();
-    }
-    else
-    {
-        manager->activate();
-    }
+void BridgingApp::start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq&)
+{
+    lg(Debug) << "Launching AsteriskSCF Session-Oriented Bridging Service." ;
 
-    bool registered = false;
-    try
-    {
-        ServiceLocatorParamsPtr parameters(new ServiceLocatorParams);
-        parameters->category = BridgeServiceDiscoveryCategory;
-        mLocator = 
-            new LocatorRegistrationWrapper<BridgeManagerPrx>(communicator, serviceLocatorManagementProperty, bridgeManagerPrx, 
-               adapterName, parameters);
-        registered = mLocator->registerService();
-    }
-    catch (const Ice::Exception&)
-    {
-    }
-    if (!registered)
+    mCommunicator = communicator;
+    mAppName = name;
+
+    if (!mInitialized)
     {
-        mRegisterThread = new RegisterThread<BridgeManagerPrx>(mLocator);
-        mRegisterThread->start();
+        initialize();
     }
+    registerWithServiceLocator();
+    mRunning = true;
     //
     // TODO: We need to know whether or not to activate!
     //
     mAdapter->activate();
 }
 
+
 void BridgingApp::stop()
 {
     if (mRegisterThread)
@@ -306,6 +213,7 @@ void BridgingApp::stop()
     }
     try
     {
+        mComponentServiceManagement->unregister();
         mLocator->unregister();
     }
     catch (const Ice::Exception&)
@@ -323,7 +231,234 @@ void BridgingApp::stop()
     {
         // TODO: log
     }
+    mRunning = false;
 }
+
+
+void BridgingApp::suspend()
+{
+    stop();
+}
+
+
+void BridgingApp::resume()
+{
+    if (!mRunning)
+    {
+        mAdapter->activate();
+        registerWithServiceLocator();
+    }
+    mRunning = true;
+}
+
+
+/**
+ * Helper function to add some parameters to one of our registered interfaces in the ServiceLocator, so that
+ * other components can look up our interfaces.
+ */
+void BridgingApp::setCategory(const ServiceManagementPrx& serviceManagement, const std::string& category)
+{
+    // Add category as a parameter to enable other components look this component up.
+    ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams;
+    genericparams->category = category;
+    serviceManagement->addLocatorParams(genericparams, "");
+}
+
+
+void BridgingApp::initialize()
+{
+    if (!mInitialized)
+    {
+        //
+        // It is standard practice to base the adapter name on the configured
+        // service instance name.
+        //
+        if (mAppName.size() == 0)
+        {
+            mAdapterName = "BridgeService";
+        }
+        else
+        {
+            mAdapterName = mAppName + ".BridgeService";
+        }
+        //
+        // Check on the threadpool properties, make sure that they are compatible with the requirements of this 
+        // service. This could be moved into a helper method, but it is somehow more clear for seeing what
+        // is going on during initialization to leave it here.
+        //
+        // TODO: Are there any other properties that need to be double-checked before proceeding?
+        //
+        Ice::Int defaultPoolSize = mCommunicator->getProperties()->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0);
+        if (mCommunicator->getProperties()->getPropertyAsIntWithDefault(mAdapterName + ".ThreadPool.Size", 0) < 4)
+        {
+            if (defaultPoolSize < 4)
+            {
+                lg(Info) << "Configured thread pool size for " << mAdapterName + " is too small, defaulting to 4";
+                mCommunicator->getProperties()->setProperty(mAdapterName + ".ThreadPool.Size", "4");
+            }
+        }
+        if (mCommunicator->getProperties()->getPropertyAsIntWithDefault(mAdapterName + "Internal.ThreadPool.Size", 0) < 4)
+        {
+            if (defaultPoolSize < 4)
+            {
+                lg(Info) << "Configured thread pool size for " << mAdapterName + "Internal is too small, defaulting to 4";
+                mCommunicator->getProperties()->setProperty(mAdapterName + "Internal.ThreadPool.Size", "4");
+            }
+        }
+        defaultPoolSize = mCommunicator->getProperties()->getPropertyAsIntWithDefault("Ice.ThreadPool.Client.Size", 0);
+        if (defaultPoolSize < 4)
+        {
+            lg(Warning) << "Client thread pool size is too small. It should be set to 4 or greater";
+        }
+
+        
+        //
+        // TODO: All adapter ids should be globally unique. This would allow replicas to be identified.
+        // How this might be useful is that it might be used as a replicated state item to identify
+        // which adapter is currently the primary in a group of replicas.
+        //
+        mAdapter = mCommunicator->createObjectAdapterWithEndpoints(mAdapterName, 
+            mCommunicator->getProperties()->getPropertyWithDefault(mAdapterName + ".Endpoints", "default"));
+        //
+        // We do not activate the main object adapter until most everything is initialized. The infrastructure
+        // adapter is for internally accessed objects or for supporting things that will be externally
+        // accessible until later so activating it now is fine.
+        //
+        mInfrastructureAdapter = mCommunicator->createObjectAdapterWithEndpoints(mAdapterName + "Internal",
+            mCommunicator->getProperties()->getPropertyWithDefault(mAdapterName + "Internal.Endpoints", "default"));
+        mInfrastructureAdapter->activate();
+
+        //
+        // Configure the AsteriskSCF lg.
+        // TODO: check whether this works right if we've already created the lg object.
+        //
+        ConfiguredIceLoggerPtr iceLogger = createIceLogger(mAdapter);
+        if (iceLogger)
+        {
+            getLoggerFactory().setLogOutput(iceLogger->getLogger());
+        }
+
+        mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("LocatorServiceManagement.Proxy"));
+
+        if (mServiceLocatorManagement == 0)
+        {
+            lg(Error) << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. This component can't be found until this is corrected.";
+            return;
+        }
+
+        //
+        // While this property is checked early in this method, it is not used until later on.
+        // This is to avoid several initialization steps if the final steps of initialization
+        // cannot be performed.
+        //
+        mServiceLocatorManagementProperty = mCommunicator->getProperties()->getProperty("ServiceLocatorManagementProxy");
+        if (mServiceLocatorManagementProperty.empty())
+        {
+            throw IceBox::FailureException(__FILE__, __LINE__, 
+                "Configuration error: Unable to locate property `ServiceLocatorManagementProxy'");
+        }
+
+        std::string locatorPropertyString = mCommunicator->getProperties()->getProperty("LocatorService.Proxy");
+        if (locatorPropertyString.empty())
+        {
+            throw IceBox::FailureException(__FILE__, __LINE__,
+                "Configuration error: Unable to locate property `LocatorService.Proxy`");
+        }
+        
+        mSLocator = ServiceLocatorPrx::checkedCast(mCommunicator->stringToProxy(locatorPropertyString));
+
+        // Register the ComponentService interface with the Service Locator.
+        Ice::ObjectPrx componentServiceObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(ComponentServiceId));
+        ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
+        std::string componentServiceGuid("BridgeService"); 
+        mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
+
+        setCategory(mComponentServiceManagement,AsteriskSCF::SessionCommunications::V1::BridgeServiceDiscoveryCategory);
+           
+        BridgeStateReplicatorParamsPtr searchParams = new BridgeStateReplicatorParams;
+        searchParams->category = StateReplicatorDiscoveryCategory;
+        searchParams->name = mCommunicator->getProperties()->getPropertyWithDefault("Bridge.StateReplicatorName", "default");
+      
+        ReplicatorSmartPrx replicator;
+        try
+        {
+            replicator = ReplicatorSmartPrx(mSLocator, searchParams, lg);
+        }
+        catch (const std::exception& ex)
+        {
+            lg(Error) << "Bridge state replicator lookup failed. Continuing without replication. " << ex.what();
+        }
+       
+        std::string managerName = 
+            mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".ManagerId", "BridgeManager");
+
+        //
+        // It's very important that uncheckedCast's be used here as there are no guarantees
+        // that the object adapter is activated yet. If it is not, then this can hang.
+        //
+        BridgeManagerServantPtr manager = createBridgeManager(mAdapter, managerName, replicator, lg);
+        mBridgeManagerPrx = BridgeManagerPrx::uncheckedCast(mAdapter->add(manager,mAdapter->getCommunicator()->stringToIdentity(managerName)));
+        assert(mBridgeManagerPrx != 0);
+        if (mBridgeManagerPrx == 0)
+        {
+            throw IceBox::FailureException(__FILE__, __LINE__, "Unable to instantiate bridge manager object");
+        }
+
+        //
+        // Configure replication connections.
+        //
+        ReplicatorListenerPtr replicaListener = createStateListener(lg, manager);
+        ReplicatorListenerPrx listenerPrx = ReplicatorListenerPrx::uncheckedCast(mInfrastructureAdapter->addWithUUID(replicaListener));
+
+        string replicaId = 
+            mAdapter->getCommunicator()->getProperties()->getPropertyWithDefault(
+                mAdapterName + ".ReplicaId", "BridgeReplica");
+        mReplicaControl = new ReplicaControl(mInfrastructureAdapter, manager, replicaId);
+        ReplicaPrx replicaControlPrx =
+            ReplicaPrx::uncheckedCast(mInfrastructureAdapter->add(mReplicaControl, mCommunicator->stringToIdentity(replicaId)));
+
+        bool onStandby = false;
+        if (replicator)
+        {
+            onStandby = mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".StateReplicatorListener", "no") == "yes";
+        }
+        if (onStandby)
+        {
+            replicator->addListener(listenerPrx);
+            replicaControlPrx->standby();
+        }
+        else
+        {
+            manager->activate();
+        }
+        mInitialized = true;
+    }
+}
+
+
+void BridgingApp::registerWithServiceLocator()
+{
+    bool registered = false;
+
+    try
+    {
+        ServiceLocatorParamsPtr parameters(new ServiceLocatorParams);
+        parameters->category = BridgeServiceDiscoveryCategory;
+        mLocator = 
+            new LocatorRegistrationWrapper<BridgeManagerPrx>(mCommunicator, mServiceLocatorManagementProperty, mBridgeManagerPrx, 
+               mAdapterName, parameters);
+        registered = mLocator->registerService();
+    }
+    catch (const Ice::Exception&)
+    {
+    }
+    if (!registered)
+    {
+        mRegisterThread = new RegisterThread<BridgeManagerPrx>(mLocator);
+        mRegisterThread->start();
+    }
+}
+
 }
 
 extern "C" {

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list