1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
// **********************************************************************
//
// Copyright (c) 2003-2009 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.
//
// **********************************************************************
//
// A dispatch interceptor with special handling for AMD requests
//
class AMDInterceptorI extends InterceptorI implements Ice.DispatchInterceptorAsyncCallback
{
AMDInterceptorI(Ice.Object servant)
{
super(servant);
}
public Ice.DispatchStatus
dispatch(Ice.Request request)
{
Ice.Current current = request.getCurrent();
_lastOperation = current.operation;
if(_lastOperation.equals("amdAddWithRetry"))
{
for(int i = 0; i < 10; ++i)
{
Ice.DispatchInterceptorAsyncCallback cb = new Ice.DispatchInterceptorAsyncCallback()
{
public boolean response(boolean ok)
{
test(ok);
return false;
}
public boolean exception(java.lang.Exception ex)
{
test(ex instanceof Test.RetryException);
return false;
}
};
_lastStatus = _servant.ice_dispatch(request, cb);
test(_lastStatus == Ice.DispatchStatus.DispatchAsync);
}
request.getCurrent().ctx.put("retry", "no");
}
_lastStatus = _servant.ice_dispatch(request, this);
return _lastStatus;
}
public boolean response(boolean ok)
{
setActualStatus(ok ? Ice.DispatchStatus.DispatchOK : Ice.DispatchStatus.DispatchUserException);
return true;
}
public boolean exception(java.lang.Exception ex)
{
setActualStatus(ex);
return true;
}
void
clear()
{
super.clear();
synchronized(this)
{
_actualStatus = null;
_exception = null;
}
}
synchronized void
setActualStatus(Ice.DispatchStatus status)
{
_actualStatus = status;
_exception = null;
}
synchronized void
setActualStatus(java.lang.Exception ex)
{
_exception = ex;
_actualStatus = null;
}
synchronized Ice.DispatchStatus
getActualStatus()
{
return _actualStatus;
}
synchronized java.lang.Exception
getException()
{
return _exception;
}
private Ice.DispatchStatus _actualStatus;
private java.lang.Exception _exception;
}
|