[asterisk-scf-commits] asterisk-scf/integration/routing.git branch "basecomponentsquash" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Aug 2 15:07:15 CDT 2011


branch "basecomponentsquash" has been created
        at  3bc738ffc9c832038c6f9811612a904b579c52cf (commit)

- Log -----------------------------------------------------------------
commit 3bc738ffc9c832038c6f9811612a904b579c52cf
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Jun 21 12:04:24 2011 -0500

    Updates for id field added to ServiceLocatorParams and use of base Component class.

diff --git a/config/routingtest.conf b/config/routingtest.conf
index a7fb9d0..e9a026c 100644
--- a/config/routingtest.conf
+++ b/config/routingtest.conf
@@ -3,7 +3,7 @@
 Ice.Default.CollocationOptimized=0
 
 Ice.Warn.UnknownProperties=0
-Ice.ThreadPool.Client.Size=4
+Ice.ThreadPool.Client.Size=6
 
 #Ice.Admin.Endpoints=tcp -p 10006
 #Ice.Admin.InstanceName=IceBox
@@ -46,7 +46,7 @@ RoutingService.ThreadPool.Size=8
 RoutingService.ThreadPool.SizeMax=14
 RoutingService.ThreadPool.SizeWarn=9
 RoutingService.Standby=no
-RoutingService.StateReplicatorName=Replicator
+RoutingService.StateReplicatorId=Replicator
 RoutingService.ComponentTest=yes
 
 RoutingService2.Endpoints=tcp -p 10052
@@ -55,7 +55,7 @@ RoutingService2.ThreadPool.Size=8
 RoutingService2.ThreadPool.SizeMax=14
 RoutingService2.ThreadPool.SizeWarn=9
 RoutingService2.Standby=yes
-RoutingService2.StateReplicatorName=Replicator
+RoutingService2.StateReplicatorId=Replicator
 
 Replicator.InstanceName=Replicator
 Replicator.Endpoints=default -p 10054
@@ -83,10 +83,11 @@ BackupLocatorRegistry.Proxy=RoutingServiceLocatorRegistry:tcp -p 10052
 SessionRouter.Proxy=SessionRouter:tcp -p 10050
 BackupSessionRouter.Proxy=SessionRouter:tcp -p 10052
 
-Replica.Proxy=BasicRoutingServiceReplica:tcp -p 10051
-BackupReplica.Proxy=BasicRoutingServiceReplica:tcp -p 10053
+Replica.Proxy=Replica:tcp -p 10051
+BackupReplica.Proxy=Replica:tcp -p 10053
 
-RoutingComponent.Proxy=BasicRoutingComponent:tcp -p 10051
+# Proxy to the Component Service inteface
+RoutingComponent.Proxy=ComponentService:tcp -p 10051
 
 TestRoutingAdapterIn.ThreadPool.Size=8
 TestRoutingAdapterIn.ThreadPool.SizeMax=14
diff --git a/local-slice/BasicRoutingStateReplicationIf.ice b/local-slice/BasicRoutingStateReplicationIf.ice
index 4ea55c1..ed464f4 100644
--- a/local-slice/BasicRoutingStateReplicationIf.ice
+++ b/local-slice/BasicRoutingStateReplicationIf.ice
@@ -30,11 +30,6 @@ module V1
     const string StateReplicatorComponentCategory = "RoutingStateReplicatorComponent";
     const string StateReplicatorDiscoveryCategory = "RoutingStateReplicator";
 
-    unsliceable class RoutingStateReplicatorParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
-    {
-       string name;
-    };
-
     ///////////////////////////////////////////////////////////////////////
     // These classes and interfaces implement the replication 
     // pattern of Asterisk SCF.
@@ -184,5 +179,5 @@ module V1
     };
 
 }; //module V1
-}; //module BasicRouting
+}; //module V1
 }; //module Asterisk SCF
diff --git a/src/BasicRoutingServiceApp.cpp b/src/BasicRoutingServiceApp.cpp
deleted file mode 100644
index 99f1669..0000000
--- a/src/BasicRoutingServiceApp.cpp
+++ /dev/null
@@ -1,827 +0,0 @@
-/*
- * Asterisk SCF -- An open-source communications framework.
- *
- * Copyright (C) 2010-2011, Digium, Inc.
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk SCF project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE.txt file
- * at the top of the source tree.
- */
-#include <Ice/Ice.h>
-#include <IceBox/IceBox.h>
-
-#include <boost/thread.hpp>
-#include <boost/shared_ptr.hpp>
-
-#include <AsteriskSCF/Discovery/SmartProxy.h>
-#include <AsteriskSCF/Core/Routing/RoutingIf.h>
-#include <AsteriskSCF/System/Component/ReplicaIf.h>
-#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
-#include <AsteriskSCF/System/Component/ComponentServiceIf.h>
-#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
-
-#include <AsteriskSCF/Logger/IceLogger.h>
-#include <AsteriskSCF/logger.h>
-
-#include "AsteriskSCF/Threading/SimpleWorkQueue.h"
-#include "RoutingStateReplicatorListener.h"
-#include "LuaScriptProcessor.h"
-#include "RoutingServiceEventPublisher.h"
-#include "EndpointRegistry.h"
-#include "RoutingAdmin.h"
-#include "SessionRouter.h"
-#include "OperationReplicaCache.h"
-#include "ReplicationContext.h"
-#include "TestContext.h"
-
-using namespace std;
-using namespace AsteriskSCF::SessionCommunications::V1;
-using namespace AsteriskSCF::Core;
-using namespace AsteriskSCF::Core::Routing::V1;
-using namespace AsteriskSCF::Core::Discovery::V1;
-using namespace AsteriskSCF::System::Component::V1;
-using namespace AsteriskSCF::System::Logging;
-using namespace AsteriskSCF::BasicRoutingService::V1;
-using namespace AsteriskSCF::Discovery;
-
-namespace
-{
-Logger lg = getLoggerFactory().getLogger("AsteriskSCF.BasicRoutingService");
-}
-using namespace AsteriskSCF::Core::Routing::V1::Event;
-
-namespace AsteriskSCF
-{
-namespace BasicRoutingService
-{
-
-class ComponentServiceImpl;
-typedef ::IceUtil::Handle<ComponentServiceImpl> ComponentServiceImplPtr;
-
-class ReplicaControl;
-typedef ::IceUtil::Handle<ReplicaControl> ReplicaControlPtr;
-
-class BasicRoutingServiceApp : public IceBox::Service
-{
-public:
-    BasicRoutingServiceApp() 
-        : mImplementationId("BasicRoutingService"),
-          mDone(false), 
-          mInitialized(false), 
-          mRunning(false),
-          mPublishTestInterface(false),
-          mSessionContext(new SessionContext()),
-          mWorkQueue( new AsteriskSCF::Threading::SimpleWorkQueue("SessionRouterWorkQueue")),
-          mListeningToReplicator(false)
-    {
-    }
-
-    void resume();
-    void suspend();
-
-    void activated();
-    void onStandby();
-    bool isActive();
-
-    ////// Overrides of IceBox::Service
-
-    virtual void start(const string& name, const ::Ice::CommunicatorPtr& ic, const ::Ice::StringSeq& args);
-    virtual void stop();
-
-private:
-    void suspendService(bool shuttingDown);
-    void initialize();
-    void locateBridgeManager();
-    void locateStateReplicator();
-    void registerWithServiceLocator(bool includeBackplaneServices);
-    void deregisterFromServiceLocator(bool includeBackplaneServices);
-    void suspendRegisteredServants(bool includeBackplaneServices);
-    void unsuspendRegisteredServants(bool includeBackplaneServices);
-
-    void listenToStateReplicator();
-    void stopListeningToStateReplicator();
-
-    /**
-     * Get an impementation-specific ID for createing service discovery guids. 
-     * This is not the same as the app name, which is configurable. 
-     */
-    const std::string mImplementationId; 
-    bool mDone;
-    bool mInitialized;
-    bool mRunning;
-    bool mPublishTestInterface;
-    SessionContextPtr mSessionContext;
-    boost::shared_ptr<AsteriskSCF::Threading::SimpleWorkQueue> mWorkQueue;
-
-    std::string mAppName;
-    ServiceLocatorManagementPrx mServiceLocatorManagement;
-    ServiceLocatorPrx mServiceLocator;
-
-    ServiceManagementPrx mRegistryLocatorManagement;
-    ServiceManagementPrx mAdminManagement;
-    ServiceManagementPrx mComponentServiceManagement;
-    ServiceManagementPrx mReplicaManagement;
-    ServiceManagementPrx mSessionRouterManagement;
-
-    // Our published interfaces.
-    BasicSessionRouterPtr mSessionRouter;
-    SessionRouterPrx mSessionRouterPrx;
-
-    RoutingServiceAdminPtr mAdminInteface;
-    RoutingServiceAdminPrx mAdminPrx;
-
-    ComponentServiceImplPtr mComponentService;
-    ComponentServicePrx mComponentServicePrx;
-
-    ComponentTestPtr mComponentTest;
-    ComponentTestPrx mComponentTestPrx;
-
-    AsteriskSCF::Discovery::SmartProxy<BridgeManagerPrx> mBridgeManager;
-    RoutingServiceEventPublisherPtr mEventPublisher;
-    boost::shared_ptr<OperationReplicaCache> mOperationReplicaCache;
-
-    EndpointRegistryPtr mEndpointRegistry;
-    LocatorRegistryPrx mEndpointRegistryPrx;
-
-    // Replication support
-    ReplicationContextPtr mReplicationContext;
-    ReplicaPrx mReplicaPrx;
-
-    ReplicaControlPtr mReplicaControl;
-    AsteriskSCF::Discovery::SmartProxy<RoutingStateReplicatorPrx> mStateReplicator;
-    RoutingStateReplicatorListenerPtr mReplicatorListener;
-
-    RoutingStateReplicatorListenerPrx mReplicatorListenerProxy;
-    bool mListeningToReplicator;
-
-    // Implementation
-    ::Ice::ObjectAdapterPtr mServiceAdapter;
-    ::Ice::ObjectAdapterPtr mBackplaneAdapter;
-
-    ::Ice::CommunicatorPtr mCommunicator;
-
-    boost::shared_mutex mReplicatorLock;
-};
-typedef ::IceUtil::Handle<BasicRoutingServiceApp> BasicRoutingServiceAppPtr;
-
-static const string RegistryLocatorObjectId("RoutingServiceLocatorRegistry");
-static const string RoutingAdminObjectId("RoutingAdmin");
-static const string ComponentServiceId("BasicRoutingComponent");
-static const string SessionRouterObjectId("SessionRouter");
-static const string ReplicaServiceId("BasicRoutingServiceReplica");
-
-/**
- * This class provides implementation for the ComponentService interface.
- * Every Asterisk SCF component is expected to expose the ComponentService interface.
- */
-class ComponentServiceImpl : public ComponentService
-{
-public:
-    ComponentServiceImpl(BasicRoutingServiceApp* app) :
-        mApp(app)
-    {
-    }
-
-public: // Overrides of the ComponentService interface.
-    void suspend(const ::Ice::Current&)
-    {
-        mApp->suspend();
-    }
-
-    void resume(const ::Ice::Current&)
-    {
-        mApp->resume();
-    }
-
-    void shutdown(const ::Ice::Current&)
-    {
-        mApp->stop();
-    }
-
-    void shutdownNotice()
-    {
-        mApp = 0;
-    }
-
-private:
-    BasicRoutingServiceAppPtr mApp;
-};
-
-/** 
- * This interface is published as a facet of the Component Service interface.
- * It exists to allow more elaborate interaction with a component during testing.
- */
-class ComponentTestImpl : public ComponentTest
-{
-public:
-    ComponentTestImpl(const TestContextPtr& testContext) :
-        mTestContext(testContext)
-    {
-    }
-
-    void setTestMode(const ::std::string& mode, const ::Ice::Current&)
-    {
-        mTestContext->setTestMode(mode);
-    }
-
-    void setTestModeWithArgs(const ::std::string& mode, 
-                             const ComponentTestParamSeq&, 
-                             const ::Ice::Current&)
-    {
-        mTestContext->setTestMode(mode);
-    }
-
-    void clearTestMode(const string&, const ::Ice::Current&)
-    {
-       mTestContext->clearTestMode();
-    }
-
-    void clearTestModes(const ::Ice::Current&)
-    {
-        mTestContext->clearTestMode();
-    }
-
-private:
-    TestContextPtr mTestContext;
-};
-
-/**
- * This class provides implementation for this component's Replica management interface.
- */
-class ReplicaControl : public Replica
-{
-public:
-    /**
-     * Constructor. 
-     *  @param app 
-     *  @param adapter The adapter is assumed to have been activated. 
-     */
-    ReplicaControl(BasicRoutingServiceApp* app, ::Ice::ObjectAdapterPtr adapter) : mApp(app), mAdapter(adapter)
-    { 
-    }
-
-    bool isActive(const ::Ice::Current&)
-    {
-        return mApp->isActive();
-    }
-
-    bool activate(const ::Ice::Current&)
-    {
-        mApp->activated();
-
-        for (vector<AsteriskSCF::System::Component::V1::ReplicaListenerPrx>::const_iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
-        {
-            (*listener)->activated(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(ReplicaServiceId))));
-        }
-
-        return true;
-    }
-
-    void standby(const ::Ice::Current&)
-    {
-        mApp->onStandby();
-
-        for (vector<AsteriskSCF::System::Component::V1::ReplicaListenerPrx>::const_iterator listener = mListeners.begin(); 
-             listener != mListeners.end(); ++listener)
-        {
-            (*listener)->onStandby(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(ReplicaServiceId))));
-        }
-    }
-
-    void addListener(const AsteriskSCF::System::Component::V1::ReplicaListenerPrx& listener, const ::Ice::Current&)
-    {
-        mListeners.push_back(listener);
-    }
-
-    void removeListener(const AsteriskSCF::System::Component::V1::ReplicaListenerPrx& listener, const ::Ice::Current&)
-    {
-        mListeners.erase(std::remove(mListeners.begin(), mListeners.end(), listener), mListeners.end());
-    }
-
-private:
-    BasicRoutingServiceAppPtr mApp;
-
-    /**
-     * Pointer to the object adapter we exist on.
-     */
-    ::Ice::ObjectAdapterPtr mAdapter;
-
-    /**
-     * Listeners that we need to push state change notifications out to.
-     */
-    vector<AsteriskSCF::System::Component::V1::ReplicaListenerPrx> mListeners;
-};
-
-bool BasicRoutingServiceApp::isActive()
-{
-    // The Replication Context is tracking our current status. 
-    return mReplicationContext->isComponentActive();
-}
-
-void BasicRoutingServiceApp::activated()
-{
-    mReplicationContext->setComponentActive();
-    stopListeningToStateReplicator();
-}
-
-void BasicRoutingServiceApp::onStandby()
-{
-    mReplicationContext->setComponentStandby();
-    listenToStateReplicator();
-}
-
-/** 
- * Register as a listener to our state replicator. 
- * A component in standby mode will do this to monitor state changes
- * being sent from an active component. 
- */
-void BasicRoutingServiceApp::listenToStateReplicator()
-{
-    boost::unique_lock<boost::shared_mutex> lock(mReplicatorLock); 
-
-    if ((mReplicationContext->getReplicatorService() == 0) || (mListeningToReplicator == true))
-    {
-        return;
-    }
-
-    try
-    {
-        // Are we in standby mode?
-        if (mReplicationContext->isComponentActive() == false)
-        {
-            AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorPrx oneWayStateReplicator = 
-                  AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorPrx::uncheckedCast(mReplicationContext->getReplicatorService()->ice_oneway());
-
-            oneWayStateReplicator->addListener(mReplicatorListenerProxy);
-            mListeningToReplicator = true;
-        }
-    }
-    catch (const Ice::Exception& e)
-    {
-        lg(Error) << e.what();
-        throw;
-    }
-}
-
-/** 
- * Unregister as a listener to our state replicator. 
- * A component in active mode doesn't neeed to listen to
- * state replication data. 
- */
-void BasicRoutingServiceApp::stopListeningToStateReplicator()
-{
-    boost::unique_lock<boost::shared_mutex> lock(mReplicatorLock); 
-
-    if ((mReplicationContext->getReplicatorService() == 0) || (mListeningToReplicator == false))
-    {
-        return;
-    }
-
-    try
-    {
-        AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorPrx oneWayStateReplicator = 
-                AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorPrx::uncheckedCast(mReplicationContext->getReplicatorService()->ice_oneway());
-
-        oneWayStateReplicator->removeListener(mReplicatorListenerProxy);
-
-        mListeningToReplicator = false;
-    }
-    catch (const Ice::Exception& e)
-    {
-        lg(Error) << e.what();
-        throw;
-    }
-}
-
-/**
- * Helper function to add some parameters to one of our registered interfaces in the ServiceLocator, so that
- * other components can look up our interfaces.
- */
-void setCategory(const AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx& serviceManagement, const string& category)
-{
-    // Add category as a parameter to enable other components look this component up.
-    ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams;
-    genericparams->category = category;
-    serviceManagement->addLocatorParams(genericparams, "");
-}
-
-/**
- * Register this component's primary public interfaces with the Service Locator.
- * This enables other Asterisk SCF components to locate the interfaces we are publishing.
- *
- * @param includeBackplaneServices If true, registers our management interfaces
- * in addition to all our other interfaces. 
- */
-void BasicRoutingServiceApp::registerWithServiceLocator(bool includeBackplaneServices)
-{
-    try
-    {
-        // Register our RoutingAdmin interface with the Service Locator.
-        string adminServiceGuid(mImplementationId + "." + Routing::V1::RoutingServiceAdminDiscoveryCategory); // Should be unique for reporting.
-        mAdminManagement = mServiceLocatorManagement->addService(mAdminPrx, adminServiceGuid);
-        setCategory(mAdminManagement, Routing::V1::RoutingServiceAdminDiscoveryCategory);
-
-        // Register our RegistryLocator interface with the Service Locator.
-        string locatorServiceGuid(mImplementationId + "." + Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory);  // Should be unique for reporting.
-        mRegistryLocatorManagement = mServiceLocatorManagement->addService(mEndpointRegistryPrx, locatorServiceGuid);
-        setCategory(mRegistryLocatorManagement, Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory);
-
-        // Register the SessionRouter interface with the Service Locator.
-        string sessionRouterGuid(mImplementationId + "." + Routing::V1::SessionRouterDiscoveryCategory);   // Should be unique
-        mSessionRouterManagement = mServiceLocatorManagement->addService(mSessionRouterPrx, sessionRouterGuid);
-        setCategory(mSessionRouterManagement, Routing::V1::SessionRouterDiscoveryCategory);
-
-        if (includeBackplaneServices)
-        {
-            // Register the ComponentService interface with the Service Locator.
-            // Note that this interface goes on the management adapter.
-            string componentServiceGuid(mImplementationId + "." + Routing::V1::ComponentServiceDiscoveryCategory);   // Should be unique for reporting.
-            mComponentServiceManagement = mServiceLocatorManagement->addService(mComponentServicePrx, componentServiceGuid);
-            setCategory(mComponentServiceManagement, ComponentServiceId); // This really needs a custom comparator.
-
-            if (mPublishTestInterface)
-            {
-                // Register our test servant as a facet of the ComponentService interface.
-                mComponentTestPrx = ComponentTestPrx::uncheckedCast(
-                    mBackplaneAdapter->addFacet(mComponentTest, 
-                                                mComponentServicePrx->ice_getIdentity(), 
-                                                AsteriskSCF::System::Component::V1::ComponentTestFacet));
-            }
-
-            // Register the Replica interface with the Service Locator.
-            string replicaServiceGuid(mImplementationId + "." + "ReplicaControl");   // Should be unique for reporting.
-            mReplicaManagement = mServiceLocatorManagement->addService(mReplicaPrx, replicaServiceGuid);
-            setCategory(mReplicaManagement, ReplicaServiceId);  // This really needs a custom comparator.
-        }
-    }
-    catch(const std::exception& e)
-    {
-        lg(Error) << "Unable to publish component interfaces in " << mAppName << BOOST_CURRENT_FUNCTION << ". Exception: " << e.what();
-        throw; // rethrow
-    }
-}
-
-/**
- * Deregister this component's interfaces from the Service Locator.
- *
- * @param includeBackplaneServices If true, deregisters our management interfaces
- * in addition to all our other interfaces, making this component unreachable from the 
- * rest of Asterisk SCF. 
- */
-void BasicRoutingServiceApp::deregisterFromServiceLocator(bool includeBackplaneServices)
-{
-    try
-    {
-        mRegistryLocatorManagement->unregister();
-        mAdminManagement->unregister();
-        mSessionRouterManagement->unregister();
-
-        if (includeBackplaneServices)
-        {
-            mComponentServiceManagement->unregister();
-            mReplicaManagement->unregister();
-        }
-    }
-    catch(const std::exception& e)
-    {
-        lg(Error) << BOOST_CURRENT_FUNCTION << e.what();
-    }
-}
-
-/**
- * Suspends this component's primary public interfaces 
- * within the Service Locator. When suspended in this manner, the ServiceLocator
- * will not consider the component during lookup requests. 
- *
- * @param includeBackplaneServices If true, affects our management interfaces
- * in addition to all our other interfaces.
- */
-void BasicRoutingServiceApp::suspendRegisteredServants(bool includeBackplaneServices)
-{
-    try
-    {
-        mRegistryLocatorManagement->suspend();
-        mAdminManagement->suspend();
-        mSessionRouterManagement->suspend();
-
-        if (includeBackplaneServices)
-        {
-            mComponentServiceManagement->suspend();
-        
-            mReplicaManagement->suspend();
-        }
-    }
-    catch(const std::exception& e)
-    {
-        lg(Error) << BOOST_CURRENT_FUNCTION << e.what();
-    }
-}
-
-/**
- * Unsuspends this component's primary public interfaces 
- * within the Service Locator. This allows them to be 
- * located again via the Service Locator. 
- *
- * @param includeBackplaneServices If true, affects our management interfaces
- * in addition to all our other interfaces.
- */
-void BasicRoutingServiceApp::unsuspendRegisteredServants(bool includeBackplaneServices)
-{
-    try
-    {
-        mRegistryLocatorManagement->unsuspend();
-        mAdminManagement->unsuspend();
-        mSessionRouterManagement->unsuspend();
-
-        if (includeBackplaneServices)
-        {
-            mComponentServiceManagement->unsuspend();
-            mReplicaManagement->unsuspend();
-        }
-    }
-    catch(const std::exception& e)
-    {
-        lg(Error) << BOOST_CURRENT_FUNCTION << e.what();
-    }
-}
-
-/**
- * Locate the BridgeManager using the Service Locator.
- */
-void BasicRoutingServiceApp::locateBridgeManager()
-{
-    try
-    {
-        mBridgeManager = AsteriskSCF::Discovery::SmartProxy<BridgeManagerPrx>(
-            mServiceLocator,
-            new ServiceLocatorParams(BridgeServiceDiscoveryCategory),
-            lg);
-    }
-    catch(const AsteriskSCF::Core::Discovery::V1::ServiceNotFound&)
-    {
-        lg(Debug) << "BridgeManager not found. (Safe to ignore ServiceNotFound for briding during startup.)";
-    }
-
-    mSessionContext->bridgeManager = mBridgeManager;
-}
-
-/**
- * Locate our State Replicator using the Service Locator.
- */
-void BasicRoutingServiceApp::locateStateReplicator()
-{
-    BasicRoutingService::V1::RoutingStateReplicatorParamsPtr replicatorParams = new BasicRoutingService::V1::RoutingStateReplicatorParams();
-    replicatorParams->category = BasicRoutingService::V1::StateReplicatorDiscoveryCategory;
-    replicatorParams->name = mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".StateReplicatorName", "default");
-
-    try
-    {
-        AsteriskSCF::Discovery::SmartProxy<RoutingStateReplicatorPrx> replicator(mServiceLocator, replicatorParams, lg);
-        mReplicationContext->setReplicatorService(replicator);
-    }
-    catch(const AsteriskSCF::Core::Discovery::V1::ServiceNotFound&)
-    {
-        lg(Error) << "StateReplicator not found. Check configuration.";
-        throw;
-    }
-}
-
-/**
- * Create the primary functional objects of this component.
- *   @param appName Name of the application or component.
- */
-void BasicRoutingServiceApp::initialize()
-{
-    try
-    {
-        // Create the adapter that our functional services are published on.
-        mServiceAdapter = mCommunicator->createObjectAdapter(mAppName);
-
-        // Create an adapter that is bound to the dedicated (non-movable) address of this component. 
-        mBackplaneAdapter = mCommunicator->createObjectAdapter(mAppName + ".Backplane");
-
-        // NOTE: In the near future, Standalone instances are the only instances that default to being active. 
-        // When that is in place, non-standalone instances will need to be made active via the Replica interface. 
-        string standaloneProp = mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".Standalone", "no");
-        bool standalone = (standaloneProp == "yes") || (standaloneProp == "true");
-
-        string standbyProp = mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".Standby", "no");
-        bool active = (standbyProp == "no") || (standbyProp == "false");
-
-        // Create the replication context.
-        mReplicationContext = ReplicationContextPtr(new ReplicationContext(active, standalone));
-
-        mEventPublisher = new RoutingServiceEventPublisher(mServiceAdapter);
-
-        // setup the logger
-        ConfiguredIceLoggerPtr mIceLogger = createIceLogger(mServiceAdapter);
-        getLoggerFactory().setLogOutput(mIceLogger->getLogger());
-
-        // Create and configure the EndpointRegistry.
-        mEndpointRegistry = new EndpointRegistry(ScriptProcessorPtr(new LuaScriptProcessor()), mEventPublisher, mReplicationContext);
-        mEndpointRegistryPrx = LocatorRegistryPrx::uncheckedCast(
-            mServiceAdapter->add(mEndpointRegistry, mCommunicator->stringToIdentity(RegistryLocatorObjectId)));
-
-        // Check to see if we're configured to publish a test interface.
-        mPublishTestInterface = (mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".ComponentTest", "no") == "yes");
-
-        if (mPublishTestInterface)
-        {
-            // Create and publish the ComponentTest servant. This will be exposed
-            // as a facet of ComponentService.
-            mComponentTest = new ComponentTestImpl(mReplicationContext->getTestContext());
-        }
-
-        // Create the session context needed to construct operations.
-        mSessionContext = SessionContextPtr(new SessionContext(mServiceAdapter, 
-                                                             mEndpointRegistry, 
-                                                             mEventPublisher, 
-                                                             mWorkQueue,
-                                                             mReplicationContext));
-                
-        // Create the replica cache. 
-        mOperationReplicaCache = OperationReplicaCachePtr(new OperationReplicaCache(mSessionContext));
-
-        // Create publish the SessionRouter interface.
-        mSessionRouter = new SessionRouter(mSessionContext, mOperationReplicaCache);
-        mSessionRouterPrx = SessionRouterPrx::uncheckedCast(
-             mServiceAdapter->add(mSessionRouter, mCommunicator->stringToIdentity(SessionRouterObjectId)));
-
-        // Create and publish the Admin interface support.
-        mAdminInteface = new RoutingAdmin(mEndpointRegistry);
-        mAdminPrx = RoutingServiceAdminPrx::uncheckedCast(
-            mServiceAdapter->add(mAdminInteface, mCommunicator->stringToIdentity(RoutingAdminObjectId)));
-
-        // Create and publish the ComponentService interface on the backplane adapter. 
-        mComponentService = new ComponentServiceImpl(this);
-        mComponentServicePrx = ComponentServicePrx::uncheckedCast(
-            mBackplaneAdapter->add(mComponentService, mCommunicator->stringToIdentity(ComponentServiceId)));
-
-        // Create and publish our Replica interface on the management adapter. This interface allows this component
-        // to be activated or placed in standby mode. 
-        mReplicaControl = new ReplicaControl(this, mBackplaneAdapter);
-        mReplicaPrx = ReplicaPrx::uncheckedCast(
-            mBackplaneAdapter->add(mReplicaControl, mCommunicator->stringToIdentity(ReplicaServiceId)));
-
-        // Create and publish our state replicator listener interface on the backplane adapter. 
-        mReplicatorListener = new RoutingStateReplicatorListenerImpl(mEndpointRegistry, mOperationReplicaCache);
-        RoutingStateReplicatorListenerPrx replicatorListener = RoutingStateReplicatorListenerPrx::uncheckedCast(mBackplaneAdapter->addWithUUID(mReplicatorListener));
-        mReplicatorListenerProxy = RoutingStateReplicatorListenerPrx::uncheckedCast(replicatorListener->ice_oneway());
-
-        if (active)
-        {
-            activated();
-        } 
-        else
-        {
-            onStandby();
-        }
-
-        mServiceAdapter->activate();
-        mBackplaneAdapter->activate();
-
-        // Get a proxy to the management interface for the Service Locator manager.
-        // This isso we can add ourselves into the system discovery mechanisms.
-        mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("LocatorServiceManagement.Proxy"));
-
-        // Get a proxy to the interface for the Service Locator.
-        // This is so we can find the other components we depend on.
-        mServiceLocator = ServiceLocatorPrx::checkedCast(mCommunicator->propertyToProxy("LocatorService.Proxy"));
-
-        mInitialized = true;
-    }
-    catch(const ::Ice::Exception &e)
-    {
-        lg(Error) << "Problems in " << mAppName << BOOST_CURRENT_FUNCTION << e.what();
-        throw e;
-    }
-
-    locateBridgeManager();
-    locateStateReplicator();
-}
-
-/**
- * Implementation of the required IceBox::Service start method.
- */
-void BasicRoutingServiceApp::start(const string& name, const ::Ice::CommunicatorPtr& communicator, const ::Ice::StringSeq&)
-{
-    lg(Info) << "Starting...";
-
-    mCommunicator = communicator;
-    mAppName = name;
-
-    if (!mInitialized)
-    {
-        initialize();
-    }
-    else
-    {
-        mServiceAdapter->activate();
-        mBackplaneAdapter->activate();
-    }
-
-    // Plug into the Asterisk SCF discovery system so that the interfaces we provide
-    // can be located.
-    registerWithServiceLocator(true);
-    
-    // Register with the state replicator in case we are in standby mode. 
-    listenToStateReplicator();
-
-    mRunning = true;
-    lg(Info) << "Started";
-}
-
-/**
- * Things we do to resume operation after a pause().
- */
-void BasicRoutingServiceApp::resume()
-{
-    if (!mRunning)
-    {
-        // If we're in standby by mode, listen for state replication.
-       listenToStateReplicator();
-
-        // Reactivate the service adapter. 
-        mServiceAdapter->activate();
-
-        // Re-enable lookups of our interfaces in the ServiceLocator. 
-        unsuspendRegisteredServants(false);
-    }
-
-    mRunning = true;
-}
-
-/** 
- * Utility function to suspend the service for a suspend() or stop().
- */
-void BasicRoutingServiceApp::suspendService(bool shuttingDown)
-{
-    if (mRunning)
-    {
-        // Suspend lookups of our interfaces in the ServiceLocator. If shutting down,
-        // we'll be deregestering our interfaces with the ServiceLocator,
-        // so don't waste the bandwidth. 
-        if (!shuttingDown)
-        {
-            suspendRegisteredServants(false);
-        }
-
-        // Remove our interfaces from the state replicator.
-        stopListeningToStateReplicator();
-
-        // Deactive the service adapter. 
-        // The adapter that services the ComponentService stays active. 
-        mServiceAdapter->deactivate();
-    }
-
-    mRunning = false;
-}
-
-/** 
- * Handle a notice from the ComponentService. 
- */
-void BasicRoutingServiceApp::suspend()
-{
-    lg(Info) << "Suspending...";
-
-    suspendService(false);
-
-    lg(Info) << "Suspended.";
-}
-
-/**
- * Implementation of the required IceBox::Service stop method.
- */
-void BasicRoutingServiceApp::stop()
-{
-    lg(Info) << "Stopping...";
-
-    suspendService(true);
-
-    deregisterFromServiceLocator(true);
-
-    // Turn off our management interface. 
-    // Only a start() directly from IceBox can restart us now. 
-    mBackplaneAdapter->deactivate();
-
-    lg(Info) << "Stopped.";
-}
-
-} // end BasicRoutingService
-} // end AsteriskSCF
-
-
-extern "C"
-{
-ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(::Ice::CommunicatorPtr)
-{
-    return new AsteriskSCF::BasicRoutingService::BasicRoutingServiceApp;
-}
-}
-
diff --git a/src/BasicRoutingStateReplicatorApp.cpp b/src/BasicRoutingStateReplicatorApp.cpp
index 22fdab0..15809fc 100644
--- a/src/BasicRoutingStateReplicatorApp.cpp
+++ b/src/BasicRoutingStateReplicatorApp.cpp
@@ -125,34 +125,21 @@ private:
     BasicRoutingStateReplicatorServicePtr mService;
 };
 
-class BasicRoutingStateReplicatorCompare : public ServiceLocatorParamsCompare
-{
-public:
-    BasicRoutingStateReplicatorCompare(const std::string& name) : mName(name) {}
-    bool isSupported(const ServiceLocatorParamsPtr &params, const Ice::Current &)
-    {
-        RoutingStateReplicatorParamsPtr routingParams = RoutingStateReplicatorParamsPtr::dynamicCast(params);
-        if (routingParams->name == mName)
-        {
-            return true;
-        }
-        return false;
-    }
-private:
-    string mName;
-};
-
-typedef IceUtil::Handle<BasicRoutingStateReplicatorCompare> BasicRoutingStateReplicatorComparePtr;
-
 /**
  * Helper function to add some parameters to one of our registered interfaces in the ServiceLocator, so that
  * other components can look up our interfaces.
  */
-void setCategory(const Discovery::V1::ServiceManagementPrx& serviceManagement, const string& category)
+void setCategory(const Discovery::V1::ServiceManagementPrx& serviceManagement, 
+                 const string& category,
+                 const string& serviceName,
+                 const string& id="")
 {
     // Add category as a parameter to enable other components look this component up.
     ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams;
     genericparams->category = category;
+    genericparams->service = serviceName;
+    genericparams->id = id;
+
     serviceManagement->addLocatorParams(genericparams, "");
 }
 
@@ -164,26 +151,22 @@ void BasicRoutingStateReplicatorService::registerWithServiceLocator()
 {
     try
     {
+        std::string serviceName = mCommunicator->getProperties()->getPropertyWithDefault(
+              mAppName + ".ServiceName", "default");
+
         // Add our ComponentService interface and add it to the Service Locator.
         // Note that this interface has its own adapter.
         string componentServiceGuid(AsteriskSCF::BasicRoutingService::V1::StateReplicatorComponentCategory);
         mComponentServiceManagement = mServiceLocatorManagement->addService(mComponentServicePrx, componentServiceGuid);
-        setCategory(mComponentServiceManagement,  AsteriskSCF::BasicRoutingService::V1::StateReplicatorComponentCategory);
+        setCategory(mComponentServiceManagement,  AsteriskSCF::BasicRoutingService::V1::StateReplicatorComponentCategory, serviceName);
 
         // Add our Replicator interface and add it to the Service Locator.
         string stateReplicationGuid(AsteriskSCF::BasicRoutingService::V1::StateReplicatorDiscoveryCategory);
         mStateReplicationManagement = mServiceLocatorManagement->addService(mStateReplicatorPrx, stateReplicationGuid);
 
-        ServiceLocatorParamsPtr discoveryParams = new ServiceLocatorParams();
-        discoveryParams->category = AsteriskSCF::BasicRoutingService::V1::StateReplicatorDiscoveryCategory;
-
         string replicatorName = mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".InstanceName", "default");
-        ServiceLocatorParamsComparePrx compareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(
-                                                    mServiceAdapter->addWithUUID(new BasicRoutingStateReplicatorCompare(replicatorName)));
 
-        string compareGuid = IceUtil::generateUUID();
-        mServiceLocatorManagement->addCompare(compareGuid, compareProxy);
-        mStateReplicationManagement->addLocatorParams(discoveryParams, compareGuid);
+        setCategory(mStateReplicationManagement, AsteriskSCF::BasicRoutingService::V1::StateReplicatorDiscoveryCategory, serviceName, replicatorName);
     }
     catch(...)
     {
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 53674ea..fc86a54 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,7 +10,7 @@ asterisk_scf_slice_include_directories(${API_SLICE_DIR})
 
 asterisk_scf_component_init(BasicRoutingService)
 asterisk_scf_component_add_slice(BasicRoutingService ../local-slice/BasicRoutingStateReplicationIf.ice)
-asterisk_scf_component_add_file(BasicRoutingService BasicRoutingServiceApp.cpp)
+asterisk_scf_component_add_file(BasicRoutingService Component.cpp)
 asterisk_scf_component_add_file(BasicRoutingService SessionRouter.cpp)
 asterisk_scf_component_add_file(BasicRoutingService SessionRouter.h)
 asterisk_scf_component_add_file(BasicRoutingService RoutingAdmin.cpp)
@@ -34,10 +34,7 @@ asterisk_scf_component_add_file(BasicRoutingService SessionListener.h)
 asterisk_scf_component_add_file(BasicRoutingService SessionListener.cpp)
 asterisk_scf_component_add_file(BasicRoutingService OperationReplicaCache.h)
 asterisk_scf_component_add_file(BasicRoutingService OperationReplicaCache.cpp)
-asterisk_scf_component_add_file(BasicRoutingService ReplicationContext.h)
-asterisk_scf_component_add_file(BasicRoutingService ReplicationContext.cpp)
-asterisk_scf_component_add_file(BasicRoutingService TestContext.h)
-asterisk_scf_component_add_file(BasicRoutingService TestContext.cpp)
+asterisk_scf_component_add_file(BasicRoutingService RoutingReplicationContext.h)
 asterisk_scf_component_add_file(BasicRoutingService RoutingStateReplicatorListener.h)
 asterisk_scf_component_add_file(BasicRoutingService RoutingStateReplicatorListener.cpp)
 asterisk_scf_component_add_ice_libraries(BasicRoutingService IceStorm)
@@ -47,6 +44,7 @@ target_link_libraries(BasicRoutingService ${LUA_LIBRARIES})
 target_link_libraries(BasicRoutingService logging-client)
 target_link_libraries(BasicRoutingService Threading)
 target_link_libraries(BasicRoutingService asterisk-scf-api)
+target_link_libraries(BasicRoutingService ice-util-cpp)
 asterisk_scf_component_install(BasicRoutingService)
 
 asterisk_scf_component_init(BasicRoutingStateReplicator)
diff --git a/src/Component.cpp b/src/Component.cpp
new file mode 100644
index 0000000..1b659af
--- /dev/null
+++ b/src/Component.cpp
@@ -0,0 +1,374 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010-2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+#include <Ice/Ice.h>
+#include <IceBox/IceBox.h>
+
+#include <boost/thread.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include <AsteriskSCF/Discovery/SmartProxy.h>
+#include <AsteriskSCF/Core/Routing/RoutingIf.h>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
+
+#include <AsteriskSCF/Logger/IceLogger.h>
+#include <AsteriskSCF/logger.h>
+
+#include <AsteriskSCF/Component/Component.h>
+#include "AsteriskSCF/Threading/SimpleWorkQueue.h"
+#include "RoutingStateReplicatorListener.h"
+#include "LuaScriptProcessor.h"
+#include "RoutingServiceEventPublisher.h"
+#include "EndpointRegistry.h"
+#include "RoutingAdmin.h"
+#include "SessionRouter.h"
+#include "OperationReplicaCache.h"
+#include "RoutingReplicationContext.h"
+
+using namespace std;
+using namespace AsteriskSCF::SessionCommunications::V1;
+using namespace AsteriskSCF::Core;
+using namespace AsteriskSCF::Core::Routing::V1;
+using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::System::Component::V1;
+using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::BasicRoutingService::V1;
+
+using namespace AsteriskSCF::Replication;
+using namespace AsteriskSCF::Discovery;
+
+namespace
+{
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.BasicRoutingService");
+}
+using namespace AsteriskSCF::Core::Routing::V1::Event;
+
+namespace AsteriskSCF
+{
+namespace BasicRoutingService
+{
+class Component : public AsteriskSCF::Component::Component
+{
+public:
+    Component() 
+        : AsteriskSCF::Component::Component(lg, 
+                                      ComponentServiceDiscoveryCategory),
+          mSessionContext(new SessionContext()),
+          mWorkQueue( new AsteriskSCF::Threading::SimpleWorkQueue("SessionRouterWorkQueue")),
+          mListeningToReplicator(false)
+    {
+    }
+
+private:
+    // Required base Component overrides
+    virtual void createPrimaryServices();
+    virtual void preparePrimaryServicesForDiscovery();
+    virtual void createReplicationStateListeners();
+    virtual void stopListeningToStateReplicators();
+    virtual void listenToStateReplicators();
+    virtual void findRemoteServices();
+
+    // Other base Component overrides
+    virtual ReplicationContextPtr createReplicationContext(ReplicationStateType state);
+
+    void locateBridgeManager();
+    void locateStateReplicator();
+
+    SessionContextPtr mSessionContext;
+    boost::shared_ptr<AsteriskSCF::Threading::SimpleWorkQueue> mWorkQueue;
+
+    LocatorRegistrationWrapperPtr mAdminRegistration;
+    LocatorRegistrationWrapperPtr mRegistryLocatorRegistration;
+    LocatorRegistrationWrapperPtr mSessionRouterRegistration;
+
+    // Our published interfaces.
+    BasicSessionRouterPtr mSessionRouter;
+    SessionRouterPrx mSessionRouterPrx;
+
+    RoutingServiceAdminPtr mAdminInteface;
+    RoutingServiceAdminPrx mAdminPrx;
+
+    EndpointRegistryPtr mEndpointRegistry;
+    LocatorRegistryPrx mEndpointRegistryPrx;
+
+    // Remote services
+    AsteriskSCF::Discovery::SmartProxy<BridgeManagerPrx> mBridgeManager;
+
+    // Support objects.
+    RoutingServiceEventPublisherPtr mEventPublisher;
+    boost::shared_ptr<OperationReplicaCache> mOperationReplicaCache;
+
+    // Replication support
+    AsteriskSCF::Discovery::SmartProxy<RoutingStateReplicatorPrx> mStateReplicator;
+    RoutingStateReplicatorListenerPtr mReplicatorListener;
+    RoutingStateReplicatorListenerPrx mReplicatorListenerProxy;
+    bool mListeningToReplicator;
+    boost::shared_mutex mReplicatorLock;
+};
+typedef ::IceUtil::Handle<Component> ComponentPtr;
+
+static const string RegistryLocatorObjectId("RoutingServiceLocatorRegistry");
+static const string RoutingAdminObjectId("RoutingAdmin");
+static const string SessionRouterObjectId("SessionRouter");
+
+/** 
+ * Register as a listener to our state replicator. 
+ * A component in standby mode will do this to monitor state changes
+ * being sent from an active component. 
+ */
+void Component::listenToStateReplicators()
+{
+    boost::unique_lock<boost::shared_mutex> lock(mReplicatorLock); 
+    RoutingReplicationContextPtr routingReplicationContext = 
+        static_pointer_cast<RoutingReplicationContext>(getReplicationContext());
+
+    if (mListeningToReplicator == true)
+    {
+        return;
+    }
+
+    if (!routingReplicationContext->getReplicator().isInitialized())
+    {
+        lg(Error) << getName() << " : State replicator could not be found. Unable to listen for state updates!";
+        return;
+    }
+
+    try
+    {
+        // Are we in standby mode?
+        if (routingReplicationContext->getState() == STANDBY_IN_REPLICA_GROUP)
+        {
+            routingReplicationContext->getReplicator().tryOneWay()->addListener(mReplicatorListenerProxy);
+            mListeningToReplicator = true;
+        }
+    }
+    catch (const Ice::Exception& e)
+    {
+        lg(Error) << e.what();
+        throw;
+    }
+}
+
+/** 
+ * Unregister as a listener to our state replicator. 
+ * A component in active mode doesn't neeed to listen to
+ * state replication data. 
+ */
+void Component::stopListeningToStateReplicators()
+{
+    boost::unique_lock<boost::shared_mutex> lock(mReplicatorLock); 
+    RoutingReplicationContextPtr routingReplicationContext = 
+        static_pointer_cast<RoutingReplicationContext>(getReplicationContext());
+
+    if ((!routingReplicationContext->getReplicator().isInitialized()) || (mListeningToReplicator == false))
+    {
+        return;
+    }
+
+    try
+    {
+        routingReplicationContext->getReplicator().tryOneWay()->removeListener(mReplicatorListenerProxy);
+        mListeningToReplicator = false;
+    }
+    catch (const Ice::Exception& e)
+    {
+        lg(Error) << e.what();
+        throw;
+    }
+}
+
+/**
+ * Prepare this component's public interfaces for discovery via the Service Locator.
+ * This enables other Asterisk SCF components to locate the interfaces we are publishing.
+ */
+void Component::preparePrimaryServicesForDiscovery()
+{
+    try
+    {
+        // Wrap our RoutingAdmin interface for the Service Locator.
+        mAdminRegistration = wrapServiceForRegistration(mAdminPrx, 
+                                                        RoutingServiceAdminDiscoveryCategory);
+        managePrimaryService(mAdminRegistration);
+
+
+        // Wrap our RegistryLocator interface for the Service Locator.
+        mRegistryLocatorRegistration = wrapServiceForRegistration(mEndpointRegistryPrx,
+                                                                  RoutingServiceLocatorRegistryDiscoveryCategory);
+        managePrimaryService(mRegistryLocatorRegistration);
+                      
+
+        // Wrap the SessionRouter interface for the Service Locator.
+        mSessionRouterRegistration = wrapServiceForRegistration(mSessionRouterPrx,
+                                                                SessionRouterDiscoveryCategory);
+        managePrimaryService(mSessionRouterRegistration);
+    }
+    catch(const std::exception& e)
+    {
+        lg(Error) << "Unable to publish component interfaces in " << getName() << BOOST_CURRENT_FUNCTION << 
+            ". Exception: " << e.what();
+        throw; // rethrow
+    }
+}
+
+/**
+ * Locate the BridgeManager using the Service Locator.
+ */
+void Component::locateBridgeManager()
+{
+    try
+    {
+       std::string serviceName = getCommunicator()->getProperties()->getPropertyWithDefault(
+          getName() + ".BridgeServiceName", "default");
+
+        mBridgeManager = AsteriskSCF::Discovery::SmartProxy<BridgeManagerPrx>(
+            getServiceLocator(),
+            new ServiceLocatorParams(BridgeManagerDiscoveryCategory, serviceName, ""),
+            lg);
+    }
+    catch(const AsteriskSCF::Core::Discovery::V1::ServiceNotFound&)
+    {
+        lg(Debug) << "BridgeManager not found. (Safe to ignore ServiceNotFound for briding during startup.)";
+    }
+
+    mSessionContext->bridgeManager = mBridgeManager;
+}
+
+/**
+ * Locate our State Replicator using the Service Locator.
+ */
+void Component::locateStateReplicator()
+{
+    if (getReplicationContext()->getState() == ACTIVE_STANDALONE)
+    {
+        return;
+    }
+
+    ServiceLocatorParamsPtr replicatorParams = new ServiceLocatorParams;
+    replicatorParams->category = BasicRoutingService::V1::StateReplicatorDiscoveryCategory;    
+    replicatorParams->service = getCommunicator()->getProperties()->getPropertyWithDefault(
+          getName() + ".StateReplicatorService", "default");
+    replicatorParams->id = getCommunicator()->getProperties()->getPropertyWithDefault(
+         getName() + ".StateReplicatorId", "");
+
+    try
+    {
+        RoutingReplicationContextPtr routingReplicationContext = 
+            static_pointer_cast<RoutingReplicationContext>(getReplicationContext());
+
+        ReplicatorSmartPrx replicator(getServiceLocator(), replicatorParams, lg);
+        routingReplicationContext->setReplicator(replicator);
+    }
+    catch(const AsteriskSCF::Core::Discovery::V1::ServiceNotFound&)
+    {
+        lg(Error) << getName() << ": StateReplicator not found. Check configuration.";
+        throw;
+    }
+}
+
+/**
+ * Override of factory method to create our replication context. 
+ */
+ReplicationContextPtr Component::createReplicationContext(ReplicationStateType state)
+{
+    RoutingReplicationContextPtr context(new RoutingReplicationContext(state, getTestContext()));
+    return context;
+}
+
+void Component::createPrimaryServices()
+{
+    try
+    {
+        // Get the replication context specific to routing. 
+        RoutingReplicationContextPtr routingReplicationContext = 
+            static_pointer_cast<RoutingReplicationContext>(getReplicationContext());
+
+        // Create a helper class for publishing events. 
+        mEventPublisher = new RoutingServiceEventPublisher(getServiceAdapter());
+
+        // Create and configure the EndpointRegistry.
+        mEndpointRegistry = new EndpointRegistry(ScriptProcessorPtr(new LuaScriptProcessor()), 
+            mEventPublisher, routingReplicationContext);
+        mEndpointRegistryPrx = LocatorRegistryPrx::uncheckedCast(getServiceAdapter()->add(
+            mEndpointRegistry, getCommunicator()->stringToIdentity(RegistryLocatorObjectId)));
+
+        // Create the session context needed to construct operations.
+       mSessionContext = SessionContextPtr(new SessionContext(getServiceAdapter(), 
+                                                                mEndpointRegistry, 
+                                                                mEventPublisher, 
+                                                                mWorkQueue,
+                                                                routingReplicationContext));
+                
+        // Create the replica cache. 
+        mOperationReplicaCache = OperationReplicaCachePtr(new OperationReplicaCache(mSessionContext));
+
+        // Create the SessionRouter interface.
+        mSessionRouter = new SessionRouter(mSessionContext, mOperationReplicaCache);
+        mSessionRouterPrx = SessionRouterPrx::uncheckedCast(
+                getServiceAdapter()->add(mSessionRouter, getCommunicator()->stringToIdentity(SessionRouterObjectId)));
+
+        // Create and publish the Admin interface support.
+        mAdminInteface = new RoutingAdmin(mEndpointRegistry);
+        mAdminPrx = RoutingServiceAdminPrx::uncheckedCast(
+            getServiceAdapter()->add(mAdminInteface, getCommunicator()->stringToIdentity(RoutingAdminObjectId)));
+    }
+    catch(const Ice::Exception& e)
+    {
+        lg(Error) << "Unable to create services in " << getName() << BOOST_CURRENT_FUNCTION << 
+            ". Exception: " << e.what();
+        throw;
+    }
+}
+
+void Component::createReplicationStateListeners()
+{
+    RoutingStateReplicatorListenerPrx prx;
+    try
+    {
+        // Create and publish our state replicator listener interface on the backplane adapter. 
+        mReplicatorListener = new RoutingStateReplicatorListenerImpl(mEndpointRegistry, mOperationReplicaCache);
+        prx = 
+            RoutingStateReplicatorListenerPrx::uncheckedCast(getBackplaneAdapter()->addWithUUID(mReplicatorListener));
+  
+        mReplicatorListenerProxy = RoutingStateReplicatorListenerPrx::uncheckedCast(prx->ice_oneway());
+    }
+    catch (const Ice::NoEndpointException&)
+    {
+        mReplicatorListenerProxy = prx; // use the two-way if configuration prohibits oneway.
+    }
+    catch(const Ice::Exception &e)
+    {
+        lg(Error) << "Problems in " << getName() << " " << BOOST_CURRENT_FUNCTION << e.what();
+        throw;
+    }
+}
+
+void Component::findRemoteServices() 
+{
+    locateBridgeManager();
+    locateStateReplicator();
+}
+
+} // end BasicRoutingService
+} // end AsteriskSCF
+
+extern "C"
+{
+ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(::Ice::CommunicatorPtr)
+{
+    return new AsteriskSCF::BasicRoutingService::Component;
+}
+}
+
diff --git a/src/ConnectBridgedSessionsWithDestinationOperation.cpp b/src/ConnectBridgedSessionsWithDestinationOperation.cpp
index ca07b82..38fd0d3 100644
--- a/src/ConnectBridgedSessionsWithDestinationOperation.cpp
+++ b/src/ConnectBridgedSessionsWithDestinationOperation.cpp
@@ -46,7 +46,7 @@ class ConnectBridgedSessionsWithDestReplicatingListener :
 {
 public:
     ConnectBridgedSessionsWithDestReplicatingListener(ConnectBridgedSessionsWithDestinationOperationPtr op, 
-                                                      const ReplicationContextPtr& replication)  
+                                                      const RoutingReplicationContextPtr& replication)  
                                                          : mOperationId(op->getOperationId()),
                                                            mOperation(op), 
                                                            mReplicationContext(replication)
@@ -77,7 +77,7 @@ public:
                      opStart(new ConnectBridgedSessionsWithDestinationOpStart());
                 opStart->operationId = mOperation->getOperationId();
                 opStart->key = mOperation->getOperationId() + 
-                     AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestStartKeyMod;
+                     ConnectBridgedSessionsWithDestStartKeyMod;
                 opStart->sessionToReplace = mOperation->getSessionToReplace();
                 opStart->destination = mOperation->getDestination();
 
@@ -92,7 +92,7 @@ public:
                  waitLookup(new ConnectBridgedSessionsWithDestinationOpWaitLookupState());
             waitLookup->operationId = mOperation->getOperationId();
             waitLookup->key = mOperation->getOperationId() + 
-                 AsteriskSCF::BasicRoutingService::V1::RouteSessionOpWaitLookupKeyMod;
+                 RouteSessionOpWaitLookupKeyMod;
             waitLookup->endpoints = mOperation->getLookupResult();
             waitLookup->remainingSessions = mOperation->getRemainingSessions();
 
@@ -110,7 +110,7 @@ public:
         RoutingStateItemSeq setItems;
 
         setItems.push_back(item);
-        mReplicationContext->getReplicatorService()->setState(setItems);
+        mReplicationContext->getReplicator()->setState(setItems);
         
         // Cache the replicated items.
         mReplicatedState.push_back(item);
@@ -134,7 +134,7 @@ public:
             {
                 // We just completed the entire operation. 
                 // Remove the items that represented this operation's state transitions from the state replicator.
-                mReplicationContext->getReplicatorService()->removeStateForItems(mReplicatedState);
+                mReplicationContext->getReplicator()->removeStateForItems(mReplicatedState);
             }
         }
         catch(...)
@@ -168,7 +168,7 @@ public:
                  bridgeOp(new ConnectBridgedSessionsWithDestinationOpBridgingState());
             bridgeOp->operationId = mOperation->getOperationId();
             bridgeOp->key = mOperation->getOperationId() + 
-                    AsteriskSCF::BasicRoutingService::V1::RouteSessionOpBridgingKeyMod;
+                    RouteSessionOpBridgingKeyMod;
             bridgeOp->bridge = mOperation->getBridge();
 
             pushState(bridgeOp);
@@ -185,7 +185,7 @@ private:
     RoutingStateItemSeq mReplicatedState;
     std::string mOperationId;
     ConnectBridgedSessionsWithDestinationOperationPtr mOperation;
-    ReplicationContextPtr mReplicationContext;
+    RoutingReplicationContextPtr mReplicationContext;
 
 }; // end ConnectBridgedSessionsWithDestReplicatingListener
 
@@ -210,7 +210,7 @@ void ConnectBridgedSessionsWithDestinationOperation::initStateMachine()
 ConnectBridgedSessionsWithDestinationOperation::ConnectBridgedSessionsWithDestinationOperation(
                           const AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr& cb,
                           const std::string& operationId,
-                          const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace, 
+                          const SessionPrx& sessionToReplace, 
                           const ::std::string& destination, 
                           const ::Ice::Current& current,
                           const SessionContextPtr& context,
@@ -234,7 +234,7 @@ ConnectBridgedSessionsWithDestinationOperation::ConnectBridgedSessionsWithDestin
 ConnectBridgedSessionsWithDestinationOperationPtr ConnectBridgedSessionsWithDestinationOperation::create(
                           const AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr& cb,
                           const std::string& operationId,
-                          const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace, 
+                          const SessionPrx& sessionToReplace, 
                           const ::std::string& destination, 
                           const ::Ice::Current& current,
                           const SessionContextPtr& context,
@@ -249,7 +249,8 @@ ConnectBridgedSessionsWithDestinationOperationPtr ConnectBridgedSessionsWithDest
                                                         context,
                                                         listener) );
 
-    boost::shared_ptr<SimpleStateMachine<ConnectBridgedSessionsWithDestinationOp::OperationState>::StateMachineListener> replicatingListener(new ConnectBridgedSessionsWithDestReplicatingListener(op, context->replicationContext));
+    boost::shared_ptr<SimpleStateMachine<ConnectBridgedSessionsWithDestinationOp::OperationState>::StateMachineListener> 
+        replicatingListener(new ConnectBridgedSessionsWithDestReplicatingListener(op, context->replicationContext));
     op->addStateMachineListener(replicatingListener);
 
     return op;
@@ -282,7 +283,8 @@ ConnectBridgedSessionsWithDestinationOperation::~ConnectBridgedSessionsWithDesti
         lg(Debug) << "ConnectBridgedSessionsWithDestinationOperation() being destroyed for " << mDestination ;
 }
 
-void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(const AsteriskSCF::BasicRoutingService::V1::OperationStateItemPtr& stateItem)
+void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(
+    const OperationStateItemPtr& stateItem)
 {
     ConnectBridgedSessionsWithDestinationOpStartPtr start;
     ConnectBridgedSessionsWithDestinationOpWaitLookupStatePtr waitLookup;
@@ -302,7 +304,8 @@ void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(const Asteris
     }
 }
 
-void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(const AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestinationOpStartPtr& item)
+void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(
+    const ConnectBridgedSessionsWithDestinationOpStartPtr& item)
 {
     mSessionToReplace = item->sessionToReplace;
     mDestination = item->destination;
@@ -311,13 +314,15 @@ void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(const Asteris
     mReplicatedStates.push_back(ConnectBridgedSessionsWithDestinationOp::STATE_LOOKUP);
 }
 
-void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(const AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestinationOpWaitLookupStatePtr& item)
+void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(
+    const ConnectBridgedSessionsWithDestinationOpWaitLookupStatePtr& item)
 {
     mLookupResult = item->endpoints;
     mReplicatedStates.push_back(ConnectBridgedSessionsWithDestinationOp::STATE_WAIT_LOOKUP_RESULTS);
 }
 
-void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(const AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestinationOpBridgingStatePtr& item)
+void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(
+    const ConnectBridgedSessionsWithDestinationOpBridgingStatePtr& item)
 {
     mBridge = item->bridge;
 
@@ -497,7 +502,7 @@ void ConnectBridgedSessionsWithDestinationOperation::establishBridgeState()
     // Test instrumentation
     if (mSessionContext->replicationContext->getTestContext().get() != 0)
     {
-        if (mSessionContext->replicationContext->getTestContext()->getTestMode() == "ConnectBridgedSessWithDestFailover")
+        if (mSessionContext->replicationContext->getTestContext()->hasTestMode("ConnectBridgedSessWithDestFailover"))
         {
             // We're going to just shutdown this operation right here, with no replies to the caller. 
             // This is so that an external test can verify the replica can take it the rest of the way.
diff --git a/src/EndpointRegistry.cpp b/src/EndpointRegistry.cpp
index 8756701..4c6bbd1 100644
--- a/src/EndpointRegistry.cpp
+++ b/src/EndpointRegistry.cpp
@@ -81,7 +81,7 @@ class EndpointRegistryPriv
 public:
     EndpointRegistryPriv(const ScriptProcessorPtr& scriptProcessor, 
                          const RoutingEventsPtr& eventPublisher, 
-                         const ReplicationContextPtr& replicationContext) :
+                         const RoutingReplicationContextPtr& replicationContext) :
             mScriptProcessor(scriptProcessor), 
             mEventPublisher(eventPublisher),
             mReplicationContext(replicationContext)
@@ -123,7 +123,7 @@ public:
      */
     void forwardRemoveEndpointLocator(const std::string& locatorId, Event::OperationResult result)
     {
-        if (!mReplicationContext->isComponentActive())
+        if (!mReplicationContext->isReplicating())
         {
             return;
         }
@@ -140,7 +140,8 @@ public:
                 addEndpointItem->key = locatorId;
                 removeItems.push_back(addEndpointItem);
 
-                mReplicationContext->getReplicatorService()->removeStateForItems(removeItems);
+                lg(Debug) << BOOST_CURRENT_FUNCTION << ": Sending replicator state removal for locator " << locatorId;
+                mReplicationContext->getReplicator()->removeStateForItems(removeItems);
             }
             catch(const Ice::Exception& e)
             {
@@ -160,7 +161,7 @@ public:
                                    const EndpointLocatorPrx& locator, 
                                    Event::OperationResult result)
     {
-        if (!mReplicationContext->isComponentActive())
+        if (!mReplicationContext->isReplicating())
         {
             return;
         }
@@ -180,7 +181,9 @@ public:
 
                 setItems.push_back(addEndpointItem);
 
-                mReplicationContext->getReplicatorService()->setState(setItems);
+                lg(Debug) << BOOST_CURRENT_FUNCTION << ": Sending replicator state update for new locator " << locatorId;
+                mReplicationContext->getReplicator()->setState(setItems);
+
             }
             catch(const Ice::Exception& e)
             {
@@ -197,7 +200,7 @@ public:
                                             const EndpointLocatorPrx& locator, 
                                             OperationResult result)
     {
-        if (!mReplicationContext->isComponentActive())
+        if (!mReplicationContext->isReplicating())
         {
             return;
         }
@@ -215,7 +218,7 @@ public:
                     removeItem->key = locatorId;
                     removeItems.push_back(removeItem);
 
-                    mReplicationContext->getReplicatorService()->removeStateForItems(removeItems);
+                    mReplicationContext->getReplicator()->removeStateForItems(removeItems);
 
                     // Now add the item with the new values. 
                     RoutingStateItemSeq setItems;
@@ -226,7 +229,7 @@ public:
 
                     setItems.push_back(addEndpointItem);
 
-                    mReplicationContext->getReplicatorService()->setState(setItems);
+                    mReplicationContext->getReplicator()->setState(setItems);
                 }
             }
             catch(const Ice::Exception& e)
@@ -254,7 +257,7 @@ public:
     ScriptProcessorPtr mScriptProcessor;
     EndpointLocatorMap mEndpointLocatorMap;
     const RoutingEventsPtr mEventPublisher;
-    ReplicationContextPtr mReplicationContext;
+    RoutingReplicationContextPtr mReplicationContext;
 };
 
 /**
@@ -361,7 +364,7 @@ typedef IceUtil::Handle<LookupResultCollector> LookupResultCollectorPtr;
  */
 EndpointRegistry::EndpointRegistry(const ScriptProcessorPtr& scriptProcessor, 
                                    const RoutingEventsPtr& eventPublisher,
-                                   const ReplicationContextPtr& replicationContext) :
+                                   const RoutingReplicationContextPtr& replicationContext) :
     mImpl(new EndpointRegistryPriv(scriptProcessor, eventPublisher, replicationContext))
 {
 }
diff --git a/src/EndpointRegistry.h b/src/EndpointRegistry.h
index 4e7e32e..e1413c5 100644
--- a/src/EndpointRegistry.h
+++ b/src/EndpointRegistry.h
@@ -21,7 +21,7 @@
 #include <AsteriskSCF/Discovery/SmartProxy.h>
 
 #include "BasicRoutingStateReplicationIf.h"
-#include "ReplicationContext.h"
+#include "RoutingReplicationContext.h"
 #include "ScriptProcessor.h"
 
 namespace AsteriskSCF
@@ -36,7 +36,7 @@ class EndpointRegistry : public AsteriskSCF::Core::Routing::V1::LocatorRegistry
 public:
     EndpointRegistry(const ScriptProcessorPtr& scriptProcessor, 
                      const AsteriskSCF::Core::Routing::V1::Event::RoutingEventsPtr& eventPublisher,
-                     const ReplicationContextPtr& replicationContext);
+                     const RoutingReplicationContextPtr& replicationContext);
 
     /**
      * Configure the EndpointRegistry to use a different scriptProcessor than the
diff --git a/src/ReplicationContext.cpp b/src/ReplicationContext.cpp
deleted file mode 100644
index ad58952..0000000
--- a/src/ReplicationContext.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Asterisk SCF -- An open-source communications framework.
- *
- * Copyright (C) 2010-2011, Digium, Inc.
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk SCF project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE.txt file
- * at the top of the source tree.
- */
-
-#include <boost/thread/locks.hpp>
-
-#include "ReplicationContext.h"
-
-using namespace ::AsteriskSCF::Discovery;
-
-namespace AsteriskSCF
-{
-namespace BasicRoutingService
-{
-
-class ReplicationContextPriv
-{
-public:
-    ReplicationContextPriv(bool componentIsActive, bool standalone) : 
-                    mActive(componentIsActive),
-                    mStandalone(standalone),
-                    mTestContext(new TestContext())
-    {
-    }
-
-    ReplicatorServicePrx mReplicatorService;
-    bool mActive;
-    bool mStandalone;
-
-    TestContextPtr mTestContext;
-
-    boost::shared_mutex mLock;
-};
-
-ReplicationContext::ReplicationContext(bool componentIsActive, bool standalone)
-    :  mImpl(new ReplicationContextPriv(componentIsActive, standalone))
-{
-}
-
-bool ReplicationContext::isReplicating()
-{
-    boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    return ((mImpl->mActive) && (!mImpl->mStandalone) && (mImpl->mReplicatorService.initialize() != 0));
-}
-
-bool ReplicationContext::isComponentActive()
-{
-    boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    return mImpl->mActive;
-}
-
-bool ReplicationContext::isStandalone()
-{
-    boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    return mImpl->mStandalone;
-}
-
-void ReplicationContext::setComponentActive() 
-{
-    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    mImpl->mActive = true;
-
-}
-
-void ReplicationContext::setComponentStandby() 
-{
-    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    mImpl->mActive = false;
-}
-
-ReplicatorServicePrx ReplicationContext::getReplicatorService() 
-{
-    boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    return mImpl->mReplicatorService;
-}
-
-void ReplicationContext::setReplicatorService(const ReplicatorServicePrx& service) 
-{
-    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    mImpl->mReplicatorService = service;
-}
-
-TestContextPtr ReplicationContext::getTestContext()
-{
-   return mImpl->mTestContext;
-}
-
-} // end BasicRoutingService
-} // end AsteriskSCF
diff --git a/src/ReplicationContext.h b/src/ReplicationContext.h
deleted file mode 100644
index 1e82e00..0000000
--- a/src/ReplicationContext.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Asterisk SCF -- An open-source communications framework.
- *
- * Copyright (C) 2010-2011, Digium, Inc.
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk SCF project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE.txt file
- * at the top of the source tree.
- */
-#pragma once
-
-#include <boost/shared_ptr.hpp>
-
-#include <AsteriskSCF/Discovery/SmartProxy.h>
-#include "BasicRoutingStateReplicationIf.h"
-#include "TestContext.h"
-
-namespace AsteriskSCF
-{
-namespace BasicRoutingService
-{
-typedef AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorPrx> ReplicatorServicePrx;
-
-class ReplicationContextPriv;
-
-/** 
- * This class provides the component's classes with the context needed to perform replication. 
- */
-class ReplicationContext 
-{
-public:
-    ReplicationContext(bool componentIsActive, bool standalone);
-
-    /**
-     * Returns true if this component is active, non-standalone and has a valid
-     * proxy to it's state replicator. 
-     */
-    bool isReplicating();
-
-    /**
-     * Indicates whether this component is in active (as opposed to standby) mode. 
-     */
-    bool isComponentActive();
-
-    /**
-     * If true, the component is in standalone mode. 
-     * @see isReplicating
-     */
-    bool isStandalone();
-
-    void setComponentActive();
-    void setComponentStandby();
-
-    /**
-     * Get a reference to the state replicator service. 
-     */
-    ReplicatorServicePrx getReplicatorService();
-
-    /** 
-     * Sets the reference to the state replicator service. 
-     */
-    void setReplicatorService(const ReplicatorServicePrx& service);
-
-    /**
-     * Access to a test context to support advanced unit tests.
-     */
-    TestContextPtr getTestContext();
-
-private:
-    boost::shared_ptr<ReplicationContextPriv> mImpl;
-};
-typedef boost::shared_ptr<ReplicationContext> ReplicationContextPtr;
-
-} // end BasicRoutingService
-} // end AsteriskSCF
diff --git a/src/RouteSessionOperation.cpp b/src/RouteSessionOperation.cpp
index 80c15e8..3adbfc9 100644
--- a/src/RouteSessionOperation.cpp
+++ b/src/RouteSessionOperation.cpp
@@ -17,10 +17,12 @@
 #include <boost/bind.hpp>
 
 #include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Component/TestContext.h>
 
 #include "BasicRoutingStateReplicationIf.h"
+#include "RoutingReplicationContext.h"
 #include "RouteSessionOperation.h"
-#include "TestContext.h"
+
 
 using namespace AsteriskSCF;
 using namespace AsteriskSCF::Core::Routing::V1;
@@ -48,7 +50,7 @@ class RouteSessionReplicatingListener :
 {
 public:
     RouteSessionReplicatingListener(RouteSessionOperationPtr op, 
-                                    const ReplicationContextPtr& replicationContext)  
+                                    const RoutingReplicationContextPtr& replicationContext)  
                                        : mTransactionId(op->getOperationId()),
                                          mOperation(op), 
                                          mReplicationContext(replicationContext)
@@ -110,7 +112,7 @@ public:
         RoutingStateItemSeq setItems;
 
         setItems.push_back(item);
-        mReplicationContext->getReplicatorService()->setState(setItems);
+        mReplicationContext->getReplicator()->setState(setItems);
         
         // Cache the replication state items.
         mReplicatedState.push_back(item);
@@ -135,7 +137,7 @@ public:
             {
                 // We just completed the entire operation. 
                 // Remove the items that represented this operation's state transitions.
-                mReplicationContext->getReplicatorService()->removeStateForItems(mReplicatedState);
+                mReplicationContext->getReplicator()->removeStateForItems(mReplicatedState);
             }
         }
         catch(...)
@@ -186,7 +188,7 @@ private:
     RoutingStateItemSeq mReplicatedState;
     std::string mTransactionId;
     RouteSessionOperationPtr mOperation;
-    ReplicationContextPtr mReplicationContext;
+    RoutingReplicationContextPtr mReplicationContext;
 };
 
 /**
@@ -444,7 +446,7 @@ void RouteSessionOperation::establishBridgeState()
     // Test instrumentation
     if (mSessionContext->replicationContext->getTestContext().get() != 0)
     {
-        if (mSessionContext->replicationContext->getTestContext()->getTestMode() == "RouteSessionFailover")
+        if (mSessionContext->replicationContext->getTestContext()->hasTestMode( "RouteSessionFailover"))
         {
             // We're going to just shutdown this operation right here, with no replies to the caller. 
             // This is so that an external test can verify the replica can take it the rest of the way.
diff --git a/src/RoutingReplicationContext.h b/src/RoutingReplicationContext.h
new file mode 100644
index 0000000..bc12b95
--- /dev/null
+++ b/src/RoutingReplicationContext.h
@@ -0,0 +1,93 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010-2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+#pragma once
+
+#include <boost/shared_ptr.hpp>
+
+#include <AsteriskSCF/Discovery/SmartProxy.h>
+#include <AsteriskSCF/Replication/ReplicationContext.h>
+#include <AsteriskSCF/Component/TestContext.h>
+
+#include "BasicRoutingStateReplicationIf.h"
+
+namespace AsteriskSCF
+{
+namespace BasicRoutingService
+{
+typedef AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorPrx> ReplicatorSmartPrx;
+
+/** 
+ * This class provides the component's classes with the context needed to perform replication. 
+ */
+class RoutingReplicationContext : public AsteriskSCF::Replication::ReplicationContext
+{
+public:
+    RoutingReplicationContext(AsteriskSCF::Replication::ReplicationStateType state,  const AsteriskSCF::Component::TestContextPtr& testContext) : 
+        AsteriskSCF::Replication::ReplicationContext(state),
+        mTestContext(testContext)
+    {
+    }
+
+    // Override
+     virtual bool isReplicating() 
+     {
+         // If the base context says we aren't replicating, we aren't. 
+         if (!ReplicationContext::isReplicating())
+         {
+             return false;
+         }
+
+         // Do we have a replicator proxy?
+         if (mReplicator.isInitialized())
+         {
+             return true;
+         }
+
+         return false;
+     }
+
+    /**
+     * Get a reference to the state replicator service. 
+     */
+    ReplicatorSmartPrx getReplicator()
+    {
+        return mReplicator;
... 375 lines suppressed ...


-- 
asterisk-scf/integration/routing.git



More information about the asterisk-scf-commits mailing list