Ejemplo n.º 1
0
 /// <summary>
 /// Dispatches an invocation to a servant. This method is used by dispatch interceptors to forward an invocation
 /// to a servant (or to another interceptor).
 /// </summary>
 /// <param name="request">The details of the invocation.</param>
 /// <param name="cb">The callback object for asynchchronous dispatch. For synchronous dispatch, the
 /// callback object must be null.</param>
 /// <returns>The dispatch status for the operation.</returns>
 public virtual DispatchStatus ice_dispatch(Request request, DispatchInterceptorAsyncCallback cb)
 {
     if (request.isCollocated())
     {
         return(collocDispatch__((IceInternal.Direct)request));
     }
     else
     {
         IceInternal.Incoming inc = (IceInternal.Incoming)request;
         if (cb != null)
         {
             inc.push(cb);
         }
         try
         {
             inc.startOver(); // may raise ResponseSentException
             return(dispatch__(inc, inc.getCurrent()));
         }
         finally
         {
             if (cb != null)
             {
                 inc.pop();
             }
         }
     }
 }
Ejemplo n.º 2
0
 public virtual Ice.DispatchStatus ice_dispatch(Ice.Request request, Ice.DispatchInterceptorAsyncCallback cb)
 {
     IceInternal.Incoming inc = (IceInternal.Incoming)request;
     if (cb != null)
     {
         inc.push(cb);
     }
     try
     {
         inc.startOver();
         return(dispatch__(inc, inc.getCurrent()));
     }
     finally
     {
         if (cb != null)
         {
             inc.pop();
         }
     }
 }
Ejemplo n.º 3
0
            Dispatch(IceInternal.Incoming incoming, Current current)
            {
                try
                {
                    incoming.startOver();
                    string context;
                    if (current.Context.TryGetValue("raiseBeforeDispatch", out context))
                    {
                        if (context.Equals("user"))
                        {
                            throw new Test.InvalidInputException();
                        }
                        else if (context.Equals("notExist"))
                        {
                            throw new Ice.ObjectNotExistException();
                        }
                        else if (context.Equals("system"))
                        {
                            throw new MySystemException();
                        }
                    }

                    lastOperation_ = current.Operation;

                    if (lastOperation_.Equals("addWithRetry") || lastOperation_.Equals("amdAddWithRetry"))
                    {
                        for (int i = 0; i < 10; ++i)
                        {
                            try
                            {
                                var t = traits_.Dispatch(servant_, incoming, current);
                                if (t != null && t.IsFaulted)
                                {
                                    throw t.Exception.InnerException;
                                }
                                else
                                {
                                    test(false);
                                }
                            }
                            catch (RetryException)
                            {
                                //
                                // Expected, retry
                                //
                            }
                        }

                        current.Context["retry"] = "no";
                    }
                    else if (current.Context.TryGetValue("retry", out context) && context.Equals("yes"))
                    {
                        //
                        // Retry the dispatch to ensure that abandoning the result of the dispatch
                        // works fine and is thread-safe
                        //
                        traits_.Dispatch(servant_, incoming, current);
                        traits_.Dispatch(servant_, incoming, current);
                    }

                    var task = traits_.Dispatch(servant_, incoming, current);
                    lastStatus_ = task != null;

                    if (current.Context.TryGetValue("raiseAfterDispatch", out context))
                    {
                        if (context.Equals("user"))
                        {
                            throw new Test.InvalidInputException();
                        }
                        else if (context.Equals("notExist"))
                        {
                            throw new Ice.ObjectNotExistException();
                        }
                        else if (context.Equals("system"))
                        {
                            throw new MySystemException();
                        }
                    }

                    return(task);
                }
                catch (Exception)
                {
                    //
                    // If the input parameters weren't read, make sure we skip them here. It's needed to read the
                    // encoding version used by the client to eventually marshal the user exception. It's also needed
                    // if we dispatch a batch oneway request to read the next batch request.
                    //
                    if (current.Encoding == null || (current.Encoding.major == 0 && current.Encoding.minor == 0))
                    {
                        incoming.skipReadParams();
                    }
                    throw;
                }
            }