diff options
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 = ""; +} |