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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Oct 11 07:03:11 CDT 2010


branch "master" has been updated
       via  ff2a953a1b3fe8a3ef15397934aaee940ce6ecaf (commit)
      from  fbf8a2c4ebcf7622cede76d899e47933a5c3e876 (commit)

Summary of changes:
 logger                           |    2 +-
 slice                            |    2 +-
 src/CollocatedIceStorm.cpp       |    5 +
 src/CollocatedIceStorm.h         |    6 +
 src/ServiceLocator.cpp           |  202 ++++++-----
 src/ServiceLocatorManagement.cpp |  219 ++++++-----
 src/ServiceLocatorManagement.h   |   39 ++-
 src/ServiceManagement.cpp        |  308 ++++++++-------
 src/ServiceManagement.h          |   42 ++-
 test/TestServiceLocator.cpp      |  780 +++++++++++++++++++++-----------------
 10 files changed, 884 insertions(+), 721 deletions(-)


- Log -----------------------------------------------------------------
commit ff2a953a1b3fe8a3ef15397934aaee940ce6ecaf
Author: Brent Eagles <beagles at digium.com>
Date:   Mon Oct 11 09:27:35 2010 -0230

    Style updates.

diff --git a/logger b/logger
index 0cc0c02..a867306 160000
--- a/logger
+++ b/logger
@@ -1 +1 @@
-Subproject commit 0cc0c02a16e404b94d54c8cb6736dee14a671352
+Subproject commit a867306cbc5dce5b0cd899094b3215921f0263d3
diff --git a/slice b/slice
index 0c62939..03ea08a 160000
--- a/slice
+++ b/slice
@@ -1 +1 @@
-Subproject commit 0c629393e2f05dc0ed43bcc6305880949df36289
+Subproject commit 03ea08a0f749b5f36ae4dc36d25493689f9e273c
diff --git a/src/CollocatedIceStorm.cpp b/src/CollocatedIceStorm.cpp
index a16198c..5146df8 100644
--- a/src/CollocatedIceStorm.cpp
+++ b/src/CollocatedIceStorm.cpp
@@ -11,6 +11,8 @@
 #include <algorithm>
 #include "CollocatedIceStorm.h"
 
+using namespace AsteriskSCF::ServiceDiscovery;
+
 //
 // The idea behind this class is that it needs to access the entry point that IceBox would
 // have used and then invoke the methods that are needed to start and stop the IceStorm
@@ -50,6 +52,7 @@ CollocatedIceStorm::~CollocatedIceStorm()
         try
         {
             stop();
+            mCommunicator->destroy();
         }
         catch(...)
         {
@@ -69,6 +72,8 @@ void CollocatedIceStorm::stop()
         {
             mService->stop();
         }
+        mCommunicator->shutdown();
+        mCommunicator->waitForShutdown();
         mStopped = true;
     }
 }
diff --git a/src/CollocatedIceStorm.h b/src/CollocatedIceStorm.h
index b276497..ccd05eb 100644
--- a/src/CollocatedIceStorm.h
+++ b/src/CollocatedIceStorm.h
@@ -14,6 +14,10 @@
 #include <IceStorm/IceStorm.h>
 #include <string>
 
+namespace AsteriskSCF
+{
+namespace ServiceDiscovery
+{
 /**
  * A helper class that instantiates IceStorm in-process, removing the need to launch
  * a separate process to access IceStorm services. 
@@ -42,4 +46,6 @@ private:
 
 typedef IceUtil::Handle<CollocatedIceStorm> CollocatedIceStormPtr;
 
+} /* end of ServiceDiscovery */
+} /* end of AsteriskSCF */
 
diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 113264b..8697581 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -23,11 +23,11 @@ using namespace std;
 using namespace AsteriskSCF::System::Discovery;
 using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::ServiceDiscovery;
 
 namespace
 {
    Logger const &lg = getLoggerFactory().getLogger("AsteriskSCF.System.Discovery");
-}
 
 /**
  * Implementation of the Ice::Application class
@@ -35,16 +35,16 @@ namespace
 class ServiceLocatorApp : public IceBox::Service
 {
 public:
-   void start(const string& name,
+    void start(const string& name,
       const Ice::CommunicatorPtr& communicator,
       const Ice::StringSeq& args);
-   void stop();
+    void stop();
 
 private:
-   Ice::ObjectAdapterPtr discovery_adapter;
-   Ice::ObjectAdapterPtr management_adapter;
-   Ice::ObjectAdapterPtr logger_adapter;
-   CollocatedIceStormPtr mIceStorm;
+    Ice::ObjectAdapterPtr mDiscoveryAdapter;
+    Ice::ObjectAdapterPtr mManagementAdapter;
+    Ice::ObjectAdapterPtr mLoggerAdapter;
+    AsteriskSCF::ServiceDiscovery::CollocatedIceStormPtr mIceStorm;
 };
 
 /**
@@ -53,28 +53,30 @@ private:
 class ServiceLocatorImpl : public ServiceLocator
 {
 public:
-   ServiceLocatorImpl(ServiceLocatorManagementImpl* LocatorServiceManagement) : 
-      mLocatorServiceManagement(LocatorServiceManagement) { };
-   Ice::ObjectPrx locate(const ServiceLocatorParamsPtr&, const Ice::Current&);
-   Ice::ObjectProxySeq locateAll(const ServiceLocatorParamsPtr&, const Ice::Current&);
+    ServiceLocatorImpl(ServiceLocatorManagementImpl* LocatorServiceManagement) : 
+        mLocatorServiceManagement(LocatorServiceManagement) { };
+    Ice::ObjectPrx locate(const ServiceLocatorParamsPtr&, const Ice::Current&);
+    Ice::ObjectProxySeq locateAll(const ServiceLocatorParamsPtr&, const Ice::Current&);
 private:
-   /**
-    * A pointer to the ServiceManagement implementation as that is where everything is
-    * actually stored. Our ServiceLocator implementation simply acts as a read-only
-    *  frontend to it.
-    */
-   ServiceLocatorManagementImpl* mLocatorServiceManagement;
+    /**
+     * A pointer to the ServiceManagement implementation as that is where everything is
+     * actually stored. Our ServiceLocator implementation simply acts as a read-only
+     *  frontend to it.
+     */
+    ServiceLocatorManagementImpl* mLocatorServiceManagement;
 };
 
+}
+
 /**
  * Implementation of the locate method as defined in service_locator.ice
  */
 Ice::ObjectPrx ServiceLocatorImpl::locate(const ServiceLocatorParamsPtr& params,
    const Ice::Current&)
 {
-   /* This API call forwards into the management implementation, it is separated to 
-    * provide a level of security. */
-   return mLocatorServiceManagement->locate(params);
+    /* This API call forwards into the management implementation, it is separated to 
+     * provide a level of security. */
+    return mLocatorServiceManagement->locate(params);
 }
 
 /**
@@ -83,111 +85,121 @@ Ice::ObjectPrx ServiceLocatorImpl::locate(const ServiceLocatorParamsPtr& params,
 Ice::ObjectProxySeq ServiceLocatorImpl::locateAll(const ServiceLocatorParamsPtr& params,
    const Ice::Current&)
 {
-   /* This API call forwards into the management implementation, it is separated to
-    * provide a level of security. */
-   return mLocatorServiceManagement->locateAll(params);
+    /* This API call forwards into the management implementation, it is separated to
+     * provide a level of security. */
+    return mLocatorServiceManagement->locateAll(params);
 }
 
-void ServiceLocatorApp::start(
-    const string& name,
-    const Ice::CommunicatorPtr& communicator,
+void ServiceLocatorApp::start(const string& name, const Ice::CommunicatorPtr& communicator,
     const Ice::StringSeq& args)
 {
-   mIceStorm = new CollocatedIceStorm("HydraIceStorm", communicator->getProperties());
+    mIceStorm = new AsteriskSCF::ServiceDiscovery::CollocatedIceStorm("HydraIceStorm", communicator->getProperties());
 
-   lg(Info) << "Initializing service discovery component";
+    lg(Info) << "Initializing service discovery component";
 
-   /* Talk to the topic manager to either create or get the service discovery topic,
-    * configured or default */
-   IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(
+    /* Talk to the topic manager to either create or get the service discovery topic,
+     * configured or default */
+    IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(
       communicator->propertyToProxy("TopicManager.Proxy"));
 
-   EventsPrx service_discovery_topic;
-
-   if (topicManager)
-   {
-      Ice::PropertiesPtr props = communicator->getProperties();
-      string topicName = props->getProperty("ServiceLocator.TopicName");
-
-      if (topicName.empty())
-      {
-         topicName = TOPIC;
-      }
-
-      IceStorm::TopicPrx topic;
-      try
-      {
-         topic = topicManager->retrieve(topicName);
-      }
-      catch (const IceStorm::NoSuchTopic&)
-      {
-         try
-         {
-            topic = topicManager->create(topicName);
-         }
-         catch (const IceStorm::TopicExists&)
-         {
-            lg(Error) << "Oh snap! Race condition creating topic, aborting";
-            return;
-         }
-         lg(Info) << "Created service discovery event topic";
-      }
-
-      service_discovery_topic = EventsPrx::uncheckedCast(topic->getPublisher());
-   }
-   else
-   {
-      lg(Info) << "IceStorm topic manager proxy not present, events disabled.";
-   }
-
-   /* Management and discovery use separate adapters to provide a level of security,
-    * management may want to be protected so arbitrary people can't inject bad services
-    * into the infrastructure while discovery as a read only function may be allowed to all.
-    */
-    management_adapter= communicator->createObjectAdapter(
+    EventsPrx serviceDiscoveryTopic;
+
+    if (topicManager)
+    {
+        Ice::PropertiesPtr props = communicator->getProperties();
+        string topicName = props->getProperty("ServiceLocator.TopicName");
+
+        if (topicName.empty())
+        {
+            topicName = TOPIC;
+        }
+
+        IceStorm::TopicPrx topic;
+        try
+        {
+            topic = topicManager->retrieve(topicName);
+        }
+        catch (const IceStorm::NoSuchTopic&)
+        {
+            try
+            {
+                topic = topicManager->create(topicName);
+            }
+            catch (const IceStorm::TopicExists&)
+            {
+                lg(Error) << "Oh snap! Race condition creating topic, aborting";
+                return;
+            }
+            lg(Info) << "Created service discovery event topic";
+        }
+
+        serviceDiscoveryTopic = EventsPrx::uncheckedCast(topic->getPublisher());
+    }
+    else
+    {
+        lg(Info) << "IceStorm topic manager proxy not present, events disabled.";
+    }
+
+    /* Management and discovery use separate adapters to provide a level of security,
+     * management may want to be protected so arbitrary people can't inject bad services
+     * into the infrastructure while discovery as a read only function may be allowed to all.
+     */
+    mManagementAdapter= communicator->createObjectAdapter(
       "ServiceLocatorManagementAdapter");
 
-   ServiceLocatorManagementImpl* LocatorServiceManagement =
-      new ServiceLocatorManagementImpl(management_adapter, service_discovery_topic);
+    ServiceLocatorManagementImpl* locatorServiceManagement =
+        new ServiceLocatorManagementImpl(mManagementAdapter, serviceDiscoveryTopic);
 
-   management_adapter->add(LocatorServiceManagement,
+    mManagementAdapter->add(locatorServiceManagement,
       communicator->stringToIdentity("LocatorServiceManagement"));
 
-   management_adapter->activate();
+    mManagementAdapter->activate();
 
-   lg(Info) << "Activated service discovery management.";
+    lg(Info) << "Activated service discovery management.";
 
-   discovery_adapter = communicator->createObjectAdapter("ServiceLocatorAdapter");
+    mDiscoveryAdapter = communicator->createObjectAdapter("ServiceLocatorAdapter");
 
-   ServiceLocatorPtr LocatorService = new ServiceLocatorImpl(LocatorServiceManagement);
+    ServiceLocatorPtr locatorService = new ServiceLocatorImpl(locatorServiceManagement);
 
-   discovery_adapter->add(LocatorService, communicator->stringToIdentity("LocatorService"));
+    mDiscoveryAdapter->add(locatorService, communicator->stringToIdentity("LocatorService"));
 
-   discovery_adapter->activate();
+    mDiscoveryAdapter->activate();
 
-   logger_adapter = communicator->createObjectAdapter("LoggerAdapter");
+    mLoggerAdapter = communicator->createObjectAdapter("LoggerAdapter");
 
-   ConfiguredIceLoggerPtr mIceLogger = createIceLogger(logger_adapter);
+    ConfiguredIceLoggerPtr mIceLogger = createIceLogger(mLoggerAdapter);
 
-   getLoggerFactory().setLogOutput(mIceLogger->getLogger());
+    getLoggerFactory().setLogOutput(mIceLogger->getLogger());
 
-   logger_adapter->activate();
+    mLoggerAdapter->activate();
 
-   lg(Info) << "Activated service discovery.";
+    lg(Info) << "Activated service discovery.";
 
-   lg(Info) << "Waiting for requests.";
+    lg(Info) << "Waiting for requests.";
 }
 
 void ServiceLocatorApp::stop()
 {
-   discovery_adapter->deactivate();
-   mIceStorm->stop();
+    //
+    // TODO: determine if this is a shared communicator or not. If it is, then we cannot destroy it.
+    //
+    try
+    {
+        Ice::CommunicatorPtr communicator = mDiscoveryAdapter->getCommunicator();
+        communicator->shutdown();
+        communicator->waitForShutdown();
+        communicator->destroy();
+    }
+    catch(...)
+    {
+    }
+    mIceStorm->stop();
 }
 
 extern "C"
 {
-   HYDRA_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr communicator)
-   {
-      return new ServiceLocatorApp;
-   }
+    HYDRA_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr communicator)
+    {
+        return new ServiceLocatorApp;
+    }
 }
diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index 3d33c65..c68224f 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -25,40 +25,47 @@ using namespace AsteriskSCF::Core::Discovery::V1;
 
 namespace
 {
-   Logger const &lg = getLoggerFactory().getLogger("AsteriskSCF.System.Discovery");
+Logger const &lg = getLoggerFactory().getLogger("AsteriskSCF.System.Discovery");
 }
 
+namespace AsteriskSCF
+{
+namespace ServiceDiscovery
+{
+
 /**
  * Small internal class which is used to store information about a comparator.
  */
 class ServiceLocatorComparator
 {
 public:
-   /**
-    * Constructor for the ServiceLocatorComparator class.
-    *
-    * @param compare A proxy to the comparator service we are wrapping.
-    */
-   ServiceLocatorComparator(const ServiceLocatorParamsComparePrx& compare) :
-      mCompare(compare) { }
-
-   /**
-    * API call which forwards an isSupported over ICE to a remote comparator.
-    *
-    * @param params Service locator parameters that describe a locator request.
-    *
-    * @return A boolean value with true indicating the parameters are supported while
-    *         false indicates otherwise.
-    */
-   bool isSupported(const ServiceLocatorParamsPtr& params)
-   {
-      return mCompare->isSupported(params);
-   }
+    /**
+     * Constructor for the ServiceLocatorComparator class.
+     *
+     * @param compare A proxy to the comparator service we are wrapping.
+     */
+    ServiceLocatorComparator(const ServiceLocatorParamsComparePrx& compare) :
+        mCompare(compare) 
+    { 
+    }
+
+    /**
+     * API call which forwards an isSupported over ICE to a remote comparator.
+     *
+     * @param params Service locator parameters that describe a locator request.
+     *
+     * @return A boolean value with true indicating the parameters are supported while
+     *         false indicates otherwise.
+     */
+    bool isSupported(const ServiceLocatorParamsPtr& params)
+    {
+        return mCompare->isSupported(params);
+    }
 private:
-   /**
-    * A proxy to the comparator service that we are wrapping.
-    */
-   ServiceLocatorParamsComparePrx mCompare;
+    /**
+     * A proxy to the comparator service that we are wrapping.
+     */
+    ServiceLocatorParamsComparePrx mCompare;
 };
 
 /**
@@ -68,43 +75,49 @@ private:
 class ServiceLocatorManagementImplPriv : public Ice::Object
 {
 public:
-   ServiceLocatorManagementImplPriv(Ice::ObjectAdapterPtr adapter, 
-      const EventsPrx& service_discovery_topic) :
-      mAdapter(adapter), mLocatorTopic(service_discovery_topic) { };
-   /**
-    * Shared mutex lock which protects the services and comparators.
-    */
-   boost::shared_mutex mLock;
-
-   /**
-    * Object adapter that our service management proxies originate from, it is houses the
-    * main management service.
-    */
-   Ice::ObjectAdapterPtr mAdapter;
-
-   /**
-    * A map of all the comparators that have been added by external components. The key
-    * is the unique identifier that they add themselves with.
-    */
-   std::map<std::string, ServiceLocatorComparator> mCompares;
-
-   /**
-    * A vector of all the services that have been added.
-    */
-   std::vector<ServiceManagementImplPtr> mServices;
-
-   /**
-    * A proxy that can be used to publish locator events.
-    */
-   AsteriskSCF::System::Discovery::EventsPrx mLocatorTopic;
+    ServiceLocatorManagementImplPriv(const Ice::ObjectAdapterPtr& adapter, const EventsPrx& serviceDiscoveryTopic) :
+        mAdapter(adapter), mLocatorTopic(serviceDiscoveryTopic) 
+    { 
+    };
+
+    /**
+     * Shared mutex lock which protects the services and comparators.
+     */
+    boost::shared_mutex mLock;
+
+    /**
+     * Object adapter that our service management proxies originate from, it is houses the
+     * main management service.
+     */
+    Ice::ObjectAdapterPtr mAdapter;
+
+    /**
+     * A map of all the comparators that have been added by external components. The key
+     * is the unique identifier that they add themselves with.
+     */
+    std::map<std::string, ServiceLocatorComparator> mCompares;
+
+    /**
+     * A vector of all the services that have been added.
+     */
+    std::vector<ServiceManagementImplPtr> mServices;
+
+    /**
+     * A proxy that can be used to publish locator events.
+     */
+    AsteriskSCF::System::Discovery::EventsPrx mLocatorTopic;
 };
+} /* end of ServiceDiscovery */
+} /* end of AsteriskSCF */
+
+using namespace AsteriskSCF::ServiceDiscovery;
 
 /**
  * Implementation of a constructor for the ServiceLocatorManagementImpl class.
  */
-ServiceLocatorManagementImpl::ServiceLocatorManagementImpl(Ice::ObjectAdapterPtr adapter, 
-   const EventsPrx& service_discovery_topic) :
-   mImpl(new ServiceLocatorManagementImplPriv(adapter, service_discovery_topic))
+ServiceLocatorManagementImpl::ServiceLocatorManagementImpl(const Ice::ObjectAdapterPtr& adapter, 
+   const EventsPrx& serviceDiscoveryTopic) :
+   mImpl(new ServiceLocatorManagementImplPriv(adapter, serviceDiscoveryTopic))
 {
 }
 
@@ -113,17 +126,17 @@ ServiceLocatorManagementImpl::ServiceLocatorManagementImpl(Ice::ObjectAdapterPtr
  */
 Ice::ObjectPrx ServiceLocatorManagementImpl::locate(const ServiceLocatorParamsPtr& params)
 {
-   boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
+    boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
 
-   for (vector<ServiceManagementImplPtr>::iterator service = mImpl->mServices.begin(); service != mImpl->mServices.end(); ++service)
-   {
-      if ((*service)->isSupported(params) == true)
-      {
-         return (*service)->GetService();
-      }
-   }
+    for (vector<ServiceManagementImplPtr>::iterator service = mImpl->mServices.begin(); service != mImpl->mServices.end(); ++service)
+    {
+        if ((*service)->isSupported(params) == true)
+        {
+            return (*service)->getService();
+        }
+    }
 
-   throw ServiceNotFound();
+    throw ServiceNotFound();
 }
 
 /**
@@ -132,33 +145,32 @@ Ice::ObjectPrx ServiceLocatorManagementImpl::locate(const ServiceLocatorParamsPt
 Ice::ObjectProxySeq ServiceLocatorManagementImpl::locateAll(
    const ServiceLocatorParamsPtr& params)
 {
-   boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
-   Ice::ObjectProxySeq applicable_services;
-
-   for (vector<ServiceManagementImplPtr>::iterator service = mImpl->mServices.begin(); 
-        service != mImpl->mServices.end(); ++service)
-   {
-      if ((*service)->isSupported(params) == true)
-      {
-         applicable_services.push_back((*service)->GetService());
-      }
-   }
-
-   if (!applicable_services.empty())
-   {
-      return applicable_services;
-   }
-   else
-   {
-      throw ServiceNotFound();
-   }
+    boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
+    Ice::ObjectProxySeq applicableServices;
+
+    for (vector<ServiceManagementImplPtr>::iterator service = mImpl->mServices.begin(); 
+      service != mImpl->mServices.end(); ++service)
+    {
+        if ((*service)->isSupported(params) == true)
+        {
+            applicableServices.push_back((*service)->getService());
+        }
+    }
+
+    if (!applicableServices.empty())
+    {
+        return applicableServices;
+    }
+    else
+    {
+        throw ServiceNotFound();
+    }
 }
 
 /**
  * Implementation of the addService method as defined in service_locator.ice
  */
-ServiceManagementPrx ServiceLocatorManagementImpl::addService(
-   const Ice::ObjectPrx& service, const string& guid, const Ice::Current&)
+ServiceManagementPrx ServiceLocatorManagementImpl::addService(const Ice::ObjectPrx& service, const string& guid, const Ice::Current&)
 {
    lg(Info) << "addService " << guid << '.';
    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
@@ -167,7 +179,7 @@ ServiceManagementPrx ServiceLocatorManagementImpl::addService(
 
    mImpl->mServices.push_back(new_service);
 
-   return new_service->GetServiceManagementPrx();
+   return new_service->getServiceManagementPrx();
 }
 
 /**
@@ -177,13 +189,12 @@ void ServiceLocatorManagementImpl::addCompare(const string& guid,
    const ServiceLocatorParamsComparePrx& service, const Ice::Current&)
 {
    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
-   ServiceLocatorComparator new_comparator(service);
+   ServiceLocatorComparator newComparator(service);
 
-   pair<map<string, ServiceLocatorComparator>::iterator, bool> insert_pair;
-   insert_pair = mImpl->mCompares.insert(pair<string, ServiceLocatorComparator>(guid,
-      new_comparator));
+   pair<map<string, ServiceLocatorComparator>::iterator, bool> insertPair = mImpl->mCompares.insert(pair<string, ServiceLocatorComparator>(guid,
+      newComparator));
 
-   if (insert_pair.second == false)
+   if (insertPair.second == false)
    {
       throw DuplicateCompare();
    }
@@ -192,7 +203,7 @@ void ServiceLocatorManagementImpl::addCompare(const string& guid,
    {
       mImpl->mLocatorTopic->comparisonRegistered(guid);
    }
-};
+}
 
 /**
  * Implementation of the removeCompare method as defined in service_locator.ice
@@ -210,19 +221,19 @@ void ServiceLocatorManagementImpl::removeCompare(const string& guid, const Ice::
    {
       mImpl->mLocatorTopic->comparisonUnregistered(guid);
    }
-};
+}
 
 /**
  * Implementation of the isSupported method as defined in service_locator.ice
  */
-bool ServiceLocatorManagementImpl::isSupported(const string& compare_guid,
+bool ServiceLocatorManagementImpl::isSupported(const string& compareGuid,
    const ServiceLocatorParamsPtr& params)
 {
    /* You'll note there is no lock here. This is because we already have a lock in the locate or locateAll
     * functions.
     */
    map<string, ServiceLocatorComparator>::iterator comparator =
-      mImpl->mCompares.find(compare_guid);
+      mImpl->mCompares.find(compareGuid);
 
    if (comparator == mImpl->mCompares.end())
    {
@@ -235,7 +246,7 @@ bool ServiceLocatorManagementImpl::isSupported(const string& compare_guid,
    }
    catch (...)
    {
-      lg(Error) << "An exception was raised when attempting to contact comparator " << compare_guid << ".";
+      lg(Error) << "An exception was raised when attempting to contact comparator " << compareGuid << ".";
       return false;
    }
 }
@@ -243,17 +254,17 @@ bool ServiceLocatorManagementImpl::isSupported(const string& compare_guid,
 /**
  * Implementation of the removeService method as defined in service_locator.ice
  */
-void ServiceLocatorManagementImpl::removeService(ServiceManagementImplPtr service)
+void ServiceLocatorManagementImpl::removeService(const ServiceManagementImplPtr& service)
 {
    lg(Info) << "removeService " << service->getGuid() << '.';
    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
-   for (vector<ServiceManagementImplPtr>::iterator existing_service =
+   for (vector<ServiceManagementImplPtr>::iterator existingService =
         mImpl->mServices.begin();
-        existing_service != mImpl->mServices.end(); ++existing_service)
+        existingService != mImpl->mServices.end(); ++existingService)
    {
-      if ((*existing_service) == service)
+      if ((*existingService) == service)
       {
-         mImpl->mServices.erase(existing_service);
+         mImpl->mServices.erase(existingService);
          return;
       }
    }
diff --git a/src/ServiceLocatorManagement.h b/src/ServiceLocatorManagement.h
index 525bfc9..142c2cc 100644
--- a/src/ServiceLocatorManagement.h
+++ b/src/ServiceLocatorManagement.h
@@ -7,11 +7,13 @@
  */
 
 #pragma once
-#ifndef _SERVICELOCATORMANAGEMENT_H
-#define _SERVICELOCATORMANAGEMENT_H
 
 #include <boost/shared_ptr.hpp>
 
+namespace AsteriskSCF
+{
+namespace ServiceDiscovery
+{
 /**
  * Forward definition for the ServiceManagementImpl class. This gets used by the ServiceLocatorManagementImpl class.
  */
@@ -33,19 +35,26 @@ class ServiceLocatorManagementImplPriv;
 class ServiceLocatorManagementImpl : public AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagement
 {
 public:
-	ServiceLocatorManagementImpl(Ice::ObjectAdapterPtr adapter, const AsteriskSCF::System::Discovery::EventsPrx& service_discovery_topic);
-	Ice::ObjectPrx locate(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
-	Ice::ObjectProxySeq locateAll(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
-	AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx addService(const Ice::ObjectPrx&, const std::string&, const Ice::Current&);
-	void addCompare(const std::string&, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsComparePrx&, const Ice::Current&);
-	void removeCompare(const std::string&, const Ice::Current&);
-	bool isSupported(const std::string&, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
-	void removeService(ServiceManagementImplPtr);
+    ServiceLocatorManagementImpl(const Ice::ObjectAdapterPtr& adapter, 
+      const AsteriskSCF::System::Discovery::EventsPrx& serviceDiscoveryTopic);
+    Ice::ObjectPrx locate(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
+    Ice::ObjectProxySeq locateAll(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
+
+    //
+    // AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagement interface.
+    //
+    AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx addService(const Ice::ObjectPrx&, const std::string&, const Ice::Current&);
+    void addCompare(const std::string&, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsComparePrx&, const Ice::Current&);
+    void removeCompare(const std::string&, const Ice::Current&);
+
+    bool isSupported(const std::string&, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
+    void removeService(const ServiceManagementImplPtr&);
 private:
-	/**
-	 * Private implementation data for ServiceLocatorManagementImpl.
-	 */
-	boost::shared_ptr<ServiceLocatorManagementImplPriv> mImpl;
+    /**
+     * Private implementation data for ServiceLocatorManagementImpl.
+     */
+    boost::shared_ptr<ServiceLocatorManagementImplPriv> mImpl;
 };
 
-#endif
+} /* end of ServiceDiscovery */
+} /* end of AsteriskSCF */
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index c5eafb8..7b6c021 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -18,33 +18,45 @@
 #include "ServiceManagement.h"
 
 using namespace std;
-using namespace AsteriskSCF::System::Discovery;
 using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::ServiceDiscovery;
 
+namespace AsteriskSCF
+{
+namespace ServiceDiscovery
+{
 /**
  * Small internal class which is used to store information about supported parameters.
  */
-class ServiceLocatorParamsSpec {
+class ServiceLocatorParamsSpec 
+{
 public:
-	ServiceLocatorParamsSpec(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr& params, const std::string& compare_guid, ServiceLocatorManagementImpl* management)
-		: mParams(params), mCompareGuid(compare_guid), mManagement(management) { };
-	bool isSupported(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
+    ServiceLocatorParamsSpec(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr& params, const std::string& compareGuid, 
+      ServiceLocatorManagementImpl* management) : 
+        mParams(params), 
+        mCompareGuid(compareGuid), 
+        mManagement(management) 
+    { 
+    }
+
+    bool isSupported(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
+
 private:
-	/**
-	 * A pointer to a parameters structure which describes what is supported.
-	 */
-	AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr mParams;
-
-	/**
-	 * A string containing the comparator uuid that should be used when comparing the parameters
-	 * in a locator request to this class. If empty no comparator will be used.
-	 */
-	std::string mCompareGuid;
-
-	/**
-	 * A pointer to the service locator management implementation that instantiated this class.
-	 */
-	ServiceLocatorManagementImpl* mManagement;
+    /**
+     * A pointer to a parameters structure which describes what is supported.
+     */
+    AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr mParams;
+
+    /**
+     * A string containing the comparator uuid that should be used when comparing the parameters
+     * in a locator request to this class. If empty no comparator will be used.
+     */
+    std::string mCompareGuid;
+
+    /**
+     * A pointer to the service locator management implementation that instantiated this class.
+     */
+    ServiceLocatorManagementImpl* mManagement;
 };
 
 /**
@@ -53,71 +65,77 @@ private:
 class ServiceManagementImplPriv
 {
 public:
-	ServiceManagementImplPriv(ServiceManagementImpl* impl, ServiceLocatorManagementImpl* management, const Ice::ObjectPrx& service, Ice::ObjectAdapterPtr adapter,
-				  const EventsPrx& service_discovery_topic, const string& guid) :
-		mSuspended(false), mManagement(management), mService(service), mAdapter(adapter), mLocatorTopic(service_discovery_topic), mGuid(guid)
-		{
-			mManagementPrx = ServiceManagementPrx::uncheckedCast(mAdapter->addWithUUID(impl));
-			if (mLocatorTopic)
-			{
-			   mLocatorTopic->serviceRegistered(mGuid);
-			}
-		}
-
-        /**
-	 * Shared mutex lock which protects the service.
-	 */
-	boost::shared_mutex mLock;
-
-	/**
-	 * A boolean value which is used to store the suspended state of this service.
-	 */
-	bool mSuspended;
-
-	/**
-	 * A pointer to the service locator management implementation that instantiated this call.
-	 */
-	ServiceLocatorManagementImpl* mManagement;
-
-	/**
-	 * A remote proxy to the service that is registered.
-	 */
-	Ice::ObjectPrx mService;
-
-	/**
-	 * A pointer to the object adapter that this service is available on.
-	 */
-	Ice::ObjectAdapterPtr mAdapter;
-
-	/**
-	 * A local proxy to this management service.
-	 */
-	AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx mManagementPrx;
-
-	/**
-	 * A vector of locator parameters that this service supports.
-	 */
-	std::vector<ServiceLocatorParamsSpec> mSupportedLocatorParams;
-
-	/**
-	 * A proxy that can be used to publish events to the service locator topic.
-	 */
-	AsteriskSCF::System::Discovery::EventsPrx mLocatorTopic;
-
-	/**
-	 * A string which contains a unique identifier for this service. This is used
-	 * in events and logging.
-	 */
-	std::string mGuid;
+    ServiceManagementImplPriv(ServiceManagementImpl* impl, ServiceLocatorManagementImpl* management,
+      const Ice::ObjectPrx& service, const Ice::ObjectAdapterPtr& adapter, const AsteriskSCF::System::Discovery::EventsPrx& serviceDiscoveryTopic,
+      const string& guid) :
+        mSuspended(false), mManagement(management), mService(service), mAdapter(adapter), 
+        mLocatorTopic(serviceDiscoveryTopic), mGuid(guid)
+    {
+        mManagementPrx = ServiceManagementPrx::uncheckedCast(mAdapter->addWithUUID(impl));
+        if (mLocatorTopic)
+        {
+            mLocatorTopic->serviceRegistered(mGuid);
+        }
+    }
+
+    /**
+     * Shared mutex lock which protects the service.
+     */
+    boost::shared_mutex mLock;
+
+    /**
+     * A boolean value which is used to store the suspended state of this service.
+     */
+    bool mSuspended;
+
+    /**
+     * A pointer to the service locator management implementation that instantiated this call.
+     */
+    ServiceLocatorManagementImpl* mManagement;
+
+    /**
+     * A remote proxy to the service that is registered.
+     */
+    Ice::ObjectPrx mService;
+
+    /**
+     * A pointer to the object adapter that this service is available on.
+     */
+    Ice::ObjectAdapterPtr mAdapter;
+
+    /**
+     * A local proxy to this management service.
+     */
+    AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx mManagementPrx;
+
+    /**
+     * A vector of locator parameters that this service supports.
+     */
+    std::vector<ServiceLocatorParamsSpec> mSupportedLocatorParams;
+
+    /**
+     * A proxy that can be used to publish events to the service locator topic.
+     */
+    AsteriskSCF::System::Discovery::EventsPrx mLocatorTopic;
+
+    /**
+     * A string which contains a unique identifier for this service. This is used
+     * in events and logging.
+     */
+    std::string mGuid;
 };
+} /* end of ServiceDiscovery */
+} /* end of AsteriskSCF */
+
+using namespace AsteriskSCF::System::Discovery;
 
 /**
  * Constructor for the ServiceManagementImpl class. This adds itself to the object adapter so the service can perform some management and
  * also sends out an event for those that are listening.
  */
-ServiceManagementImpl::ServiceManagementImpl(ServiceLocatorManagementImpl* management, const Ice::ObjectPrx& service, Ice::ObjectAdapterPtr adapter,
-					     const EventsPrx& service_discovery_topic, const string& guid)
-	: mImpl(new ServiceManagementImplPriv(this, management, service, adapter, service_discovery_topic, guid))
+ServiceManagementImpl::ServiceManagementImpl(ServiceLocatorManagementImpl* management, 
+  const Ice::ObjectPrx& service, const Ice::ObjectAdapterPtr& adapter, const EventsPrx& serviceDiscoveryTopic, const string& guid) : 
+    mImpl(new ServiceManagementImplPriv(this, management, service, adapter, serviceDiscoveryTopic, guid))
 {
 }
 
@@ -126,9 +144,9 @@ ServiceManagementImpl::ServiceManagementImpl(ServiceLocatorManagementImpl* manag
  *
  * @return A proxy to this service.
  */
-Ice::ObjectPrx ServiceManagementImpl::GetService()
+Ice::ObjectPrx ServiceManagementImpl::getService()
 {
-	return mImpl->mService;
+    return mImpl->mService;
 }
 
 /**
@@ -136,9 +154,9 @@ Ice::ObjectPrx ServiceManagementImpl::GetService()
  *
  * @return A proxy to the management service.
  */
-ServiceManagementPrx ServiceManagementImpl::GetServiceManagementPrx()
+ServiceManagementPrx ServiceManagementImpl::getServiceManagementPrx()
 {
-	return mImpl->mManagementPrx;
+    return mImpl->mManagementPrx;
 }
 
 /**
@@ -152,28 +170,28 @@ ServiceManagementPrx ServiceManagementImpl::GetServiceManagementPrx()
  */
 bool ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params)
 {
-	boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-	/* If this service is suspended we can just skip the entire check and return false now, easy as pie */
-	if (mImpl->mSuspended)
-	{
-		return false;
-	}
-
-	for (vector<ServiceLocatorParamsSpec>::iterator spec = mImpl->mSupportedLocatorParams.begin(); spec != mImpl->mSupportedLocatorParams.end(); ++spec)
-	{
-		if ((*spec).isSupported(params) == true)
-		{
-			return true;
-		}
-	}
-
-	return false;
+    boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
+
+    /* If this service is suspended we can just skip the entire check and return false now, easy as pie */
+    if (mImpl->mSuspended)
+    {
+        return false;
+    }
+
+    for (vector<ServiceLocatorParamsSpec>::iterator spec = mImpl->mSupportedLocatorParams.begin(); spec != mImpl->mSupportedLocatorParams.end(); ++spec)
+    {
+        if ((*spec).isSupported(params) == true)
+        {
+            return true;
+        }
+    }
+
+    return false;
 }
 
 std::string const &ServiceManagementImpl::getGuid() const
 {
-	return mImpl->mGuid;
+    return mImpl->mGuid;
 }
 
 /**
@@ -187,37 +205,37 @@ std::string const &ServiceManagementImpl::getGuid() const
  */
 bool ServiceLocatorParamsSpec::isSupported(const ServiceLocatorParamsPtr& params)
 {
-	// If no category is passed to us then the component doing the locate wants everything/anything, so give it to them
-	if (params->category.empty())
-	{
-	   return true;
-	}
-
-	/* This is just a simple comparison that acts as a preliminary, and perhaps final, check */
-	if (mParams->category != params->category)
-	{
-		return false;
-	}
-
-	/* If a comparator was provided then yield to it for a final yay or nay */
-	if (!mCompareGuid.empty())
-	{
-		return mManagement->isSupported(mCompareGuid, params);
-	}
-
-	return true;
+    // If no category is passed to us then the component doing the locate wants everything/anything, so give it to them
+    if (params->category.empty())
+    {
+        return true;
+    }
+
+    /* This is just a simple comparison that acts as a preliminary, and perhaps final, check */
+    if (mParams->category != params->category)
+    {
+        return false;
+    }
+
+    /* If a comparator was provided then yield to it for a final yay or nay */
+    if (!mCompareGuid.empty())
+    {
+        return mManagement->isSupported(mCompareGuid, params);
+    }
+
+    return true;
 }
 
 /**
  * Implementation of the addLocatorParams method as defined in service_locator.ice
  */
-void ServiceManagementImpl::addLocatorParams(const ServiceLocatorParamsPtr& params, const std::string& compare_guid, const Ice::Current&)
+void ServiceManagementImpl::addLocatorParams(const ServiceLocatorParamsPtr& params, const std::string& compareGuid, const Ice::Current&)
 {
-	boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
+    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
 
-	ServiceLocatorParamsSpec spec(params, compare_guid, mImpl->mManagement);
+    ServiceLocatorParamsSpec spec(params, compareGuid, mImpl->mManagement);
 
-	mImpl->mSupportedLocatorParams.push_back(spec);
+    mImpl->mSupportedLocatorParams.push_back(spec);
 }
 
 /**
@@ -225,14 +243,14 @@ void ServiceManagementImpl::addLocatorParams(const ServiceLocatorParamsPtr& para
  */
 void ServiceManagementImpl::suspend(const Ice::Current&)
 {
-	boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
+    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
 
-	mImpl->mSuspended = true;
+    mImpl->mSuspended = true;
 
-	if (mImpl->mLocatorTopic)
-	{
-	   mImpl->mLocatorTopic->serviceSuspended(mImpl->mGuid);
-	}
+    if (mImpl->mLocatorTopic)
+    {
+        mImpl->mLocatorTopic->serviceSuspended(mImpl->mGuid);
+    }
 }
 
 /**
@@ -240,14 +258,14 @@ void ServiceManagementImpl::suspend(const Ice::Current&)
  */
 void ServiceManagementImpl::unsuspend(const Ice::Current&)
 {
-	boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
+    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
 
-	mImpl->mSuspended = false;
+    mImpl->mSuspended = false;
 
-	if (mImpl->mLocatorTopic)
-	{
-	   mImpl->mLocatorTopic->serviceUnsuspended(mImpl->mGuid);
-	}
+    if (mImpl->mLocatorTopic)
+    {
+        mImpl->mLocatorTopic->serviceUnsuspended(mImpl->mGuid);
+    }
 }
 
 /**
@@ -255,18 +273,18 @@ void ServiceManagementImpl::unsuspend(const Ice::Current&)
  */
 void ServiceManagementImpl::unregister(const Ice::Current&)
 {
-	/* You'll notice no lock here. That's because we aren't actually modifying any internal state that should
-	 * be protected, and if we did lock here there is a chance for a deadlock which is super sad.
-	 */
+    /* You'll notice no lock here. That's because we aren't actually modifying any internal state that should
+     * be protected, and if we did lock here there is a chance for a deadlock which is super sad.
+     */
 
-	mImpl->mAdapter->remove(mImpl->mManagementPrx->ice_getIdentity());
+    mImpl->mAdapter->remove(mImpl->mManagementPrx->ice_getIdentity());
 
-	mImpl->mManagement->removeService(this);
+    mImpl->mManagement->removeService(this);
 
-	if (mImpl->mLocatorTopic)
-	{
-	   mImpl->mLocatorTopic->serviceUnregistered(mImpl->mGuid);
-	}
+    if (mImpl->mLocatorTopic)
+    {
+        mImpl->mLocatorTopic->serviceUnregistered(mImpl->mGuid);
+    }
 }
 
 
diff --git a/src/ServiceManagement.h b/src/ServiceManagement.h
index 5bf6ffd..ee044eb 100644
--- a/src/ServiceManagement.h
+++ b/src/ServiceManagement.h
@@ -7,11 +7,13 @@
  */
 
 #pragma once
-#ifndef _SERVICEMANAGEMENT_H
-#define _SERVICEMANAGEMENT_H
 
 #include <boost/shared_ptr.hpp>
 
+namespace AsteriskSCF
+{
+namespace ServiceDiscovery
+{
 /**
  * Forward definition for our private implementation of ServiceLocatorManagement.
  */
@@ -23,21 +25,29 @@ class ServiceManagementImplPriv;
 class ServiceManagementImpl : public AsteriskSCF::Core::Discovery::V1::ServiceManagement
 {
 public:
-   ServiceManagementImpl(ServiceLocatorManagementImpl*, const Ice::ObjectPrx&, Ice::ObjectAdapterPtr, const AsteriskSCF::System::Discovery::EventsPrx&, const std::string&);
-   void addLocatorParams(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&, const std::string&, const Ice::Current&);
-   void suspend(const Ice::Current&);
-   void unsuspend(const Ice::Current&);
-   void unregister(const Ice::Current&);
-   Ice::ObjectPrx GetService();
-   AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx GetServiceManagementPrx();
-   bool isSupported(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
-   std::string const &getGuid() const;
+    ServiceManagementImpl(ServiceLocatorManagementImpl*, const Ice::ObjectPrx&, const Ice::ObjectAdapterPtr&,
+      const AsteriskSCF::System::Discovery::EventsPrx&, const std::string&);
+
+    //
+    // AsteriskSCF::Core::Discovery::V1::ServiceManagement interface.
+    //
+    void addLocatorParams(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&, const std::string&, const Ice::Current&);
+    void suspend(const Ice::Current&);
+    void unsuspend(const Ice::Current&);
+    void unregister(const Ice::Current&);
+
+    Ice::ObjectPrx getService();
+    AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx getServiceManagementPrx();
+    bool isSupported(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
+    const std::string &getGuid() const;
 
 private:
-   /**
-    * Private implementation data for ServiceManagementImpl.
-    */
-   boost::shared_ptr<ServiceManagementImplPriv> mImpl;
+    /**
+     * Private implementation data for ServiceManagementImpl.
+     */
+    boost::shared_ptr<ServiceManagementImplPriv> mImpl;
 };
 
-#endif
+} /* end of ServiceDiscovery */
+} /* end of AsteriskSCF */
+
diff --git a/test/TestServiceLocator.cpp b/test/TestServiceLocator.cpp
index e37fea4..d4ec501 100644
--- a/test/TestServiceLocator.cpp
+++ b/test/TestServiceLocator.cpp
@@ -22,16 +22,16 @@
 using namespace std;
 using namespace AsteriskSCF::Core::Discovery::V1;
 
+namespace
+{
 /**
  * Test service, for loading into icebox
  */
 class ServiceLocatorTest : public IceBox::Service
 {
 public:
-   void start(const std::string&,
-              const Ice::CommunicatorPtr&,
-              const Ice::StringSeq&);
-   void stop();
+    void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&);
+    void stop();
 };
 
 /* A basic compare service implementation that always returns true, this is registered as both a compare service
@@ -40,15 +40,15 @@ public:
 class TestCompareServiceImpl : public ServiceLocatorParamsCompare
 {
 public:
-	bool isSupported(const ServiceLocatorParamsPtr&, const Ice::Current&) { return true; };
+    bool isSupported(const ServiceLocatorParamsPtr&, const Ice::Current&) { return true; };
 };
 
 /* Cache the command line arguments so that Ice can be initialized within the global fixture. */
 struct ArgCacheType
 {
 public:
-	int argc;
-	char **argv;
+    int argc;
+    char **argv;
 };
 static ArgCacheType mCachedArgs;
 
@@ -59,80 +59,95 @@ static ArgCacheType mCachedArgs;
 struct SharedTestData
 {
 public:
-	/* Communicator for outgoing stuff */
-	Ice::CommunicatorPtr communicator_outgoing;
-
-	/* Communicator for incoming stuff */
-	Ice::CommunicatorPtr communicator_incoming;
-
-	/* Actual object adapter used for our compare service */
-	Ice::ObjectAdapterPtr adapter;
-
-	/* A proxy to the management service */
-	ServiceLocatorManagementPrx management;
-
-	/* A proxy to the actual locate service */
-	ServiceLocatorPrx discovery;
-
-	/* A proxy to our own compare service, registered as both a compare service and as a regular service */
-	ServiceLocatorParamsComparePrx compare;
-
-	/* A proxy to the service specific management interface for our compare service we registered */
-	ServiceManagementPrx compare_management;
-
-	/* A proxy we received from service discovery for our own compare service */
-	ServiceLocatorParamsComparePrx found_compare;
-
-	/* Common implementation for locating a service */
-	bool FindService(string category) {
-		bool found = true;
-
-		try {
-			/* Setup our parameters, for now we are simply using test as the category */
-			ServiceLocatorParamsPtr params = new ServiceLocatorParams;
-			params->category = category;
-
-			/* Actually do the locate request */
-			found_compare = ServiceLocatorParamsComparePrx::uncheckedCast(discovery->locate(params));
-
-			/* If we get here we didn't get an exception back telling us no service found... which is wrong! */
-		} catch (const ServiceNotFound&) {
-			found = false;
-		} catch (const Ice::Exception &e) {
-			BOOST_TEST_MESSAGE(e.ice_name());
-			BOOST_TEST_MESSAGE(e.what());
-			found = false;
-		}
-
-		return found;
-	}
-
-	/* Common implementation for finding multiple services */
-	bool FindServices(string category, unsigned int expected_num_of_results) {
-		bool found = true;
-
-		try {
-			ServiceLocatorParamsPtr params = new ServiceLocatorParams;
-			params->category = category;
-
-			Ice::ObjectProxySeq services = discovery->locateAll(params);
-
-			if (services.size() != expected_num_of_results) {
-				found = false;
-			}
-		} catch (const ServiceNotFound&) {
-			found = false;
-		} catch (const Ice::Exception &e) {
-			BOOST_TEST_MESSAGE(e.ice_name());
-			BOOST_TEST_MESSAGE(e.what());
-			found = false;
-		} catch (...) {
-		}
-
-		return found;
-	}
+    /* Communicator for outgoing stuff */
+    Ice::CommunicatorPtr communicatorOutgoing;
+
+    /* Communicator for incoming stuff */
+    Ice::CommunicatorPtr communicatorIncoming;
+
+    /* Actual object adapter used for our compare service */
+    Ice::ObjectAdapterPtr adapter;
+
+    /* A proxy to the management service */
+    ServiceLocatorManagementPrx management;
+
+    /* A proxy to the actual locate service */
+    ServiceLocatorPrx discovery;
+
+    /* A proxy to our own compare service, registered as both a compare service and as a regular service */
+    ServiceLocatorParamsComparePrx compare;
+
+    /* A proxy to the service specific management interface for our compare service we registered */
+    ServiceManagementPrx compareManagement;
+
+    /* A proxy we received from service discovery for our own compare service */
+    ServiceLocatorParamsComparePrx foundCompare;
+
+    /* Common implementation for locating a service */
+    bool findService(const string& category) 
+    {
+        bool found = true;
+
+        try 
+        {
+            /* Setup our parameters, for now we are simply using test as the category */
+            ServiceLocatorParamsPtr params = new ServiceLocatorParams;
+            params->category = category;
+
+            /* Actually do the locate request */
+            foundCompare = ServiceLocatorParamsComparePrx::uncheckedCast(discovery->locate(params));
+
+            /* If we get here we didn't get an exception back telling us no service found... which is wrong! */
+        } 
+        catch (const ServiceNotFound&) 
+        {
+            found = false;
+        } 
+        catch (const Ice::Exception &e) 
+        {
+            BOOST_TEST_MESSAGE(e.ice_name());
+            BOOST_TEST_MESSAGE(e.what());
+            found = false;
+        }
+
+        return found;
+    }
+
+    /* Common implementation for finding multiple services */
+    bool findServices(const string& category, unsigned int expectedNumOfResults) 
+    {
+        bool found = true;
+
+        try 
+        {
+            ServiceLocatorParamsPtr params = new ServiceLocatorParams;
+            params->category = category;
+
+            Ice::ObjectProxySeq services = discovery->locateAll(params);
+
+            if (services.size() != expectedNumOfResults) 
+            {
+                found = false;
+            }
+        } 
+        catch (const ServiceNotFound&) 
+        {
+            found = false;
+        } 
+        catch (const Ice::Exception &e) 
+        {
+            BOOST_TEST_MESSAGE(e.ice_name());
+            BOOST_TEST_MESSAGE(e.what());
+            found = false;
+        } 
+        catch (...) 
+        {
+        }
+
+        return found;
+    }
 };
-static SharedTestData Testbed;
+static SharedTestData testbed;
 
 /**
  * A global fixture for Ice initialization.
@@ -140,71 +155,76 @@ static SharedTestData Testbed;
  */
 struct GlobalIceFixture
 {
-	GlobalIceFixture()
-	        {
-			BOOST_TEST_MESSAGE("Setting up ServiceLocator test fixture");
+    GlobalIceFixture()
+    {
+        BOOST_TEST_MESSAGE("Setting up ServiceLocator test fixture");
 
-			::boost::debug::detect_memory_leaks(false);
-			::boost::unit_test::unit_test_log.set_stream( std::cout );
+        ::boost::debug::detect_memory_leaks(false);
+        ::boost::unit_test::unit_test_log.set_stream( std::cout );
 
-			int status = 0;
-			try
-				{
-					Testbed.communicator_incoming = Ice::initialize(mCachedArgs.argc, mCachedArgs.argv);
+        int status = 0;
+        try
+        {
+            testbed.communicatorIncoming = Ice::initialize(mCachedArgs.argc, mCachedArgs.argv);
 
-					Testbed.adapter = Testbed.communicator_incoming->createObjectAdapterWithEndpoints("CompareServiceAdapter", "default");
+            testbed.adapter = testbed.communicatorIncoming->createObjectAdapterWithEndpoints("CompareServiceAdapter", "default");
 
-					ServiceLocatorParamsComparePtr CompareService = new TestCompareServiceImpl();
+            ServiceLocatorParamsComparePtr CompareService = new TestCompareServiceImpl();
 
-					Testbed.compare = ServiceLocatorParamsComparePrx::uncheckedCast(Testbed.adapter->addWithUUID(CompareService));
+            testbed.compare = ServiceLocatorParamsComparePrx::uncheckedCast(testbed.adapter->addWithUUID(CompareService));
 
-					Testbed.adapter->activate();
+            testbed.adapter->activate();
 
-					Testbed.communicator_outgoing = Ice::initialize(mCachedArgs.argc, mCachedArgs.argv);
+            testbed.communicatorOutgoing = Ice::initialize(mCachedArgs.argc, mCachedArgs.argv);
 
-					// TODO: This should use a configuration file most likely instead of hardcoding
+            // TODO: This should use a configuration file most likely instead of hardcoding
 
-					Testbed.management = ServiceLocatorManagementPrx::checkedCast(Testbed.communicator_outgoing->stringToProxy("LocatorServiceManagement:tcp -p 4422"));
+            testbed.management = ServiceLocatorManagementPrx::checkedCast(testbed.communicatorOutgoing->stringToProxy("LocatorServiceManagement:tcp -p 4422"));
 
-					if (!Testbed.management) {
-						throw "Invalid service discovery management proxy";
-					}
+            if (!testbed.management) 
+            {
+                throw "Invalid service discovery management proxy";
+            }
 
-					Testbed.discovery = ServiceLocatorPrx::checkedCast(Testbed.communicator_outgoing->stringToProxy("LocatorService:tcp -p 4411"));
+            testbed.discovery = ServiceLocatorPrx::checkedCast(testbed.communicatorOutgoing->stringToProxy("LocatorService:tcp -p 4411"));
 
-					if (!Testbed.discovery) {
-						throw "Invalid service discovery proxy";
-					}
-				}
-			catch (const Ice::Exception& ex)
-				{
-					cerr << ex << endl;
-					status = 1;
-				}
-			catch (const char* msg)
-				{
-					cerr << msg << endl;
-					status = 1;
-				}
+            if (!testbed.discovery) 
+            {
+                throw "Invalid service discovery proxy";
+            }
+        }
+        catch (const Ice::Exception& ex)
+        {
+            cerr << ex << endl;
+            status = 1;
+        }
+        catch (const char* msg)
+        {
+            cerr << msg << endl;
+            status = 1;
+        }
 
-		} // end Fixture() constructor
+    } // end Fixture() constructor
 
-	~GlobalIceFixture()
-	        {
-			BOOST_TEST_MESSAGE("Tearing down service discovery test fixture");
+    ~GlobalIceFixture()
+    {
+        BOOST_TEST_MESSAGE("Tearing down service discovery test fixture");
 
 
-			if (Testbed.communicator_incoming) {
-				Testbed.communicator_incoming->shutdown();
-				Testbed.communicator_incoming = 0;
-			}
-			if (Testbed.communicator_outgoing) {
-				Testbed.communicator_outgoing->shutdown();
-				Testbed.communicator_outgoing = 0;
-			}
-		}
+        if (testbed.communicatorIncoming) 
+        {
+            testbed.communicatorIncoming->shutdown();
+            testbed.communicatorIncoming = 0;
+        }
+        if (testbed.communicatorOutgoing) 
+        {
+            testbed.communicatorOutgoing->shutdown();
+            testbed.communicatorOutgoing = 0;
+        }
+    }
 private:
 };
+}
 
 BOOST_GLOBAL_FIXTURE(GlobalIceFixture);
 
@@ -213,9 +233,9 @@ BOOST_GLOBAL_FIXTURE(GlobalIceFixture);
  */
 BOOST_AUTO_TEST_CASE(ServiceNotFoundBeforeAdd)
 {
-	bool found = Testbed.FindService("test");
+    bool found = testbed.findService("test");
 
-	BOOST_CHECK(!found);
+    BOOST_CHECK(!found);
 }
 
 /**
@@ -223,9 +243,9 @@ BOOST_AUTO_TEST_CASE(ServiceNotFoundBeforeAdd)
  */
 BOOST_AUTO_TEST_CASE(ServicesNotFoundBeforeAdd)
 {
-	bool found = Testbed.FindServices("test", 1);
+    bool found = testbed.findServices("test", 1);
 
-	BOOST_CHECK(!found);
+    BOOST_CHECK(!found);
 }
 
 /**
@@ -233,22 +253,27 @@ BOOST_AUTO_TEST_CASE(ServicesNotFoundBeforeAdd)
  */
 BOOST_AUTO_TEST_CASE(AddService)
 {
-	bool added = false;
-
-	/* Since the service locator doesn't care if there are multiple services registered with the same identifier or
-	 * if the same service is registered multiple times there really isn't any way for this to fail, besides something
-	 * outside the control of the service locator itself or I suppose if it crashes.
-	 */
-	try {
-		Testbed.compare_management = Testbed.management->addService(Testbed.compare, "testcompare");
-		added = true;
-	} catch (const Ice::Exception &e) {
-		BOOST_TEST_MESSAGE(e.ice_name());
-		BOOST_TEST_MESSAGE(e.what());
-	} catch (...) {
-	}
-
-	BOOST_CHECK(added);
+    bool added = false;
+
+    /* Since the service locator doesn't care if there are multiple services registered with the same identifier or
+     * if the same service is registered multiple times there really isn't any way for this to fail, besides something
+     * outside the control of the service locator itself or I suppose if it crashes.
+     */
+    try 
+    {
+        testbed.compareManagement = testbed.management->addService(testbed.compare, "testcompare");
+        added = true;
+    } 
+    catch (const Ice::Exception &e) 
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    } 
+    catch (...) 
+    {
+    }
+
+    BOOST_CHECK(added);
 }
 
 /**
@@ -256,9 +281,9 @@ BOOST_AUTO_TEST_CASE(AddService)
  */
 BOOST_AUTO_TEST_CASE(ServiceNotFoundAfterAdd)
 {
-	bool found = Testbed.FindService("test");
+    bool found = testbed.findService("test");
 
-	BOOST_CHECK(!found);
+    BOOST_CHECK(!found);
 }
 
 /**
@@ -266,9 +291,9 @@ BOOST_AUTO_TEST_CASE(ServiceNotFoundAfterAdd)
  */
 BOOST_AUTO_TEST_CASE(ServicesNotFoundAfterAdd)
 {
-	bool found = Testbed.FindServices("test", 0);
+    bool found = testbed.findServices("test", 0);
 
-	BOOST_CHECK(!found);
+    BOOST_CHECK(!found);
 }
 
 /**
@@ -276,22 +301,27 @@ BOOST_AUTO_TEST_CASE(ServicesNotFoundAfterAdd)
  */
 BOOST_AUTO_TEST_CASE(AddLocatorParamsWithoutCompareService)
 {
-	bool added = false;
+    bool added = false;
 
-	try {
-		ServiceLocatorParamsPtr params = new ServiceLocatorParams;
-		params->category = "test";
+    try 
+    {
+        ServiceLocatorParamsPtr params = new ServiceLocatorParams;
+        params->category = "test";
 
-		Testbed.compare_management->addLocatorParams(params, "");
+        testbed.compareManagement->addLocatorParams(params, "");
 
-		added = true;
-	} catch (const Ice::Exception &e) {
-		BOOST_TEST_MESSAGE(e.ice_name());
-		BOOST_TEST_MESSAGE(e.what());
-	} catch (...) {
-	}
+        added = true;
+    } 
+    catch (const Ice::Exception &e) 
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    } 
+    catch (...) 
+    {
+    }
 
-	BOOST_CHECK(added);
+    BOOST_CHECK(added);
 }
 
 /**
@@ -299,9 +329,9 @@ BOOST_AUTO_TEST_CASE(AddLocatorParamsWithoutCompareService)
  */
 BOOST_AUTO_TEST_CASE(FindServiceWithoutCompareService)
 {
-	bool found = Testbed.FindService("test");
+    bool found = testbed.findService("test");
 
-	BOOST_CHECK(found);
+    BOOST_CHECK(found);
 }
 
 /**
@@ -309,9 +339,9 @@ BOOST_AUTO_TEST_CASE(FindServiceWithoutCompareService)
  */
 BOOST_AUTO_TEST_CASE(FindServicesWithoutCompareService)
 {
-	bool found = Testbed.FindServices("test", 1);
+    bool found = testbed.findServices("test", 1);
 
-	BOOST_CHECK(found);
+    BOOST_CHECK(found);
 }
 
 /**
@@ -319,22 +349,28 @@ BOOST_AUTO_TEST_CASE(FindServicesWithoutCompareService)
  */
 BOOST_AUTO_TEST_CASE(UseServiceFoundWithoutCompareService)
 {
-	bool usable = false;
-
-	try {
-		ServiceLocatorParamsPtr params = new ServiceLocatorParams;
-		params->category = "bob";
-
-		if ((Testbed.found_compare == Testbed.compare) && (Testbed.found_compare->isSupported(params) == true)) {
-			usable = true;
-		}
-	} catch (const Ice::Exception &e) {
-		BOOST_TEST_MESSAGE(e.ice_name());
-		BOOST_TEST_MESSAGE(e.what());
-	} catch (...) {
-	}
-
-	BOOST_CHECK(usable);
+    bool usable = false;
+
+    try 
+    {
+        ServiceLocatorParamsPtr params = new ServiceLocatorParams;
+        params->category = "bob";
+
+        if ((testbed.foundCompare == testbed.compare) && (testbed.foundCompare->isSupported(params) == true)) 
+        {
+            usable = true;
+        }
+    } 
+    catch (const Ice::Exception &e) 
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    } 
+    catch (...) 
+    {
+    }
+
+    BOOST_CHECK(usable);
 }
 
 /**
@@ -342,20 +378,27 @@ BOOST_AUTO_TEST_CASE(UseServiceFoundWithoutCompareService)
  */
 BOOST_AUTO_TEST_CASE(AddCompare)
 {
-	bool added = false;
-
-	try {
-		Testbed.management->addCompare("testcompare", Testbed.compare);
-
-		added = true;
-	} catch (const DuplicateCompare&) {
-	} catch (Ice::Exception &e) {
-		BOOST_TEST_MESSAGE(e.ice_name());
-		BOOST_TEST_MESSAGE(e.what());
-	} catch (...) {
-	}
-
-	BOOST_CHECK(added);
+    bool added = false;
+
+    try 
+    {
+        testbed.management->addCompare("testcompare", testbed.compare);
+
+        added = true;
+    } 
+    catch (const DuplicateCompare&) 
+    {
+    } 
+    catch (const Ice::Exception &e) 
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    } 
+    catch (...) 
+    {
+    }
+
+    BOOST_CHECK(added);
 }
 
 /**
@@ -363,20 +406,27 @@ BOOST_AUTO_TEST_CASE(AddCompare)
  */
 BOOST_AUTO_TEST_CASE(AddDuplicateCompare)
 {
-	bool added = false;
-
-	try {
-		Testbed.management->addCompare("testcompare", Testbed.compare);
-
-		added = true;
-	} catch (const DuplicateCompare&) {
-	} catch (Ice::Exception &e) {
-		BOOST_TEST_MESSAGE(e.ice_name());
-		BOOST_TEST_MESSAGE(e.what());
-	} catch (...) {
-	}
-
-	BOOST_CHECK(!added);
+    bool added = false;
+
+    try 
+    {
+        testbed.management->addCompare("testcompare", testbed.compare);
+
+        added = true;
+    } 
+    catch (const DuplicateCompare&) 
+    {
+    } 
+    catch (const Ice::Exception &e) 
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    } 
+    catch (...) 
+    {
+    }
+
+    BOOST_CHECK(!added);
 }
 
 /**
@@ -384,22 +434,27 @@ BOOST_AUTO_TEST_CASE(AddDuplicateCompare)
  */
 BOOST_AUTO_TEST_CASE(AddLocatorParamsWithCompareService)
 {
-	bool added = false;
+    bool added = false;
 
-	try {
-		ServiceLocatorParamsPtr params = new ServiceLocatorParams;
-		params->category = "test2";
+    try 
+    {
+        ServiceLocatorParamsPtr params = new ServiceLocatorParams;
+        params->category = "test2";
 
-		Testbed.compare_management->addLocatorParams(params, "testcompare");
+        testbed.compareManagement->addLocatorParams(params, "testcompare");
 
-		added = true;
-	} catch (const Ice::Exception &e) {
-		BOOST_TEST_MESSAGE(e.ice_name());
-		BOOST_TEST_MESSAGE(e.what());
-	} catch (...) {
-	}
+        added = true;
+    } 
+    catch (const Ice::Exception &e) 
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    } 
+    catch (...) 
+    {
+    }
 
-	BOOST_CHECK(added);
+    BOOST_CHECK(added);
 }
 
 /**
@@ -407,9 +462,9 @@ BOOST_AUTO_TEST_CASE(AddLocatorParamsWithCompareService)
  */
 BOOST_AUTO_TEST_CASE(FindServiceWithCompareService)
 {
-	bool found = Testbed.FindService("test2");
+    bool found = testbed.findService("test2");
 
-	BOOST_CHECK(found);
+    BOOST_CHECK(found);
 }
 
 /**
@@ -417,22 +472,28 @@ BOOST_AUTO_TEST_CASE(FindServiceWithCompareService)
  */
 BOOST_AUTO_TEST_CASE(UseServiceFoundWithCompareService)
 {
-	bool usable = false;
-
-	try {
-		ServiceLocatorParamsPtr params = new ServiceLocatorParams;
-		params->category = "bob";
-
-		if ((Testbed.found_compare == Testbed.compare) && (Testbed.found_compare->isSupported(params) == true)) {
-			usable = true;
-		}
-	} catch (const Ice::Exception &e) {
-		BOOST_TEST_MESSAGE(e.ice_name());
-		BOOST_TEST_MESSAGE(e.what());
-	} catch (...) {
-	}
-
-	BOOST_CHECK(usable);
+    bool usable = false;
+
+    try 
+    {
+        ServiceLocatorParamsPtr params = new ServiceLocatorParams;
+        params->category = "bob";
+
+        if ((testbed.foundCompare == testbed.compare) && (testbed.foundCompare->isSupported(params) == true)) 
+        {
+            usable = true;
+        }
+    } 
+    catch (const Ice::Exception &e) 
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    } 
+    catch (...) 
+    {
+    }
+
+    BOOST_CHECK(usable);
 }
 
 /**
@@ -440,18 +501,18 @@ BOOST_AUTO_TEST_CASE(UseServiceFoundWithCompareService)
  */
 BOOST_AUTO_TEST_CASE(FindMultipleServices)
 {
-	ServiceLocatorParamsPtr params = new ServiceLocatorParams;
-	ServiceManagementPrx compare_management = Testbed.management->addService(Testbed.compare, "testcompare2");
+    ServiceLocatorParamsPtr params = new ServiceLocatorParams;
+    ServiceManagementPrx compareManagement = testbed.management->addService(testbed.compare, "testcompare2");
 
-	params->category = "test";
+    params->category = "test";
 
-	compare_management->addLocatorParams(params, "");
+    compareManagement->addLocatorParams(params, "");
 
-	bool found = Testbed.FindServices("test", 2);
+    bool found = testbed.findServices("test", 2);
 
-	compare_management->unregister();
+    compareManagement->unregister();
 
-	BOOST_CHECK(found);
+    BOOST_CHECK(found);
 }
 
 /**
@@ -459,18 +520,18 @@ BOOST_AUTO_TEST_CASE(FindMultipleServices)
  */
 BOOST_AUTO_TEST_CASE(FindMultipleServicesUsingEmptyCategory)
 {
-	ServiceLocatorParamsPtr params = new ServiceLocatorParams;
-	ServiceManagementPrx compare_management = Testbed.management->addService(Testbed.compare, "testcompare2");
+    ServiceLocatorParamsPtr params = new ServiceLocatorParams;
+    ServiceManagementPrx compareManagement = testbed.management->addService(testbed.compare, "testcompare2");
 
-	params->category = "test";
+    params->category = "test";
 
-	compare_management->addLocatorParams(params, "");
+    compareManagement->addLocatorParams(params, "");
 
-	bool found = Testbed.FindServices("", 2);
+    bool found = testbed.findServices("", 2);
 
-	compare_management->unregister();
... 299 lines suppressed ...


-- 
asterisk-scf/integration/servicediscovery.git



More information about the asterisk-scf-commits mailing list