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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Oct 6 18:10:23 CDT 2010


branch "master" has been updated
       via  e7788f5e7f86c826b2563eff5ad4d74c0b05bbc8 (commit)
      from  eb712f319152ac7cfca1d157a2e15fe1b98aa323 (commit)

Summary of changes:
 cmake                                |    2 +-
 slice                                |    2 +-
 src/BasicRoutingServiceApp.cpp       |  208 ++++++++++------------------------
 src/BasicRoutingServiceDataModel.h   |   41 -------
 src/BridgeManagerAccessor.cpp        |  126 ++++++++++++++++++++
 src/BridgeManagerAccessor.h          |   40 +++++++
 src/CMakeLists.txt                   |    3 +-
 src/EndpointRegistry.cpp             |   64 +++++++----
 src/EndpointRegistry.h               |   20 ++-
 src/LuaScriptProcessor.h             |    5 +-
 src/RoutingAdmin.cpp                 |    7 +-
 src/RoutingAdmin.h                   |    7 +-
 src/RoutingServiceEventPublisher.cpp |   38 ++++---
 src/RoutingServiceEventPublisher.h   |   31 +++--
 src/SessionRouter.cpp                |   43 ++++++-
 src/SessionRouter.h                  |   15 ++-
 test/TestRouting.cpp                 |   10 ++-
 17 files changed, 392 insertions(+), 270 deletions(-)
 delete mode 100644 src/BasicRoutingServiceDataModel.h
 create mode 100644 src/BridgeManagerAccessor.cpp
 create mode 100644 src/BridgeManagerAccessor.h


- Log -----------------------------------------------------------------
commit e7788f5e7f86c826b2563eff5ad4d74c0b05bbc8
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Oct 5 17:51:15 2010 -0500

    Refectored the singleton hack used for expediency out of the code.

diff --git a/cmake b/cmake
index e9cf9f2..364040a 160000
--- a/cmake
+++ b/cmake
@@ -1 +1 @@
-Subproject commit e9cf9f2e6dd03fe7bc39c363d72812aceed28367
+Subproject commit 364040aa2e2252eb07d896dc98eee1d2362f56e9
diff --git a/slice b/slice
index 0c62939..df22de4 160000
--- a/slice
+++ b/slice
@@ -1 +1 @@
-Subproject commit 0c629393e2f05dc0ed43bcc6305880949df36289
+Subproject commit df22de4cdfa237ab7cbabbc8af895de73f554a9a
diff --git a/src/BasicRoutingServiceApp.cpp b/src/BasicRoutingServiceApp.cpp
index c918e29..15d2481 100644
--- a/src/BasicRoutingServiceApp.cpp
+++ b/src/BasicRoutingServiceApp.cpp
@@ -11,12 +11,12 @@
 #include <boost/thread.hpp>
 #include <boost/shared_ptr.hpp>
 
-#include "RoutingIf.h"
-#include "ServiceLocatorIf.h"
-#include "BridgingIf.h"
-#include "ComponentServiceIf.h"
-#include "SessionCommunicationsIf.h"
-#include "BasicRoutingServiceDataModel.h"
+#include "Core/Routing/RoutingIf.h"
+#include "Core/Discovery/ServiceLocatorIf.h"
+#include "SessionCommunications/Bridging/BridgingIf.h"
+#include "System/Component/ComponentServiceIf.h"
+#include "SessionCommunications/SessionCommunicationsIf.h"
+
 #include "LuaScriptProcessor.h"
 #include "RoutingServiceEventPublisher.h"
 #include "EndpointRegistry.h"
@@ -27,6 +27,7 @@
 
 using namespace std;
 using namespace AsteriskSCF::BasicRoutingService;
+using namespace AsteriskSCF::SessionCommunications::V1;
 using namespace AsteriskSCF::SessionCommunications::Bridging::V1;
 using namespace AsteriskSCF::Core;
 using namespace AsteriskSCF::Core::Routing::V1;
@@ -38,125 +39,36 @@ namespace
 {
 Logger &lg = getLoggerFactory().getLogger("AsteriskSCF.BasicRoutingService");
 }
+using namespace AsteriskSCF::Core::Routing::V1::Event;
 
 namespace AsteriskSCF
 {
 namespace BasicRoutingService
 {
-/**
- * Private implementation of the BasicRoutingServiceDataModel singleton. This
- * object provides access to the data model of the component. 
- */
-class BasicRoutingServiceDataModelImpl : public BasicRoutingServiceDataModel
-{
-public:
-BasicRoutingServiceDataModelImpl() : mBridgeManager(0), mPaused(false)
-   {
-   }
-
-public: // Overrides of the BasicRoutingServiceDataModel singleton's public interface. 
-
-   virtual const Ice::CommunicatorPtr getCommunicator() 
-   {
-      return mCommunicator;
-   }
-
-   virtual const RoutingServiceEventPublisher& getEventPublisher()
-   {
-      return *mEventPublisher;
-   }
-
-   virtual EndpointRegistry& getEndpointRegistry()
-   {
-      return *mEndpointRegistry;
-   }
-
-   virtual Ice::ObjectAdapterPtr getObjectAdapter()
-   {
-      return mAdapter;
-   }
-
-   virtual BridgeManagerPrx getBridgeManager()
-   {
-      if (mBridgeManager == 0)
-      {
-         locateBridgeManager();
-      }
-
-      return mBridgeManager;
-   }
-
-public: // Implementation details are visible to this file's classes. 
-   /**
-    * Cleanup the dangling cruft. 
-    */
-   void cleanup()
-   {
-      mCommunicator = 0;
-      
-      if (mEventPublisher != 0)
-      {
-         delete mEventPublisher;
-         mEventPublisher = 0;
-      }
-   }
-
-   /**
-    * Get and cache a refence to the BridgeManager. 
-    */
-   void locateBridgeManager()
-   {
-      string bridgeId = "BridgeService"; 
-
-      try
-      {
-         // Use the locator to find the BridgeManger. 
-         ServiceLocatorParamsPtr nameparam = new ServiceLocatorParams();
-         nameparam->category = BridgeServiceDiscoveryCategory;
-         Ice::ObjectPrx bridgeManagerObject = mServiceLocator->locate(nameparam);
-         mBridgeManager = BridgeManagerPrx::checkedCast(bridgeManagerObject);
-      }
-      catch(const Ice::Exception &e)
-      {
-         lg(Error) << "Exception locating " << bridgeId << ": " << e.what();
-         return;
-      }
-
-      if (mBridgeManager == 0)
-      {
-         lg(Error) << "Unable to locate " << bridgeId;
-      }
-   }
-
-   Ice::CommunicatorPtr mCommunicator;
-   Ice::ObjectAdapterPtr mAdapter;
-   RoutingServiceEventPublisher *mEventPublisher;
-   EndpointRegistry *mEndpointRegistry;
-   ServiceLocatorPrx mServiceLocator;
-   BridgeManagerPrx mBridgeManager;
-
-   bool mPaused;
-};
-
-BasicRoutingServiceDataModelImpl mDataModelInstance;
-BasicRoutingServiceDataModel& BasicRoutingServiceDataModel::getInstance()
-{
-  return mDataModelInstance;
-}
 
-/**
- * This private class initializes the startup and controls the shutdown of the component. 
- */
 class BasicRoutingServiceApp : public Ice::Application
 {
 public: 
-	BasicRoutingServiceApp() : mDone(false) {}
+	BasicRoutingServiceApp() : mDone(false), mPaused(false) {}
    ~BasicRoutingServiceApp()
    {
       // Smart pointers do your thing. 
-      mLocatorRegistry = 0;
+      mSessionRouter = 0;
       mAdminInteface = 0;
       mComponentService = 0;
+      mEndpointRegistry = 0;
+      mBridgeManagerAccessor.reset();
+      mEventPublisher = 0;
+   }
+   
+   bool isPaused()
+   {
+      return mPaused;
+   }
+
+   void setPaused(bool val)
+   {
+      mPaused = val;
    }
 
 public:   // Overrides of Ice::Application
@@ -172,6 +84,7 @@ private:
    bool mDone;
    std::string mAppName;
    ServiceLocatorManagementPrx mServiceLocatorManagement;
+   ServiceLocatorPrx mServiceLocator;
 
    Discovery::V1::ServiceManagementPrx mRegistryLocatorManagement;
    Discovery::V1::ServiceManagementPrx mAdminManagement;
@@ -179,10 +92,16 @@ private:
    Discovery::V1::ServiceManagementPrx mSessionRouterManagement;
 
    // Our published interfaces.
-   LocatorRegistryPtr mLocatorRegistry;
-   AsteriskSCF::SessionCommunications::V1::SessionRouterPtr mSessionRouter;
+   BasicSessionRouterPtr mSessionRouter;
    RoutingServiceAdminPtr mAdminInteface;
    ComponentServicePtr mComponentService;
+   BridgeManagerAccessorPtr mBridgeManagerAccessor;
+   RoutingEventsPtr mEventPublisher;
+   EndpointRegistryPtr mEndpointRegistry;
+
+   // Implementation
+   Ice::ObjectAdapterPtr mAdapter;
+   bool mPaused;
 };
 
 static const string RegistryLocatorObjectId("RoutingServiceLocatorRegistry");
@@ -202,12 +121,12 @@ public:
 public: // Overrides of the ComponentService interface.
    virtual void suspend(const ::Ice::Current& = ::Ice::Current())
    {
-      mDataModelInstance.mPaused = true;
+      mApp.setPaused(true);
    }
 
    virtual void resume(const ::Ice::Current& = ::Ice::Current())
    {
-      mDataModelInstance.mPaused = false;
+      mApp.setPaused(false);
    }
 
    virtual void shutdown(const ::Ice::Current& = ::Ice::Current())
@@ -251,8 +170,6 @@ void BasicRoutingServiceApp::registerWithServiceLocator()
 {
    try
    {
-      Ice::ObjectAdapterPtr adapter = mDataModelInstance.mAdapter;
-
       // Get a proxy to the management interface for the Service Locator, so we can add ourselves into the system discovery mechanisms.
 	   mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(communicator()->propertyToProxy("LocatorServiceManagement.Proxy")); 
 
@@ -263,7 +180,7 @@ void BasicRoutingServiceApp::registerWithServiceLocator()
       }
 
       // Register our RoutingAdmin interface with the Service Locator. 
-      Ice::ObjectPrx adminObjectPrx = adapter->createDirectProxy(communicator()->stringToIdentity(RoutingAdminObjectId));
+      Ice::ObjectPrx adminObjectPrx = mAdapter->createDirectProxy(communicator()->stringToIdentity(RoutingAdminObjectId));
       RoutingServiceAdminPrx adminPrx = RoutingServiceAdminPrx::checkedCast(adminObjectPrx);
       string adminServiceGuid("BasicRoutingServiceAdmin"); // Should be unique for reporting.
       mAdminManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(adminPrx, adminServiceGuid));
@@ -271,7 +188,7 @@ void BasicRoutingServiceApp::registerWithServiceLocator()
       setCategory(mAdminManagement, Routing::V1::RoutingServiceAdminDiscoveryCategory);
    	
       // Register our RegistryLocator interface with the Service Locator. 
-      Ice::ObjectPrx locatorObjectPrx = adapter->createDirectProxy(communicator()->stringToIdentity(RegistryLocatorObjectId));
+      Ice::ObjectPrx locatorObjectPrx = mAdapter->createDirectProxy(communicator()->stringToIdentity(RegistryLocatorObjectId));
       LocatorRegistryPrx locatorRegistryPrx = LocatorRegistryPrx::checkedCast(locatorObjectPrx);
       string locatorServiceGuid("BasicRoutingServiceRegistryLocator");  // Should be unique for reporting.
       mRegistryLocatorManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(locatorRegistryPrx, locatorServiceGuid));
@@ -279,7 +196,7 @@ void BasicRoutingServiceApp::registerWithServiceLocator()
       setCategory(mRegistryLocatorManagement, Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory);
 
       // Register the ComponentService interface with the Service Locator. 
-      Ice::ObjectPrx componentServiceObjectPrx = adapter->createDirectProxy(communicator()->stringToIdentity(ComponentServiceId));
+      Ice::ObjectPrx componentServiceObjectPrx = mAdapter->createDirectProxy(communicator()->stringToIdentity(ComponentServiceId));
       ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
       string componentServiceGuid("BasicRoutingService");   // Should be unique for reporting.
       mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
@@ -287,7 +204,7 @@ void BasicRoutingServiceApp::registerWithServiceLocator()
       setCategory(mComponentServiceManagement, Routing::V1::ComponentServiceDiscoveryCategory);
 
       // Register the SessionRouter interface with the Service Locator.  
-      Ice::ObjectPrx sessionRouterObjectPrx = adapter->createDirectProxy(communicator()->stringToIdentity(SessionRouterObjectId));
+      Ice::ObjectPrx sessionRouterObjectPrx = mAdapter->createDirectProxy(communicator()->stringToIdentity(SessionRouterObjectId));
       AsteriskSCF::SessionCommunications::V1::SessionRouterPrx sessionRouterPrx = AsteriskSCF::SessionCommunications::V1::SessionRouterPrx::checkedCast(sessionRouterObjectPrx);
       string sessionRouterGuid("SessionRouter");   // Should be unique
       mSessionRouterManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(sessionRouterPrx, sessionRouterGuid));
@@ -330,52 +247,52 @@ void BasicRoutingServiceApp::initialize(const std::string appName)
    {
       mAppName = appName;
 
-      // Init the fields of the Data Model singleton. 
-      mDataModelInstance.mCommunicator = communicator();
-
-      mDataModelInstance.mEventPublisher = new RoutingServiceEventPublisher(); 
-
       // Create the adapter. 
-      mDataModelInstance.mAdapter = communicator()->createObjectAdapter("BasicRoutingServiceAdapter");
+      mAdapter = communicator()->createObjectAdapter("BasicRoutingServiceAdapter");
+
+      mEventPublisher = new RoutingServiceEventPublisher(mAdapter); 
 
       // setup the logger
-      ConfiguredIceLoggerPtr mIceLogger = createIceLogger(
-         mDataModelInstance.mAdapter);
+      ConfiguredIceLoggerPtr mIceLogger = createIceLogger(mAdapter);
       getLoggerFactory().setLogOutput(mIceLogger->getLogger());
 
       // Create and configure the EndpointRegistry. 
-      mDataModelInstance.mEndpointRegistry = new EndpointRegistry();
-      boost::shared_ptr<ScriptProcessor> scriptProcesor(new LuaScriptProcessor());
-      mDataModelInstance.mEndpointRegistry->setScriptProcessor(scriptProcesor);
+      ScriptProcessor* scriptProcesor(new LuaScriptProcessor());
+      mEndpointRegistry = new EndpointRegistry(scriptProcesor, mEventPublisher);
 
       // Publish the LocatorRegistry interface.  
-      mLocatorRegistry = mDataModelInstance.mEndpointRegistry;
-      mDataModelInstance.mAdapter->add(mLocatorRegistry, communicator()->stringToIdentity(RegistryLocatorObjectId));
+      mAdapter->add(mEndpointRegistry, communicator()->stringToIdentity(RegistryLocatorObjectId));
 
       // Create publish the SessionRouter interface.
-      mSessionRouter = new SessionRouter();
-      mDataModelInstance.mAdapter->add(mSessionRouter, communicator()->stringToIdentity(SessionRouterObjectId));
+      SessionRouter *rawSessionRouter(new SessionRouter(mAdapter, mEndpointRegistry, mEventPublisher));
+      BasicSessionRouterPtr basicSessionPtr(rawSessionRouter);
+      mSessionRouter = basicSessionPtr;
+      mAdapter->add(rawSessionRouter, communicator()->stringToIdentity(SessionRouterObjectId));
 
       // Create and publish the Admin interface support.
-      mAdminInteface = new RoutingAdmin();
-      mDataModelInstance.mAdapter->add(mAdminInteface, communicator()->stringToIdentity(RoutingAdminObjectId));
+      mAdminInteface = new RoutingAdmin(mEndpointRegistry);
+      mAdapter->add(mAdminInteface, communicator()->stringToIdentity(RoutingAdminObjectId));
 
       // Create and publish the ComponentService interface.
       mComponentService = new ComponentServiceImpl(*this);
-      mDataModelInstance.mAdapter->add(mComponentService, communicator()->stringToIdentity(ComponentServiceId));
+      mAdapter->add(mComponentService, communicator()->stringToIdentity(ComponentServiceId));
 
-      mDataModelInstance.mAdapter->activate();
+      mAdapter->activate();
 
       // Get a proxy to the interface for the Service Locator.
-      mDataModelInstance.mServiceLocator = ServiceLocatorPrx::checkedCast(communicator()->propertyToProxy("LocatorService.Proxy")); 
+	   mServiceLocator = ServiceLocatorPrx::checkedCast(communicator()->propertyToProxy("LocatorService.Proxy")); 
    }
    catch(const Ice::Exception &exception)
    {
-      lg(Error) << "Major problems in " << mAppName << " initialization(): " << exception.what();
+      lg(Error) << "Problems in " << mAppName << " initialization(): " << exception.what();
    }
 
-   mDataModelInstance.locateBridgeManager();
-   if (mDataModelInstance.mBridgeManager == 0)
+
+   BridgeManagerAccessorPtr ptr(new BridgeManagerAccessor(mServiceLocator));
+   mBridgeManagerAccessor = ptr;
+   mSessionRouter->setBridgeManagerAccessor(mBridgeManagerAccessor);
+
+   if (!mBridgeManagerAccessor->isInitialized())
    {
       lg(Debug) << "Probabaly safe to ignore ServiceNotFound during startup. Will attempt to locate Bridge Service again when it is needed.";
    }
@@ -398,9 +315,6 @@ int BasicRoutingServiceApp::run(int argc, char* argv[])
    // Run until it's time to run no more. 
    communicator()->waitForShutdown();
 
-   // Give our singleton a chance to shut down gracefully. 
-   mDataModelInstance.cleanup();
-
    return EXIT_SUCCESS;
 }
 
diff --git a/src/BasicRoutingServiceDataModel.h b/src/BasicRoutingServiceDataModel.h
deleted file mode 100644
index 6184bf4..0000000
--- a/src/BasicRoutingServiceDataModel.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Asterisk Scalable Communications Framework
- *
- * Copyright (C) 2010 -- Digium, Inc.
- *
- * All rights reserved.
- */
-#pragma once
-
-#include <Ice/Ice.h>
-#include "BridgingIf.h"
-
-namespace AsteriskSCF
-{
-namespace BasicRoutingService
-{
-class RoutingServiceEventPublisher;
-class EndpointRegistry;
-
-/**
- * Singleton for access to the service's data model. 
- */
-class BasicRoutingServiceDataModel
-{
-public:
-   static BasicRoutingServiceDataModel &getInstance();
-
-   virtual const Ice::CommunicatorPtr getCommunicator() = 0;
-   virtual Ice::ObjectAdapterPtr getObjectAdapter() = 0;
-   virtual const RoutingServiceEventPublisher& getEventPublisher() = 0;
-   virtual EndpointRegistry& getEndpointRegistry() = 0;
-   virtual AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx getBridgeManager() = 0;
-
-protected:
-   BasicRoutingServiceDataModel() {};
-   ~BasicRoutingServiceDataModel() {};
-};
-
-}; // BasicRoutingService
-}; // AsteriskSCF
-
diff --git a/src/BridgeManagerAccessor.cpp b/src/BridgeManagerAccessor.cpp
new file mode 100644
index 0000000..297f2eb
--- /dev/null
+++ b/src/BridgeManagerAccessor.cpp
@@ -0,0 +1,126 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+#include <Ice/Ice.h>
+#include <IceStorm/IceStorm.h>
+
+#include "Core/Discovery/ServiceLocatorIf.h"
+#include "SessionCommunications/Bridging/BridgingIf.h"
+#include "BridgeManagerAccessor.h"
+
+using namespace ::std;
+using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::SessionCommunications::Bridging::V1;
+
+namespace AsteriskSCF
+{
+namespace BasicRoutingService
+{
+
+/**
+ * The private implementation of BridgeManagerAccessor. 
+ */
+class BridgeManagerAccessorPriv
+{
+public:
+   BridgeManagerAccessorPriv(const ServiceLocatorPrx& locator) :  mServiceLocator(locator), mInitialized(false)
+   {
+      initialize();
+   }
+
+   /**
+    * Initialization. Primarily involves acquring access to specific IceStorm topic. 
+    */
+   void initialize()
+   {
+      try
+      {
+         // Use the locator to find the BridgeManger. 
+         ServiceLocatorParamsPtr nameparam = new ServiceLocatorParams();
+         nameparam->category = BridgeServiceDiscoveryCategory;
+         Ice::ObjectPrx bridgeManagerObject = mServiceLocator->locate(nameparam);
+         mBridgeManager = BridgeManagerPrx::checkedCast(bridgeManagerObject);
+      }
+      catch(const Ice::Exception &e)
+      {
+         cout << "Exception locating " << BridgeServiceDiscoveryCategory << ": " << e.what() << endl; 
+         return;
+      }
+
+      if (mBridgeManager == 0)
+      {
+         cout << "Unable to locate " << BridgeServiceDiscoveryCategory << endl;
+      }
+
+      mInitialized = true;
+   }
+
+   /**
+    * Utiltity to check for initialization state. 
+    */
+   bool verifyInitialized()
+   {
+      if (mInitialized)
+      {
+         return true;
+      }
+
+      // Try again to initialize. 
+      initialize();
+
+      if (!mInitialized)
+      {
+         // TBD...Logging
+         cerr << "Routing Service can't locate BridgeManager at this time." << endl;
+      }
+
+      return mInitialized;
+   }
+
+   bool isInitialized()
+   {
+      return mInitialized;
+   }
+
+public:
+   BridgeManagerPrx mBridgeManager;
+
+private:
+   ServiceLocatorPrx mServiceLocator;
+   bool mInitialized;
+};
+
+/**
+ * Class constructor. 
+ */
+BridgeManagerAccessor::BridgeManagerAccessor(const ServiceLocatorPrx& locator) 
+                                      : mImpl(new BridgeManagerAccessorPriv(locator))
+{
+}
+
+/**
+ * Provide acess to the actual proxy.
+ */
+const BridgeManagerPrx& BridgeManagerAccessor::getBridgeManager() const
+{
+   if (!mImpl->verifyInitialized())
+   {
+      throw "No access to BridgeManager.";
+   }
+
+   return mImpl->mBridgeManager;
+}
+
+bool BridgeManagerAccessor::isInitialized()
+{
+   return mImpl->isInitialized();
+}
+
+
+}; // end BasicRoutingService
+}; // end AsteriskSCF
+
diff --git a/src/BridgeManagerAccessor.h b/src/BridgeManagerAccessor.h
new file mode 100644
index 0000000..b2be780
--- /dev/null
+++ b/src/BridgeManagerAccessor.h
@@ -0,0 +1,40 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+#pragma once
+
+#include <Ice/Ice.h>
+#include <boost/shared_ptr.hpp>
+
+#include "Core/Discovery/ServiceLocatorIf.h"
+#include "SessionCommunications/Bridging/BridgingIf.h"
+
+namespace AsteriskSCF
+{
+namespace BasicRoutingService
+{
+class BridgeManagerAccessorPriv;
+
+/**
+ * A wrapper for the Bridge Manager proxy.  
+ */
+class BridgeManagerAccessor
+{
+public:
+   BridgeManagerAccessor(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& locator); 
+
+   const SessionCommunications::Bridging::V1::BridgeManagerPrx& getBridgeManager() const ;
+   bool isInitialized();
+
+private:
+   boost::shared_ptr<BridgeManagerAccessorPriv> mImpl; // pimpl idiom applied. 
+};
+
+typedef boost::shared_ptr<BridgeManagerAccessor> BridgeManagerAccessorPtr;
+
+}; // end BasicRoutingService
+}; // end AsteriskSCF
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8fa9180..f1bac0f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,7 +9,6 @@ hydra_component_add_slice(BasicRoutingService SessionCommunicationsIf)
 hydra_component_add_slice(BasicRoutingService BridgingIf)
 hydra_component_add_slice(BasicRoutingService ComponentServiceIf)
 hydra_component_add_file(BasicRoutingService BasicRoutingServiceApp.cpp)
-hydra_component_add_file(BasicRoutingService BasicRoutingServiceDataModel.h)
 hydra_component_add_file(BasicRoutingService SessionRouter.cpp)
 hydra_component_add_file(BasicRoutingService SessionRouter.h)
 hydra_component_add_file(BasicRoutingService RoutingAdmin.cpp)
@@ -21,6 +20,8 @@ hydra_component_add_file(BasicRoutingService LuaScriptProcessor.cpp)
 hydra_component_add_file(BasicRoutingService LuaScriptProcessor.h)
 hydra_component_add_file(BasicRoutingService RoutingServiceEventPublisher.cpp)
 hydra_component_add_file(BasicRoutingService RoutingServiceEventPublisher.h)
+hydra_component_add_file(BasicRoutingService BridgeManagerAccessor.cpp)
+hydra_component_add_file(BasicRoutingService BridgeManagerAccessor.h)
 
 hydra_component_add_ice_libraries(BasicRoutingService IceStorm)
 hydra_component_add_boost_libraries(BasicRoutingService thread core regex)
diff --git a/src/EndpointRegistry.cpp b/src/EndpointRegistry.cpp
index a84ff32..f1996be 100644
--- a/src/EndpointRegistry.cpp
+++ b/src/EndpointRegistry.cpp
@@ -7,7 +7,6 @@
  */
 #include <boost/regex.hpp> 
 
-#include "BasicRoutingServiceDataModel.h"
 #include "RoutingServiceEventPublisher.h"
 #include "EndpointRegistry.h"
 #include "ScriptProcessor.h"
@@ -15,6 +14,7 @@
 
 using namespace ::AsteriskSCF::Core::Routing::V1;
 using namespace ::AsteriskSCF::System::Logging;
+using namespace ::AsteriskSCF::Core::Routing::V1::Event;
 using namespace ::std;
 
 namespace
@@ -61,20 +61,22 @@ public:
 class EndpointRegistryPriv
 {
 public:
-   EndpointRegistryPriv() : mEventPublisher(BasicRoutingServiceDataModel::getInstance().getEventPublisher()) 
+   EndpointRegistryPriv(ScriptProcessor* scriptProcessor, RoutingEventsPtr& eventPublisher) 
+         : mScriptProcessor(scriptProcessor), mEventPublisher(eventPublisher) 
    {
    }
 
    map<std::string, RegisteredLocator> mEndpointLocatorMap;
    boost::shared_ptr<ScriptProcessor> mScriptProcessor;
-   const RoutingServiceEventPublisher& mEventPublisher;
+   const RoutingEventsPtr mEventPublisher;
 };
 typedef map<std::string, RegisteredLocator>::iterator EndpointLocatorMapIterator;
 
 /**
  * Constructor.
  */
-EndpointRegistry::EndpointRegistry() : mImpl(new EndpointRegistryPriv())
+EndpointRegistry::EndpointRegistry(ScriptProcessor* scriptProcessor, RoutingEventsPtr& eventPublisher) 
+      : mImpl(new EndpointRegistryPriv(scriptProcessor, eventPublisher))
 {
 }
 
@@ -101,12 +103,13 @@ void EndpointRegistry::addEndpointLocator(const ::std::string& locatorId,
       RegisteredLocator newLocator(locator, regexList);
 
       mImpl->mEndpointLocatorMap[locatorId] = newLocator;
-      mImpl->mEventPublisher.sendAddEndpointLocatorEvent(locatorId, regexList, Event::SUCCESS);
+      mImpl->mEventPublisher->addEndpointLocatorEvent(locatorId, regexList, Event::SUCCESS);
    }
    catch (...)
    {
+
       lg(Error) << "Exception adding EndpointLocator.";
-      mImpl->mEventPublisher.sendAddEndpointLocatorEvent(locatorId, regexList, Event::FAILURE);
+      mImpl->mEventPublisher->addEndpointLocatorEvent(locatorId, regexList, Event::FAILURE);
       return;
    }
 }
@@ -124,19 +127,19 @@ void EndpointRegistry::removeEndpointLocator(const ::std::string& locatorId, con
       {
          lg(Warning) << "Received request to remove Endpoint Locator not currently registered. Id = " << locatorId;
 
-         mImpl->mEventPublisher.sendRemoveEndpointLocatorEvent(locatorId, Event::FAILURE);
+         mImpl->mEventPublisher->removeEndpointLocatorEvent(locatorId, Event::FAILURE);
          return;
       }
 
 
       mImpl->mEndpointLocatorMap.erase(locatorId);
-      mImpl->mEventPublisher.sendRemoveEndpointLocatorEvent(locatorId, Event::SUCCESS);
+      mImpl->mEventPublisher->removeEndpointLocatorEvent(locatorId, Event::SUCCESS);
 
       lg(Info) << "Removed Endpoint Locator with Id = " << locatorId;
    }
    catch(const std::exception &e)
    {
-      mImpl->mEventPublisher.sendRemoveEndpointLocatorEvent(locatorId, Event::FAILURE);
+      mImpl->mEventPublisher->removeEndpointLocatorEvent(locatorId, Event::FAILURE);
       lg(Error) << e.what();
    }
 }
@@ -156,18 +159,18 @@ void EndpointRegistry::setEndpointLocatorDestinationIds(const ::std::string& loc
        EndpointLocatorMapIterator existing = mImpl->mEndpointLocatorMap.find(locatorId);
        if (existing == mImpl->mEndpointLocatorMap.end())
        {
-          mImpl->mEventPublisher.sendSetEndpointLocatorDestinationIdsEvent(locatorId, regExList, Event::FAILURE);
+          mImpl->mEventPublisher->setEndpointLocatorDestinationIdsEvent(locatorId, regExList, Event::FAILURE);
           throw DestinationNotFoundException(locatorId);
        }
 
        // Replace the regular expression. 
        existing->second.setRegEx(regExList);
-       mImpl->mEventPublisher.sendSetEndpointLocatorDestinationIdsEvent(locatorId, regExList, Event::SUCCESS);
+       mImpl->mEventPublisher->setEndpointLocatorDestinationIdsEvent(locatorId, regExList, Event::SUCCESS);
 
    }
    catch(const std::exception &e)
    {
-      mImpl->mEventPublisher.sendSetEndpointLocatorDestinationIdsEvent(locatorId, regExList, Event::FAILURE);
+      mImpl->mEventPublisher->setEndpointLocatorDestinationIdsEvent(locatorId, regExList, Event::FAILURE);
       lg(Error) << "Exception modifying the destination specifications for EndpointLocator " << locatorId;
       lg(Error) << "   - " << e.what();
    }
@@ -182,12 +185,16 @@ void EndpointRegistry::setEndpointLocatorDestinationIds(const ::std::string& loc
 {
    ::AsteriskSCF::Core::Endpoint::V1::EndpointSeq endpoints;
 
-   string modifiedDestination;
-   if (!mImpl->mScriptProcessor->confirmLookup(destination, modifiedDestination))
+   string modifiedDestination(destination);
+   if (mImpl->mScriptProcessor.get() != 0)
    {
-      mImpl->mEventPublisher.sendLookupEvent(destination, Event::FAILURE);
-      lg(Error) << "lookup(): denied by confirmLookup() script.";
-      return endpoints;
+      if (!mImpl->mScriptProcessor->confirmLookup(destination, modifiedDestination))
+      {
+         mImpl->mEventPublisher->lookupEvent(destination, Event::FAILURE);
+
+         lg(Error) << "lookup(): denied by confirmLookup() script.";
+         return endpoints;
+      }
    }
 
    EndpointLocatorMapIterator entry;
@@ -197,11 +204,11 @@ void EndpointRegistry::setEndpointLocatorDestinationIds(const ::std::string& loc
       vector<boost::regex>::iterator reg;
       for(reg=entry->second.regexList.begin(); reg != entry->second.regexList.end(); reg++)
       {
-         if (boost::regex_match(destination, *reg))
+         if (boost::regex_match(modifiedDestination, *reg))
          {
             try
             {
-              endpoints = entry->second.locator->lookup(destination);
+              endpoints = entry->second.locator->lookup(modifiedDestination);
             }
             catch (const IceUtil::Exception &e)
             {
@@ -217,7 +224,7 @@ void EndpointRegistry::setEndpointLocatorDestinationIds(const ::std::string& loc
    {
       result = Event::SUCCESS;
    }
-   mImpl->mEventPublisher.sendLookupEvent(destination, result);
+   mImpl->mEventPublisher->lookupEvent(destination, result);
 
    return endpoints;
 }
@@ -225,9 +232,18 @@ void EndpointRegistry::setEndpointLocatorDestinationIds(const ::std::string& loc
 /**
  * Configure this object with a ScriptProcessor. 
  */
-void EndpointRegistry::setScriptProcessor(boost::shared_ptr<ScriptProcessor> scriptProcessor)
+void EndpointRegistry::setScriptProcessor(ScriptProcessor* scriptProcessor)
 { 
-   mImpl->mScriptProcessor = scriptProcessor;
+   if (scriptProcessor == mImpl->mScriptProcessor.get())
+   {
+      // Calling this method with a pointer to the scriptProcessor that's already held in the shared_ptr would
+      // result in deleting the very object we're trying to set. 
+      return;
+   }
+
+   boost::shared_ptr<ScriptProcessor> ptr(scriptProcessor);
+
+   mImpl->mScriptProcessor = ptr;
 }
 
 /**
@@ -237,7 +253,7 @@ void EndpointRegistry::setScriptProcessor(boost::shared_ptr<ScriptProcessor> scr
 void EndpointRegistry::clearEndpointLocators()
 {
    mImpl->mEndpointLocatorMap.clear();
-   mImpl->mEventPublisher.sendClearEndpointLocatorsEvent();
+   mImpl->mEventPublisher->clearEndpointLocatorsEvent();
 }
 
 /**
@@ -249,7 +265,7 @@ void EndpointRegistry::clearEndpointLocators()
 void EndpointRegistry::setPolicy(::std::string policy)
 {
    mImpl->mScriptProcessor->setPolicy(policy);
-   mImpl->mEventPublisher.sendSetPolicyEvent(policy);
+   mImpl->mEventPublisher->setPolicyEvent(policy);
 }
 
 }; // end BasicRoutingService
diff --git a/src/EndpointRegistry.h b/src/EndpointRegistry.h
index 2a28869..55c2c03 100644
--- a/src/EndpointRegistry.h
+++ b/src/EndpointRegistry.h
@@ -22,9 +22,13 @@ class ScriptProcessor;
 class EndpointRegistry : public AsteriskSCF::Core::Routing::V1::LocatorRegistry
 {
 public:
-   EndpointRegistry();
-
-   void setScriptProcessor(boost::shared_ptr<ScriptProcessor> scriptProcessor);
+   EndpointRegistry(ScriptProcessor* scriptProcessor, ::AsteriskSCF::Core::Routing::V1::Event::RoutingEventsPtr& eventPublisher );
+   
+   /**
+    * Configure the EndpointRegistry to use a different scriptProcessor than the 
+    * one created with. 
+    */
+   void setScriptProcessor(ScriptProcessor* scriptProcessor);
 
 public: 
     // LocatorRegistry overrides
@@ -38,14 +42,14 @@ public:
    virtual void addEndpointLocator(const ::std::string& locatorId, 
                                    const ::AsteriskSCF::Core::Routing::V1::RegExSeq& regexList, 
                                    const ::AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx& locator, 
-                                   const ::Ice::Current& = ::Ice::Current());
+                                   const ::Ice::Current&);
 
    /**
     * Remove an EndpointLocator from the registry. The EndpointLocator must have been previously added
     * via a call to addEndpointLocator. 
     *   @param The unique id of the locator to remove. 
     */
-   virtual void removeEndpointLocator(const ::std::string& locatorId, const ::Ice::Current& = ::Ice::Current());
+   virtual void removeEndpointLocator(const ::std::string& locatorId, const ::Ice::Current& );
 
 
    /**
@@ -56,7 +60,7 @@ public:
     */
    virtual void setEndpointLocatorDestinationIds(const ::std::string& locatorId, 
                                                  const ::AsteriskSCF::Core::Routing::V1::RegExSeq& regexList, 
-                                                 const ::Ice::Current& = ::Ice::Current());
+                                                 const ::Ice::Current&);
    
    // EndpointLocator overrides
 
@@ -64,7 +68,7 @@ public:
     * Returns the endpoints that match the specified destination id. 
     *   @param id String identifier of the the destination. 
     */
-   virtual ::AsteriskSCF::Core::Endpoint::V1::EndpointSeq lookup(const ::std::string& destination, const ::Ice::Current& = ::Ice::Current());
+   virtual ::AsteriskSCF::Core::Endpoint::V1::EndpointSeq lookup(const ::std::string& destination, const ::Ice::Current&);
 
 public:
 
@@ -85,5 +89,7 @@ private:
    boost::shared_ptr<EndpointRegistryPriv> mImpl;
 };
 
+typedef IceInternal::Handle<EndpointRegistry> EndpointRegistryPtr;
+
 }; // end BasicRoutingService
 }; // end AsteriskSCF
diff --git a/src/LuaScriptProcessor.h b/src/LuaScriptProcessor.h
index 29f25f0..c3d939e 100644
--- a/src/LuaScriptProcessor.h
+++ b/src/LuaScriptProcessor.h
@@ -26,8 +26,9 @@ class LuaScriptProcessor : public ScriptProcessor
 public:
    LuaScriptProcessor();
 
-   bool confirmLookup(const ::std::string& destination, ::std::string& modifiedDestination);
-   void setPolicy(const ::std::string& policy);
+   // Overrides
+   virtual bool confirmLookup(const ::std::string& destination, ::std::string& modifiedDestination);
+   virtual void setPolicy(const ::std::string& policy);
 
 private:
    boost::shared_ptr<LuaScriptProcessorPriv> mImpl;
diff --git a/src/RoutingAdmin.cpp b/src/RoutingAdmin.cpp
index d3a03d3..4654476 100644
--- a/src/RoutingAdmin.cpp
+++ b/src/RoutingAdmin.cpp
@@ -8,7 +8,6 @@
 #include <boost/regex.hpp> 
 
 #include "RoutingAdmin.h"
-#include "BasicRoutingServiceDataModel.h"
 #include "EndpointRegistry.h"
 
 using namespace ::AsteriskSCF::Core::Routing::V1;
@@ -19,7 +18,7 @@ namespace AsteriskSCF
 namespace BasicRoutingService
 {
 
-RoutingAdmin::RoutingAdmin()
+RoutingAdmin::RoutingAdmin(EndpointRegistryPtr endpointRegistry) : mEndpointRegistry(endpointRegistry)
 {
 }
 
@@ -30,7 +29,7 @@ void RoutingAdmin::clearEndpointLocators(const ::Ice::Current&)
 {
    // For now we just forward to the registry. Some type of authentication may be required 
    // in the future, or perhaps the access to the interface is controlled externally. 
-   BasicRoutingServiceDataModel::getInstance().getEndpointRegistry().clearEndpointLocators();
+   mEndpointRegistry->clearEndpointLocators();
 }
 
 /**
@@ -42,7 +41,7 @@ void RoutingAdmin::setPolicy(const ::std::string& policy, const ::Ice::Current&)
 {
    // For now we just forward to the registry. Some type of authentication may be required 
    // in the future, or perhaps the access to the interface is controlled externally. 
-   BasicRoutingServiceDataModel::getInstance().getEndpointRegistry().setPolicy(policy);
+   mEndpointRegistry->setPolicy(policy);
 }
 
 }; // end BasicRoutingService
diff --git a/src/RoutingAdmin.h b/src/RoutingAdmin.h
index 3538038..5945c51 100644
--- a/src/RoutingAdmin.h
+++ b/src/RoutingAdmin.h
@@ -7,9 +7,8 @@
  */
 #pragma once
 
-#include <boost/shared_ptr.hpp>
-
 #include "RoutingIf.h"
+#include "EndpointRegistry.h"
 
 namespace AsteriskSCF
 {
@@ -23,7 +22,7 @@ class EndpointRegistryPriv;
 class RoutingAdmin : public AsteriskSCF::Core::Routing::V1::RoutingServiceAdmin
 {
 public:
-   RoutingAdmin();
+   RoutingAdmin(EndpointRegistryPtr endpointRegistry);
 
 public:  // RoutingServiceAdmin overrides
 
@@ -39,6 +38,8 @@ public:  // RoutingServiceAdmin overrides
     */
    virtual void setPolicy(const ::std::string& policy, const ::Ice::Current& = ::Ice::Current());
 
+private:
+   EndpointRegistryPtr mEndpointRegistry;
 };
 
 }; // end BasicRoutingService
diff --git a/src/RoutingServiceEventPublisher.cpp b/src/RoutingServiceEventPublisher.cpp
index bf865bb..7c84ea5 100644
--- a/src/RoutingServiceEventPublisher.cpp
+++ b/src/RoutingServiceEventPublisher.cpp
@@ -8,7 +8,6 @@
 #include <Ice/Ice.h>
 #include <IceStorm/IceStorm.h>
 
-#include "BasicRoutingServiceDataModel.h"
 #include "RoutingServiceEventPublisher.h"
 #include "logger.h"
 
@@ -32,7 +31,7 @@ namespace BasicRoutingService
 class RoutingServiceEventPublisherPriv
 {
 public:
-   RoutingServiceEventPublisherPriv() :  mInitialized(false)
+   RoutingServiceEventPublisherPriv(Ice::ObjectAdapterPtr adapter) :  mAdapter(adapter), mInitialized(false)
    {
       initialize();
    }
@@ -42,7 +41,7 @@ public:
     */
    void initialize()
    {
-      const Ice::CommunicatorPtr& communicator = BasicRoutingServiceDataModel::getInstance().getCommunicator();
+      const Ice::CommunicatorPtr communicator = mAdapter->getCommunicator();
       IceStorm::TopicManagerPrx topicManager(0);
 
       try
@@ -101,7 +100,7 @@ public:
 
       if (!mInitialized)
       {
-         lg(Error) << "Routing Service event publishing can't locate IceStorm.";
+         lg(Error) << "Routing Service can't locate IceStorm. Events will not be published.";
       }
 
       return mInitialized;
@@ -109,22 +108,26 @@ public:
 
 public:
    Event::RoutingEventsPrx mEventTopic;
+
+private:
+   Ice::ObjectAdapterPtr mAdapter;
    bool mInitialized;
 };
 
 /**
  * Class constructor. 
  */
-RoutingServiceEventPublisher::RoutingServiceEventPublisher() 
-                                      : mImpl(new RoutingServiceEventPublisherPriv())
+RoutingServiceEventPublisher::RoutingServiceEventPublisher(Ice::ObjectAdapterPtr adapter) 
+                                      : mImpl(new RoutingServiceEventPublisherPriv(adapter))
 {
 }
 
 /**
  * Send a message to the service's event topic to report a lookup event.
  */
-void RoutingServiceEventPublisher::sendLookupEvent(const ::std::string& destination, 
-                                               ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result) const
+void RoutingServiceEventPublisher::lookupEvent(const ::std::string& destination, 
+                                               ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
+                                               const Ice::Current &)
 {
    if (!mImpl->isInitialized())
    {
@@ -138,9 +141,10 @@ void RoutingServiceEventPublisher::sendLookupEvent(const ::std::string& destinat
 /**
  * Send a message to the service's event topic to report the addEndpointLocator event.
  */
-void RoutingServiceEventPublisher::sendAddEndpointLocatorEvent(const ::std::string& locatorId, 
+void RoutingServiceEventPublisher::addEndpointLocatorEvent(const ::std::string& locatorId, 
                                                            const ::AsteriskSCF::Core::Routing::V1::RegExSeq& regexList, 
-                                                           ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result) const
+                                                           ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
+                                                           const Ice::Current &)
 {
    if (!mImpl->isInitialized())
    {
@@ -153,8 +157,9 @@ void RoutingServiceEventPublisher::sendAddEndpointLocatorEvent(const ::std::stri
 /**
  * Send a message to the service's event topic to report the removeEndpointLocator event.
  */
-void RoutingServiceEventPublisher::sendRemoveEndpointLocatorEvent(const ::std::string& locatorId, 
-                                                              ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result) const
+void RoutingServiceEventPublisher::removeEndpointLocatorEvent(const ::std::string& locatorId, 
+                                                              ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
+                                                              const Ice::Current &)
 {
    if (!mImpl->isInitialized())
    {
@@ -167,9 +172,10 @@ void RoutingServiceEventPublisher::sendRemoveEndpointLocatorEvent(const ::std::s
 /**
  * Send a message to the service's event topic to report the setEndpointLocatorDestinationIds event.
  */
-void RoutingServiceEventPublisher::sendSetEndpointLocatorDestinationIdsEvent(const ::std::string& locatorId, 
+void RoutingServiceEventPublisher::setEndpointLocatorDestinationIdsEvent(const ::std::string& locatorId, 
                                                                const ::AsteriskSCF::Core::Routing::V1::RegExSeq& regexList, 
-                                                               ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result) const
+                                                               ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
+                                                               const Ice::Current &)
 {
    if (!mImpl->isInitialized())
    {
@@ -182,7 +188,7 @@ void RoutingServiceEventPublisher::sendSetEndpointLocatorDestinationIdsEvent(con
 /**
  * Send a message to the service's event topic to report the clearEndpointLocators event.
  */
-void RoutingServiceEventPublisher::sendClearEndpointLocatorsEvent() const
+void RoutingServiceEventPublisher::clearEndpointLocatorsEvent(const Ice::Current &)
 {
    if (!mImpl->isInitialized())
    {
@@ -195,7 +201,7 @@ void RoutingServiceEventPublisher::sendClearEndpointLocatorsEvent() const
 /**
  * Send a message to the service's event topic to report the setPolicy event.
  */
-void RoutingServiceEventPublisher::sendSetPolicyEvent(const ::std::string& policy) const
+void RoutingServiceEventPublisher::setPolicyEvent(const ::std::string& policy, const Ice::Current &)
 {
    if (!mImpl->isInitialized())
    {
diff --git a/src/RoutingServiceEventPublisher.h b/src/RoutingServiceEventPublisher.h
index 6c82f86..88d5dc1 100644
--- a/src/RoutingServiceEventPublisher.h
+++ b/src/RoutingServiceEventPublisher.h
@@ -7,6 +7,7 @@
  */
 #pragma once
 
+#include <Ice/Ice.h>
 #include <boost/shared_ptr.hpp>
 
 #include "RoutingIf.h"
@@ -20,18 +21,21 @@ class RoutingServiceEventPublisherPriv;
 /**
  * Publishes key events to the rest of the system. 
  */
-class RoutingServiceEventPublisher 
+class RoutingServiceEventPublisher : public ::AsteriskSCF::Core::Routing::V1::Event::RoutingEvents
 {
 public:
-   RoutingServiceEventPublisher(); 
+   RoutingServiceEventPublisher(Ice::ObjectAdapterPtr adapter); 
+
+   // Overrides
 
    /**
     * Send a message to the service's event topic to report a lookup event.
     *  @param destination The destination to be looked up. 
     *  @param result Informs event listeners of the operations success or failure. 
     */
-   void sendLookupEvent(const ::std::string& destination, 
-                        ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result) const;
+   void lookupEvent(const ::std::string& destination, 
+                        ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
+                        const Ice::Current &);
 
    /**
     * Send a message to the service's event topic to report an addEndpointLocator event.
@@ -39,17 +43,19 @@ public:
     *  @param regexList List of regex strings used to identify the destinations available by this locator. 
     *  @param result Informs event listeners of the operations success or failure. 
     */
-   void sendAddEndpointLocatorEvent(const ::std::string& locatorId, 
+   void addEndpointLocatorEvent(const ::std::string& locatorId, 
                                     const ::AsteriskSCF::Core::Routing::V1::RegExSeq& regexList, 
-                                    ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result) const;
+                                    ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
+                                    const Ice::Current &);
 
    /**
     * Send a message to the service's event topic to report a removeEndpointLocator event.
     *  @param locatorId The identity of the EndpointLocator being removed. 
     *  @param result Informs event listeners of the operations success or failure. 
     */
-   void sendRemoveEndpointLocatorEvent(const ::std::string& locatorId, 
-                                       ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result) const;
+   void removeEndpointLocatorEvent(const ::std::string& locatorId, 
+                                       ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
+                                       const Ice::Current &);
 
    /**
     * Send a message to the service's event topic to report a aetEndpointLocatorDestinationIds event.
@@ -57,20 +63,21 @@ public:
     *  @param regexList New list of regex strings to be used to identify the destinations available by this locator. 
     *  @param result Informs event listeners of the operations success or failure. 
     */
-   void sendSetEndpointLocatorDestinationIdsEvent(const ::std::string& locatorId, 
+   void setEndpointLocatorDestinationIdsEvent(const ::std::string& locatorId, 
                                                   const ::AsteriskSCF::Core::Routing::V1::RegExSeq& regexList, 
-                                                  ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result) const;
+                                                  ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
+                                                  const Ice::Current &);
 
 
    /**
     * Send a message to the service's event topic to report the clearEndpointLocators event.
     */
-   void sendClearEndpointLocatorsEvent() const;
+   void clearEndpointLocatorsEvent(const Ice::Current &);
 
    /**
     * Send a message to the service's event topic to report the setPolicy event.
     */
-   void sendSetPolicyEvent(const ::std::string& policy) const;
+   void setPolicyEvent(const ::std::string& policy, const Ice::Current &);
 
 private:
    boost::shared_ptr<RoutingServiceEventPublisherPriv> mImpl; // pimpl idiom applied. 
diff --git a/src/SessionRouter.cpp b/src/SessionRouter.cpp
index 9a91682..fcb5680 100644
--- a/src/SessionRouter.cpp
+++ b/src/SessionRouter.cpp
@@ -8,16 +8,17 @@
 
 #include "SessionRouter.h"
 #include "EndpointRegistry.h"
-#include "BasicRoutingServiceDataModel.h"
 #include "RoutingIf.h"
 #include "EndpointIf.h"
 #include "logger.h"
+#include "BridgeManagerAccessor.h"
 
 using namespace ::AsteriskSCF::Core::Routing::V1;
 using namespace ::AsteriskSCF::Core::Endpoint::V1;
 using namespace ::AsteriskSCF::System::Logging;
 using namespace ::AsteriskSCF::SessionCommunications::V1;
 using namespace ::AsteriskSCF::SessionCommunications::Bridging::V1;
+using namespace ::AsteriskSCF::Core::Routing::V1::Event;
 using namespace ::AsteriskSCF::BasicRoutingService;
 
 using namespace ::std;
@@ -140,7 +141,15 @@ typedef ::IceInternal::Handle<SessionListenerImpl> SessionListenerImplPtr;
 class SessionRouterPriv
 {
 public: 
-   SessionRouterPriv()  {}
+   SessionRouterPriv(Ice::ObjectAdapterPtr& objectAdapter,  
+                     EndpointRegistryPtr& endpointRegistry,
+                     ::AsteriskSCF::Core::Routing::V1::Event::RoutingEventsPtr& eventPublisher)
+         : mAdapter(objectAdapter), 
+           mEndpointRegistry(endpointRegistry), 
+           mEventPublisher(eventPublisher) 
+   {
+   }
+
    ~SessionRouterPriv()  
    {
       for (map<string, SessionListenerImplPtr>::iterator i = mActiveListeners.begin(); i != mActiveListeners.end(); ++i) 
@@ -155,7 +164,7 @@ public:
 
    Ice::Identity getListenerId(string sourceId)
    {
-      return BasicRoutingServiceDataModel::getInstance().getCommunicator()->stringToIdentity(sourceId + "Listener");
+      return mAdapter->getCommunicator()->stringToIdentity(sourceId + "Listener");
    }
 
    /**
@@ -177,7 +186,7 @@ public:
 
          SessionListenerImplPtr listener = new SessionListenerImpl(source);
 
-         Ice::ObjectPrx prx = BasicRoutingServiceDataModel::getInstance().getObjectAdapter()->addWithUUID(listener);
+         Ice::ObjectPrx prx = mAdapter->addWithUUID(listener);
          listener->setProxy(SessionListenerPrx::checkedCast(prx));
 
          mActiveListeners[listener->ice_id()] = listener;
@@ -204,9 +213,24 @@ public:
       mActiveListeners[key] = 0; // Set smart point to null. 
       mActiveListeners.erase(key);
    }
+
+   void setBridgeAccessor(BridgeManagerAccessorPtr bridgeAccessor)
+   {
+      mBridgeManagerAccessor = bridgeAccessor;
+   }
+
+public:
+   Ice::ObjectAdapterPtr mAdapter;
+   EndpointRegistryPtr mEndpointRegistry;
+   RoutingEventsPtr mEventPublisher;
+   BridgeManagerAccessorPtr mBridgeManagerAccessor;
+
 };
 
-SessionRouter::SessionRouter() : mImpl(new SessionRouterPriv())
+SessionRouter::SessionRouter(Ice::ObjectAdapterPtr& objectAdapter,  
+                             EndpointRegistryPtr& endpointRegistry,
+                             ::AsteriskSCF::Core::Routing::V1::Event::RoutingEventsPtr& eventPublisher) 
+  : mImpl(new SessionRouterPriv(objectAdapter, endpointRegistry, eventPublisher))
 {
 }
 
@@ -215,6 +239,11 @@ SessionRouter::~SessionRouter()
    mImpl.reset();
 }
 
+void SessionRouter::setBridgeManagerAccessor(BridgeManagerAccessorPtr bridgeAccessor)
+{
+   mImpl->mBridgeManagerAccessor = bridgeAccessor;
+}
+
 /**
  * Route the session by looking up the destination endpoint and configuring a complimentary session for the destination. 
  *   TBD - Need to rework with asynch support.
@@ -230,7 +259,7 @@ void SessionRouter::routeSession(const ::AsteriskSCF::SessionCommunications::V1:
    try
    {
       // Lookup the destination. 
-      endpoints = BasicRoutingServiceDataModel::getInstance().getEndpointRegistry().lookup(destination, current);
+      endpoints = mImpl->mEndpointRegistry->lookup(destination, current);
 
       if (endpoints.empty())
       {
@@ -280,7 +309,7 @@ void SessionRouter::routeSession(const ::AsteriskSCF::SessionCommunications::V1:
    BridgePrx bridge;
    try
    {
-      bridge = BasicRoutingServiceDataModel::getInstance().getBridgeManager()->createBridge(listener->getSessions(), 0);
+      bridge = mImpl->mBridgeManagerAccessor->getBridgeManager()->createBridge(listener->getSessions(), 0);
    }
    catch (const Ice::Exception &)
    {
diff --git a/src/SessionRouter.h b/src/SessionRouter.h
index 67c0232..7d60cf7 100644
--- a/src/SessionRouter.h
+++ b/src/SessionRouter.h
@@ -7,9 +7,12 @@
  */
 #pragma once
 
+#include <Ice/Ice.h>
 #include <boost/shared_ptr.hpp>
 
-#include "SessionCommunicationsIf.h"
+#include "SessionCommunications/SessionCommunicationsIf.h"
+#include "BridgeManagerAccessor.h"
+#include "EndpointRegistry.h"
 
 namespace AsteriskSCF
 {
@@ -23,9 +26,13 @@ class SessionRouterPriv;
 class SessionRouter : public AsteriskSCF::SessionCommunications::V1::SessionRouter
 {
 public:
-   SessionRouter();
+   SessionRouter(Ice::ObjectAdapterPtr& objectAdapter,  
+                 EndpointRegistryPtr& endpointRegistry,
+                 ::AsteriskSCF::Core::Routing::V1::Event::RoutingEventsPtr& eventPublisher);
    ~SessionRouter();
 
+   void setBridgeManagerAccessor(BridgeManagerAccessorPtr bridgeAccessor);
+
 public:  
     // SessionRouter overrides
 
@@ -34,11 +41,13 @@ public:
     */
    virtual void routeSession(const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& source, 
                              const ::std::string& destination, 
-                             const ::Ice::Current& = ::Ice::Current());
+                             const ::Ice::Current&);
 private: 
    boost::shared_ptr<SessionRouterPriv> mImpl;
 };
 
+typedef IceInternal::Handle<AsteriskSCF::BasicRoutingService::SessionRouter> BasicSessionRouterPtr;
+
 }; // end BasicRoutingService
 }; // end AsteriskSCF
 
diff --git a/test/TestRouting.cpp b/test/TestRouting.cpp
index 4f5157e..bdea0b3 100644
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@ -168,7 +168,7 @@ struct GlobalIceFixture
 
 	~GlobalIceFixture()
    {
-		BOOST_TEST_MESSAGE("Tearing down service discovery test fixture");
+		BOOST_TEST_MESSAGE("Tearing down Routing Test global test fixture");
 
 
 		if (SharedTestData::instance.communicator_in) 
@@ -207,7 +207,11 @@ public:
    {
 	   try
       {
+         BOOST_TEST_MESSAGE("PerTestFixture initializing...");
+
          SharedTestData::instance.locatorRegistry->addEndpointLocator("TestChannel", SharedTestData::instance.mRegExIds, SharedTestData::instance.mEndpointLocatorPrx);
+
+         BOOST_TEST_MESSAGE("PerTestFixture initialized.");
       }
       catch (...)
       {
@@ -219,8 +223,12 @@ public:
    {
 	   try
       {
+         BOOST_TEST_MESSAGE("PerTestFixture cleanup starting...");
+
          SharedTestData::instance.locatorRegistry->removeEndpointLocator("TestChannel");
          SharedTestData::instance.mEndpointLocator->perTestCleanup();
+
+         BOOST_TEST_MESSAGE("PerTestFixture cleanup complete.");
       }
       catch(const std::exception &e)
       {

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


-- 
asterisk-scf/integration/routing.git



More information about the asterisk-scf-commits mailing list