[asterisk-scf-commits] asterisk-scf/release/servicediscovery.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Feb 6 11:14:06 CST 2012
branch "master" has been updated
via 49de44e17305e5ef7f8fba20ace61f10b01bf400 (commit)
from 781b2b7edd18b0f8e0c88e6fe5f53d1ff840210e (commit)
Summary of changes:
.../ServiceLocatorStateReplicationIf.ice | 3 +
src/CMakeLists.txt | 4 +-
src/ComponentStateReplicator.cpp | 99 ++++++++++++++++++++
3 files changed, 104 insertions(+), 2 deletions(-)
create mode 100644 src/ComponentStateReplicator.cpp
- Log -----------------------------------------------------------------
commit 49de44e17305e5ef7f8fba20ace61f10b01bf400
Author: Ken Hunt <ken.hunt at digium.com>
Date: Fri Feb 3 18:37:03 2012 -0600
State replicator uses base class ComponentStateReplicator.
diff --git a/slice/AsteriskSCF/Replication/ServiceLocator/ServiceLocatorStateReplicationIf.ice b/slice/AsteriskSCF/Replication/ServiceLocator/ServiceLocatorStateReplicationIf.ice
index 3ec0dd1..3f509a9 100644
--- a/slice/AsteriskSCF/Replication/ServiceLocator/ServiceLocatorStateReplicationIf.ice
+++ b/slice/AsteriskSCF/Replication/ServiceLocator/ServiceLocatorStateReplicationIf.ice
@@ -32,6 +32,9 @@ module ServiceLocator
["suppress"]
module V1
{
+ const string StateReplicatorComponentCategory = "ServiceLocatorStateReplicatorComponent";
+ const string StateReplicatorDiscoveryCategory = "ServiceLocatorStateReplicator";
+
class ServiceLocatorStateItem
{
string key;
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6a91640..728cf52 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -18,10 +18,10 @@ astscf_component_install(ServiceLocator)
astscf_component_init(ServiceLocatorStateReplicator)
astscf_component_add_slices(ServiceLocatorStateReplicator PROJECT AsteriskSCF/Replication/ServiceLocator/ServiceLocatorStateReplicationIf.ice)
-astscf_component_add_files(ServiceLocatorStateReplicator ServiceLocatorStateReplicatorApp.cpp)
+astscf_component_add_files(ServiceLocatorStateReplicator ComponentStateReplicator.cpp)
astscf_component_add_files(ServiceLocatorStateReplicator ServiceLocatorStateReplicator.h)
astscf_component_add_ice_libraries(ServiceLocatorStateReplicator IceStorm)
astscf_component_add_boost_libraries(ServiceLocatorStateReplicator thread date_time)
astscf_component_build_icebox(ServiceLocatorStateReplicator)
-target_link_libraries(ServiceLocatorStateReplicator LoggingClient)
+target_link_libraries(ServiceLocatorStateReplicator LoggingClient ASTSCFIceUtilCpp)
astscf_component_install(ServiceLocatorStateReplicator)
diff --git a/src/ComponentStateReplicator.cpp b/src/ComponentStateReplicator.cpp
new file mode 100644
index 0000000..92dcd09
--- /dev/null
+++ b/src/ComponentStateReplicator.cpp
@@ -0,0 +1,99 @@
+/*
+ * 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 <Ice/Ice.h>
+
+#include <AsteriskSCF/Component/ComponentStateReplicator.h>
+#include <AsteriskSCF/logger.h>
+#include "ServiceLocatorStateReplicator.h"
+
+using namespace std;
+using namespace AsteriskSCF::Core;
+using namespace AsteriskSCF::Discovery;
+using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::System::Component::V1;
+using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::Replication::ServiceLocator::V1;
+
+namespace
+{
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.ServiceLocatorStateReplicator");
+}
+
+class ComponentStateReplicator : public AsteriskSCF::Component::ComponentStateReplicator
+{
+public:
+ ComponentStateReplicator() :
+ AsteriskSCF::Component::ComponentStateReplicator(lg,
+ AsteriskSCF::Replication::ServiceLocator::V1::StateReplicatorComponentCategory,
+ false) // if true, supports configuration
+ {
+ }
+
+ ~ComponentStateReplicator() {};
+
+ ///////////////////////////////////////////////////
+ // Required overrides
+
+ void createPrimaryServices();
+ void preparePrimaryServicesForDiscovery();
+
+private:
+ ServiceLocatorStateReplicatorIPtr mStateReplicator;
+ ServiceLocatorStateReplicatorPrx mStateReplicatorPrx;
+ LocatorRegistrationWrapperPtr mStateReplicatorRegistration;
+};
+
+static const string ServiceDiscoveryId("ServiceLocatorStateReplicatorService");
+
+/**
+ * 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 authentication extensions point for the Service Locator.
+ mStateReplicatorRegistration = wrapServiceForRegistration(mStateReplicatorPrx,
+ AsteriskSCF::Replication::ServiceLocator::V1::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 the state replicator servant
+ mStateReplicator = new ServiceLocatorStateReplicatorI();
+
+ mStateReplicatorPrx = ServiceLocatorStateReplicatorPrx::uncheckedCast(
+ getServiceAdapter()->add(mStateReplicator, getCommunicator()->stringToIdentity(ServiceDiscoveryId)));
+}
+
+extern "C"
+{
+ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
+{
+ return new ComponentStateReplicator;
+}
+}
+
-----------------------------------------------------------------------
--
asterisk-scf/release/servicediscovery.git
More information about the asterisk-scf-commits
mailing list