[asterisk-scf-commits] asterisk-scf/integration/file_session_gateway.git branch "initial_development" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Nov 10 09:18:28 CST 2011


branch "initial_development" has been updated
       via  377beed4fec4f9bc266ac7932142d275703dae03 (commit)
       via  eadae41723188d84b2c838f9afe575b24ee3fe34 (commit)
       via  359e32444a5ebbf27491e9c6e3b0e45457970f08 (commit)
       via  7cefc1c295787dc8d0ff1fda9936c42ea4d62e51 (commit)
      from  e5f30196e06205dbdf0eba0d1734cfdf73191979 (commit)

Summary of changes:
 CMakeLists.txt                                     |    8 +-
 .../.FileSessionGatewayConfigurationIf.ice.swp     |  Bin 0 -> 12288 bytes
 .../FileSessionGatewayConfigurationIf.ice          |  145 +++++
 .../FileSessionGateway/FileSessionGatewayIf.ice    |   17 +-
 .../FileSessionReplicationIf.ice                   |  109 ++++
 .../FileSession/FileSessionGatewayIf.ice           |   38 --
 src/CMakeLists.txt                                 |   39 ++-
 src/Component.cpp                                  |  464 +--------------
 src/ComponentFeature.h                             |   19 +-
 src/Configuration.cpp                              |  243 +++++----
 src/Endpoint.cpp                                   |  268 +++++++++
 src/Endpoint.h                                     |   48 ++
 src/EndpointLocator.cpp                            |  602 ++++++++++++++++++++
 src/EndpointLocator.h                              |   52 ++-
 src/FileSessionComponent.h                         |   41 --
 src/FileSessionGatewayComponent.h                  |   93 ++--
 src/{Configuration.h => LoggerF.h}                 |   15 +-
 src/ReplicationContext.h                           |    3 +-
 src/ReplicationListener.h                          |    2 +-
 src/Replicator.h                                   |   12 +-
 src/Session.cpp                                    |  447 +++++++++++++++
 src/Session.h                                      |   63 ++
 22 files changed, 2019 insertions(+), 709 deletions(-)
 create mode 100644 slice/AsteriskSCF/Configuration/FileSessionGateway/.FileSessionGatewayConfigurationIf.ice.swp
 create mode 100644 slice/AsteriskSCF/Configuration/FileSessionGateway/FileSessionGatewayConfigurationIf.ice
 copy src/EndpointLocator.h => slice/AsteriskSCF/FileSessionGateway/FileSessionGatewayIf.ice (70%)
 create mode 100644 slice/AsteriskSCF/Replication/FileSessionGateway/FileSessionReplicationIf.ice
 delete mode 100755 slice/AsteriskSCF/SessionCommunications/FileSession/FileSessionGatewayIf.ice
 mode change 100755 => 100644 src/CMakeLists.txt
 mode change 100755 => 100644 src/Component.cpp
 mode change 100755 => 100644 src/ComponentFeature.h
 mode change 100755 => 100644 src/Config.h
 mode change 100755 => 100644 src/Configuration.cpp
 mode change 100755 => 100644 src/Configuration.h
 create mode 100644 src/Endpoint.cpp
 create mode 100644 src/Endpoint.h
 create mode 100644 src/EndpointLocator.cpp
 mode change 100755 => 100644 src/EndpointLocator.h
 delete mode 100755 src/FileSessionComponent.h
 mode change 100755 => 100644 src/FileSessionGatewayComponent.h
 copy src/{Configuration.h => LoggerF.h} (70%)
 mode change 100755 => 100644
 mode change 100755 => 100644 src/Replication.h
 mode change 100755 => 100644 src/ReplicationContext.h
 mode change 100755 => 100644 src/ReplicationListener.h
 mode change 100755 => 100644 src/Replicator.h
 mode change 100755 => 100644 src/ReplicatorListener.h
 create mode 100644 src/Session.cpp
 create mode 100644 src/Session.h


- Log -----------------------------------------------------------------
commit 377beed4fec4f9bc266ac7932142d275703dae03
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Nov 10 11:47:07 2011 -0330

    Rename variables/method to match changes to slice

diff --git a/src/Session.cpp b/src/Session.cpp
index c040e2d..cea5a78 100644
--- a/src/Session.cpp
+++ b/src/Session.cpp
@@ -330,7 +330,7 @@ public:
         cb->ice_response(AsteriskSCF::SessionCommunications::PartyIdentification::V1::SessionOwnerIdPtr());
     }
 
-    void getRedirecting_async(const AMD_Session_getRedirectingPtr& cb, const Ice::Current&)
+    void getRedirections_async(const AMD_Session_getRedirectionsPtr& cb, const Ice::Current&)
     {
         cb->ice_response(AsteriskSCF::SessionCommunications::PartyIdentification::V1::RedirectingPtr());
     }

commit eadae41723188d84b2c838f9afe575b24ee3fe34
Author: Brent Eagles <beagles at digium.com>
Date:   Mon Oct 10 07:12:20 2011 -0230

    Cleanups on sketchup.

diff --git a/slice/AsteriskSCF/Configuration/FileSessionGateway/.FileSessionGatewayConfigurationIf.ice.swp b/slice/AsteriskSCF/Configuration/FileSessionGateway/.FileSessionGatewayConfigurationIf.ice.swp
new file mode 100644
index 0000000..b416602
Binary files /dev/null and b/slice/AsteriskSCF/Configuration/FileSessionGateway/.FileSessionGatewayConfigurationIf.ice.swp differ
diff --git a/slice/AsteriskSCF/Configuration/FileSessionGateway/FileSessionGatewayConfigurationIf.ice b/slice/AsteriskSCF/Configuration/FileSessionGateway/FileSessionGatewayConfigurationIf.ice
new file mode 100644
index 0000000..94dcd17
--- /dev/null
+++ b/slice/AsteriskSCF/Configuration/FileSessionGateway/FileSessionGatewayConfigurationIf.ice
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <Ice/BuiltinSequences.ice>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.ice>
+#include <AsteriskSCF/System/Component/ConfigurationIf.ice>
+#include <AsteriskSCF/Media/File/FileMediaIf.ice>
+
+module AsteriskSCF
+{
+
+module Configuration
+{
+
+module FileSessionGateway
+{
+
+["suppress"]
+module V1
+{
+
+/**
+ * Service locator category for finding the configuration service
+ */
+const string ConfigurationDiscoveryCategory = "FileSessionGatewayConfiguration";
+
+/**
+ * Local visitor class for visiting configuration groups
+ */
+local class ConfigurationGroupVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationGroupVisitor
+{
+};
+
+/**
+ * Generic configuration group
+ */
+["visitor:ConfigurationGroupVisitor"] class ConfigurationGroup extends AsteriskSCF::System::Configuration::V1::ConfigurationGroup
+{
+};
+
+/**
+ * General configuration group that contains general items related to the component as a whole
+ */
+class GeneralGroup extends ConfigurationGroup
+{
+};
+
+/**
+ * Local visitor class for visiting configuration items
+ */
+local class ConfigurationItemVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationItemVisitor
+{
+};
+
+/**
+ * Generic configuration item
+ */
+["visitor:ConfigurationItemVisitor"] class ConfigurationItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+{
+};
+
+/**
+ * Endpoint group, used to configure an endpoint
+ */
+class EndpointGroup extends ConfigurationGroup
+{
+    /**
+     *  A unique id
+     */
+    string id;
+};
+
+/**
+ * 
+ * Destination string for the endpoint. 
+ * 
+ */
+class EndpointDestinationName extends ConfigurationItem
+{
+    string value;
+};
+
+/**
+ *
+ * Media file specification for .
+ *
+ **/
+class MediaFile extends ConfigurationItem
+{
+    /**
+     * Identifier for the file media.
+     */
+    string id;
+
+    /**
+     * Operations that it is supposed to support.
+     **/
+    AsteriskSCF::Media::File::V1::FileOperations operations =
+        AsteriskSCF::Media::File::V1::Playback;
+};
+
+/**
+ * Routing service configuration item
+ */
+class RoutingItem extends ConfigurationItem
+{
+    /**
+     * Name of the routing service to use
+     */
+    string routingServiceName;
+};
+
+/**
+ * RTP Media service configuration item
+ */
+class FileMediaServiceItem extends ConfigurationItem
+{
+    /**
+     * Name of the File media service to use
+     */
+    string mediaServiceName;
+};
+
+}; /* module V1 */
+
+}; /* module FileSessionGateway */
+
+}; /* module Configuration */
+
+}; /* module AsteriskSCF */
diff --git a/slice/AsteriskSCF/FileSessionGateway/FileSession/FileSessionGatewayIf.ice b/slice/AsteriskSCF/FileSessionGateway/FileSessionGatewayIf.ice
similarity index 65%
rename from slice/AsteriskSCF/FileSessionGateway/FileSession/FileSessionGatewayIf.ice
rename to slice/AsteriskSCF/FileSessionGateway/FileSessionGatewayIf.ice
index 82fbd2e..fa9434e 100755
--- a/slice/AsteriskSCF/FileSessionGateway/FileSession/FileSessionGatewayIf.ice
+++ b/slice/AsteriskSCF/FileSessionGateway/FileSessionGatewayIf.ice
@@ -18,21 +18,13 @@
 
 module AsteriskSCF
 {
-module SessionCommunications
-{
-module FileSession
+module FileSessionGateway
 {
 module V1
 {
+
+const string ComponentServiceDiscoveryCategory = "FileSessionGateway";
     
-interface FileSessionEndpoint
-{
-    /** XXX
-        can't think of any additional methods at the moment.
-     */ 
-};
-    
-} /* end of module V1 */
-} /* end of module FileSession */
-} /* end of module SessionCommunications */
-} /* end of module AsteriskSCF */
\ No newline at end of file
+}; /* end of module V1 */
+}; /* end of module FileSessionGatway */
+}; /* end of module AsteriskSCF */
diff --git a/slice/AsteriskSCF/Replication/FileSessionGateway/FileSessionReplicationIf.ice b/slice/AsteriskSCF/Replication/FileSessionGateway/FileSessionReplicationIf.ice
new file mode 100644
index 0000000..fc9d718
--- /dev/null
+++ b/slice/AsteriskSCF/Replication/FileSessionGateway/FileSessionReplicationIf.ice
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+ 
+#pragma once
+#include <Ice/BuiltinSequences.ice>
+#include <Ice/Identity.ice>
+#include <AsteriskSCF/Media/MediaIf.ice>
+#include <AsteriskSCF/Media/File/FileMediaIf.ice>
+#include <AsteriskSCF/Media/RTP/MediaRTPIf.ice>
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.ice>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.ice>
+#include <AsteriskSCF/System/Component/ConfigurationIf.ice>
+
+module AsteriskSCF
+{
+
+module Replication
+{
+
+module FileSessionGateway
+{
+
+["suppress"]
+module V1
+{
+   const string StateReplicatorComponentCategory = "FileSessionReplicatorComponent";
+   const string StateReplicatorDiscoveryCategory = "FileSessionReplicator";
+
+   class StateItem
+   {
+      string key;
+      string sessionId;
+   };
+
+   sequence<StateItem> StateItemSeq;
+
+   interface StateReplicatorListener
+   {
+      void stateRemoved(Ice::StringSeq itemKeys);
+      void stateRemovedForItems(StateItemSeq items);
+      void stateSet(StateItemSeq items);
+   };
+
+   interface StateReplicator
+   {
+      void addListener(StateReplicatorListener *listener);
+      void removeListener(StateReplicatorListener *listener);
+      void setState (StateItemSeq items);
+      void removeState(Ice::StringSeq items);
+      void removeStateForItems(StateItemSeq items);
+      idempotent StateItemSeq getState(Ice::StringSeq iteKeys);
+      idempotent StateItemSeq getAllState();
+   };
+
+   sequence<AsteriskSCF::Media::File::V1::FileSession*> MediaSessionSeq;
+
+   class SessionState extends StateItem
+   {
+      string endpointName;
+
+      Ice::Identity sessionObjectId;
+      Ice::Identity mediaSessionObjectId;
+      Ice::Identity sessionControllerObjectId;
+
+      AsteriskSCF::Media::V1::StreamSourceSeq sources;
+      AsteriskSCF::Media::V1::StreamSinkSeq sinks;
+      AsteriskSCF::Media::V1::StreamInformationDict streams;
+
+      MediaSessionSeq rtpMediaSessions;
+
+      AsteriskSCF::SessionCommunications::V1::SessionListenerSeq listeners;
+
+      AsteriskSCF::SessionCommunications::V1::Bridge *bridge;
+
+      AsteriskSCF::SessionCommunications::V1::SessionCookieDict cookies;
+   };
+
+   class DefaultSessionListenerItem extends StateItem
+   {
+      string endpointName;
+      AsteriskSCF::SessionCommunications::V1::SessionListener* listener;
+   };
+
+   class DefaultSessionCookieItem extends StateItem
+   {
+      string endpointName;
+      AsteriskSCF::SessionCommunications::V1::SessionCookie cookie;
+   };
+
+}; /* module V1 */
+
+}; /* module FileSessionGateway */
+
+}; /* module Replication */
+
+}; /* module AsteriskSCF */
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 777690d..144f394 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -22,8 +22,10 @@ astscf_component_add_files(FileSessionGateway Component.cpp)
 astscf_component_add_files(FileSessionGateway Configuration.cpp)
 astscf_component_add_files(FileSessionGateway Configuration.h)
 astscf_component_add_slices(FileSessionGateway PROJECT 
+    AsteriskSCF/FileSessionGateway/FileSessionGatewayIf.ice
     AsteriskSCF/Configuration/FileSessionGateway/FileSessionGatewayConfigurationIf.ice   
-    AsteriskSCF/Replication/FileSessionGateway/FileSessionReplicationIf.ice)
+    AsteriskSCF/Replication/FileSessionGateway/FileSessionReplicationIf.ice
+    )
 
 astscf_component_add_ice_libraries(FileSessionGateway IceStorm)
 astscf_component_add_boost_libraries(FileSessionGateway core)
@@ -32,17 +34,17 @@ astscf_component_build_icebox(FileSessionGateway)
 target_link_libraries(FileSessionGateway astscf-ice-util-cpp logging-client)
 astscf_component_install(FileSessionGateway)
 
-astscf_component_init(FileSessionReplicator)
-astscf_component_add_files(FileSessionReplicator
-    Replicator.h
-    ReplicatorListener.h
-    )
-
-astscf_component_add_ice_libraries(FileSessionReplicator IceStorm)
-astscf_component_add_boost_libraries(FileSessionReplicator core)
-astscf_component_add_slice_collection_libraries(FileSessionReplicator ASTSCF)
-astscf_component_build_icebox(FileSessionReplicator)
-target_link_libraries(FileSessionReplicator astscf-ice-util-cpp logging-client)
-astscf_component_install(FileSessionReplicator)
-
+# # astscf_component_init(FileSessionReplicator)
+# astscf_component_add_files(FileSessionReplicator
+#     Replicator.h
+#     ReplicatorListener.h
+#     )
+# 
+# astscf_component_add_ice_libraries(FileSessionReplicator IceStorm)
+# astscf_component_add_boost_libraries(FileSessionReplicator core)
+# astscf_component_add_slice_collection_libraries(FileSessionReplicator ASTSCF)
+# astscf_component_build_icebox(FileSessionReplicator)
+# target_link_libraries(FileSessionReplicator astscf-ice-util-cpp logging-client)
+# astscf_component_install(FileSessionReplicator)
+# 
 
diff --git a/src/Component.cpp b/src/Component.cpp
index 95b9265..5013318 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -23,14 +23,16 @@
 #include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
 #include <AsteriskSCF/Discovery/SmartProxy.h>
 #include <AsteriskSCF/System/Component/ConfigurationIf.h>
+#include <AsteriskSCF/FileSessionGateway/FileSessionGatewayIf.h>
 
 #include <AsteriskSCF/Logger/IceLogger.h>
 #include <AsteriskSCF/logger.h>
 
 #include "EndpointLocator.h"
-#include "ReplicationListener.h"
-#include "ReplicationContext.h"
+// #include "ReplicationListener.h"
+// #include "ReplicationContext.h"
 #include "FileSessionGatewayComponent.h"
+#include "Config.h"
 
 using namespace AsteriskSCF::Core::Routing::V1;
 using namespace AsteriskSCF::Core::Discovery::V1;
@@ -54,6 +56,12 @@ namespace FileSessionGtw
 class FileSessionGatewayComponentImpl : public FileSessionGatewayComponent
 {
 public:
+    FileSessionGatewayComponentImpl() :
+        FileSessionGatewayComponent(getLoggerFactory().getLogger(LoggerId + ".Gateway"),
+        AsteriskSCF::FileSessionGateway::V1::ComponentServiceDiscoveryCategory)
+    {
+    }
+
     void addFeatureProxyToServices(const Ice::ObjectPrx& proxy, const std::string& category)
     {
         managePrimaryService(wrapServiceForRegistration(proxy, category));
@@ -95,6 +103,6 @@ extern "C"
 {
 ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
 {
-    return new AsteriskSCF::FileSessionGtw::Component;
+    return new AsteriskSCF::FileSessionGtw::FileSessionGatewayComponentImpl;
 }
 }
diff --git a/src/Configuration.cpp b/src/Configuration.cpp
index ecec5a3..a6d5fd2 100644
--- a/src/Configuration.cpp
+++ b/src/Configuration.cpp
@@ -1,123 +1,128 @@
-/*
- * 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 "Configuration.h"
-
-#include <AsteriskSCF/System/Component/ConfigurationIf.h>
-#include <AsteriskSCF/logger.h>
-#include <IceUtil/UUID.h>
-
-using namespace AsteriskSCF::FileSessionGtw;
-using namespace AsteriskSCF::System::Configuration::V1;
-using namespace AsteriskSCF::System::Logging;
-using namespace std;
-
-namespace 
-{
-    class ConfigurationImpl : public AsteriskSCF::System::Configuration::V1::ConfigurationService
-    {
-    public:
-        ConfigurationImpl()
-        {
-        }
-
-        ConfigurationGroupSeq getConfiguration(const ConfigurationGroupSeq& groups, const Ice::Current& current)
-        {
-        }
-
-        ConfigurationGroupSeq getConfigurationAll(const ConfigurationGroupSeq& groups, const Ice::Current& current)
-        {
-        }
-
-        ConfigurationGroupSeq getConfigurationGroups(const Ice::Current& current)
-        {
-        }
-
-        void setConfiguration(const ConfigurationGroupSeq& groups, const Ice::Current& current)
-        {
-        }
-
-        void removeConfigurationItems(const ConfigurationGroupSeq& groups, const Ice::Current& current)
-        {
-        }
-
-        void removeConfigurationGroups(const ConfigurationGroupSeq& groups, const Ice::Current& current)
-        {
-        }
-    };
-    typedef IceUtil::Handle<ConfigurationImpl> ConfigurationImplPtr;
-
-    class ConfigurationFeature : public ComponentFeature
-    {
-    public:
-        ConfigurationFeature(const Logger& logger) :
-            mServant(new ConfiurationImpl),
-            mId(std::string("ascf.fsgtw.") + IceUtil::generateUUID()),
-            mLogger(logger)
-        {
-        }
-
-        Ice::ObjectPrx activate(const Ice::ObjectAdapterPtr& adapter)
-        {
-            Ice::Identity id(adapter->getCommunicator()->stringToIdentity(mId));
-            mPublicProxy = ConfigurationPrx::uncheckedCast(adapter->add(mServant, id));
-            mDirectoryProxy = ConfigurationPrx::uncheckedCast(adapter->createDirectProxy(id));
-            return mDirectoryProxy;
-        }
-
-        void registerFeature(const FileSessionGatewayComponentPtr& gatewayComponent)
-        {
-            assert(gatewayComponent);
-            if (gatewayComponent)
-            {
-                //
-                // This should be a public proxy because if we fail over to a
-                // replica, we want the proxy in discovery to be remain generally
-                // valid.
-                //
-                gatewayComponent->addFeatureProxyToBackplane(mPublicProxy, 
-                    AsteriskSCF::System::Configuration::V1::ConfigurationDiscoveryCategory);
-            }
-            else
-            {
-                mLogger(Error) << "Unable to register configuration service. Provided component reference is nil";
-            }
-        }
-
-        void makeReady()
-        {
-            //
-            // Nothing to do here.
-            //
-        }
-
-    private:
-        //
-        // These variable names are pretty self-explanatory, so we will let them.
-        //
-        ConfigurationImplPtr mServant; 
-        string mId;
-        ConfigurationPrx mPublicProxy;
-        ConfigurationPrx mDirectProxy;
-        Logger mLogger;
-    };
-    typedef IceUtil::Handle<ConfigurationFeature> ConfigurationFeaturePtr;
-}
-
-AsteriskSCF::FileSessionGtw::ComponentFeaturePtr AsteriskSCF::FileSessionGtw::createConfigurationFeature()
-{
-    return new ConfigurationFeature(getLoggerFactory().getLogger(LoggerId + ".Configuration"));
-}
+/*
+ * 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 "Configuration.h"
+#include "Config.h"
+
+#include <AsteriskSCF/Configuration/FileSessionGateway/FileSessionGatewayConfigurationIf.h>
+#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/System/Component/ConfigurationIf.h>
+
+#include <Ice/Ice.h>
+#include <IceUtil/UUID.h>
+
+using namespace AsteriskSCF::FileSessionGtw;
+using namespace AsteriskSCF::System::Configuration::V1;
+using namespace AsteriskSCF::System::Logging;
+using namespace std;
+
+namespace 
+{
+    class ConfigurationImpl : public AsteriskSCF::System::Configuration::V1::ConfigurationService
+    {
+    public:
+        ConfigurationImpl()
+        {
+        }
+
+        ConfigurationGroupSeq getConfiguration(const ConfigurationGroupSeq&, const Ice::Current&)
+        {
+            return ConfigurationGroupSeq();
+        }
+
+        ConfigurationGroupSeq getConfigurationAll(const ConfigurationGroupSeq&, const Ice::Current&)
+        {
+            return ConfigurationGroupSeq();
+        }
+
+        ConfigurationGroupSeq getConfigurationGroups(const Ice::Current&)
+        {
+            return ConfigurationGroupSeq();
+        }
+
+        void setConfiguration(const ConfigurationGroupSeq&, const Ice::Current&)
+        {
+        }
+
+        void removeConfigurationItems(const ConfigurationGroupSeq&, const Ice::Current&)
+        {
+        }
+
+        void removeConfigurationGroups(const ConfigurationGroupSeq&, const Ice::Current&)
+        {
+        }
+    };
+    typedef IceUtil::Handle<ConfigurationImpl> ConfigurationImplPtr;
+
+    class ConfigurationFeature : public ComponentFeature
+    {
+    public:
+        ConfigurationFeature(const Logger& logger) :
+            mServant(new ConfigurationImpl),
+            mId(std::string("ascf.fsgtw.") + IceUtil::generateUUID()),
+            mLogger(logger)
+        {
+        }
+
+        Ice::ObjectPrx activate(const Ice::ObjectAdapterPtr& adapter)
+        {
+            Ice::Identity id(adapter->getCommunicator()->stringToIdentity(mId));
+            mPublicProxy = ConfigurationServicePrx::uncheckedCast(adapter->add(mServant, id));
+            mDirectProxy = ConfigurationServicePrx::uncheckedCast(adapter->createDirectProxy(id));
+            return mDirectProxy;
+        }
+
+        void registerFeature(const FileSessionGatewayComponentPtr& gatewayComponent)
+        {
+            assert(gatewayComponent);
+            if (gatewayComponent)
+            {
+                //
+                // This should be a public proxy because if we fail over to a
+                // replica, we want the proxy in discovery to be remain generally
+                // valid.
+                //
+                gatewayComponent->addFeatureProxyToBackplane(mPublicProxy, 
+                    AsteriskSCF::Configuration::FileSessionGateway::V1::ConfigurationDiscoveryCategory);
+            }
+            else
+            {
+                mLogger(Error) << "Unable to register configuration service. Provided component reference is nil";
+            }
+        }
+
+        void makeReady(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& /* locator */)
+        {
+            // XXX
+        }
+
+    private:
+        //
+        // These variable names are pretty self-explanatory, so we will let them.
+        //
+        ConfigurationImplPtr mServant; 
+        string mId;
+        ConfigurationServicePrx mPublicProxy;
+        ConfigurationServicePrx mDirectProxy;
+        Logger mLogger;
+    };
+    typedef IceUtil::Handle<ConfigurationFeature> ConfigurationFeaturePtr;
+}
+
+AsteriskSCF::FileSessionGtw::ComponentFeaturePtr AsteriskSCF::FileSessionGtw::createConfigurationFeature()
+{
+    return new ConfigurationFeature(getLoggerFactory().getLogger(LoggerId + ".Configuration"));
+}
diff --git a/src/FileSessionComponent.h b/src/FileSessionComponent.h
deleted file mode 100644
index 100b6b3..0000000
--- a/src/FileSessionComponent.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.
- */
-
-#pragma once
-
-#include <AsteriskSCF/Component/Component.h>
-
-namespace AsteriskSCF
-{
-namespace FileSessionGtw
-{
-//
-// The file session gateway defines a derived instance of the common component
-// base class to expose certain features as public, allowing some of the 
-// initialization implementation to be moved out of the core Component.cpp. 
-// With that in mind, to keep consistency with the other component implementations
-// there is a mismatch between this header file name and its corresponding
-// implementation source file (i.e. look in Component.cpp).
-//
-class FileSessionComponent : public AsteriskSCF::Component::Component
-{
-public:
-    virtual void addFeatureToServices(const AsteriskSCF::Discovery::LocatorRegistrationWrapperPtr& locationWrapper) = 0;
-};
-typedef IceUtil::Handle<FileSessionComponent> FileSessionComponentPtr;
-
-} /* End of namespace FileSessionGtw */
-} /* End of namespace AsteriskSCF */
diff --git a/src/FileSessionGatewayComponent.h b/src/FileSessionGatewayComponent.h
index 678f49d..bfd00b8 100644
--- a/src/FileSessionGatewayComponent.h
+++ b/src/FileSessionGatewayComponent.h
@@ -1,44 +1,49 @@
-/*
- * 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.
- */
-
-#pragma once
-
-#include <AsteriskSCF/Component/Component.h>
-
-namespace AsteriskSCF
-{
-namespace FileSessionGtw
-{
-//
-// The file session gateway defines a derived instance of the common component
-// base class to expose certain features as public, allowing some of the
-// initialization implementation to be moved out of the core Component.cpp.
-// With that in mind, to keep consistency with the other component
-// implementations there is a mismatch between this header file name and its
-// corresponding implementation source file (i.e. look in Component.cpp).
-//
-class FileSessionGatewayComponent : public AsteriskSCF::Component::Component
-{
-public:
-    virtual void addFeatureProxyToServices(const Ice::ObjectPrx& proxy, const std::string& category, 
-        const std::string& service, const std::string& id) = 0;
-    virtual void addFeatureProxyToBackplane(const Ice::ObjectPrx& proxy, const std::string& category, 
-        const std::string& service, const std::string& id) = 0;
-};
-typedef IceUtil::Handle<FileSessionGatewayComponent> FileSessionGatewayComponentPtr;
-
-} /* End of namespace FileSessionGtw */
-} /* End of namespace AsteriskSCF */
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <AsteriskSCF/Component/Component.h>
+#include "LoggerF.h"
+
+namespace AsteriskSCF
+{
+namespace FileSessionGtw
+{
+//
+// The file session gateway defines a derived instance of the common component
+// base class to expose certain features as public, allowing some of the
+// initialization implementation to be moved out of the core Component.cpp.
+// With that in mind, to keep consistency with the other component
+// implementations there is a mismatch between this header file name and its
+// corresponding implementation source file (i.e. look in Component.cpp).
+//
+class FileSessionGatewayComponent : public AsteriskSCF::Component::Component
+{
+public:
+    FileSessionGatewayComponent(const AsteriskSCF::System::Logging::Logger& logger,
+        const std::string& category) :
+        AsteriskSCF::Component::Component(logger, category)
+    {
+    }
+
+    virtual void addFeatureProxyToServices(const Ice::ObjectPrx& proxy, const std::string& category) = 0; 
+    virtual void addFeatureProxyToBackplane(const Ice::ObjectPrx& proxy, const std::string& category) = 0;
+};
+typedef IceUtil::Handle<FileSessionGatewayComponent> FileSessionGatewayComponentPtr;
+
+} /* End of namespace FileSessionGtw */
+} /* End of namespace AsteriskSCF */

commit 359e32444a5ebbf27491e9c6e3b0e45457970f08
Author: Brent Eagles <beagles at digium.com>
Date:   Mon Oct 10 00:04:37 2011 -0230

    Sketching out the skeletons of several servants.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8002327..c049ee8 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,9 @@
 astscf_project(FileSessionGateway 3.4)
 
 add_subdirectory(src)
-if(BUILD_TESTING)
-  add_subdirectory(test)
-endif()
+#
+#if(BUILD_TESTING)
+#
+#  add_subdirectory(test)
+#endif()
 astscf_slice_collection_install(PROJECT)
diff --git a/slice/AsteriskSCF/SessionCommunications/FileSession/FileSessionGatewayIf.ice b/slice/AsteriskSCF/FileSessionGateway/FileSession/FileSessionGatewayIf.ice
similarity index 100%
rename from slice/AsteriskSCF/SessionCommunications/FileSession/FileSessionGatewayIf.ice
rename to slice/AsteriskSCF/FileSessionGateway/FileSession/FileSessionGatewayIf.ice
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6d21a6b..777690d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,13 +1,48 @@
 include_directories(${logger_dir}/include)
 include_directories(${astscf-ice-util-cpp_dir}/include)
+
 astscf_component_init(FileSessionGateway)
 astscf_component_add_files(FileSessionGateway Config.h)
 astscf_component_add_files(FileSessionGateway FileSessionGatewayComponent.h)
+astscf_component_add_files(FileSessionGateway
+    ComponentFeature.h
+    Config.h
+    Endpoint.h
+    Endpoint.cpp
+    EndpointLocator.h
+    EndpointLocator.cpp
+    LoggerF.h
+    ReplicationContext.h
+    Replication.h
+    ReplicationListener.h
+    Session.h
+    Session.cpp
+    )
 astscf_component_add_files(FileSessionGateway Component.cpp)
 astscf_component_add_files(FileSessionGateway Configuration.cpp)
 astscf_component_add_files(FileSessionGateway Configuration.h)
+astscf_component_add_slices(FileSessionGateway PROJECT 
+    AsteriskSCF/Configuration/FileSessionGateway/FileSessionGatewayConfigurationIf.ice   
+    AsteriskSCF/Replication/FileSessionGateway/FileSessionReplicationIf.ice)
 
 astscf_component_add_ice_libraries(FileSessionGateway IceStorm)
 astscf_component_add_boost_libraries(FileSessionGateway core)
 astscf_component_add_slice_collection_libraries(FileSessionGateway ASTSCF)
-astscf_component_add_build_icebox(FileSessionGateway)
+astscf_component_build_icebox(FileSessionGateway)
+target_link_libraries(FileSessionGateway astscf-ice-util-cpp logging-client)
+astscf_component_install(FileSessionGateway)
+
+astscf_component_init(FileSessionReplicator)
+astscf_component_add_files(FileSessionReplicator
+    Replicator.h
+    ReplicatorListener.h
+    )
+
+astscf_component_add_ice_libraries(FileSessionReplicator IceStorm)
+astscf_component_add_boost_libraries(FileSessionReplicator core)
+astscf_component_add_slice_collection_libraries(FileSessionReplicator ASTSCF)
+astscf_component_build_icebox(FileSessionReplicator)
+target_link_libraries(FileSessionReplicator astscf-ice-util-cpp logging-client)
+astscf_component_install(FileSessionReplicator)
+
+
diff --git a/src/Component.cpp b/src/Component.cpp
index 592fd73..95b9265 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -51,7 +51,6 @@ namespace FileSessionGtw
 // tiers of objects to grab their own reference to some things instead of
 // using a cached instance.
 //
-
 class FileSessionGatewayComponentImpl : public FileSessionGatewayComponent
 {
 public:
@@ -96,6 +95,6 @@ extern "C"
 {
 ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
 {
-    return new AsteriskSCF::SipSessionManager::Component;
+    return new AsteriskSCF::FileSessionGtw::Component;
 }
 }
diff --git a/src/ComponentFeature.h b/src/ComponentFeature.h
index 49c6c31..1359881 100644
--- a/src/ComponentFeature.h
+++ b/src/ComponentFeature.h
@@ -15,7 +15,12 @@
  */
 
 #pragma once
+
+
+#include "FileSessionGatewayComponent.h"
+
 #include <IceUtil/Shared.h>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
 
 namespace AsteriskSCF
 {
@@ -34,9 +39,15 @@ public:
     virtual ~ComponentFeature() {}
 
     virtual Ice::ObjectPrx activate(const Ice::ObjectAdapterPtr& adapter) = 0;
+    virtual void registerFeature(const FileSessionGatewayComponentPtr& component) = 0;
+
+    /**
+     * make final preparations.
+     */
+    virtual void makeReady(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& locator) = 0;
 };
 
 typedef IceUtil::Handle<ComponentFeature> ComponentFeaturePtr;
 
 } /* End of namespace FileSessionGtw */
-} /* End of
+} /* End of namespace AsteriskSCF */
diff --git a/src/Configuration.cpp b/src/Configuration.cpp
index 6f9b21e..ecec5a3 100644
--- a/src/Configuration.cpp
+++ b/src/Configuration.cpp
@@ -70,11 +70,12 @@ namespace
         {
         }
 
-        void activate(const Ice::ObjectAdapterPtr& adapter)
+        Ice::ObjectPrx activate(const Ice::ObjectAdapterPtr& adapter)
         {
             Ice::Identity id(adapter->getCommunicator()->stringToIdentity(mId));
             mPublicProxy = ConfigurationPrx::uncheckedCast(adapter->add(mServant, id));
             mDirectoryProxy = ConfigurationPrx::uncheckedCast(adapter->createDirectProxy(id));
+            return mDirectoryProxy;
         }
 
         void registerFeature(const FileSessionGatewayComponentPtr& gatewayComponent)
@@ -96,6 +97,13 @@ namespace
             }
         }
 
+        void makeReady()
+        {
+            //
+            // Nothing to do here.
+            //
+        }
+
     private:
         //
         // These variable names are pretty self-explanatory, so we will let them.
diff --git a/src/Endpoint.cpp b/src/Endpoint.cpp
index e4617a4..72516ef 100644
--- a/src/Endpoint.cpp
+++ b/src/Endpoint.cpp
@@ -15,8 +15,12 @@
  */
 
 #include "Endpoint.h"
+#include "Session.h"
+
+#include <AsteriskSCF/logger.h>
 
 #include <IceUtil/UUID.h>
+#include <Ice/Ice.h>
 
 #include <map>
 
@@ -31,13 +35,22 @@ namespace AsteriskSCF
 {
 namespace FileSessionGtw
 {
+
+struct SessionImplActivation
+{
+    SessionImplPtr servant;
+    SessionPrx proxy;
+};
+
+typedef vector<SessionImplActivation> Sessions;
+
 class EndpointServant : public EndpointImpl
 {
 public:
-        struct Update
-        {
-        };
-        typedef boost::shared_ptr<Update> UpdatePtr;
+    struct Update
+    {
+    };
+    typedef boost::shared_ptr<Update> UpdatePtr;
 
     EndpointServant(const Ice::ObjectAdapterPtr& adapterForCreatingSessions,
         const AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx& myAllegedProxy,
@@ -56,17 +69,19 @@ public:
         baseId += ".ascf_file_session." + IceUtil::generateUUID();
         Ice::Identity id = mAdapter->getCommunicator()->stringToIdentity(baseId);
 
-        SessionPrx realProxy = mAdapter->createProxy(id);
+        SessionPrx realProxy = SessionPrx::uncheckedCast(mAdapter->createProxy(id));
         //
         // We don't implement hooks yet, so the public proxy is going to be the same as the 
         // actual.
         //
+        SessionPrx newProxy;
         UpdatePtr update;
         {
             UniqueLock lock(mMutex);
-            SessionImplPtr s = SessionImpl::create(mAdapter, realProxy);
-            SessionPrx newProxy = SessionPrx::uncheckedCast(mAdapter->add(s, id));
-            mSessions[baseId] = s;
+            SessionImplActivation activation;
+            activation.servant = SessionImpl::create(mAdapter, realProxy, baseId, mLogger);
+            activation.proxy = SessionPrx::uncheckedCast(mAdapter->add(activation.servant, id));
+            mSessions.push_back(activation);
             update = createUpdate();
         }
         if (update)
@@ -74,7 +89,6 @@ public:
             pushUpdate(update);
         }
 
-
         //
         // For the time being this assert should be true! When it becomes possible to specify
         // a different public proxy, this assert needs to go.
@@ -85,22 +99,30 @@ public:
 
     SessionSeq getSessions(const Ice::Current&)
     {
+        //
+        // TODO: maybe initially lock as shared and then try to upgrade if we find a servant that needs
+        // reaping.
+        //
         UniqueLock lock(mMutex);
         SessionSeq results;
-        for (SessionImplSeq::iterator iter = mSessions.begin(); iter != mSession.end(); ++iter )
+        for (Sessions::iterator iter = mSessions.begin(); iter != mSessions.end(); ++iter )
         {
-            if ((*iter)->isDestroyed())
+            //
+            // Reap step.
+            //
+            if (iter->servant->isDestroyed())
             {
                 iter = mSessions.erase(iter);
             }
             else
             {
-                results.push_back(prx);
+                results.push_back(iter->proxy);
             }
         }
+        return results;
     }
 
-    void addDefaultSessionListener(const SessionListenerPrx& listener, const Ice::Current&)
+    void addDefaultSessionListener(const SessionListenerPrx& listener, const Ice::Current& current)
     {
         UpdatePtr update;
         {
@@ -110,12 +132,12 @@ public:
             Listeners::iterator iter = mListeners.find(idString);
             if (iter != mListeners.end())
             {
-                logger(Debug) << "Refreshing proxy for default session listener : " << idString;
+                mLogger(Debug) << "Refreshing proxy for default session listener : " << idString;
                 iter->second = listener;
             }
             else
             {
-                logger(Debug) << "Adding new default session listener : " << idString;
+                mLogger(Debug) << "Adding new default session listener : " << idString;
                 mListeners[idString] = listener;
             }
             update = createUpdate();
@@ -136,7 +158,7 @@ public:
             Listeners::iterator iter = mListeners.find(idString);
             if (iter != mListeners.end())
             {
-                logger(Debug) << "Removing default session listener : " << idString;
+                mLogger(Debug) << "Removing default session listener : " << idString;
                 mListeners.erase(iter);
             }
         }
@@ -146,21 +168,50 @@ public:
         }
     }
 
+    void addDefaultSessionCookies(const SessionCookies&, const Ice::Current&)
+    {
+        //
+        // TODO:
+        // We don't have no stinking cookies.. not yet 
+        //
+    }
+
+    void removeDefaultSessionCookies(const SessionCookies&, const Ice::Current&)
+    {
+        //
+        // TODO:
+        // Like I said before.. we don't have cookie support yet.
+        //
+    }
+
+
+    string getId(const Ice::Current&)
+    {
+        return mAdapter->getCommunicator()->identityToString(mPublicProxy->ice_getIdentity());
+    }
+
     void destroySession(const SessionPrx& sessionToDestroy)
     {
         //
         // Called from replication.
         //
         Ice::Identity id = sessionToDestroy->ice_getIdentity();
-        string key = mAdapter->getCommunicator()->identityToString(id);
 
-        size_t eraseCount = 0;
+        bool found = false;
         {
             UniqueLock lock(mMutex);
-            eraseCount = mSessions.erase(key);
+            for (Sessions::iterator iter = mSessions.begin(); iter != mSessions.end(); ++iter)
+            {
+                if (iter->proxy->ice_getIdentity() == id)
+                {
+                    found = true;
+                    iter = mSessions.erase(iter);
+                    break;
+                }
+            }
         }
 
-        if (eraseCount != 0)
+        if (found)
         {
             try
             {
@@ -168,7 +219,7 @@ public:
             }
             catch (const Ice::Exception& ex)
             {
-                mLogger(Debug) << "Exception caught when removing " << key << " from endpoint's object adapter: "
+                mLogger(Debug) << "Exception caught when removing session object from endpoint's object adapter: "
                     << ex.what();
             }
         }
@@ -179,6 +230,7 @@ public:
         return mPublicProxy;
     }
 
+
 private:
     Ice::ObjectAdapterPtr mAdapter;
     AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx mPublicProxy;
@@ -191,7 +243,7 @@ private:
     typedef map<string, SessionListenerPrx> Listeners;
     Listeners mListeners;
 
-    SessionImplSeq mSessions;
+    Sessions mSessions;
 
     UpdatePtr createUpdate()
     {
@@ -208,6 +260,7 @@ EndpointImplPtr EndpointImpl::create(const Ice::ObjectAdapterPtr& adapter,
     const AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx& myProxy,
     const Logger& logger)
 {
+    return new EndpointServant(adapter, myProxy, logger);
 }
 
 } /* End of namespace FileSessionGtw */
diff --git a/src/Endpoint.h b/src/Endpoint.h
index 2f86630..863f5cb 100644
--- a/src/Endpoint.h
+++ b/src/Endpoint.h
@@ -26,10 +26,8 @@ namespace FileSessionGtw
     class EndpointImpl : public AsteriskSCF::SessionCommunications::V1::SessionEndpoint
     {
     public:
-
-        void destroySession(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session) = 0;
-
-        AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx getProxy() = 0;
+        virtual void destroySession(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session) = 0;
+        virtual AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx getProxy() = 0;
 
         /**
          * @param adapter The Ice object adapter that objects created by this endpoint
@@ -38,9 +36,9 @@ namespace FileSessionGtw
          * @param myProxy The proxy that this Endpoint instance should pass off as referencing
          *   itself. Handy to pass this when implementing extension points.
          */
-        IceUtil::Handle<EndpointImpl> create(const Ice::ObjectAdapterPtr& adapter, 
+        static IceUtil::Handle<EndpointImpl> create(const Ice::ObjectAdapterPtr& adapter, 
             const AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx& myProxy,
-            const AsteriskSCF::System::Logging& logger);
+            const AsteriskSCF::System::Logging::Logger& logger);
     };
 
     typedef IceUtil::Handle<EndpointImpl> EndpointImplPtr;
diff --git a/src/EndpointLocator.cpp b/src/EndpointLocator.cpp
index f45bb2e..48cb4a9 100644
--- a/src/EndpointLocator.cpp
+++ b/src/EndpointLocator.cpp
@@ -16,29 +16,183 @@
 
 #include "EndpointLocator.h"
 #include "Endpoint.h"
+#include "Config.h"
 
-#include <AsteriskSCF/Core/Routing/RoutingIf.h>
-
-#include <AsteriskSCF/System/Logging.h>
+#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+#include <AsteriskSCF/Core/Endpoint/EndpointIf.h>
 
+#include <IceUtil/UUID.h>
 #include <IceUtil/Thread.h>
 
+using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::Core::Endpoint::V1;
 using namespace AsteriskSCF::Core::Routing::V1;
+using namespace AsteriskSCF::SessionCommunications::V1;
 using namespace AsteriskSCF::System::Logging;
+using namespace std;
 
 namespace AsteriskSCF
 {
 namespace FileSessionGtw
 {
 
+//
+// TODO: thread pool
+//
+class RegisterEndpointLocator : public IceUtil::Thread
+{
+public:
+    //
+    // We always go back to the locator in case the registration iself has been
+    // updated.
+    //
+    RegisterEndpointLocator(const ServiceLocatorPrx& locator, 
+        const ServiceLocatorParamsPtr& query,
+        const string id,
+        const IceUtil::Time& retryInterval,
+        const EndpointLocatorImplPtr& impl,
+        const Logger& logger) :
+        mLocator(locator),
+        mQuery(query),
+        mId(id),
+        mRetryInterval(retryInterval),
+        mEndpointLocator(impl),
+        mLogger(logger),
+        mDone(false)
+    {
+    }
+
+    void run()
+    {
+        if (!mLocator)
+        {
+            mLogger(Error) << "Cannot continue without a valid locator proxy!";
+            return;
+        }
+        while(!done()) 
+        {
+            Ice::ObjectPrx prx; 
+            try
+            {
+                prx = mLocator->locate(mQuery);
+                assert(prx); // The locator is supposed to throw an exception if it fails. A nil proxy is bad.
+            }
+            catch (const std::exception& ex)
+            {
+                mLogger(Warning) << "Attempt to locate the endpoint locator registry failed with: " << ex.what();
+                continue;
+            }
+            catch (...)
+            {
+                mLogger(Warning) << "Attempt to locate the endpoint locator registry failed with an unknown "
+                    "exception";
+            }
+
+            try
+            {
+                LocatorRegistryPrx registry = LocatorRegistryPrx::checkedCast(prx);
+                registry->addEndpointLocator(mId, mEndpointLocator->getDestinationList(), 
+                    mEndpointLocator->getProxy());
+
+                mLogger(Info) << "Endpoint locator successfully registered with endpoint locator registry";
+                break;
+            }
+            catch (const LocatorAlreadyRegisteredException&)
+            {
+                //
+                // Things that make you go hmmm.
+                //
+                mLogger(Info) << "Attempt to register the endpoint locator with the endpoint locator registry indicated "
+                    " that it was already registered. We are done for now.";
+                return;
+            }
+            catch (const InvalidParamsException&)
+            {
+                //
+                // this is a major fail.. we should not have gotten here.
+                //
+                mLogger(Error) << "Registering the endpoint locator threw an invalid parameter exception. Failing! "
+                    "Service is unusable and should be brought down. Contact your system administrator or check configuration";
+                return;
+            }
+            catch (const Ice::SyscallException& ex)
+            {
+                mLogger(Warning) << "Attempt to register the endpoint locator with the registry failed with: " << ex.what() 
+                    << " retrying ";
+
+                //
+                // Only these exceptions should allow retries. Since we are in
+                // a loop, we need not do anything here.
+                //
+            }
+            catch (const std::exception& ex)
+            {
+                mLogger(Warning) << "Attempt to register the endpoint locator with the registry failed with: " << ex.what();
+
+                //
+                // The only thing we should *ever* want to retry on are syscall
+                // exceptions. Everything else probably indicates that we can
+                // retry until the cows come home, the cats find their pyjamas,
+                // and visually impaired mice learn to stay away from old
+                // bitties toting knives.. it is not going to change anything,
+                // so let's stop pretending!
+                //
+                return;
+            }
+            catch (...)
+            {
+                mLogger(Warning) << "Attempt to register the endpoint locator with the registry failed with an unknown "
+                    "exception";
+                //
+                // Ummm.. no way? 
+                //
+                return;
+            }
+        }
+    }
+
+    void stop()
+    {
+        Monitor::Lock lock(mMonitor);
+        mDone = true;
+        mMonitor.notify();
+    }
+
+    bool done()
+    {
+       Monitor::Lock lock(mMonitor);
+       if (!mDone)
+       {
+           return true;
+       }
+       mMonitor.timedWait(mRetryInterval);
+       return mDone;
+    }
+
+private:
+    ServiceLocatorPrx mLocator;
+    ServiceLocatorParamsPtr mQuery;
+    string mId;
+    IceUtil::Time mRetryInterval;
+    EndpointLocatorImplPtr mEndpointLocator;
+    Logger mLogger;
+    bool mDone;
+    typedef IceUtil::Monitor<IceUtil::Mutex> Monitor;
+    Monitor mMonitor;
+};
+typedef IceUtil::Handle<RegisterEndpointLocator> RegisterEndpointLocatorPtr;
+
+const string EndpointIdPrefix("asteriskscf.file_session_gateway.endpoint.");
+
 class EndpointLocatorServant : public EndpointLocatorImpl
 {
 public:
     EndpointLocatorServant(const Ice::ObjectAdapterPtr& adapter,
         const Logger& logger) :
         mEndpointAdapter(adapter),
-        mLogger(logger)
+        mLogger(logger),
+        mDestroyed(false)
     {
     }
 
@@ -48,12 +202,19 @@ public:
         try
         {
             SharedLock lock(mLock);
+            if (isDestroyed())
+            {
+                throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+            }
+
             DestinationIndex::const_iterator iter = mIndex.find(destination);
             if (iter == mIndex.end())
             {
                 throw DestinationNotFoundException();
             }
-            cb->ice_response(mEndpoints[iter->second]->getProxy());
+            EndpointSeq result;
+            result.push_back(mEndpoints[iter->second]->getProxy());
+            cb->ice_response(result);
         }
         catch (const Ice::Exception& ex)
         {
@@ -65,11 +226,10 @@ public:
         }
     }
 
-    const string EndpointIdPrefix("asteriskscf.file_session_gateway.endpoint.");
-    
     void addEndpoints(const EndpointConfigurationSeq& endpointConfig)
     {
         UniqueLock lock(mLock);
+
         for (EndpointConfigurationSeq::const_iterator config = endpointConfig.begin();
             config != endpointConfig.end(); ++config)
         {
@@ -86,10 +246,10 @@ public:
                 Ice::Identity id = mEndpointAdapter->getCommunicator()->stringToIdentity(idString);
                 SessionEndpointPrx prx = 
                     SessionEndpointPrx::uncheckedCast(mEndpointAdapter->createProxy(id));
-                EndpointImplPtr newEndpoint = EndpointImpl::create(mEndpointAdapter, prx, logger);
+                EndpointImplPtr newEndpoint = EndpointImpl::create(mEndpointAdapter, prx, mLogger);
                 mEndpointAdapter->add(newEndpoint, id);
-                mEndpoints[id] =  newEndpoint;
-                mIndex[(*config)->destination] = id;
+                mEndpoints[idString] =  newEndpoint;
+                mIndex[(*config)->destination] = idString;
 
                 //
                 // Now.. at this point we don't really have anything to replicate. Anything
@@ -99,66 +259,181 @@ public:
                 //
             }
         }
-        
-        void removeEndpoints(const EndpointConfigurationSeq& endpoints)
+    }
+
+    void removeEndpoints(const EndpointConfigurationSeq& endpoints)
+    {
+        UniqueLock lock(mLock);
+
+        for (EndpointConfigurationSeq::const_iterator iter = endpoints.begin();
+            iter != endpoints.end(); ++iter)
         {
-            UniqueLock lock(mLock);
-            for (EndpointConfigurationSeq::const_iterator iter = endpoints.begin();
-                iter != endpoints.end(); ++iter)
+            EndpointMap::iterator endpointEntry = mEndpoints.find((*iter)->id);
+            if (endpointEntry != mEndpoints.end())
             {
-                EndpointMap::iterator endpointEntry = mEndpoints.find((*iter)->id);
-                if (endpointEntry != mEndpoints.end())
+                //
+                // Undo index entry.. but I'm not at all sure we can rely
+                // on the destination being correct, better to find it by
+                // way of checking the values.
+                //
+                for (DestinationIndex::iterator indexEntry = mIndex.begin();
+                    indexEntry != mIndex.end() ; ++indexEntry)
                 {
-                    //
-                    // Undo index entry.. but I'm not at all sure we can rely
-                    // on the destination being correct, better to find it by
-                    // way of checking the values.
-                    //
-                    for (DestinationIndex::iterator indexEntry = mIndex.begin();
-                        indexEntry != mIndex.end() ; ++indexEntry)
+                    if (indexEntry->second == (*iter)->id)
                     {
-                        if (indexEntry->second == (*iter)->id)
-                        {
-                            string destination = indexEntry->first;
-                            //
-                            // TODO: it might be nice to put a little
-                            // defensive check in here.
-                            //
-                            mIndex.erase(destination);
-                            break;
-                        }
-                    }
-                    //
-                    // Now let's remove the servant from the object adapter, 
-                    // this has the nice effect of causing any calls that haven't
-                    // already been dispatched on the servant to fail with
-                    // ONE's. 
-                    //
-                    string idString = EndpointIdPrefix + (*iter)->id;
-                    Ice::Identity id = 
-                        mEndpointAdapter->getCommunicator()->stringToIdentity(idString);
-                    try
-                    {
-                        mEndpointAdapter->remove(id);
-                    }
-                    catch (const Ice::Exception& ex)
-                    {
-                        mLogger(Error) << "Unexpected exception when deactivating " << id <<
-                            ": " << ex.what();
-                    }
-                    catch (...)
-                    {
-                        mLogger(Error) << "Unknown exception when deactivating " << id;
-                    }
+                        string destination = indexEntry->first;
+                        //
+                        // TODO: it might be nice to put a little
+                        // defensive check in here.
+                        //
+                        mIndex.erase(destination);
 
-                    //
-                    // After this... the only reference counts left to that endpoint
-                    // should be for any pending upcalls.
-                    //
-                    mEndpoints.erase(endpointEntry);
+                        //
+                        // Keep going in case we have multiple destinations
+                        // mapping to this Endpoint (i.e. alias). I know
+                        // this might be weird but I cannot think of
+                        // a good reason to disallow it for file sessions.
+                        //
+                    }
+                }
+                //
+                // Now let's remove the servant from the object adapter, 
+                // this has the nice effect of causing any calls that haven't
+                // already been dispatched on the servant to fail with
+                // ONE's. 
+                //
+                string idString = EndpointIdPrefix + (*iter)->id;
+                Ice::Identity id = 
+                    mEndpointAdapter->getCommunicator()->stringToIdentity(idString);
+                try
+                {
+                    mEndpointAdapter->remove(id);
                 }
+                catch (const Ice::Exception& ex)
+                {
+                    mLogger(Error) << "Unexpected exception when deactivating " << idString << ": " << ex.what();
+                }
+                catch (...)
+                {
+                    mLogger(Error) << "Unknown exception when deactivating " << idString;
+                }
+
+                //
+                // After this... the only reference counts left to that endpoint
+                // should be for any pending upcalls.
+                //
+                mEndpoints.erase(endpointEntry);
+            }
+        }
+    }
+
+    RegExSeq getDestinationList() 
+    {
+        SharedLock lock(mLock);
+        //
+        // Wwooo.. configure this!
+        //
+        return RegExSeq();
+    }
+
+    EndpointLocatorPrx getProxy()
+    {
+        SharedLock lock(mLock);
+        return mProxy;
+    }
+
+    void setId(const string& id)
+    {
+        UniqueLock lock(mLock);
+        mId = id;
+    }
+
+    string getId()
+    {
+        SharedLock lock(mLock);
+        return mId;
+    }
+
+    void setProxy(const EndpointLocatorPrx& prx)
+    {
+        UniqueLock lock(mLock);
+        mProxy = prx;
+    }
+
+    void destroy()
+    {
+        {
+            UniqueLock lock(mLock);
+            if (isDestroyed())
+            {
+                return;
+            }
+            mDestroyed = true;
+        }
+
+        ServiceLocatorParamsPtr query = new ServiceLocatorParams;
+        query->category = RoutingServiceLocatorRegistryDiscoveryCategory;
+
+        //
+        // TODO: We want the service name to be configurable! 
+        //
+
+        //
+        // For destruction, we are only making a best effort to remove our registration 
+        // from the endpoint locator registry.
+        //
+        try
+        {
+
+            //
+            // We don't actually have our locator proxy anymore at this point.
+            // However, by convention, if we got to this point and we actually
+            // need to remove ourselves from the endpoint locator registry, the
+            // following property lookup on our object adapter should work. Of
+            // course, there is a chance that something valid will happen later
+            // on that will make this code *not* work. We'll log for that
+            // eventuality.
+            // 
+            // Note: we could always *stash* the locator registry proxy we obtained
+            // for the registration in the first place however, this seems counter
+            // to the whole spirit of things.
+            //
+            ServiceLocatorPrx locator = 
+                ServiceLocatorPrx::checkedCast(
+                    mEndpointAdapter->getCommunicator()->propertyToProxy("LocatorService.Proxy")
+                );
+
+            if (locator)
+            {
+                //
+                // The locator is supposed to throw an exception if it fails. A nil proxy is bad.
+                //
+                Ice::ObjectPrx prx = locator->locate(query);
+                assert(prx); 
+
+                //
+                // We will use a checked cast because it will give us some more information if the 
+                // endpoint locator registry is inaccessible.
+                //
+                LocatorRegistryPrx registry = LocatorRegistryPrx::checkedCast(prx);
+                registry->addEndpointLocator(mId, RegExSeq(), mProxy);
+            }
+            else
+            {
+                mLogger(Error) << "EndpointLocator is being destroyed, but cannot obtain reference to " 
+                    "service locator to get the relevant router object";
             }
         }
+        catch (const std::exception& ex)
+        {
+            mLogger(Error) << "Unexpected exception occurred while trying to remove registration from endpoint "
+                "locator registry : " << ex.what();
+        }
+        catch (...)
+        {
+            mLogger(Error) << "Unknown exception occurred while trying to remove registration from endpoint "
+                "locato registry";
+        }
     }
 
 private:
@@ -175,34 +450,151 @@ private:
 
     typedef map<string, EndpointImplPtr> EndpointMap;
     EndpointMap mEndpoints;
+
+    string mId;
+
+    EndpointLocatorPrx mProxy;
+
+    bool mDestroyed;
+
+    bool isDestroyed()
+    {
+        return mDestroyed;
+    }
 };
-typedef IceUtil::Handle<EndpointLocatorImpl> EndpointLocatorImplPtr;
+typedef IceUtil::Handle<EndpointLocatorServant> EndpointLocatorServantPtr;
 
 class EndpointLocatorFeature : public ComponentFeature
 {
 public:
 
-    EndpointLocatorFeature(const  EndpointLocatorImplPtr& el) :
-        mEndpointLocator(el)
+    EndpointLocatorFeature(const EndpointLocatorServantPtr& el, const Logger& logger) :
+        mEndpointLocator(el),
+        mId(std::string("ascf.endpointlocator.") + IceUtil::generateUUID()),
+        mLogger(logger)
     {
     }
 
     Ice::ObjectPrx activate(const Ice::ObjectAdapterPtr& adapter)
     {
-        return adapter->addWithUUID(mEndpointLocator);
+        Ice::Identity id(adapter->getCommunicator()->stringToIdentity(mId));
+        mProxy = EndpointLocatorPrx::uncheckedCast(adapter->add(mEndpointLocator, id));
+        mRetryInterval = IceUtil::Time::milliSeconds(
+            adapter->getCommunicator()->getProperties()->getPropertyAsIntWithDefault(
+                "FileSessionGateway.SetupRetryInterval", 5000)
+            );
+        mEndpointLocator->setProxy(mProxy);
+        return mProxy;
     }
 
-    Ice::ObjectPrx activateWithId(const Ice::ObjectAdapterPtr& adapter,
-        const std::string& id) 
+    void registerFeature(const FileSessionGatewayComponentPtr&)
     {
-        return adapter->add(mEndpointLocator, adapter->getCommunicator()->stringToIdentity(id));
+        //
+        // Hrmm.. I don't think we register to the locator, but we do register
+        // the endpoint locator with the router's thing. This might not be the
+        // place to do it.
+        //
+    }
+
+    void makeReady(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& locator)
+    {
+        assert(mProxy);
+
+        //
+        // Register with router's endpoint locator registry.
+        //
+
+        //
+        // Find me the router's locator registry.
+        //
+        ServiceLocatorParamsPtr query = new ServiceLocatorParams;
+        query->category = RoutingServiceLocatorRegistryDiscoveryCategory;
+
+        //
+        // TODO: we want the service name to be configurable!
+        //
+        try
+        {
+            Ice::ObjectPrx prx = locator->locate(query);
+            assert(prx); // The locator is supposed to throw an exception if it fails. A nil proxy is bad.
+
+            //
+            // We will use a checked cast because it will give us some more information if the 
+            // endpoint locator registry is inaccessible.
+            //
+            LocatorRegistryPrx registry = LocatorRegistryPrx::checkedCast(prx);
+            registry->addEndpointLocator(mId, RegExSeq(), mEndpointLocator->getProxy());
+
+            return;  // Early break on success.
+        }
+        catch (const LocatorAlreadyRegisteredException&)
+        {
+            //
+            // Things that make you go hmmm.
+            //
+            mLogger(Info) << "Attempt to register the endpoint locator with the endpoint locator registry indicated "
+                " that it was already registered. We are done for now.";
+            return;
+        }
+        catch (const InvalidParamsException&)
+        {
+            //
+            // this is a major fail.. we should not have gotten here.
+            //
+            mLogger(Error) << "Registering the endpoint locator threw an invalid parameter exception. Failing! "
+                "Service is unusable and should be brought down. Contact your system administrator or check configuration";
+            throw;
+        }
+        catch (const std::exception& ex)
+        {
+            mLogger(Warning) << "Initial attempt to locate the endpoint locator registry failed with: " << ex.what();
+        }
+        catch (...)
+        {
+            mLogger(Warning) << "Initial attempt to locate the endpoint locator registry failed with an unknown "
+                "exception";
+            throw;
+        }
+        mLogger(Info) << "As we failed to get the endpoint locator registry and register ourselves, we are going "
+            "to go into retry mode";
+            
+        //
+        // TODO: make retry configurable.
+        //
+        mRegistrationThread = new RegisterEndpointLocator(locator, query, mId, mRetryInterval, 
+            mEndpointLocator, mLogger);
+        mRegistrationThread->start();
+
+        //
+        // TODO: So where do we kill the thread if things have gone wrong and we want to give up?
+        //
     }
+
+protected:
+
+    //
+    // Stuff we are given.
+    //
+    EndpointLocatorServantPtr mEndpointLocator;
+    string mId;
+    Logger mLogger;
+
+    //
+    // Our own stuff.
+    //
+    RegisterEndpointLocatorPtr mRegistrationThread;
+    IceUtil::Time mRetryInterval;     // Oh, and btw... we will probably want to configure this. <= TODO
+
+    //
+    // Stuff we need to find. 
+    //
+    EndpointLocatorPrx mProxy;
 };
 
-ComponentFeaturePtr createEndpointLocator(const Ice::ObjectAdapterPtr& adapter,
-    const Logger& logger)
+ComponentFeaturePtr createEndpointLocatorFeature(const Ice::ObjectAdapterPtr& adapter)
 {
-    return new EndpointLocatorFeature(new EndpointLocatorImpl(adapter, logger)); 
+    Logger logger = getLoggerFactory().getLogger(LoggerId + ".Gateway"); 
+    return new EndpointLocatorFeature(new EndpointLocatorServant(adapter, logger), logger);
 }
 
 } /* End of namespace FileSessionGtw */
diff --git a/src/EndpointLocator.h b/src/EndpointLocator.h
index d7bf96b..f37a975 100644
--- a/src/EndpointLocator.h
+++ b/src/EndpointLocator.h
@@ -21,6 +21,7 @@
 
 #include <boost/shared_ptr.hpp>
 #include <vector>
+#include <AsteriskSCF/Core/Routing/RoutingIf.h>
 
 namespace AsteriskSCF
 {
@@ -46,11 +47,33 @@ public:
 
     virtual void removeEndpoints(const EndpointConfigurationSeq&) = 0;
 
-    static ComponentFeaturePtr createEndpointLocator(
-        const Ice::ObjectAdapterPtr& endpointAdapter,
-        const AsteriskSCF::System::Logging::Logger& logger);
+    virtual AsteriskSCF::Core::Routing::V1::RegExSeq getDestinationList() = 0;
+
+    virtual AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx getProxy() = 0; 
+
+    //
+    // The EndpointLocator servant does not know it's id until some time after
+    // it has been instantiated and the related Ice object will not truly be
+    // incarnated on the host object adapter until some time after. However,
+    // there are operations that require that the endpoint locator "know"
+    // itself so we provide this method.
+    //
+    virtual void setProxy(const AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx& prx) = 0;
 };
 
+typedef IceUtil::Handle<EndpointLocatorImpl> EndpointLocatorImplPtr;
+
+/**
+ * 
+ * @param endpointObjectAdapter Defines the object adapter that must be used
+ * when creating new endpoint objects. We need to specify it here instead of
+ * relying on "activate()" to pass it in because the object adapter that the
+ * endpoint locator is on is not *necessarily* the one that will be used for
+ * the endpoints. e.g. we may want to secure the endpoint locator's adapter.
+ * 
+ */
+ComponentFeaturePtr createEndpointLocatorFeature(const Ice::ObjectAdapterPtr& endpointObjectAdapter);
+
 
 } /* End of namespace FileSessionGtw */
 } /* End of namespace AsteriskSCF */
diff --git a/src/ReplicationContext.h b/src/ReplicationContext.h
index 77a671b..39f67bb 100644
--- a/src/ReplicationContext.h
+++ b/src/ReplicationContext.h
@@ -15,8 +15,7 @@
  */
 #pragma once
 
-#include <AsteriskSCF/Replication/ReplicationContext.h>
-#include "FileSessionStateReplicationIf.h"
+#include <AsteriskSCF/Replication/FileSessionGateway/FileSessionReplicationIf.h>
... 1841 lines suppressed ...


-- 
asterisk-scf/integration/file_session_gateway.git



More information about the asterisk-scf-commits mailing list