[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "retry_deux" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Mar 23 17:28:36 CDT 2012


branch "retry_deux" has been updated
       via  2dd1870f965830cf4a7a69bdc0b1d45d611ddb8f (commit)
      from  bf499c004ddc0a11774ac51fc446a220d62d106f (commit)

Summary of changes:
 .../SIPSessionManager/SIPStateReplicationIf.ice    |    1 +
 src/Component.cpp                                  |   25 +-
 src/PJSIPRegistrarModule.cpp                       |    9 +-
 src/PJSIPRegistrarModule.h                         |    2 +
 src/PJSIPSessionModule.cpp                         |   26 +-
 src/PJSIPSessionModule.h                           |   14 +-
 src/PJSIPSessionModuleConstruction.cpp             |   15 +-
 src/SIPClientRegistration.cpp                      |   10 +-
 src/SIPConfiguration.cpp                           |   17 +-
 src/SIPEndpoint.cpp                                |   64 ++++-
 src/SIPEndpoint.h                                  |   18 +-
 src/SIPRegistrarListener.cpp                       |   11 +-
 src/SIPRegistrarListener.h                         |    6 +-
 src/SIPSession.cpp                                 |  303 +++++++++++---------
 src/SIPSession.h                                   |   58 +++--
 src/SIPStateReplicatorListener.cpp                 |    8 +-
 src/SIPTelephonyEventSink.cpp                      |   10 +-
 src/SIPTelephonyEventSink.h                        |    7 +-
 src/SIPTelephonyEventSource.cpp                    |    8 +-
 src/SIPTelephonyEventSource.h                      |    6 +-
 src/SIPTransfer.cpp                                |   14 +-
 src/SIPTransfer.h                                  |    8 +-
 22 files changed, 407 insertions(+), 233 deletions(-)


- Log -----------------------------------------------------------------
commit 2dd1870f965830cf4a7a69bdc0b1d45d611ddb8f
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Fri Mar 23 17:27:52 2012 -0500

    First pass on retry refurbishment. Incomplete.

diff --git a/slice/AsteriskSCF/Replication/SIPSessionManager/SIPStateReplicationIf.ice b/slice/AsteriskSCF/Replication/SIPSessionManager/SIPStateReplicationIf.ice
index 5b29ff3..d78f5a1 100644
--- a/slice/AsteriskSCF/Replication/SIPSessionManager/SIPStateReplicationIf.ice
+++ b/slice/AsteriskSCF/Replication/SIPSessionManager/SIPStateReplicationIf.ice
@@ -151,6 +151,7 @@ module V1
       Ice::Identity sessionObjectId;
       Ice::Identity mediaSessionObjectId;
       Ice::Identity sessionControllerObjectId;
+      AsteriskSCF::System::V1::OperationContext originalContext;
       AsteriskSCF::Media::V1::StreamSourceSeq sources;
       AsteriskSCF::Media::V1::StreamSinkSeq sinks;
       AsteriskSCF::Media::V1::StreamInformationDict streams;
diff --git a/src/Component.cpp b/src/Component.cpp
index 904fd84..e261fcf 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -28,6 +28,7 @@
 #include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
 #include <AsteriskSCF/Discovery/SmartProxy.h>
 #include <AsteriskSCF/System/Component/ConfigurationIf.h>
+#include <AsteriskSCF/System/OperationsIf.h>
 
 #include <AsteriskSCF/Logger/IceLogger.h>
 #include <AsteriskSCF/Logger.h>
@@ -61,6 +62,7 @@ using namespace AsteriskSCF::SIP::Registration::V1;
 using namespace AsteriskSCF::System::Configuration::V1;
 using namespace AsteriskSCF::Replication;
 using namespace AsteriskSCF::Discovery;
+using namespace AsteriskSCF::System::V1;
 
 
 namespace
@@ -82,20 +84,21 @@ public:
     }
 
     void addAuthHook(
-            const AuthHookPrx &hook,
-            int priority,
-            const RequestTypeSeq &requestTypes,
-            const Ice::Current&)
+        const OperationContextPtr& operationContext,
+        const AuthHookPrx &hook,
+        int priority,
+        const RequestTypeSeq &requestTypes,
+        const Ice::Current&)
     {
         mPJSIPManager->addAuthHook(hook, priority, requestTypes);
     }
 
-    void removeAuthHook(const AuthHookPrx &hook, const Ice::Current&)
+    void removeAuthHook(const OperationContextPtr& operationContext, const AuthHookPrx &hook, const Ice::Current&)
     {
         mPJSIPManager->removeAuthHook(hook);
     }
 
-    void clearAuthHooks(const Ice::Current&)
+    void clearAuthHooks(const OperationContextPtr& operationContext, const Ice::Current&)
     {
         mPJSIPManager->clearAuthHooks();
     }
@@ -284,9 +287,9 @@ void Component::locateStateReplicator()
 
         // Since we're not in standalone mode, we'll get our configuration updates routed via the
         // replicator service.
-	    ConfigurationReplicatorPrx configurationReplicator = ConfigurationReplicatorPrx::checkedCast(
-            sipReplicationContext->getReplicator().initialize(), ReplicatorFacet);
-	    configurationReplicator->registerConfigurationService(mConfigurationServiceProxy);
+        ConfigurationReplicatorPrx configurationReplicator = ConfigurationReplicatorPrx::checkedCast(
+        sipReplicationContext->getReplicator().initialize(), ReplicatorFacet);
+        configurationReplicator->registerConfigurationService(AsteriskSCF::Operations::createContext(), mConfigurationServiceProxy);
     }
     catch (...)
     {
@@ -451,7 +454,7 @@ void Component::registerWithRoutingService()
 
         EndpointLocatorPrx locator = EndpointLocatorPrx::uncheckedCast(
             getServiceAdapter()->createDirectProxy(getCommunicator()->stringToIdentity(EndpointLocatorObjectId)));
-        mRoutingServiceLocatorRegistry->addEndpointLocator(mRoutingId, destinations, locator);
+        mRoutingServiceLocatorRegistry->addEndpointLocator(AsteriskSCF::Operations::createContext(), mRoutingId, destinations, locator);
     }
     catch(const std::exception& e)
     {
@@ -466,7 +469,7 @@ void Component::unregisterFromRoutingService()
 {
     try
     {
-        mRoutingServiceLocatorRegistry->removeEndpointLocator(mRoutingId);
+        mRoutingServiceLocatorRegistry->removeEndpointLocator(AsteriskSCF::Operations::createContext(), mRoutingId);
     }
     catch(const std::exception& e)
     {
diff --git a/src/PJSIPRegistrarModule.cpp b/src/PJSIPRegistrarModule.cpp
index 590c584..a4506f7 100644
--- a/src/PJSIPRegistrarModule.cpp
+++ b/src/PJSIPRegistrarModule.cpp
@@ -31,6 +31,7 @@ using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::System::WorkQueue::V1;
 using namespace AsteriskSCF::System::Hook::V1;
 using namespace AsteriskSCF::SIP::ExtensionPoint::V1;
+using namespace AsteriskSCF::System::V1;
 
 namespace
 {
@@ -73,7 +74,7 @@ public:
                 iter != listeners.end(); ++iter)
         {
             lg(Debug) << "Alerting listener " << (*iter)->ice_getIdentity().name << " about removal of binding due to expiration.";
-            (*iter)->contactsRemoved(removedBindingUpdateSeq);
+            (*iter)->contactsRemoved(Operations::createContext(), removedBindingUpdateSeq);
         }
 
         BindingWrapperSeq emptySeq;
@@ -196,6 +197,7 @@ private:
 
 void RegistrarI::addListener_async(
         const AMD_Registrar_addListenerPtr& cb,
+        const OperationContextPtr& operationContext,
         const RegistrarListenerPrx& listener,
         const Ice::Current&)
 {
@@ -228,6 +230,7 @@ private:
 
 void RegistrarI::removeListener_async(
         const AMD_Registrar_removeListenerPtr& cb,
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
         const RegistrarListenerPrx& listener,
         const Ice::Current&)
 {
@@ -516,8 +519,8 @@ public:
         {
             //Listeners are only concerned with new and removed bindings. There's no need to tell them of existing ones.
             lg(Debug) << "Alerting listener " << (*iter)->ice_getIdentity().name << " about changes to bindings";
-            (*iter)->contactsAdded(newBindingUpdateSeq);
-            (*iter)->contactsRemoved(removedBindingUpdateSeq);
+            (*iter)->contactsAdded(Operations::createContext(), newBindingUpdateSeq);
+            (*iter)->contactsRemoved(Operations::createContext(), removedBindingUpdateSeq);
         }
     }
 private:
diff --git a/src/PJSIPRegistrarModule.h b/src/PJSIPRegistrarModule.h
index a1094a1..bfa9033 100644
--- a/src/PJSIPRegistrarModule.h
+++ b/src/PJSIPRegistrarModule.h
@@ -44,11 +44,13 @@ public:
 
     void addListener_async(
             const AsteriskSCF::SIP::Registration::V1::AMD_Registrar_addListenerPtr& cb,
+            const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
             const AsteriskSCF::SIP::Registration::V1::RegistrarListenerPrx& listener,
             const Ice::Current&);
 
     void removeListener_async(
             const AsteriskSCF::SIP::Registration::V1::AMD_Registrar_removeListenerPtr& cb,
+            const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
             const AsteriskSCF::SIP::Registration::V1::RegistrarListenerPrx& listener,
             const Ice::Current&);
 
diff --git a/src/PJSIPSessionModule.cpp b/src/PJSIPSessionModule.cpp
index d74e359..e80a970 100644
--- a/src/PJSIPSessionModule.cpp
+++ b/src/PJSIPSessionModule.cpp
@@ -41,7 +41,7 @@
 #include <AsteriskSCF/WorkQueue/WorkQueue.h>
 #include <AsteriskSCF/WorkQueue/SuspendableWorkQueue.h>
 #include <AsteriskSCF/Helpers/Retry.h>
-#include <AsteriskSCF/Helpers/OperationContext.h>
+#include <AsteriskSCF/Operations/OperationContext.h>
 
 using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::SIP::ExtensionPoint::V1;
@@ -112,6 +112,7 @@ void PJSIPSessionModInfo::updateSessionState(pjsip_inv_session *inv_session)
         mSessionState->sessionObjectId = mSession->getSessionProxy()->ice_getIdentity();
         mSessionState->mediaSessionObjectId = mSession->getMediaSessionProxy()->ice_getIdentity();
 	    mSessionState->sessionControllerObjectId = mSession->getOurSessionControllerProxy()->ice_getIdentity();
+        mSessionState->originalContext = mSession->getOperationContext();
         mSessionState->sources = mSession->getMediaSources();
         mSessionState->sinks = mSession->getMediaSinks();
         mSessionState->rtpMediaSessions = mSession->getRTPMediaSessions();
@@ -194,17 +195,22 @@ SessionWorkPtr PJSIPSessionModInfo::getSessionWork()
     return mSessionWork;
 }
 
-void SIPSessionCreationExtensionPoint::addSessionCreationHook(const SessionCreationHookPrx& hook, const Ice::Current&)
+void SIPSessionCreationExtensionPoint::addSessionCreationHook(
+    const OperationContextPtr& operationContext, 
+    const SessionCreationHookPrx& hook, const Ice::Current&)
 {
     boost::unique_lock<boost::shared_mutex> lock(mLock);
     mHooks.push_back(hook);
 }
-void SIPSessionCreationExtensionPoint::removeSessionCreationHook(const SessionCreationHookPrx& hook, const Ice::Current&)
+void SIPSessionCreationExtensionPoint::removeSessionCreationHook(
+    const OperationContextPtr& operationContext, 
+    const SessionCreationHookPrx& hook, const Ice::Current&)
 {
     boost::unique_lock<boost::shared_mutex> lock(mLock);
     mHooks.erase(std::find(mHooks.begin(), mHooks.end(), hook));
 }
-void SIPSessionCreationExtensionPoint::clearSessionCreationHooks(const Ice::Current&)
+void SIPSessionCreationExtensionPoint::clearSessionCreationHooks(
+    const OperationContextPtr& operationContext, const Ice::Current&)
 {
     boost::unique_lock<boost::shared_mutex> lock(mLock);
     mHooks.clear();
@@ -390,7 +396,7 @@ public:
         mCallerID(callerID),
         mRedirections(redirections),
         mRetryPolicy(5, 500),
-        mOperationContext(AsteriskSCF::createContext()) { }
+        mOperationContext(AsteriskSCF::Operations::createContext()) { }
 
 protected:
     SuspendableWorkResult initial(const SuspendableWorkListenerPtr&)
@@ -483,7 +489,7 @@ protected:
                 mSession->setSelfAsCaller();
 
                 // Setup an operation context to support retries. 
-                mOperationContext = AsteriskSCF::createContext();
+                mOperationContext = AsteriskSCF::Operations::createContext();
 
                 SIPAMICallbackPtr amiCallback = new SIPAMICallback(listener, mSession, this, false, true);
                 SIPAMICallbackCookiePtr cookie = new SIPAMICallbackCookie(amiCallback);
@@ -1444,7 +1450,7 @@ public:
 protected:
     SuspendableWorkResult initial(const SuspendableWorkListenerPtr&)
     {
-        OperationContextPtr context = AsteriskSCF::createContext();
+        OperationContextPtr context = AsteriskSCF::Operations::createContext();
         lg(Debug) << "Executing HandleInviteResponseOperation" << std::endl;
         //Treat all 1XX messages we don't recognize the same as a 180
         if (mRespCode > 100 && mRespCode < 200 && mRespCode != 183)
@@ -1766,7 +1772,7 @@ protected:
                 lg(Debug) << "Relating stopped state to " << listeners.size() << " listeners";
                 AsteriskSCF::SessionCommunications::V1::StoppedIndicationPtr stopped(new AsteriskSCF::SessionCommunications::V1::StoppedIndication());
                 stopped->response = response;
-                OperationContextPtr context = AsteriskSCF::createContext();
+                OperationContextPtr context = AsteriskSCF::Operations::createContext();
                 for (std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>::iterator listener =
                          listeners.begin();
                      listener != listeners.end();
@@ -2041,7 +2047,7 @@ public:
           mRouter(router), 
           mSession(session),
           mRetryPolicy(5, 500),
-          mOperationContext(AsteriskSCF::createContext()) { }
+          mOperationContext(AsteriskSCF::Operations::createContext()) { }
 
 protected:
     SuspendableWorkResult initial(const SuspendableWorkListenerPtr&)
@@ -2163,7 +2169,7 @@ public:
       : mInv(inv), 
         mModuleId(moduleId), 
         mResponse(tdata),
-        mOperationContext(AsteriskSCF::createContext()) { }
+        mOperationContext(AsteriskSCF::Operations::createContext()) { }
 
 protected:
     SuspendableWorkResult initial(const SuspendableWorkListenerPtr&)
diff --git a/src/PJSIPSessionModule.h b/src/PJSIPSessionModule.h
index a6d2189..beedfb5 100644
--- a/src/PJSIPSessionModule.h
+++ b/src/PJSIPSessionModule.h
@@ -84,9 +84,17 @@ typedef IceUtil::Handle<PJSIPSessionModuleThreadPoolListener> PJSIPSessionModule
 class SIPSessionCreationExtensionPoint : public AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationExtensionPoint
 {
 public:
-    void addSessionCreationHook(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& hook, const Ice::Current&);
-    void removeSessionCreationHook(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& hook, const Ice::Current&);
-    void clearSessionCreationHooks(const Ice::Current&);
+    void addSessionCreationHook(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& hook, 
+        const Ice::Current&);
+    void removeSessionCreationHook(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& hook, 
+        const Ice::Current&);
+    void clearSessionCreationHooks(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const Ice::Current&);
     AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookSeq getHooks();
 
 private:
diff --git a/src/PJSIPSessionModuleConstruction.cpp b/src/PJSIPSessionModuleConstruction.cpp
index f57db1e..c7a6886 100644
--- a/src/PJSIPSessionModuleConstruction.cpp
+++ b/src/PJSIPSessionModuleConstruction.cpp
@@ -17,7 +17,7 @@
 #include <AsteriskSCF/Logger.h>
 #include <AsteriskSCF/WorkQueue/WorkQueue.h>
 #include <AsteriskSCF/ThreadPool/ThreadPool.h>
-#include <AsteriskSCF/Helpers/OperationContext.h>
+#include <AsteriskSCF/Operations/OperationContext.h>
 
 #include "PJSIPSessionModule.h"
 #include "AuthManager.h"
@@ -148,9 +148,16 @@ PJSIPSessionModule::PJSIPSessionModule(pjsip_endpoint *endpt,
     mSessionCreationExtensionPointPrx =
         SessionCreationExtensionPointPrx::uncheckedCast(mAdapter->addWithUUID(mSessionCreationExtensionPoint));
 
-    mSessionCreationExtensionPointService = serviceLocatorManagement->addService(mSessionCreationExtensionPointPrx, SessionCreationExtensionPointId);
+    mSessionCreationExtensionPointService = serviceLocatorManagement->addService(
+        Operations::createContext(),
+        mSessionCreationExtensionPointPrx, 
+        SessionCreationExtensionPointId);
+
     // TBD... how to access the Component's service and instance ids. 
-    mSessionCreationExtensionPointService->addLocatorParams(AsteriskSCF::createContext(), new ServiceLocatorParams(SessionCreationHookLocatorCategory, "default", ""), "");
+    mSessionCreationExtensionPointService->addLocatorParams(
+        AsteriskSCF::Operations::createContext(), 
+        new ServiceLocatorParams(SessionCreationHookLocatorCategory, "default", ""), 
+        "");
 
     mPoolQueue = new AsteriskSCF::WorkQueue::WorkQueue();
     mPoolListener = new PJSIPSessionModuleThreadPoolListener(); 
@@ -195,7 +202,7 @@ PJSIPSessionModule::~PJSIPSessionModule()
     try
     {
         mPoolQueue->shutdown();
-        mSessionCreationExtensionPointService->unregister();
+        mSessionCreationExtensionPointService->unregister(Operations::createContext());
         mAdapter->remove(mSessionCreationExtensionPointPrx->ice_getIdentity());
     }
     catch (const AsteriskSCF::System::WorkQueue::V1::ShuttingDown&)
diff --git a/src/SIPClientRegistration.cpp b/src/SIPClientRegistration.cpp
index 91cc147..10a86e7 100644
--- a/src/SIPClientRegistration.cpp
+++ b/src/SIPClientRegistration.cpp
@@ -16,6 +16,7 @@
 
 #include "SIPClientRegistration.h"
 #include "PJUtil.h"
+#include <AsteriskSCF/Operations/OperationContext.h>
 #include <boost/numeric/conversion/cast.hpp>
 
 using namespace AsteriskSCF::System::Logging;
@@ -29,6 +30,7 @@ using namespace AsteriskSCF::SIPSessionManager;
 using namespace AsteriskSCF::System::Hook::V1;
 using namespace AsteriskSCF::Configuration::SIPSessionManager::V1;
 using namespace AsteriskSCF::System::Component::V1;
+using namespace AsteriskSCF::System::V1;
 
 void regCallback(struct pjsip_regc_cbparam *param)
 {
@@ -109,12 +111,12 @@ public:
     ClientRegistrationReplicaListener(const SIPRegistrationClientPtr& client)
         : mClient(client) { }
 
-    void activated(const ReplicaPrx&, const Ice::Current&)
+    void activated(const OperationContextPtr&, const ReplicaPrx&, const Ice::Current&)
     {
         mClient->sendRegister();
     }
 
-    void onStandby(const ReplicaPrx&, const Ice::Current&)
+    void onStandby(const OperationContextPtr&, const ReplicaPrx&, const Ice::Current&)
     {
     }
     void heartbeat(const ReplicaPrx&, bool, const Ice::Current&)
@@ -150,7 +152,7 @@ void SIPRegistrationClient::activate()
 {
     ReplicaListenerPtr listener(new ClientRegistrationReplicaListener(this));
     mReplicaListenerProxy = ReplicaListenerPrx::uncheckedCast(mBackplaneAdapter->addWithUUID(listener));
-    mReplica->addListener(mReplicaListenerProxy);
+    mReplica->addListener(Operations::createContext(), mReplicaListenerProxy);
 }
 
 void SIPRegistrationClient::createPJSIPRegistration(
@@ -201,7 +203,7 @@ void SIPRegistrationClient::createPJSIPRegistration(
 
 void SIPRegistrationClient::destroy()
 {
-    mReplica->removeListener(mReplicaListenerProxy);
+    mReplica->removeListener(Operations::createContext(), mReplicaListenerProxy);
     mBackplaneAdapter->remove(mReplicaListenerProxy->ice_getIdentity());
     destroyPJSIPRegistration();
 }
diff --git a/src/SIPConfiguration.cpp b/src/SIPConfiguration.cpp
index eb7486e..5204d53 100644
--- a/src/SIPConfiguration.cpp
+++ b/src/SIPConfiguration.cpp
@@ -36,15 +36,15 @@
 #include "TLSTransport.h"
 #include "STUNTransportConfig.h"
 #include <vector>
-#include <AsteriskSCF/Helpers/OperationContext.h>
-#include <AsteriskSCF/Helpers/OperationContextCache.h>
+#include <AsteriskSCF/Operations/OperationContext.h>
+#include <AsteriskSCF/Operations/OperationContextCache.h>
 
 using namespace AsteriskSCF::System::Configuration::V1;
 using namespace AsteriskSCF::Configuration::SIPSessionManager::V1;
 using namespace AsteriskSCF::SessionCommunications::PartyIdentification::V1;
 using namespace AsteriskSCF::Core::Routing::V1;
 using namespace AsteriskSCF::System::V1;
-using namespace AsteriskSCF::Helpers;
+using namespace AsteriskSCF::Operations;
 using namespace std;
 
 //
@@ -642,7 +642,7 @@ public:
         }
         if (updateSystem)
         {
-            mRegistry->setEndpointLocatorDestinationIds(mRoutingId, destinations);
+            mRegistry->setEndpointLocatorDestinationIds(Operations::createContext(), mRoutingId, destinations);
         }
     }
 
@@ -1646,7 +1646,7 @@ ConfigurationServiceImpl::ConfigurationServiceImpl(const PJSIPManagerPtr& manage
         const boost::shared_ptr<SIPEndpointFactory>& factory, const std::string& routingId,
         const LocatorRegistrySmartPrx& registry) :
     mData(new ConfigurationData(manager, factory, routingId, registry)),
-    mOperationContextCache(new OperationContextCache(180))
+    mOperationContextCache(OperationContextCache::create(180))
 {
 }
 
@@ -1874,7 +1874,8 @@ void ConfigurationServiceImpl::setConfiguration(
     // Is this a retry for an operation we're already processing?
     if (!mOperationContextCache->addOperationContext(operationContext))
     {
-        throw OperationCallCancelledException(operationContext->id, Duplicate);
+        // It's not quite this simple. But for now, ...
+        return;
     }
 
     class GroupsVisitor : public SIPConfigurationGroupVisitor
@@ -1953,7 +1954,7 @@ void ConfigurationServiceImpl::removeConfigurationItems(
     // Is this a retry for an operation we're already processing?
     if (!mOperationContextCache->addOperationContext(operationContext))
     {
-        throw OperationCallCancelledException(operationContext->id, Duplicate);
+        return; 
     }
 
     class GroupsVisitor : public SIPConfigurationGroupVisitor
@@ -2030,7 +2031,7 @@ const Ice::Current&)
     // Is this a retry for an operation we're already processing?
     if (!mOperationContextCache->addOperationContext(operationContext))
     {
-        throw OperationCallCancelledException(operationContext->id, Duplicate);
+        return;
     }
 
     class Visitor : public SIPConfigurationGroupVisitor
diff --git a/src/SIPEndpoint.cpp b/src/SIPEndpoint.cpp
index 7253d87..0fd6798 100644
--- a/src/SIPEndpoint.cpp
+++ b/src/SIPEndpoint.cpp
@@ -27,6 +27,8 @@
 #include <AsteriskSCF/Collections/HandleSet.h>
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
+#include <AsteriskSCF/Operations/OperationContextCache.h>
+#include <AsteriskSCF/Operations/OperationContext.h>
 
 #include "NATOptions.h"
 
@@ -41,6 +43,7 @@ using namespace AsteriskSCF::Replication::SIPSessionManager::V1;
 using namespace AsteriskSCF::Discovery;
 using namespace AsteriskSCF::Configuration::SIPSessionManager::V1;
 using namespace AsteriskSCF::System::Component::V1;
+using namespace AsteriskSCF::Operations;
 
 namespace
 {
@@ -212,7 +215,8 @@ public:
         mReplica(replica),
         mAuthManager(authManager),
         mDefaultListeners(new AsteriskSCF::Collections::ProxySet<SessionListenerPrx>(adapter, lg, "Default Session Listeners")),
-        mDefaultSessionCookies(new AsteriskSCF::Collections::HandleSet<AsteriskSCF::SessionCommunications::V1::SessionCookiePtr>(lg, "Default Cookies"))
+        mDefaultSessionCookies(new AsteriskSCF::Collections::HandleSet<AsteriskSCF::SessionCommunications::V1::SessionCookiePtr>(lg, "Default Cookies")),
+        mOperationContextCache(OperationContextCache::create(180))
     {
     };
     
@@ -272,6 +276,7 @@ public:
 
     std::map<std::string, SIPRegistrationClientPtr> mClientRegistrations;
     AsteriskSCF::Collections::HandleSet<AsteriskSCF::SessionCommunications::V1::SessionCookiePtr>::SetPtr mDefaultSessionCookies;
+    AsteriskSCF::Operations::OperationContextCachePtr mOperationContextCache;
 };
 
 SIPEndpoint::SIPEndpoint(const Ice::ObjectAdapterPtr& adapter, 
@@ -514,6 +519,9 @@ std::string SIPEndpoint::getId(const Ice::Current&)
     return mImplPriv->mEndpointProxy->ice_getIdentity().name;
 }
 
+/**
+ * This version of this overloaded operation handles a slice invocation. 
+ */
 AsteriskSCF::SessionCommunications::V1::SessionPrx SIPEndpoint::createSession(
         const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
         const string& destination,
@@ -540,6 +548,7 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SIPEndpoint::createSession(
     AsteriskSCF::SessionCommunications::V1::SessionCookies defaultCookies = mImplPriv->mDefaultSessionCookies->getAll();
 
     SIPSessionPtr session = SIPSession::create(
+            operationContext,
             mImplPriv->mAdapter, 
 	    this, 
 	    destination, 
@@ -564,12 +573,16 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SIPEndpoint::createSession(
     return session->getSessionProxy();
 }
 
+/**
+ * This version of this overloaded method is called for sessions originating at this endpoint. 
+ */
 AsteriskSCF::SIPSessionManager::SIPSessionPtr SIPEndpoint::createSession(const std::string& destination)
 {
     vector<SessionListenerPrx> defaultListeners = mImplPriv->mDefaultListeners->getAll();
     AsteriskSCF::SessionCommunications::V1::SessionCookies defaultCookies = mImplPriv->mDefaultSessionCookies->getAll();
 
     SIPSessionPtr session = SIPSession::create(
+             AsteriskSCF::Operations::createContext(), 
              mImplPriv->mAdapter, 
 	     this, 
 	     destination, 
@@ -603,13 +616,15 @@ SIPSessionPtr SIPEndpoint::createSession
                 const Ice::Identity& sessionid, 
 		const Ice::Identity& controllerid,
                 const Ice::Identity& mediaid,
+                const OperationContextPtr& originalContext,
                 const AsteriskSCF::Replication::SIPSessionManager::V1::RTPMediaSessionDict& mediasessions,
                 const AsteriskSCF::Replication::SIPSessionManager::V1::UDPTLMediaSessionSeq& udptlMediaSessions,
                 const AsteriskSCF::Media::V1::StreamSourceSeq& sources,
                 const AsteriskSCF::Media::V1::StreamSinkSeq& sinks)
 {
     SIPSessionPtr session = SIPSession::create
-        (mImplPriv->mAdapter, 
+        (originalContext,
+         mImplPriv->mAdapter, 
          this, 
          destination, 
          sessionid, 
@@ -675,8 +690,17 @@ AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx SIPEndpoint::getEndpo
     return mImplPriv->mEndpointProxy;
 }
 
-void SIPEndpoint::addDefaultSessionListener(const SessionListenerPrx& listener, const Ice::Current&)
+void SIPEndpoint::addDefaultSessionListener(
+    const OperationContextPtr& operationContext,
+    const SessionListenerPrx& listener, 
+    const Ice::Current&)
 {
+    if (!mImplPriv->mOperationContextCache->addOperationContext(operationContext))
+    {
+        lg(Debug) << BOOST_CURRENT_FUNCTION << " detected and rejected duplicate operation. Id = " << operationContext->id << " transaction = " <<  operationContext->transactionId;
+        return;
+    }
+
     mImplPriv->mDefaultListeners->add(listener);
 
     if (mImplPriv->mReplicationContext->isReplicating() == false)
@@ -695,8 +719,17 @@ void SIPEndpoint::addDefaultSessionListener(const SessionListenerPrx& listener,
     mImplPriv->mReplicationContext->getReplicator().tryOneWay()->setState(items);
 }
 
-void SIPEndpoint::removeDefaultSessionListener(const SessionListenerPrx& listener, const Ice::Current&)
+void SIPEndpoint::removeDefaultSessionListener(
+    const OperationContextPtr& operationContext,
+    const SessionListenerPrx& listener, 
+    const Ice::Current&)
 {
+    if (!mImplPriv->mOperationContextCache->addOperationContext(operationContext))
+    {
+        lg(Debug) << BOOST_CURRENT_FUNCTION << " detected and rejected duplicate operation. Id = " << operationContext->id << " transaction = " <<  operationContext->transactionId;
+        return;
+    }
+
     mImplPriv->mDefaultListeners->remove(listener);
 
     if (mImplPriv->mReplicationContext->isReplicating() == false)
@@ -776,8 +809,17 @@ void SIPEndpoint::addDefaultSessionCookies(const AsteriskSCF::SessionCommunicati
     mImplPriv->mReplicationContext->getReplicator().tryOneWay()->setState(items);
 }
 
-void SIPEndpoint::addDefaultSessionCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies, const Ice::Current&)
+void SIPEndpoint::addDefaultSessionCookies(
+    const OperationContextPtr& operationContext,
+    const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies, 
+    const Ice::Current&)
 {
+    if (!mImplPriv->mOperationContextCache->addOperationContext(operationContext))
+    {
+        lg(Debug) << BOOST_CURRENT_FUNCTION << " detected and rejected duplicate operation. Id = " << operationContext->id << " transaction = " <<  operationContext->transactionId;
+        return;
+    }
+
     addDefaultSessionCookies(cookies, false);
 }
 
@@ -820,8 +862,18 @@ void SIPEndpoint::removeDefaultSessionCookies(const AsteriskSCF::SessionCommunic
     mImplPriv->mReplicationContext->getReplicator().tryOneWay()->removeStateForItems(items);
 }
 
-void SIPEndpoint::removeDefaultSessionCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies, const Ice::Current&)
+void SIPEndpoint::removeDefaultSessionCookies(
+    const OperationContextPtr& operationContext,
+    const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies, 
+    const Ice::Current&)
 {
+
+    if (!mImplPriv->mOperationContextCache->addOperationContext(operationContext))
+    {
+        lg(Debug) << BOOST_CURRENT_FUNCTION << " detected and rejected duplicate operation. Id = " << operationContext->id << " transaction = " <<  operationContext->transactionId;
+        return;
+    }
+
     removeDefaultSessionCookies(cookies, false);
 }
 
diff --git a/src/SIPEndpoint.h b/src/SIPEndpoint.h
index 28196be..4b033e6 100644
--- a/src/SIPEndpoint.h
+++ b/src/SIPEndpoint.h
@@ -305,15 +305,19 @@ public:
             const Ice::Current&);
     AsteriskSCF::SessionCommunications::V1::SessionSeq getSessions(const Ice::Current&);
     void addDefaultSessionListener(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
         const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener, 
         const Ice::Current& = Ice::Current());
     void removeDefaultSessionListener(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
         const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
          const Ice::Current& = Ice::Current());
      void addDefaultSessionCookies(
+         const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
          const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies,
          const Ice::Current& = Ice::Current());
      void removeDefaultSessionCookies(
+         const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
          const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies,
          const Ice::Current& = Ice::Current());
 
@@ -335,10 +339,16 @@ public:
     // dependency insanity
     //
     AsteriskSCF::SIPSessionManager::SIPSessionPtr createSession(const std::string&);
-    AsteriskSCF::SIPSessionManager::SIPSessionPtr createSession(const std::string&, const Ice::Identity&, const Ice::Identity&,
-                                                                const Ice::Identity&, const AsteriskSCF::Replication::SIPSessionManager::V1::RTPMediaSessionDict&,
-                                                                const AsteriskSCF::Replication::SIPSessionManager::V1::UDPTLMediaSessionSeq&,
-                                                                const AsteriskSCF::Media::V1::StreamSourceSeq&, const AsteriskSCF::Media::V1::StreamSinkSeq&);
+    AsteriskSCF::SIPSessionManager::SIPSessionPtr createSession(
+        const std::string&, 
+        const Ice::Identity&, 
+        const Ice::Identity&,                                  
+        const Ice::Identity&, 
+        const AsteriskSCF::System::V1::OperationContextPtr& originalContext,
+        const AsteriskSCF::Replication::SIPSessionManager::V1::RTPMediaSessionDict&,
+        const AsteriskSCF::Replication::SIPSessionManager::V1::UDPTLMediaSessionSeq&,
+        const AsteriskSCF::Media::V1::StreamSourceSeq&, 
+        const AsteriskSCF::Media::V1::StreamSinkSeq&);
 
     void removeSession(const AsteriskSCF::SessionCommunications::V1::SessionPtr&);
 
diff --git a/src/SIPRegistrarListener.cpp b/src/SIPRegistrarListener.cpp
index ded34f2..93c2ca5 100644
--- a/src/SIPRegistrarListener.cpp
+++ b/src/SIPRegistrarListener.cpp
@@ -18,6 +18,7 @@
 #include "SIPRegistrarListener.h"
 
 using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::System::V1;
 
 namespace
 {
@@ -73,7 +74,10 @@ void SIPDefaultRegistrarListener::updateEndpoints(const SIPEndpointSeq& endpoint
     }
 }
 
-void SIPDefaultRegistrarListener::contactsAdded(const BindingUpdateSeq& contacts, const Ice::Current&)
+void SIPDefaultRegistrarListener::contactsAdded(
+     const OperationContextPtr& operationContext,
+     const BindingUpdateSeq& contacts, 
+     const Ice::Current&)
 {
     pj_pool_t *pool = pj_pool_create(&mCachingPool.factory, "DefaultRegistrarListener", 256, 256, NULL);
     for (BindingUpdateSeq::const_iterator iter = contacts.begin(); iter != contacts.end(); ++iter)
@@ -88,7 +92,10 @@ void SIPDefaultRegistrarListener::contactsAdded(const BindingUpdateSeq& contacts
     pj_pool_release(pool);
 }
 
-void SIPDefaultRegistrarListener::contactsRemoved(const BindingUpdateSeq& contacts, const Ice::Current&)
+void SIPDefaultRegistrarListener::contactsRemoved(
+    const OperationContextPtr& operationContext,
+    const BindingUpdateSeq& contacts, 
+    const Ice::Current&)
 {
     pj_pool_t *pool = pj_pool_create(&mCachingPool.factory, "DefaultRegistrarListener", 256, 256, NULL);
     for (BindingUpdateSeq::const_iterator iter = contacts.begin(); iter != contacts.end(); ++iter)
diff --git a/src/SIPRegistrarListener.h b/src/SIPRegistrarListener.h
index de6a8a9..bfe5879 100644
--- a/src/SIPRegistrarListener.h
+++ b/src/SIPRegistrarListener.h
@@ -33,8 +33,10 @@ public:
     SIPDefaultRegistrarListener(const boost::shared_ptr<SIPEndpointFactory>& endpointFactory);
     ~SIPDefaultRegistrarListener();
 
-    void contactsAdded(const AsteriskSCF::SIP::Registration::V1::BindingUpdateSeq&, const Ice::Current&);
-    void contactsRemoved(const AsteriskSCF::SIP::Registration::V1::BindingUpdateSeq&, const Ice::Current&);
+    void contactsAdded(const AsteriskSCF::System::V1::OperationContextPtr&,
+        const AsteriskSCF::SIP::Registration::V1::BindingUpdateSeq&, const Ice::Current&);
+    void contactsRemoved(const AsteriskSCF::System::V1::OperationContextPtr&,
+        const AsteriskSCF::SIP::Registration::V1::BindingUpdateSeq&, const Ice::Current&);
 private:
     SIPEndpointSeq getEndpoints(pj_pool_t *pool, const std::string& aor);
     void updateEndpoints(const SIPEndpointSeq& endpoints, pj_pool_t *pool, const std::string& contact);
diff --git a/src/SIPSession.cpp b/src/SIPSession.cpp
index 693e9e4..96658f1 100755
--- a/src/SIPSession.cpp
+++ b/src/SIPSession.cpp
@@ -46,8 +46,8 @@
 #include <AsteriskSCF/Media/NetworkIf.h>
 #include <AsteriskSCF/SessionCookies/SIPSessionManager/SIPSessionCookiesIf.h>
 #include <AsteriskSCF/Collections/HandleSet.h>
-#include <AsteriskSCF/Helpers/OperationContextCache.h>
-#include <AsteriskSCF/Helpers/OperationContext.h>
+#include <AsteriskSCF/Operations/OperationContextCache.h>
+#include <AsteriskSCF/Operations/OperationContext.h>
 #include "NATOptions.h"
 #include "PJSIPSessionModule.h"
 
@@ -64,6 +64,7 @@ using namespace AsteriskSCF::Media::UDPTL::V1;
 using namespace AsteriskSCF::Media::Formats::T38Udptl::V1;
 using namespace AsteriskSCF::Network::V1;
 using namespace AsteriskSCF::System::V1;
+using namespace AsteriskSCF::Operations;
 using namespace AsteriskSCF::Helpers;
 using namespace std;
 
@@ -129,14 +130,20 @@ public:
     /**
      * Constructor for the SIPSessionPriv class.
      */
-    SIPSessionPriv(const Ice::ObjectAdapterPtr& adapter, const SIPEndpointPtr& endpoint,
-        const std::string& destination, const PJSIPManagerPtr& manager,
+    SIPSessionPriv(
+        const OperationContextPtr& operationContext,
+        const Ice::ObjectAdapterPtr& adapter, 
+        const SIPEndpointPtr& endpoint,
+        const std::string& destination, 
+        const PJSIPManagerPtr& manager,
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
         const SIPReplicationContextPtr& replicationContext,
         const NATEndpointOptions& natOptions)
-        : mAdapter(adapter), mDialog(0), mInviteSession(0), mEndpoint(endpoint), mDestination(destination),
+        : mOperationContext(operationContext),
+          mAdapter(adapter), mDialog(0), mInviteSession(0), mEndpoint(endpoint), mDestination(destination),
           mManager(manager), mServiceLocator(serviceLocator), mReplicationContext(replicationContext), 
-      mNatOptions(natOptions), mSDP(0), mOperationContextCache(new OperationContextCache(180))
+          mNatOptions(natOptions), mSDP(0), 
+          mOperationContextCache(OperationContextCache::create(180))
     { 
 
     }
@@ -222,6 +229,11 @@ public:
     AsteriskSCF::SessionCommunications::V1::SessionPrx mPublicSessionProxy;
 
     /**
+     * The OperationContext that caused this session to be created.
+     */
+    OperationContextPtr mOperationContext;
+
+    /**
      * The Ice object adapter that our proxies were added to.
      */
     Ice::ObjectAdapterPtr mAdapter;
@@ -337,7 +349,7 @@ public:
 
     AsteriskSCF::SessionCommunications::V1::TelephonyEventSourceSeq mExternalEventSources;
 
-    AsteriskSCF::Helpers::OperationContextCachePtr mOperationContextCache;
+    AsteriskSCF::Operations::OperationContextCachePtr mOperationContextCache;
 
 private:
     static ReadOnlyCookieTypes mReadOnlyCookieTypes;
@@ -414,9 +426,10 @@ public:
      * @param sessionPriv The session for whom the information is requested from.
      */
     SetMediaSessionCookiesOperation(
+        const OperationContextPtr& sourceContext,
         const AsteriskSCF::Media::V1::SessionCookies& cookies, 
         const SIPSessionPtr& session)
-         : mCookies(cookies), mSession(session)
+         : mSourceContext(sourceContext), mCookies(cookies), mSession(session)
     {
     }
 
@@ -431,13 +444,14 @@ public:
         for(RTPMediaSessionDict::iterator i = mediaSessions.begin(); 
             i != mediaSessions.end(); ++i)
         {
-            i->second->setCookies(mCookies);
+            i->second->setCookies(Operations::createContext(mSourceContext), mCookies);
         }
 
         return Complete;
     }
 
 private:
+    OperationContextPtr mSourceContext;
     AsteriskSCF::Media::V1::SessionCookies mCookies;
     SIPSessionPtr mSession;
 };
@@ -454,9 +468,10 @@ public:
      * @param sessionPriv The session for whom the information is requested from.
      */
     RemoveMediaSessionCookiesOperation(
+        const OperationContextPtr& sourceContext,
         const AsteriskSCF::Media::V1::SessionCookies& cookieTypes, 
         const SIPSessionPtr& session)
-         : mCookieTypes(cookieTypes), mSession(session)
+         : mSourceContext(sourceContext), mCookieTypes(cookieTypes), mSession(session)
     {
     }
 
@@ -471,13 +486,14 @@ public:
         for(RTPMediaSessionDict::iterator i = mediaSessions.begin(); 
             i != mediaSessions.end(); ++i)
         {
-            i->second->removeCookies(mCookieTypes);
+            i->second->removeCookies(Operations::createContext(mSourceContext), mCookieTypes);
         }
 
         return Complete;
     }
 
 private:
+    OperationContextPtr mSourceContext;
     AsteriskSCF::Media::V1::SessionCookies mCookieTypes;
     SIPSessionPtr mSession;
 };
@@ -509,24 +525,28 @@ public:
         return mId;
     }
 
-    void setCookies(const AsteriskSCF::Media::V1::SessionCookies& cookies, 
-                    const Ice::Current&)
+    void setCookies(
+        const OperationContextPtr& operationContext,
+        const AsteriskSCF::Media::V1::SessionCookies& cookies, 
+        const Ice::Current&)
     {
-        mSession->enqueueSessionWork(new SetMediaSessionCookiesOperation(cookies, mSession));
+        mSession->enqueueSessionWork(new SetMediaSessionCookiesOperation(operationContext, cookies, mSession));
     }
 
     void getCookies_async(
-          const ::AsteriskSCF::Media::V1::AMD_Session_getCookiesPtr& cb,
+          const AsteriskSCF::Media::V1::AMD_Session_getCookiesPtr& cb,
           const AsteriskSCF::Media::V1::SessionCookies& cookiesToGet, 
           const Ice::Current&)
     {
         mSession->enqueueSessionWork(new GetMediaSessionCookiesOperation(cb, cookiesToGet, mSession));
     }
 
-    void removeCookies(const AsteriskSCF::Media::V1::SessionCookies& cookies, 
-                    const Ice::Current&)
+    void removeCookies(
+        const OperationContextPtr& operationContext,
+        const AsteriskSCF::Media::V1::SessionCookies& cookies, 
+        const Ice::Current&)
     {
-        mSession->enqueueSessionWork(new RemoveMediaSessionCookiesOperation(cookies, mSession));
+        mSession->enqueueSessionWork(new RemoveMediaSessionCookiesOperation(operationContext, cookies, mSession));
     }
 
 private:
@@ -566,7 +586,6 @@ public:
         if (!mImplPriv->mOperationContextCache->addOperationContext(mOperationContext))
         {
             lg(Debug) << "Retry of previously processed changeStreamStates() operation detected and rejected.";
-            mCb->ice_exception(OperationCallCancelledException(mOperationContext->id, Duplicate));
             return Complete;
         }
 
@@ -693,7 +712,6 @@ public:
         if (!mImplPriv->mOperationContextCache->addOperationContext(mOperationContext))
         {
             lg(Debug) << "Retry of previously processed addStreams() operation detected and rejected.";
-            mCb->ice_exception(OperationCallCancelledException(mOperationContext->id, Duplicate));
             return Complete;
         }
 
@@ -764,7 +782,6 @@ public:
         if (!mImplPriv->mOperationContextCache->addOperationContext(mOperationContext))
         {
             lg(Debug) << "Retry of previously processed removeStates() operation detected and rejected.";
-            mCb->ice_exception(OperationCallCancelledException(mOperationContext->id, Duplicate));
             return Complete;
         }
 
@@ -950,6 +967,11 @@ void SIPSession::setSelfAsCaller()
     mImplPriv->mSessionCookies[dialed->ice_id()] = dialed;
 }
 
+OperationContextPtr SIPSession::getOperationContext()
+{
+    return mImplPriv->mOperationContext;
+}
+
 void SIPSession::setSessionOwnerId(const SessionOwnerIdPtr& owner)
 {
     mImplPriv->mSessionCookies[owner->ice_id()] = owner;
@@ -1003,7 +1025,6 @@ public:
         if (!mImplPriv->mOperationContextCache->addOperationContext(mOperationContext))
         {
             lg(Debug) << "Retry of previously processed connectStreams() operation detected and rejected.";
-            mCb->ice_exception(OperationCallCancelledException(mOperationContext->id, Duplicate));
             return Complete;
         }
 
@@ -1055,7 +1076,6 @@ public:
         if (!mImplPriv->mOperationContextCache->addOperationContext(mOperationContext))
         {
             lg(Debug) << "Retry of previously processed disconnectStreams() operation detected and rejected.";
-            mCb->ice_exception(OperationCallCancelledException(mOperationContext->id, Duplicate));
             return Complete;
         }
 
@@ -1263,7 +1283,7 @@ void SIPSession::activateIceObjects(const AsteriskSCF::SessionCommunications::Ex
         AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr out;
         try
         {
-            result = (*iter)->modifySession(in, out);
+            result = (*iter)->modifySession(Operations::createContext(), in, out);
         }
         catch (const Ice::Exception& ex)
         {
@@ -1305,32 +1325,36 @@ void SIPSession::setTelephonyEventSourcesAndSinks(const SIPEndpointConfig& confi
 /**
  * Standard factory method used by an active component to create SIPSession objects.
  */
-SIPSessionPtr SIPSession::create(const Ice::ObjectAdapterPtr& adapter, 
-        const SIPEndpointPtr& endpoint,
-        const std::string& destination, 
-        const vector<SessionListenerPrx>& listeners,
-        const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies,
-        const PJSIPManagerPtr& manager, 
-        const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
-        const SIPReplicationContextPtr& replicationContext, 
-        const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
-        bool doIpV6, 
-        bool isUAC, 
-        const SIPEndpointConfig &config,
-        const NATEndpointOptions& natOptions)
+SIPSessionPtr SIPSession::create(
+    const OperationContextPtr& operationContext,
+    const Ice::ObjectAdapterPtr& adapter, 
+    const SIPEndpointPtr& endpoint,
+    const std::string& destination, 
+    const vector<SessionListenerPrx>& listeners,
+    const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies,
+    const PJSIPManagerPtr& manager, 
+    const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
+    const SIPReplicationContextPtr& replicationContext, 
+    const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
+    bool doIpV6, 
+    bool isUAC, 
+    const SIPEndpointConfig &config,
+    const NATEndpointOptions& natOptions)
 {
-    SIPSessionPtr newSession = new SIPSession(adapter, 
-       endpoint,
-       destination, 
-       listeners,
-       cookies,
-       manager, 
-       serviceLocator,
-       replicationContext, 
-       doIpV6, 
-       isUAC, 
-       config,
-       natOptions);
+    SIPSessionPtr newSession = new SIPSession(
+        operationContext,
+        adapter, 
+        endpoint,
+        destination, 
+        listeners,
+        cookies,
+        manager, 
+        serviceLocator,
+        replicationContext, 
+        doIpV6, 
+        isUAC, 
+        config,
+        natOptions);
 
     AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookSeq hooks = 
         newSession->mImplPriv->mManager->getSessionModule()->getSessionCreationHooks();
@@ -1347,40 +1371,44 @@ SIPSessionPtr SIPSession::create(const Ice::ObjectAdapterPtr& adapter,
 /**
  * Factory used by a standby component to create replicas. 
  */
-SIPSessionPtr SIPSession::create(const Ice::ObjectAdapterPtr& adapter, 
-                                 const SIPEndpointPtr& endpoint,
-                                 const std::string& destination, 
-                                 const Ice::Identity& sessionid,
-                                 const Ice::Identity& controllerid,
-                                 const Ice::Identity& mediaid, 
-                                 const AsteriskSCF::Replication::SIPSessionManager::V1::RTPMediaSessionDict& mediasessions,
-                                 const AsteriskSCF::Replication::SIPSessionManager::V1::UDPTLMediaSessionSeq& udptlMediaSessions,
-                                 const AsteriskSCF::Media::V1::StreamSourceSeq& sources, 
-                                 const AsteriskSCF::Media::V1::StreamSinkSeq& sinks,
-                                 const PJSIPManagerPtr& manager, 
-                                 const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
-                                 const SIPReplicationContextPtr& replicationContext, 
-                                 const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
-                                 bool isUAC, 
-                                 const SIPEndpointConfig &config,
-                                 const NATEndpointOptions& natOptions)
+SIPSessionPtr SIPSession::create(
+    const OperationContextPtr& operationContext,
+    const Ice::ObjectAdapterPtr& adapter, 
+    const SIPEndpointPtr& endpoint,
+    const std::string& destination, 
+    const Ice::Identity& sessionid,
+    const Ice::Identity& controllerid,
+    const Ice::Identity& mediaid, 
+    const AsteriskSCF::Replication::SIPSessionManager::V1::RTPMediaSessionDict& mediasessions,
+    const AsteriskSCF::Replication::SIPSessionManager::V1::UDPTLMediaSessionSeq& udptlMediaSessions,
+    const AsteriskSCF::Media::V1::StreamSourceSeq& sources, 
+    const AsteriskSCF::Media::V1::StreamSinkSeq& sinks,
+    const PJSIPManagerPtr& manager, 
+    const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
+    const SIPReplicationContextPtr& replicationContext, 
+    const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
+    bool isUAC, 
+    const SIPEndpointConfig &config,
+    const NATEndpointOptions& natOptions)
 {
-    SIPSessionPtr newSession = new SIPSession(adapter, 
-                                              endpoint,
-                                              destination, 
-                                              sessionid,
-                                              controllerid,
-                                              mediaid, 
-                                              mediasessions,
-                                              udptlMediaSessions,
-                                              sources, 
-                                              sinks,
-                                              manager, 
-                                              serviceLocator,
-                                              replicationContext, 
-                                              isUAC, 
-                                              config,
-                                              natOptions);
+    SIPSessionPtr newSession = new SIPSession(
+        operationContext,
+        adapter, 
+        endpoint,
+        destination, 
+        sessionid,
+        controllerid,
+        mediaid, 
+        mediasessions,
+        udptlMediaSessions,
+        sources, 
+        sinks,
+        manager, 
+        serviceLocator,
+        replicationContext, 
+        isUAC, 
+        config,
+        natOptions);
 
     AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookSeq hooks =
         newSession->mImplPriv->mManager->getSessionModule()->getSessionCreationHooks();
@@ -1397,19 +1425,21 @@ SIPSessionPtr SIPSession::create(const Ice::ObjectAdapterPtr& adapter,
 /**
  * Standard constructor for use by an active component.
  */
-SIPSession::SIPSession(const Ice::ObjectAdapterPtr& adapter, 
-        const SIPEndpointPtr& endpoint,
-        const std::string& destination, 
-        const vector<SessionListenerPrx>& listeners,
-        const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies, 
-        const PJSIPManagerPtr& manager, 
-        const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
-        const SIPReplicationContextPtr& replicationContext, 
-        bool /* ipv6 */, 
-        bool isUAC, 
-        const SIPEndpointConfig &config,
-        const NATEndpointOptions& natOptions)
-    : mImplPriv(new SIPSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replicationContext, natOptions))
+SIPSession::SIPSession(
+    const OperationContextPtr& operationContext,
+    const Ice::ObjectAdapterPtr& adapter, 
+    const SIPEndpointPtr& endpoint,
+    const std::string& destination, 
+    const vector<SessionListenerPrx>& listeners,
+    const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies, 
+    const PJSIPManagerPtr& manager, 
+    const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
+    const SIPReplicationContextPtr& replicationContext, 
+    bool /* ipv6 */, 
+    bool isUAC, 
+    const SIPEndpointConfig &config,
+    const NATEndpointOptions& natOptions)
+    : mImplPriv(new SIPSessionPriv(operationContext, adapter, endpoint, destination, manager, serviceLocator, replicationContext, natOptions))
 {
     mImplPriv->mListeners.insert(mImplPriv->mListeners.end(), listeners.begin(), listeners.end());
 
@@ -1443,23 +1473,25 @@ SIPSession::SIPSession(const Ice::ObjectAdapterPtr& adapter,
 /**
  * Replica constructor.
  */
-SIPSession::SIPSession(const Ice::ObjectAdapterPtr& adapter,
-                       const SIPEndpointPtr& endpoint,
-                       const std::string& destination, 
-                       const Ice::Identity& sessionid,
-                       const Ice::Identity& controllerid,
-                       const Ice::Identity& mediaid,
-                       const AsteriskSCF::Replication::SIPSessionManager::V1::RTPMediaSessionDict& mediasessions,
-                       const AsteriskSCF::Replication::SIPSessionManager::V1::UDPTLMediaSessionSeq& udptlMediaSessions,
-                       const AsteriskSCF::Media::V1::StreamSourceSeq& sources,
-                       const AsteriskSCF::Media::V1::StreamSinkSeq& sinks,
-                       const PJSIPManagerPtr& manager,
-                       const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
-                       const SIPReplicationContextPtr& replicationContext,
-                       bool isUAC,
-                       const SIPEndpointConfig &config,
-                       const NATEndpointOptions& natOptions)
-    : mImplPriv(new SIPSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replicationContext, natOptions))
+SIPSession::SIPSession(
+    const OperationContextPtr& operationContext,
+    const Ice::ObjectAdapterPtr& adapter,
+    const SIPEndpointPtr& endpoint,
+    const std::string& destination, 
+    const Ice::Identity& sessionid,
+    const Ice::Identity& controllerid,
+    const Ice::Identity& mediaid,
+    const AsteriskSCF::Replication::SIPSessionManager::V1::RTPMediaSessionDict& mediasessions,
+    const AsteriskSCF::Replication::SIPSessionManager::V1::UDPTLMediaSessionSeq& udptlMediaSessions,
+    const AsteriskSCF::Media::V1::StreamSourceSeq& sources,
+    const AsteriskSCF::Media::V1::StreamSinkSeq& sinks,
+    const PJSIPManagerPtr& manager,
+    const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
+    const SIPReplicationContextPtr& replicationContext,
+    bool isUAC,
+    const SIPEndpointConfig &config,
+    const NATEndpointOptions& natOptions)
+    : mImplPriv(new SIPSessionPriv(operationContext, adapter, endpoint, destination, manager, serviceLocator, replicationContext, natOptions))
 {
     mImplPriv->mSessionProxy = 
         AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(mImplPriv->mAdapter->addWithUUID(this));
@@ -1512,6 +1544,7 @@ private:
 
 void SIPSession::addListener_async(
         const AsteriskSCF::SessionCommunications::V1::AMD_Session_addListenerPtr& cb,
+        const OperationContextPtr& operationContext,
         const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
         const Ice::Current&)
 {
@@ -1552,7 +1585,6 @@ public:
         if (!mImplPriv->mOperationContextCache->addOperationContext(mOperationContext))
         {
             lg(Debug) << "Retry of previously processed indicate() operation detected and rejected.";
-            mCb->ice_exception(OperationCallCancelledException(mOperationContext->id, Duplicate));
             return Complete;
         }
 
@@ -1912,7 +1944,6 @@ public:
         {
             lg(Debug) << "Retry of previously processed setAndGetSessionController() operation detected and rejected.";
 
-            // Since a return value is expected, don't throw the usual OperationCallCancelledException.
             mCb->ice_response(mImplPriv->mOurSessionControllerProxy);
             return Complete;
         }
@@ -1997,9 +2028,11 @@ private:
 /**
  * An implementation of the removeSessionController method as defined in SessionCommunications.ice
  */
-void SIPSession::removeSessionController_async(const AsteriskSCF::SessionCommunications::V1::AMD_Session_removeSessionControllerPtr& cb,
-                                               const AsteriskSCF::SessionCommunications::V1::SessionControllerPrx& controller,
-                                               const Ice::Current&)
+void SIPSession::removeSessionController_async(
+    const AsteriskSCF::SessionCommunications::V1::AMD_Session_removeSessionControllerPtr& cb,
+    const OperationContextPtr& operationContext,
+    const AsteriskSCF::SessionCommunications::V1::SessionControllerPrx& controller,
+    const Ice::Current&)
 {
     lg(Debug) << "queueing a removeSessionController operation";
     enqueueSessionWork(new RemoveSessionControllerOperation(cb, controller, mImplPriv));
@@ -2038,6 +2071,7 @@ private:
  */
 void SIPSession::setBridge_async(
     const AsteriskSCF::SessionCommunications::V1::AMD_Session_setBridgePtr& cb,
+    const OperationContextPtr& operationContext,
     const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge,
     const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
     const Ice::Current& current)
@@ -2098,6 +2132,7 @@ private:
  */
 void SIPSession::removeBridge_async(
         const AsteriskSCF::SessionCommunications::V1::AMD_Session_removeBridgePtr& cb,
+        const OperationContextPtr& operationContext,
         const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
         const Ice::Current& current)
 {
@@ -2109,8 +2144,9 @@ class RemoveListenerOperation : public SuspendableWork
 {
 public:
     RemoveListenerOperation(
-            const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
-            const boost::shared_ptr<SIPSessionPriv>& sessionPriv)
+        const OperationContextPtr& operationContext,
+        const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
+        const boost::shared_ptr<SIPSessionPriv>& sessionPriv)
         : mListener(listener), mImplPriv(sessionPriv) { }
 
     SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
@@ -2127,10 +2163,12 @@ private:
 /**
  * An implementation of the removeListener method as defined in SessionCommunications.ice
  */
-void SIPSession::removeListener(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener, const Ice::Current&)
+void SIPSession::removeListener(
+    const OperationContextPtr& operationContext,
+    const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener, const Ice::Current&)
 {
     lg(Debug) << "removeListener called. Queuing operation";
-    enqueueSessionWork(new RemoveListenerOperation(listener, mImplPriv));
+    enqueueSessionWork(new RemoveListenerOperation(operationContext, listener, mImplPriv));
 }
 
 class StartOperation : public SuspendableWork
@@ -2332,7 +2370,7 @@ private:
  * An implementation of the start method as defined in SessionCommunications.ice which sends
  * an INVITE with SDP to the SIP endpoint.
  */
-void SIPSession::start(const Ice::Current&)
+void SIPSession::start(const OperationContextPtr& operationContext, const Ice::Current&)
 {
     lg(Debug) << "We've been asked to start a session.";
     enqueueSessionWork(new StartOperation(this, mImplPriv));
@@ -2435,7 +2473,10 @@ private:
  * An implementation of the stop method as defined in SessionCommunications.ice which sends
  * a BYE or applicable response code to the SIP endpoint depending upon the state of the dialog.
  */
-void SIPSession::stop(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response, const Ice::Current&)
+void SIPSession::stop(
+    const OperationContextPtr& operationContext, 
+    const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response, 
+    const Ice::Current&)
 {
     lg(Debug) << "queuing a stop operation";
     enqueueSessionWork(new StopOperation(response, mImplPriv->mInviteSession));
@@ -3154,7 +3195,7 @@ pjmedia_sdp_session *SIPSession::createSDPOffer(const AsteriskSCF::Media::V1::St
         mImplPriv->mSDP = createSDP();
     }
 
-    OperationContextPtr operationContext(AsteriskSCF::createContext());
+    OperationContextPtr operationContext(AsteriskSCF::Operations::createContext());
 
     // Iterate through each requested stream
     for (StreamInformationDict::const_iterator stream = requestedStreams.begin();
@@ -3433,7 +3474,7 @@ pjmedia_sdp_session *SIPSession::createSDPAnswer(const pjmedia_sdp_session* offe
     {
         mImplPriv->mSDP = createSDP();
     }
-    OperationContextPtr operationContext(AsteriskSCF::createContext());
+    OperationContextPtr operationContext(AsteriskSCF::Operations::createContext());
 
     // Get the non-stream level connection information in case there is no connection level one
     std::string destination(pj_strbuf(&offer->conn->addr), pj_strlen(&offer->conn->addr));
@@ -3806,7 +3847,7 @@ pjmedia_sdp_session *SIPSession::createSDPAnswer(const pjmedia_sdp_session* offe
             // something is critically wrong and stuff will most likely fall apart quickly
             try
             {
-                sink->setRemoteDetails(connection, offer->media[stream]->desc.port);
+                sink->setRemoteDetails(Operations::createContext(), connection, offer->media[stream]->desc.port);
             }
             catch (const AsteriskSCF::Media::RTP::V1::InvalidAddress&)
             {
@@ -3949,7 +3990,7 @@ pjmedia_sdp_session *SIPSession::createSDPAnswer(const pjmedia_sdp_session* offe
             StreamSinkUDPTLPrx sink = StreamSinkUDPTLPrx::uncheckedCast(ourStream->sinks.front());
             try
             {
-                sink->setRemoteDetails(connection, offer->media[stream]->desc.port);
+                sink->setRemoteDetails(Operations::createContext(), connection, offer->media[stream]->desc.port);
             }
             catch (const AsteriskSCF::Network::V1::InvalidAddress&)
             {
@@ -3970,14 +4011,14 @@ pjmedia_sdp_session *SIPSession::createSDPAnswer(const pjmedia_sdp_session* offe
             // If the max datagram has been overridden then use that instead of what they offered
             if (t38Configuration->maxDatagram)
             {
-                sink->setFarMaxDatagram(t38Configuration->maxDatagram);
+                sink->setFarMaxDatagram(Operations::createContext(), t38Configuration->maxDatagram);
             }
             else
             {
-                sink->setFarMaxDatagram(t38->maxDatagram);
+                sink->setFarMaxDatagram(Operations::createContext(), t38->maxDatagram);
             }
 
-            sink->setErrorCorrectionScheme(t38->errorCorrection);
+            sink->setErrorCorrectionScheme(Operations::createContext(), t38->errorCorrection);
 
 	    break;
         }
@@ -4303,7 +4344,7 @@ void SIPSession::startMedia(const pjmedia_sdp_session*, const pjmedia_sdp_sessio
                     key;
             
             }
-            srtpSession->start(AsteriskSCF::createContext(), suite, key, config.srtpConfig.enableAuthentication,
+            srtpSession->start(AsteriskSCF::Operations::createContext(), suite, key, config.srtpConfig.enableAuthentication,
                     config.srtpConfig.enableEncryption);
         }
     }
diff --git a/src/SIPSession.h b/src/SIPSession.h
index ebda37d..3a15024 100644
--- a/src/SIPSession.h
+++ b/src/SIPSession.h
@@ -119,7 +119,10 @@ public:
     /**
      * Standard factory method used by an active component to create SIPSession objects.
      */
-    static SIPSessionPtr create(const Ice::ObjectAdapterPtr&, const SIPEndpointPtr&, 
+    static SIPSessionPtr create(
+        const AsteriskSCF::System::V1::OperationContextPtr&,
+        const Ice::ObjectAdapterPtr&, 
+        const SIPEndpointPtr&, 
         const std::string&,
         const std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>&,         
         const AsteriskSCF::SessionCommunications::V1::SessionCookies&, 
@@ -135,7 +138,10 @@ public:
     /**
      * Factory used by a standby component to create replicas. 
      */
-    static SIPSessionPtr create(const Ice::ObjectAdapterPtr& adapter, const SIPEndpointPtr& endpoint,
+    static SIPSessionPtr create(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const Ice::ObjectAdapterPtr& adapter, 
+        const SIPEndpointPtr& endpoint,
         const std::string& destination, 
         const Ice::Identity& sessionid,
         const Ice::Identity& controllerid,
@@ -159,6 +165,7 @@ public:
      */
     void addListener_async(
             const AsteriskSCF::SessionCommunications::V1::AMD_Session_addListenerPtr& cb,
+            const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
             const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&,
             const Ice::Current&);
 
@@ -192,21 +199,26 @@ public:
 
     void setBridge_async(
         const AsteriskSCF::SessionCommunications::V1::AMD_Session_setBridgePtr& cb,
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
         const AsteriskSCF::SessionCommunications::V1::BridgePrx&,
         const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, const Ice::Current&);
 
     void setBridge(const AsteriskSCF::SessionCommunications::V1::BridgePrx&);
 
     void removeBridge_async(
-            const AsteriskSCF::SessionCommunications::V1::AMD_Session_removeBridgePtr& cb,
-            const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&,
-            const Ice::Current&);
+        const AsteriskSCF::SessionCommunications::V1::AMD_Session_removeBridgePtr& cb,
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&,
+        const Ice::Current&);
 
     void activateIceObjects(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookSeq& hooks);
 
-    void removeListener(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, const Ice::Current&);
-    void start(const Ice::Current&);
-    void stop(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const Ice::Current&);
+    void removeListener(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, 
+        const Ice::Current&);
+    void start(const AsteriskSCF::System::V1::OperationContextPtr& operationContext, const Ice::Current&);
+    void stop(const AsteriskSCF::System::V1::OperationContextPtr& operationContext, const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const Ice::Current&);
     void setCookies(
         const AsteriskSCF::System::V1::OperationContextPtr&,
         const AsteriskSCF::SessionCommunications::V1::SessionCookies&, 
@@ -267,9 +279,11 @@ public:
         const AsteriskSCF::SessionCommunications::V1::SessionControllerPrx&,
         const Ice::Current&);
 
-    void removeSessionController_async(const AsteriskSCF::SessionCommunications::V1::AMD_Session_removeSessionControllerPtr&,
-                                       const AsteriskSCF::SessionCommunications::V1::SessionControllerPrx&,
-                                       const Ice::Current&);
+    void removeSessionController_async(
+        const AsteriskSCF::SessionCommunications::V1::AMD_Session_removeSessionControllerPtr&,
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const AsteriskSCF::SessionCommunications::V1::SessionControllerPrx&,
+        const Ice::Current&);
 
     /**
      * TelephonySession overrides
@@ -378,13 +392,17 @@ public:
 
     void setSelfAsCaller();
 
+    AsteriskSCF::System::V1::OperationContextPtr getOperationContext();
+
     //Must be called from a queued operation
     void setSessionOwnerId(const AsteriskSCF::SessionCommunications::PartyIdentification::V1::SessionOwnerIdPtr& owner);
 
     void setRedirections(const AsteriskSCF::SessionCommunications::PartyIdentification::V1::RedirectionsPtr& redirections);
 
 private:
-    SIPSession(const Ice::ObjectAdapterPtr&, const SIPEndpointPtr&, const std::string&,
+    SIPSession(
+        const AsteriskSCF::System::V1::OperationContextPtr&,
+        const Ice::ObjectAdapterPtr&, const SIPEndpointPtr&, const std::string&,
         const std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx>&,         
         const AsteriskSCF::SessionCommunications::V1::SessionCookies&, 
         const PJSIPManagerPtr& manager,
@@ -392,13 +410,15 @@ private:
         const SIPReplicationContextPtr& replicationContext,
         bool ipv6, bool isUAC, const SIPEndpointConfig& config, const NATEndpointOptions& natOptions);
 
-    SIPSession(const Ice::ObjectAdapterPtr&, const SIPEndpointPtr&, const std::string&, const Ice::Identity&, const Ice::Identity&,
-               const Ice::Identity&, const AsteriskSCF::Replication::SIPSessionManager::V1::RTPMediaSessionDict&,
-               const AsteriskSCF::Replication::SIPSessionManager::V1::UDPTLMediaSessionSeq&,
-               const AsteriskSCF::Media::V1::StreamSourceSeq&, const AsteriskSCF::Media::V1::StreamSinkSeq&,
-               const PJSIPManagerPtr& manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
-               const SIPReplicationContextPtr& replicationContext,
-               bool isUAC, const SIPEndpointConfig& config, const NATEndpointOptions& natOptions);
+    SIPSession(
+        const AsteriskSCF::System::V1::OperationContextPtr&,
+        const Ice::ObjectAdapterPtr&, const SIPEndpointPtr&, const std::string&, const Ice::Identity&, const Ice::Identity&,
+        const Ice::Identity&, const AsteriskSCF::Replication::SIPSessionManager::V1::RTPMediaSessionDict&,
+        const AsteriskSCF::Replication::SIPSessionManager::V1::UDPTLMediaSessionSeq&,
+        const AsteriskSCF::Media::V1::StreamSourceSeq&, const AsteriskSCF::Media::V1::StreamSinkSeq&,
+        const PJSIPManagerPtr& manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
+        const SIPReplicationContextPtr& replicationContext,
+        bool isUAC, const SIPEndpointConfig& config, const NATEndpointOptions& natOptions);
 
 
     void initializePJSIPStructs();
diff --git a/src/SIPStateReplicatorListener.cpp b/src/SIPStateReplicatorListener.cpp
index f54ab58..97a1f48 100644
--- a/src/SIPStateReplicatorListener.cpp
+++ b/src/SIPStateReplicatorListener.cpp
@@ -172,7 +172,7 @@ public:
                     continue;
                 }
 
-                endpoint->removeDefaultSessionListener(defaultListenerItem->listener);
+                endpoint->removeDefaultSessionListener(Operations::createContext(), defaultListenerItem->listener);
             }
             else if ((transferHook = TransferSessionCreationHookStateItemPtr::dynamicCast(*iter)))
             {
@@ -327,7 +327,9 @@ public:
                     // Now that all is well we can create an actual session
                     SIPSessionPtr localSession = endpoint->createSession("", session->sessionObjectId,
                                                                          session->sessionControllerObjectId,
-                                                                         session->mediaSessionObjectId, session->rtpMediaSessions,
+                                                                         session->mediaSessionObjectId, 
+                                                                         session->originalContext,
+                                                                         session->rtpMediaSessions,
                                                                          session->udptlMediaSessions, session->sources, session->sinks);
                     localitem->setSession(localSession);
                 }
@@ -508,7 +510,7 @@ public:
                     continue;
                 }
 
-                endpoint->addDefaultSessionListener(defaultListenerItem->listener);
+                endpoint->addDefaultSessionListener(Operations::createContext(), defaultListenerItem->listener);
             }
             else if (defaultCookieItem  = DefaultSessionCookieItemPtr::dynamicCast((*item)))
             {
diff --git a/src/SIPTelephonyEventSink.cpp b/src/SIPTelephonyEventSink.cpp
index 2b8fb02..7ce69eb 100644
--- a/src/SIPTelephonyEventSink.cpp
+++ b/src/SIPTelephonyEventSink.cpp
@@ -23,8 +23,9 @@ namespace SIPSessionManager
 {
 
 using namespace AsteriskSCF::System::WorkQueue::V1;
-using namespace AsteriskSCF::Helpers;
+using namespace AsteriskSCF::Operations;
 using namespace AsteriskSCF::System::V1;
+using namespace AsteriskSCF::SessionCommunications::V1;
 
 class WriteTelephonyEvent : public SuspendableWork
 {
@@ -168,7 +169,7 @@ private:
 SIPTelephonyEventSink::SIPTelephonyEventSink(const SessionWorkPtr& sessionWork, pjsip_inv_session *inv)
     : mSessionWork(sessionWork), 
       mInv(inv),
-      mOperationContextCache(new OperationContextCache(180))
+      mOperationContextCache(OperationContextCache::create(180))
 { 
 }
 
@@ -210,8 +211,9 @@ private:
 };
 
 void SIPTelephonyEventSink::setSource_async(
-        const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSink_setSourcePtr& cb,
-        const AsteriskSCF::SessionCommunications::V1::TelephonyEventSourcePrx& source,
+        const AMD_TelephonyEventSink_setSourcePtr& cb,
+        const OperationContextPtr& operationContext,
+        const TelephonyEventSourcePrx& source,
         const Ice::Current&)
 {
     mSessionWork->enqueueWork(new SetTelephonyEventSource(cb, this, source));
diff --git a/src/SIPTelephonyEventSink.h b/src/SIPTelephonyEventSink.h
index ec237f0..9502648 100644
--- a/src/SIPTelephonyEventSink.h
+++ b/src/SIPTelephonyEventSink.h
@@ -17,7 +17,7 @@
 #include "SIPSession.h"
 
 #include <AsteriskSCF/WorkQueue/Dispatched.h>
-#include <AsteriskSCF/Helpers/OperationContextCache.h>
+#include <AsteriskSCF/Operations/OperationContextCache.h>
 
 namespace AsteriskSCF
 {
@@ -36,6 +36,7 @@ public:
             const Ice::Current&);
     void setSource_async(
             const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSink_setSourcePtr&,
+            const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
             const AsteriskSCF::SessionCommunications::V1::TelephonyEventSourcePrx& source,
             const Ice::Current&);
 
@@ -48,7 +49,7 @@ public:
             const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSink_getSourcePtr&,
             const Ice::Current&);
 
-    AsteriskSCF::Helpers::OperationContextCachePtr getOperationContextCache();
+    AsteriskSCF::Operations::OperationContextCachePtr getOperationContextCache();
 
     /**
      * Only called from within a queued operation.
@@ -59,7 +60,7 @@ private:
     SessionWorkPtr mSessionWork;
     pjsip_inv_session *mInv;
     AsteriskSCF::SessionCommunications::V1::TelephonyEventSourcePrx mSource;
-    AsteriskSCF::Helpers::OperationContextCachePtr mOperationContextCache;
+    AsteriskSCF::Operations::OperationContextCachePtr mOperationContextCache;
 };
 
 typedef IceUtil::Handle<SIPTelephonyEventSink> SIPTelephonyEventSinkPtr;
diff --git a/src/SIPTelephonyEventSource.cpp b/src/SIPTelephonyEventSource.cpp
index 268ffa7..06c581b 100644
--- a/src/SIPTelephonyEventSource.cpp
+++ b/src/SIPTelephonyEventSource.cpp
@@ -17,9 +17,9 @@
 #include "SIPTelephonyEventSource.h"
 #include <AsteriskSCF/Helpers/ProxyHelper.h>
 #include <AsteriskSCF/System/WorkQueue/WorkQueueIf.h>
-#include <AsteriskSCF/Helpers/OperationContext.h>
+#include <AsteriskSCF/Operations/OperationContext.h>
 
-using namespace AsteriskSCF::Helpers;
+using namespace AsteriskSCF::Operations;
 
 namespace AsteriskSCF
 {
@@ -36,14 +36,14 @@ void SIPTelephonyEventSource::distributeToSinks(const TelephonyEventPtr& event)
     for (TelephonyEventSinkSeq::const_iterator iter = mSinks.begin();
             iter != mSinks.end(); ++iter)
     {
-        OperationContextPtr operationContext = AsteriskSCF::createContext();
+        OperationContextPtr operationContext = AsteriskSCF::Operations::createContext();
         (*iter)->write(operationContext, event);
     }
 }
 
 SIPTelephonyEventSource::SIPTelephonyEventSource(const SessionWorkPtr& sessionWork)
     : mSessionWork(sessionWork),
-      mOperationContextCache(new OperationContextCache(180))
+      mOperationContextCache(OperationContextCache::create(180))
 { 
 }
 
diff --git a/src/SIPTelephonyEventSource.h b/src/SIPTelephonyEventSource.h
index 8797768..9593130 100644
--- a/src/SIPTelephonyEventSource.h
+++ b/src/SIPTelephonyEventSource.h
@@ -18,7 +18,7 @@
 #include "SIPSession.h"
 
 #include <AsteriskSCF/WorkQueue/Dispatched.h>
-#include <AsteriskSCF/Helpers/OperationContextCache.h>
+#include <AsteriskSCF/Operations/OperationContextCache.h>
 
 namespace AsteriskSCF
 {
@@ -56,7 +56,7 @@ public:
     void addSinks(const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq& sinks);
     void removeSinks(const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq& sinks);
 
-    AsteriskSCF::Helpers::OperationContextCachePtr getOperationContextCache();
+    AsteriskSCF::Operations::OperationContextCachePtr getOperationContextCache();
 
     /**
      * Write an event to all the configured sinks.
@@ -67,7 +67,7 @@ public:
 private:
     SessionWorkPtr mSessionWork;
     AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq mSinks;
-    AsteriskSCF::Helpers::OperationContextCachePtr mOperationContextCache;
+    AsteriskSCF::Operations::OperationContextCachePtr mOperationContextCache;
 };
 
 typedef IceUtil::Handle<SIPTelephonyEventSource> SIPTelephonyEventSourcePtr;
diff --git a/src/SIPTransfer.cpp b/src/SIPTransfer.cpp
index b74e542..c23020f 100644
--- a/src/SIPTransfer.cpp
+++ b/src/SIPTransfer.cpp
@@ -20,7 +20,7 @@
 #include <boost/algorithm/string.hpp>
 #include <IceUtil/UUID.h>
 
-#include <AsteriskSCF/Helpers/OperationContext.h>
+#include <AsteriskSCF/Operations/OperationContext.h>
 #include <AsteriskSCF/Logger.h>
 #include <AsteriskSCF/SessionCookies/SIPSessionManager/SIPSessionCookiesIf.h>
 
@@ -203,7 +203,7 @@ void TransferListener::shutdown(const SessionPrx& session)
 {
     try
     {
-        session->removeListener(mListenerProxy);
+        session->removeListener(Operations::createContext(), mListenerProxy);
     }
     catch (const Ice::Exception& ex)
     {
@@ -293,12 +293,13 @@ TransferSessionCreationHook::TransferSessionCreationHook(
 }
 
 HookResult TransferSessionCreationHook::modifySession(
+        const OperationContextPtr& operationContext,
         const SessionCreationHookDataPtr& originalData,
         SessionCreationHookDataPtr& replacementData,
         const Ice::Current&)
 {
     replacementData = new SessionCreationHookData();
-    modifySession(originalData, replacementData);
+    modifySession(operationContext, originalData, replacementData);
     HookResult result;
     result.status = Succeeded;
     //There's no need for this hook to exist after the sesion
@@ -308,8 +309,9 @@ HookResult TransferSessionCreationHook::modifySession(
 }
 
 void TransferSessionCreationHook::modifySession(
-        const SessionCreationHookDataPtr& original,
-        SessionCreationHookDataPtr& replacement)
+    const OperationContextPtr& operationContext,
+    const SessionCreationHookDataPtr& original,
+    SessionCreationHookDataPtr& replacement)
 {
     TransferListenerPtr transferListener = new TransferListener(mAdapter, mDialog, mReferCSeq, mReplicationContext);
     SessionListenerSeq listeners = original->listeners;
@@ -421,7 +423,7 @@ HandleReferOperation::HandleReferOperation(
     mModuleId(moduleId),
     mReferCSeq(tsx->cseq),
     mBlindTransfer(false),
-    mOperationContext(AsteriskSCF::createContext()),
+    mOperationContext(AsteriskSCF::Operations::createContext()),
     mRetryPolicy(5, 500)  {}
 
 HandleReferOperation::~HandleReferOperation()
diff --git a/src/SIPTransfer.h b/src/SIPTransfer.h
index c0e2447..87a730e 100644
--- a/src/SIPTransfer.h
+++ b/src/SIPTransfer.h
@@ -165,9 +165,10 @@ public:
      * 2. It creates a TransferListener to listen to the outbound session.
      */
     AsteriskSCF::System::Hook::V1::HookResult modifySession(
-            const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr& originalData,
-            AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr& replacementData,
-            const Ice::Current&);
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr& originalData,
+        AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr& replacementData,
+        const Ice::Current&);
 
     /**
      * Get the proxy for this object
@@ -188,6 +189,7 @@ private:
      * This is where the "meat" of the method is.
      */
     void modifySession(
+            const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
             const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr& original,
             AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr& replacement);
 

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list