summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/Outgoing.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2012-07-27 13:07:32 +0200
committerBenoit Foucher <benoit@zeroc.com>2012-07-27 13:07:32 +0200
commit901fd391336495286219a8610d5787113a816963 (patch)
tree850c6081489f45d6f6b7a27590b91fb5c03a8bbd /cpp/src/Ice/Outgoing.cpp
parentMore work (diff)
downloadice-901fd391336495286219a8610d5787113a816963.tar.bz2
ice-901fd391336495286219a8610d5787113a816963.tar.xz
ice-901fd391336495286219a8610d5787113a816963.zip
Before RequestObserver change
Diffstat (limited to 'cpp/src/Ice/Outgoing.cpp')
-rw-r--r--cpp/src/Ice/Outgoing.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp
index e922fb30486..e09669dd8f7 100644
--- a/cpp/src/Ice/Outgoing.cpp
+++ b/cpp/src/Ice/Outgoing.cpp
@@ -17,6 +17,7 @@
#include <Ice/Protocol.h>
#include <Ice/Instance.h>
#include <Ice/ReplyStatus.h>
+#include <Ice/Observer.h>
using namespace std;
using namespace Ice;
@@ -89,6 +90,30 @@ IceInternal::Outgoing::Outgoing(RequestHandler* handler, const string& operation
_os(handler->getReference()->getInstance().get(), Ice::currentProtocolEncoding),
_sent(false)
{
+ const ObserverResolverPtr& resolver = _handler->getReference()->getInstance()->initializationData().observerResolver;
+ if(resolver)
+ {
+ try
+ {
+ _observer = resolver->getInvocationObserver(handler->getProxy(),
+ operation,
+ *context,
+ handler->getConnection(false));
+ }
+ catch(const Ice::LocalException&)
+ {
+ //
+ // Ignore: can be raised by getConnection is no connection could be obtained,
+ // the request will be re-tried in this case.
+ //
+ }
+
+ if(_observer)
+ {
+ _observer->attach();
+ }
+ }
+
switch(_handler->getReference()->getMode())
{
case Reference::ModeTwoway:
@@ -158,6 +183,14 @@ IceInternal::Outgoing::Outgoing(RequestHandler* handler, const string& operation
}
}
+Outgoing::~Outgoing()
+{
+ if(_observer)
+ {
+ _observer->detach();
+ }
+}
+
bool
IceInternal::Outgoing::invoke()
{
@@ -368,12 +401,20 @@ IceInternal::Outgoing::finished(BasicStream& is)
{
case replyOK:
{
+ if(_observer)
+ {
+ _observer->responseOK();
+ }
_state = StateOK; // The state must be set last, in case there is an exception.
break;
}
case replyUserException:
{
+ if(_observer)
+ {
+ _observer->responseUserException();
+ }
_state = StateUserException; // The state must be set last, in case there is an exception.
break;
}
@@ -382,6 +423,11 @@ IceInternal::Outgoing::finished(BasicStream& is)
case replyFacetNotExist:
case replyOperationNotExist:
{
+ if(_observer)
+ {
+ _observer->responseRequestFailedException();
+ }
+
//
// Don't read the exception members directly into the
// exception. Otherwise if reading fails and raises an
@@ -450,6 +496,11 @@ IceInternal::Outgoing::finished(BasicStream& is)
case replyUnknownLocalException:
case replyUnknownUserException:
{
+ if(_observer)
+ {
+ _observer->responseUnknownException();
+ }
+
//
// Don't read the exception members directly into the
// exception. Otherwise if reading fails and raises an
@@ -496,6 +547,10 @@ IceInternal::Outgoing::finished(BasicStream& is)
default:
{
+ if(_observer)
+ {
+ _observer->responseUnknownException();
+ }
_exception.reset(new UnknownReplyStatusException(__FILE__, __LINE__));
_state = StateLocalException;
break;
@@ -521,12 +576,20 @@ IceInternal::Outgoing::throwUserException()
{
try
{
+ if(_observer)
+ {
+ _watch.start();
+ }
_is.startReadEncaps();
_is.throwException();
}
catch(const Ice::UserException&)
{
_is.endReadEncaps();
+ if(_observer)
+ {
+ _observer->unmarshalTime(_watch.stop());
+ }
throw;
}
}