[asterisk-scf-commits] asterisk-scf/integration/media_operations_core.git branch "baserep" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Fri Dec 16 08:42:02 CST 2011
branch "baserep" has been created
at 50921981130fa73f2d33612067af9ca4021cd3cb (commit)
- Log -----------------------------------------------------------------
commit 50921981130fa73f2d33612067af9ca4021cd3cb
Author: Ken Hunt <ken.hunt at digium.com>
Date: Fri Dec 16 08:41:30 2011 -0600
Renamed MediaOperationStateReplicatorApp.cpp, which also now uses base replicator class.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d4b15f4..3022fd3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -40,7 +40,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 ed61e9e..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/integration/media_operations_core.git
More information about the asterisk-scf-commits
mailing list