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

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


branch "master" has been updated
       via  c91a0c85688818d5278f056fdeb65a4ab15e7695 (commit)
      from  3f25585831ec69af4f2b0cb788c64dac667186c5 (commit)

Summary of changes:
 src/CMakeLists.txt                       |    2 +-
 src/ComponentStateReplicator.cpp         |  112 ++++++++++++++++++++++++++++++
 src/MediaOperationStateReplicatorApp.cpp |  112 ------------------------------
 3 files changed, 113 insertions(+), 113 deletions(-)
 create mode 100644 src/ComponentStateReplicator.cpp
 delete mode 100644 src/MediaOperationStateReplicatorApp.cpp


- Log -----------------------------------------------------------------
commit c91a0c85688818d5278f056fdeb65a4ab15e7695
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Fri Feb 3 18:00:47 2012 -0600

    Using base class for ComponentStateReplicator.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4cee3e7..c6a52da 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -44,7 +44,7 @@ pjproject_link(MediaOperationsCore pjnath)
 astscf_component_install(MediaOperationsCore)
 
 astscf_component_init(MediaOperationStateReplicator)
-astscf_component_add_files(MediaOperationStateReplicator MediaOperationStateReplicatorApp.cpp)
+astscf_component_add_files(MediaOperationStateReplicator ComponentStateReplicator.cpp)
 astscf_component_add_files(MediaOperationStateReplicator MediaOperationStateReplicator.h)
 astscf_component_add_slices(MediaOperationStateReplicator PROJECT AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice)
 astscf_component_add_slice_collection_libraries(MediaOperationStateReplicator ASTSCF)
diff --git a/src/ComponentStateReplicator.cpp b/src/ComponentStateReplicator.cpp
new file mode 100644
index 0000000..9912a2f
--- /dev/null
+++ b/src/ComponentStateReplicator.cpp
@@ -0,0 +1,112 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 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 "MediaOperationStateReplicator.h"
+
+#include <Ice/Ice.h>
+
+#include <AsteriskSCF/Component/ComponentStateReplicator.h>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+#include <AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.h>
+#include <AsteriskSCF/logger.h>
+
+using namespace AsteriskSCF::System::Logging;
+
+namespace
+{
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaOperationStateReplicator");
+
+const std::string ReplicatorId("MediaOperationStateReplicator");
+}
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::Replication::MediaOperationsCore::V1;
+using namespace AsteriskSCF::Discovery;
+
+class ComponentStateReplicator : public AsteriskSCF::Component::ComponentStateReplicator
+{
+public:
+    ComponentStateReplicator() :
+      AsteriskSCF::Component::ComponentStateReplicator(lg, 
+            AsteriskSCF::Replication::MediaOperationsCore::V1::StateReplicatorComponentCategory, 
+            false)
+    {
+    }
+
+    ~ComponentStateReplicator() {};
+
+    ///////////////////////////////////////////////////
+    // Required overrides
+
+    void createPrimaryServices();
+    void preparePrimaryServicesForDiscovery();
+
+    MediaOperationStateReplicatorImplPtr mReplicator;
+    MediaOperationStateReplicatorPrx 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()
+{
+    // Create our state replication servant.
+    mReplicator = new MediaOperationStateReplicatorImpl;
+    mReplicatorPrx = MediaOperationStateReplicatorPrx::uncheckedCast(
+        getServiceAdapter()->add(mReplicator, getCommunicator()->stringToIdentity(ReplicatorId)));
+
+    assert(mReplicatorPrx != 0);
+    if(mReplicatorPrx == 0)
+    {
+        throw IceBox::FailureException(__FILE__, __LINE__, "Unable to instantiate MediaOperationsCore replicator object");
+    }
+}
+
+extern "C"
+{
+ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
+{
+    return new ComponentStateReplicator;
+}
+}
+
+} //end namespace MediaOperationsCore
+} //end namespace AsteriskSCF
diff --git a/src/MediaOperationStateReplicatorApp.cpp b/src/MediaOperationStateReplicatorApp.cpp
deleted file mode 100644
index a40cdfb..0000000
--- a/src/MediaOperationStateReplicatorApp.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Asterisk SCF -- An open-source communications framework.
- *
- * Copyright (C) 2010, 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 "MediaOperationStateReplicator.h"
-
-#include <Ice/Ice.h>
-#include <IceBox/IceBox.h>
-
-#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
-#include <AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.h>
-#include <AsteriskSCF/Logger.h>
-
-using namespace AsteriskSCF::System::Logging;
-
-namespace
-{
-Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaOperationStateReplicator");
-
-const std::string ReplicatorId("MediaOperationStateReplicator");
-}
-
-namespace AsteriskSCF
-{
-
-namespace MediaOperationsCore
-{
-
-using namespace AsteriskSCF::Core::Discovery::V1;
-using namespace AsteriskSCF::Replication::MediaOperationsCore::V1;
-
-class MediaOperationStateReplicatorService : public IceBox::Service
-{
-public:
-    virtual void start(
-            const std::string& name,
-            const Ice::CommunicatorPtr&,
-            const Ice::StringSeq&);
-
-    virtual void stop();
-
-    void createStateReplicator(const Ice::CommunicatorPtr& communicator);
-    void registerWithServiceLocator(const Ice::CommunicatorPtr& communicator,
-                                    const std::string& appName);
-
-    ServiceLocatorManagementPrx mManagement;
-    Ice::ObjectAdapterPtr mAdapter;
-    MediaOperationStateReplicatorImplPtr mReplicator;
-};
-
-void MediaOperationStateReplicatorService::createStateReplicator(const Ice::CommunicatorPtr& communicator)
-{
-    mReplicator = new MediaOperationStateReplicatorImpl;
-    mAdapter->add(mReplicator, communicator->stringToIdentity(ReplicatorId));
-}
-
-void MediaOperationStateReplicatorService::registerWithServiceLocator(const Ice::CommunicatorPtr& communicator,
-                                                                      const std::string& appName)
-{
-    MediaOperationStateReplicatorPrx stateReplicatorProxy =
-        MediaOperationStateReplicatorPrx::uncheckedCast(mAdapter->createDirectProxy(communicator->stringToIdentity(ReplicatorId)));
-
-    ServiceManagementPrx serviceManagement = mManagement->addService(stateReplicatorProxy, ReplicatorId);
-
-    ServiceLocatorParamsPtr params = new ServiceLocatorParams();
-    params->category = StateReplicatorDiscoveryCategory;
-    params->service = communicator->getProperties()->getPropertyWithDefault(appName + ".ServiceName", "default");
-    params->id = appName;
-    serviceManagement->addLocatorParams(params, "");
-}
-
-void MediaOperationStateReplicatorService::start(
-        const std::string& appName,
-        const Ice::CommunicatorPtr& communicator,
-        const Ice::StringSeq&)
-{
-    mManagement = ServiceLocatorManagementPrx::checkedCast(communicator->propertyToProxy("LocatorServiceManagement.Proxy"));
-    mAdapter = communicator->createObjectAdapter(appName + ".Adapter");
-
-    createStateReplicator(communicator);
-    registerWithServiceLocator(communicator, appName);
-
-    mAdapter->activate();
-}
-
-void MediaOperationStateReplicatorService::stop()
-{
-    //stub
-}
-
-extern "C"
-{
-ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
-{
-    return new MediaOperationStateReplicatorService;
-}
-}
-
-} //end namespace MediaOperationsCore
-} //end namespace AsteriskSCF

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


-- 
asterisk-scf/release/media_operations_core.git



More information about the asterisk-scf-commits mailing list