[asterisk-scf-commits] asterisk-scf/release/bridging.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Feb 6 10:51:18 CST 2012


branch "master" has been updated
       via  3c93c0a3ad074ed810e4fe3f17de7fb1f9306ce7 (commit)
      from  30c83a13fdf0bf4746ac55a96e1049c1e1823c0a (commit)

Summary of changes:
 src/CMakeLists.txt               |    4 +-
 src/ComponentStateReplicator.cpp |  115 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+), 2 deletions(-)
 create mode 100644 src/ComponentStateReplicator.cpp


- Log -----------------------------------------------------------------
commit 3c93c0a3ad074ed810e4fe3f17de7fb1f9306ce7
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Fri Feb 3 17:42:11 2012 -0600

    Using base ComponentStateReplicator class for the replicator.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 09eb772..5995653 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -45,11 +45,11 @@ target_link_libraries(BridgeService ASTSCFIceUtilCpp LoggingClient)
 astscf_component_install(BridgeService)
 
 astscf_component_init(BridgeReplicator)
-astscf_component_add_files(BridgeReplicator BridgeReplicatorService.cpp)
+astscf_component_add_files(BridgeReplicator ComponentStateReplicator.cpp)
 astscf_component_add_slices(BridgeReplicator PROJECT AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice)
 astscf_component_add_ice_libraries(BridgeReplicator IceStorm)
 astscf_component_add_boost_libraries(BridgeReplicator thread date_time)
 astscf_component_add_slice_collection_libraries(BridgeReplicator ASTSCF)
 astscf_component_build_icebox(BridgeReplicator)
-target_link_libraries(BridgeReplicator LoggingClient)
+target_link_libraries(BridgeReplicator LoggingClient astscf-ice-util-cpp)
 astscf_component_install(BridgeReplicator)
diff --git a/src/ComponentStateReplicator.cpp b/src/ComponentStateReplicator.cpp
new file mode 100644
index 0000000..c651315
--- /dev/null
+++ b/src/ComponentStateReplicator.cpp
@@ -0,0 +1,115 @@
+/*
+ * 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 <AsteriskSCF/Component/ComponentStateReplicator.h>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+#include <AsteriskSCF/Replication/StateReplicator.h>
+#include <AsteriskSCF/logger.h>
+#include "ServiceUtil.h"
+#include "BridgeReplicatorIf.h"
+
+using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::Replication::BridgeService::V1;
+using namespace AsteriskSCF::Discovery;
+using namespace AsteriskSCF;
+using namespace std;
+
+typedef AsteriskSCF::Replication::StateReplicator<
+    AsteriskSCF::Replication::BridgeService::V1::Replicator,
+    AsteriskSCF::Replication::BridgeService::V1::ReplicatedStateItemPtr,
+    string,
+    AsteriskSCF::Replication::BridgeService::V1::ReplicatorListenerPrx> ReplicatorI;
+
+typedef IceUtil::Handle<ReplicatorI> ReplicatorIPtr;
+
+namespace
+{
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.BridgeService");
+}
+
+namespace
+{
+
+class ComponentStateReplicator : public AsteriskSCF::Component::ComponentStateReplicator
+{
+public:
+    ComponentStateReplicator() :
+      AsteriskSCF::Component::ComponentStateReplicator(lg, AsteriskSCF::Replication::BridgeService::V1::StateReplicatorComponentCategory, false)
+    {
+    }
+
+    ~ComponentStateReplicator() {}
+
+    ///////////////////////////////////////////////////
+    // Required overrides
+
+    void createPrimaryServices();
+    void preparePrimaryServicesForDiscovery();
+
+private:
+    ReplicatorIPtr mReplicator;
+    ReplicatorPrx mReplicatorPrx;
+    LocatorRegistrationWrapperPtr mStateReplicatorRegistration;
+};
+
+/**
+ * Register this component's primary public interfaces with the Service Locator.
+ * This enables other Asterisk SCF components to locate our interfaces.
+ */
+void ComponentStateReplicator::preparePrimaryServicesForDiscovery()
+{
+    try
+    {
+        // Wrap our replicator interface for the Service Locator.
+        mStateReplicatorRegistration = wrapServiceForRegistration(mReplicatorPrx,
+                                                                  StateReplicatorDiscoveryCategory);
+        managePrimaryService(mStateReplicatorRegistration);
+    }
+    catch(const std::exception& e)
+    {
+        lg(Error) << "Unable to publish component interfaces in " << getName() << BOOST_CURRENT_FUNCTION <<
+            ". Exception: " << e.what();
+        throw; // rethrow
+    }
+}
+
+void ComponentStateReplicator::createPrimaryServices()
+{
+    //
+    // TODO: The bridge manager's identity should come from a central configuration and/or a replicator
+    // service.
+    //
+    string managerName = "BridgeReplicator";
+    mReplicator = new ReplicatorI;
+    mReplicatorPrx = ReplicatorPrx::uncheckedCast(getServiceAdapter()->add(mReplicator, getCommunicator()->stringToIdentity(managerName)));
+
+    assert(mReplicatorPrx != 0);
+    if(mReplicatorPrx == 0)
+    {
+        throw IceBox::FailureException(__FILE__, __LINE__, "Unable to instantiate bridge replicator object");
+    }
+}
+
+} // end unnamed namespace
+
+extern "C" {
+ASTSCF_DLL_EXPORT ::IceBox::Service* create(Ice::CommunicatorPtr)
+{
+    return new ComponentStateReplicator;
+}
+}

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


-- 
asterisk-scf/release/bridging.git



More information about the asterisk-scf-commits mailing list