diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-05-16 19:14:39 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-05-16 19:14:39 +0000 |
commit | 93349d8446a3847d38c8bed0cefb71cdecb0570a (patch) | |
tree | 1426813a2e221e92dc7ce56c36d4aba240ed0c96 /cpp/src/Ice/Object.cpp | |
parent | Bug 1996 - multihomed hostnames (diff) | |
download | ice-93349d8446a3847d38c8bed0cefb71cdecb0570a.tar.bz2 ice-93349d8446a3847d38c8bed0cefb71cdecb0570a.tar.xz ice-93349d8446a3847d38c8bed0cefb71cdecb0570a.zip |
New Dispatch Interceptor (see bug #2126)
Diffstat (limited to 'cpp/src/Ice/Object.cpp')
-rw-r--r-- | cpp/src/Ice/Object.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index fc789ea83ab..18bc62cf633 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -10,6 +10,8 @@ #include <Ice/Object.h> #include <Ice/Incoming.h> #include <Ice/IncomingAsync.h> +#include <Ice/IncomingRequest.h> +#include <Ice/Direct.h> #include <Ice/LocalException.h> #include <Ice/Stream.h> @@ -147,6 +149,50 @@ string Ice::Object::__all[] = "ice_ping" }; + +DispatchStatus +Ice::Object::ice_dispatch(Request& request, const DispatchInterceptorAsyncCallbackPtr& cb) +{ + class PushCb + { + public: + PushCb(IceInternal::Incoming& in, const DispatchInterceptorAsyncCallbackPtr& cb) : + _in(in), + _cb(cb) + { + if(_cb != 0) + { + _in.push(_cb); + } + } + + ~PushCb() + { + if(_cb != 0) + { + _in.pop(); + } + } + private: + IceInternal::Incoming& _in; + const DispatchInterceptorAsyncCallbackPtr& _cb; + }; + + + if(request.isCollocated()) + { + return __collocDispatch(dynamic_cast<IceInternal::Direct&>(request)); + } + else + { + IceInternal::Incoming& in = dynamic_cast<IceInternal::IncomingRequest&>(request)._in; + + PushCb pusbCb(in, cb); + in.startOver(); // may raise ResponseSentException + return __dispatch(in, in.getCurrent()); + } +} + DispatchStatus Ice::Object::__dispatch(Incoming& in, const Current& current) { @@ -182,6 +228,12 @@ Ice::Object::__dispatch(Incoming& in, const Current& current) return DispatchOperationNotExist; } +DispatchStatus +Ice::Object::__collocDispatch(IceInternal::Direct& request) +{ + return request.run(this); +} + void Ice::Object::__write(BasicStream* __os) const { |