[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Oct 7 17:42:02 CDT 2010
branch "master" has been updated
via 85373c17bc0f89441d4b76376d737c4bf6938f80 (commit)
from a1986da81791a0fe47b68fddefa07b34263d8194 (commit)
Summary of changes:
src/CMakeLists.txt | 4 +-
src/SipStateReplicatorApp.cpp | 73 ++++++++++++++++++-----------------------
2 files changed, 34 insertions(+), 43 deletions(-)
- Log -----------------------------------------------------------------
commit 85373c17bc0f89441d4b76376d737c4bf6938f80
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Oct 7 17:45:19 2010 -0500
Make the Sip State Replicator iceboxified.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b9edca7..d08b85b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -70,6 +70,6 @@ hydra_component_add_file(SipStateReplicator SipStateReplicator.h)
hydra_component_add_ice_libraries(SipStateReplicator IceStorm)
-hydra_component_build_standalone(SipStateReplicator)
+hydra_component_build_icebox(SipStateReplicator)
-hydra_component_install(SipStateReplicator RUNTIME bin "Sip State Replicator" SipStateReplicator)
+#hydra_component_install(SipStateReplicator RUNTIME bin "Sip State Replicator" SipStateReplicator)
diff --git a/src/SipStateReplicatorApp.cpp b/src/SipStateReplicatorApp.cpp
index 0224430..3accb19 100644
--- a/src/SipStateReplicatorApp.cpp
+++ b/src/SipStateReplicatorApp.cpp
@@ -9,6 +9,7 @@
#include <Ice/Ice.h>
#include <IceUtil/UUID.h>
#include <IceStorm/IceStorm.h>
+#include <IceBox/IceBox.h>
#include "ServiceLocatorIf.h"
#include "ComponentServiceIf.h"
@@ -21,21 +22,21 @@ using namespace AsteriskSCF::Core::Discovery::V1;
using namespace AsteriskSCF::System::Component::V1;
using namespace AsteriskSCF::SipChannelService;
-class SipStateReplicatorApp : public Ice::Application
+class SipStateReplicatorService : public IceBox::Service
{
public:
- SipStateReplicatorApp() { };
- ~SipStateReplicatorApp()
+ SipStateReplicatorService() { };
+ ~SipStateReplicatorService()
{
mComponentService = 0;
mAdapter = 0;
mStateReplicator = 0;
};
- virtual int run(int, char *[]);
- virtual void interruptCallback(int);
+ virtual void start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args);
+ virtual void stop();
private:
- void initialize(std::string appName);
- void registerWithServiceLocator();
+ void initialize(std::string appName, const Ice::CommunicatorPtr& ic);
+ void registerWithServiceLocator(const Ice::CommunicatorPtr& ic);
void deregisterFromServiceLocator();
std::string mAppName;
//vector<SipStateReplicatorListenerPrx> mListeners;
@@ -57,7 +58,7 @@ static const string ServiceDiscoveryId("SipStateReplicatorService");
class ComponentServiceImpl : public ComponentService
{
public:
- ComponentServiceImpl(SipStateReplicatorApp &app) : mApp(app) {}
+ ComponentServiceImpl(SipStateReplicatorService &service) : mService(service) {}
public: // Overrides of the ComponentService interface.
virtual void suspend(const ::Ice::Current& = ::Ice::Current())
@@ -76,7 +77,7 @@ public: // Overrides of the ComponentService interface.
}
private:
- SipStateReplicatorApp& mApp;
+ SipStateReplicatorService& mService;
};
class SipStateReplicatorCompare : public ServiceLocatorParamsCompare
@@ -99,25 +100,15 @@ private:
typedef IceUtil::Handle<SipStateReplicatorCompare> SipStateReplicatorComparePtr;
/**
- * Handles control characters in case the component is invoked as a console app.
- */
-void SipStateReplicatorApp::interruptCallback(int val)
-{
- cout << "Exiting..." << endl;
- // Should probably do more to gracefully exit.
- _exit(EXIT_SUCCESS);
-}
-
-/**
* Register this component's primary public interfaces with the Service Locator.
* This enables other Asterisk SCF components to locate our interfaces.
*/
-void SipStateReplicatorApp::registerWithServiceLocator()
+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(communicator()->propertyToProxy("LocatorServiceManagement.Proxy"));
+ mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(ic->propertyToProxy("LocatorServiceManagement.Proxy"));
if (mServiceLocatorManagement == 0)
{
@@ -126,7 +117,7 @@ void SipStateReplicatorApp::registerWithServiceLocator()
}
// Get a proxy to our ComponentService interface and add it to the Service Locator.
- Ice::ObjectPrx componentServiceObjectPrx = mAdapter->createDirectProxy(communicator()->stringToIdentity(ComponentServiceId));
+ 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.
@@ -139,7 +130,7 @@ void SipStateReplicatorApp::registerWithServiceLocator()
mComponentServiceManagement->addLocatorParams(genericparams, "");
- Ice::ObjectPrx stateReplicatorObjectPrx = mAdapter->createDirectProxy(communicator()->stringToIdentity(ServiceDiscoveryId));
+ Ice::ObjectPrx stateReplicatorObjectPrx = mAdapter->createDirectProxy(ic->stringToIdentity(ServiceDiscoveryId));
SipStateReplicatorPrx stateReplicatorPrx = SipStateReplicatorPrx::checkedCast(stateReplicatorObjectPrx);
string stateReplicationGuid(AsteriskSCF::SIP::V1::StateReplicatorDiscoveryCategory);
@@ -148,7 +139,7 @@ void SipStateReplicatorApp::registerWithServiceLocator()
ServiceLocatorParamsPtr discoveryParams = new ServiceLocatorParams();
discoveryParams->category = AsteriskSCF::SIP::V1::StateReplicatorDiscoveryCategory;
- string replicatorName = communicator()->getProperties()->getPropertyWithDefault("SipStateReplicator.Name", "default");
+ string replicatorName = ic->getProperties()->getPropertyWithDefault("SipStateReplicator.Name", "default");
SipStateReplicatorCompare* nameCompare = new SipStateReplicatorCompare(replicatorName);
ServiceLocatorParamsComparePrx compareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(mAdapter->addWithUUID(nameCompare));
@@ -169,7 +160,7 @@ void SipStateReplicatorApp::registerWithServiceLocator()
* This is done at shutdown, and whenever we want to keep other services from locating
* our interfaces.
*/
-void SipStateReplicatorApp::deregisterFromServiceLocator()
+void SipStateReplicatorService::deregisterFromServiceLocator()
{
try
{
@@ -181,38 +172,38 @@ void SipStateReplicatorApp::deregisterFromServiceLocator()
}
}
-void SipStateReplicatorApp::initialize(const std::string appName)
+void SipStateReplicatorService::initialize(const std::string appName, const Ice::CommunicatorPtr& ic)
{
- mAdapter = communicator()->createObjectAdapter("SipStateReplicator");
+ mAdapter = ic->createObjectAdapter("SipStateReplicator");
mAppName = appName;
// Create and publish our ComponentService interface support.
mComponentService = new ComponentServiceImpl(*this);
- mAdapter->add(mComponentService, communicator()->stringToIdentity(ComponentServiceId));
+ mAdapter->add(mComponentService, ic->stringToIdentity(ComponentServiceId));
mStateReplicator = new SipStateReplicatorI();
- mAdapter->add(mStateReplicator, communicator()->stringToIdentity(ServiceDiscoveryId));
+ mAdapter->add(mStateReplicator, ic->stringToIdentity(ServiceDiscoveryId));
mAdapter->activate();
}
-int SipStateReplicatorApp::run(int argc, char *argv[])
+void SipStateReplicatorService::start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args)
{
- initialize(argv[0]);
+ initialize(name, ic);
// Plug into the Asterisk SCF discovery system so that the interfaces we provide
// can be located.
- registerWithServiceLocator();
-
- // Run until it's time to run no more.
- communicator()->waitForShutdown();
+ registerWithServiceLocator(ic);
+}
+void SipStateReplicatorService::stop()
+{
// Remove our interfaces from the service locator.
deregisterFromServiceLocator();
-
- return EXIT_SUCCESS;
}
-int main(int argc, char *argv[])
+extern "C"
{
- SipStateReplicatorApp app;
- app.callbackOnInterrupt();
- return app.main(argc, argv);
+ HYDRA_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr communicator)
+ {
+ return new SipStateReplicatorService;
+ }
}
+
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list