[asterisk-scf-commits] asterisk-scf/release/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Aug 11 17:18:35 CDT 2011
branch "master" has been updated
via ccec5ae8cb8bc658387d41ed309c134b35f2038e (commit)
from 12f7bb81986f9c7d63a975447fdb7baa6f15e9d3 (commit)
Summary of changes:
src/SipEndpoint.cpp | 7 +-
src/SipStateReplicatorApp -basecomponent.cpp | 308 --------------------------
2 files changed, 5 insertions(+), 310 deletions(-)
delete mode 100644 src/SipStateReplicatorApp -basecomponent.cpp
- Log -----------------------------------------------------------------
commit ccec5ae8cb8bc658387d41ed309c134b35f2038e
Author: Ken Hunt <ken.hunt at digium.com>
Date: Thu Aug 11 17:06:16 2011 -0500
- Updates for changes to collection templates in ice-util-cpp.
- Removed file accidentally added in some prior commit.
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index b9a58b1..87c2d35 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -21,7 +21,8 @@
#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
#include <AsteriskSCF/logger.h>
-#include <AsteriskSCF/Collections/Set.h>
+#include <AsteriskSCF/Collections/ProxySet.h>
+#include <AsteriskSCF/Collections/HandleSet.h>
#include <AsteriskSCF/Media/MediaIf.h>
#include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
@@ -181,7 +182,9 @@ public:
const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
const SipReplicationContextPtr& replicationContext) :
mName(name), mAdapter(adapter), mEndpointFactory(factory), mManager(manager), mServiceLocator(serviceLocator),
- mReplicationContext(replicationContext)
+ mReplicationContext(replicationContext),
+ mDefaultListeners(new AsteriskSCF::Collections::ProxySet<SessionListenerPrx>(adapter, lg, "Default Session Listeners")),
+ mDefaultSessionCookies(new AsteriskSCF::Collections::HandleSet<SessionCookiePtr>(lg, "Default Cookies"))
{
};
diff --git a/src/SipStateReplicatorApp -basecomponent.cpp b/src/SipStateReplicatorApp -basecomponent.cpp
deleted file mode 100644
index 28ed3cb..0000000
--- a/src/SipStateReplicatorApp -basecomponent.cpp
+++ /dev/null
@@ -1,308 +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 "SipStateReplicator.h"
-
-#include <Ice/Ice.h>
-#include <IceUtil/UUID.h>
-#include <IceStorm/IceStorm.h>
-#include <IceBox/IceBox.h>
-
-#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
-#include <AsteriskSCF/System/Component/ComponentServiceIf.h>
-#include <AsteriskSCF/logger.h>
-#include <AsteriskSCF/Logger/IceLogger.h>
-#include <AsteriskSCF/CollocatedIceStorm/CollocatedIceStorm.h>
-#include <AsteriskSCF/System/Component/ConfigurationIf.h>
-
-#include <SipIf.h>
-
-#include "SipConfigurationIf.h"
-
-using namespace std;
-using namespace AsteriskSCF::Core;
-using namespace AsteriskSCF::Core::Discovery::V1;
-using namespace AsteriskSCF::SIP::V1;
-using namespace AsteriskSCF::System::Component::V1;
-using namespace AsteriskSCF::System::Logging;
-using namespace AsteriskSCF::SipSessionManager;
-using namespace AsteriskSCF::CollocatedIceStorm;
-using namespace AsteriskSCF::System::Configuration::V1;
-
-namespace
-{
-Logger lg = getLoggerFactory().getLogger("AsteriskSCF.SipSessionManager");
-}
-
-class SipStateReplicatorService : public IceBox::Service
-{
-public:
- SipStateReplicatorService() { };
- ~SipStateReplicatorService()
- {
- mComponentService = 0;
- mAdapter = 0;
- mStateReplicator = 0;
- mConfigurationReplicator = 0;
- };
- virtual void start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args);
- virtual void stop();
-private:
- void initialize(const std::string& appName, const Ice::CommunicatorPtr& ic);
- void registerWithServiceLocator(const Ice::CommunicatorPtr& ic);
- void deregisterFromServiceLocator();
- std::string mAppName;
- //vector<SipStateReplicatorListenerPrx> mListeners;
- Ice::ObjectAdapterPtr mAdapter;
- ServiceLocatorManagementPrx mServiceLocatorManagement;
- Discovery::V1::ServiceManagementPrx mComponentServiceManagement;
- Discovery::V1::ServiceManagementPrx mStateReplicationManagement;
- ConfiguredIceLoggerPtr mIceLogger;
- ComponentServicePtr mComponentService;
- SipStateReplicatorIPtr mStateReplicator;
- ConfigurationReplicatorPtr mConfigurationReplicator;
- CollocatedIceStormPtr mIceStorm;
- Ice::ObjectPrx mConfigurationPublisher;
- Discovery::V1::ServiceManagementPrx mConfigurationManagement;
- std::string mConfigCompareGuid;
-};
-
-static const string ComponentServiceId("SipStateReplicatorComponent");
-static const string ServiceDiscoveryId("SipStateReplicatorService");
-
-/**
- * This class provides implementation for the ComponentService interface, which
- * every Asterisk SCF component is expected to publish.
- */
-class ComponentServiceImpl : public ComponentService
-{
-public:
- ComponentServiceImpl(SipStateReplicatorService &service) : mService(service) {}
-
-public: // Overrides of the ComponentService interface.
- virtual void suspend(const ::Ice::Current& = ::Ice::Current())
- {
- // TBD
- }
-
- virtual void resume(const ::Ice::Current& = ::Ice::Current())
- {
- // TBD
- }
-
- virtual void shutdown(const ::Ice::Current& = ::Ice::Current())
- {
- // TBD
- }
-
-private:
- SipStateReplicatorService& mService; // TODO: Reference?
-};
-
-class ConfigurationReplicatorI : public ConfigurationReplicator
-{
-public:
- ConfigurationReplicatorI(const IceStorm::TopicPrx& topic) : mConfigurationReplicationTopic(topic) { };
- void registerConfigurationService(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx&, const Ice::Current&);
-private:
- IceStorm::TopicPrx mConfigurationReplicationTopic;
-};
-
-void ConfigurationReplicatorI::registerConfigurationService(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx& service, const Ice::Current&)
-{
- if (mConfigurationReplicationTopic)
- {
- IceStorm::QoS qos;
- qos["reliability"] = "ordered";
-
- try
- {
- mConfigurationReplicationTopic->subscribeAndGetPublisher(qos, service);
- }
- catch (const IceStorm::AlreadySubscribed&)
- {
- // This is perfectly okay actually, it just means what they wanted us to do
- // is already done.
- }
- }
-}
-
-/**
- * Register this component's primary public interfaces with the Service Locator.
- * This enables other Asterisk SCF components to locate our interfaces.
- */
-void SipStateReplicatorService::registerWithServiceLocator(const Ice::CommunicatorPtr& ic)
-{
- try
- {
- // Get a proxy to the management interface for the Service Locator, so we can add ourselves into the system discovery mechanisms.
- mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(
- ic->propertyToProxy("LocatorServiceManagement.Proxy"));
-
- if (mServiceLocatorManagement == 0)
- {
- lg(Error) << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. "
- "This component can't be found until this is corrected.";
- return;
- }
-
- // Get a proxy to our ComponentService interface and add it to the Service Locator.
- Ice::ObjectPrx componentServiceObjectPrx =
- mAdapter->createDirectProxy(ic->stringToIdentity(ComponentServiceId));
- ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
-
- // The GUID passed in to add service needs to be unique for reporting.
- string componentServiceGuid(AsteriskSCF::SIP::V1::StateReplicatorComponentCategory);
- mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(
- mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
-
- // Add category as a parameter to enable other components look this component up.
- ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
- genericparams->category = AsteriskSCF::SIP::V1::StateReplicatorComponentCategory;
-
- mComponentServiceManagement->addLocatorParams(genericparams, "");
-
- Ice::ObjectPrx stateReplicatorObjectPrx = mAdapter->createDirectProxy(ic->stringToIdentity(ServiceDiscoveryId));
- SipStateReplicatorPrx stateReplicatorPrx = SipStateReplicatorPrx::checkedCast(stateReplicatorObjectPrx);
-
- string stateReplicationGuid(AsteriskSCF::SIP::V1::StateReplicatorDiscoveryCategory);
- mStateReplicationManagement = ServiceManagementPrx::uncheckedCast(
- mServiceLocatorManagement->addService(stateReplicatorPrx, stateReplicationGuid));
-
- ServiceLocatorParamsPtr discoveryParams = new ServiceLocatorParams();
- discoveryParams->category = AsteriskSCF::SIP::V1::StateReplicatorDiscoveryCategory;
- discoveryParams->service = ic->getProperties()->getPropertyWithDefault("SipStateReplicator.Service", "default");
- discoveryParams->id = ic->getProperties()->getPropertyWithDefault("SipStateReplicator.Name", "default");
- mStateReplicationManagement->addLocatorParams(discoveryParams, "");
-
- // Publish the configuration service IceStorm topic so everybody gets configuration
- mConfigurationManagement = ServiceManagementPrx::uncheckedCast(
- mServiceLocatorManagement->addService(mConfigurationPublisher, ""));
-
- // Populate the configuration parameters with details so we can be found
- ServiceLocatorParamsPtr configurationParams = new ServiceLocatorParams();
- configurationParams->category = ConfigurationDiscoveryCategory;
- configurationParams->service = ic->getProperties()->getPropertyWithDefault("SipConfiguration.Service", "default");
- configurationParams->id = ic->getProperties()->getPropertyWithDefault("SipConfiguration.Name", "");
- mConfigurationManagement->addLocatorParams(configurationParams, "");
-
- // TBD... We may have other interfaces to publish to the Service Locator.
- }
- catch(...)
- {
- lg(Error) << "Exception in " << mAppName << " registerWithServiceLocator()" << endl;
- }
-}
-
-/**
- * Deregister this component's primary public interfaces from the Service Locator.
- * This is done at shutdown, and whenever we want to keep other services from locating
- * our interfaces.
- */
-void SipStateReplicatorService::deregisterFromServiceLocator()
-{
- try
- {
- mComponentServiceManagement->unregister();
- mConfigurationManagement->unregister();
- mServiceLocatorManagement->removeCompare(mConfigCompareGuid);
- }
- catch(...)
- {
- lg(Error) << "Had trouble in deregisterFromServiceLocator()." << endl;
- }
-}
-
-void SipStateReplicatorService::initialize(const std::string& appName, const Ice::CommunicatorPtr& ic)
-{
- mIceStorm = new CollocatedIceStorm("SipStateReplicatorIceStorm", ic->getProperties());
-
- IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(
- ic->propertyToProxy("SipStateReplicatorTopicManager.Proxy"));
-
- IceStorm::TopicPrx topic;
-
- if (topicManager)
- {
- try
- {
- topic = topicManager->retrieve("ConfigurationReplication");
- }
- catch (const IceStorm::NoSuchTopic&)
- {
- try
- {
- topic = topicManager->create("ConfigurationReplication");
- }
- catch (const IceStorm::TopicExists&)
- {
- lg(Error) << "Oh snap! Race condition creating topic, aborting";
- return;
- }
- }
- // There is no cast here on purpose as this is just going to get passed to
- // the service locator which just takes a plain ol' proxy anyway.
- mConfigurationPublisher = topic->getPublisher();
- }
- else
- {
- lg(Info) << "IceStorm topic manager proxy not present, unable to perform configuration replication.";
- }
-
- mAdapter = ic->createObjectAdapter("SipStateReplicator");
-
- // setup logging client
- mIceLogger = createIceLogger(mAdapter);
- getLoggerFactory().setLogOutput(mIceLogger->getLogger());
-
- mAppName = appName;
- // Create and publish our ComponentService interface support.
- mComponentService = new ComponentServiceImpl(*this);
- mAdapter->add(mComponentService, ic->stringToIdentity(ComponentServiceId));
- mStateReplicator = new SipStateReplicatorI();
- mAdapter->add(mStateReplicator, ic->stringToIdentity(ServiceDiscoveryId));
- mConfigurationReplicator = new ConfigurationReplicatorI(topic);
- mAdapter->addFacet(mConfigurationReplicator, ic->stringToIdentity(ServiceDiscoveryId),
- ReplicatorFacet);
-
- mAdapter->activate();
-}
-
-void SipStateReplicatorService::start(const string& name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq&)
-{
- initialize(name, ic);
- // Plug into the Asterisk SCF discovery system so that the interfaces we provide
- // can be located.
- registerWithServiceLocator(ic);
-}
-
-void SipStateReplicatorService::stop()
-{
- // Remove our interfaces from the service locator.
- deregisterFromServiceLocator();
-
- // Stop our local IceStorm instance
- mIceStorm->stop();
-}
-
-extern "C"
-{
-ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
-{
- return new SipStateReplicatorService;
-}
-}
-
-----------------------------------------------------------------------
--
asterisk-scf/release/sip.git
More information about the asterisk-scf-commits
mailing list