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/test/Ice/interceptor/InterceptorI.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/test/Ice/interceptor/InterceptorI.cpp')
-rw-r--r-- | cpp/test/Ice/interceptor/InterceptorI.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/cpp/test/Ice/interceptor/InterceptorI.cpp b/cpp/test/Ice/interceptor/InterceptorI.cpp new file mode 100644 index 00000000000..19150e5bbfa --- /dev/null +++ b/cpp/test/Ice/interceptor/InterceptorI.cpp @@ -0,0 +1,68 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <InterceptorI.h> +#include <Test.h> +#include <TestCommon.h> + +InterceptorI::InterceptorI(const Ice::ObjectPtr& servant) : + _servant(servant), + _lastStatus(IceInternal::DispatchAsync) +{ +} + + +IceInternal::DispatchStatus +InterceptorI::dispatch(Ice::Request& request) +{ + Ice::Current& current = const_cast<Ice::Current&>(request.getCurrent()); + _lastOperation = current.operation; + + if(_lastOperation == "addWithRetry") + { + for(int i = 0; i < 10; ++i) + { + try + { + _servant->ice_dispatch(request); + test(false); + } + catch(const Test::RetryException&) + { + // + // Expected, retry + // + } + } + + current.ctx["retry"] = "no"; + } + + _lastStatus = _servant->ice_dispatch(request); + return _lastStatus; +} + +IceInternal::DispatchStatus +InterceptorI::getLastStatus() const +{ + return _lastStatus; +} + +const std::string& +InterceptorI::getLastOperation() const +{ + return _lastOperation; +} + +void +InterceptorI::clear() +{ + _lastStatus = IceInternal::DispatchAsync; + _lastOperation = ""; +} |