Exemplo n.º 1
0
        /// <summary>
        /// Dispatches work into appropriate handler passing through filters.
        /// The default implementation processes requests on the calling thread and disposes WorkContext deterministically
        /// </summary>
        public virtual void Dispatch(WorkContext work)
        {
            WorkFilter  filter  = null;
            WorkHandler handler = null;

            try
            {
                var filters = m_Filters.OrderedValues.ToList().AsReadOnly();//captures context
                filter = filters.FirstOrDefault();
                if (filter != null)
                {
                    filter.FilterWork(work, filters, 0);
                }
                else
                {
                    InvokeHandler(work, out handler);
                }
            }
            catch (Exception error)
            {
                work.LastError = error;
                HandleException(work, filter, handler, error);
            }
            finally
            {
                try
                {
                    if (!work.NoDefaultAutoClose)
                    {
                        work.Dispose();
                    }
                }
                catch (Exception error)
                {
                    HandleException(null, null, null, error);
                }
            }
        }
Exemplo n.º 2
0
 public FilterPipelineException(WorkFilter filter, Exception inner) : base(inner.Message, inner)
 {
     Filter = filter;
 }
Exemplo n.º 3
0
      /// <summary>
      /// Unregisters filter and returns true if the named instance has been removed
      /// Note: it is possible to call this method on active server that is - remove filters while serving requests
      /// </summary>
      public bool UnRegisterFilter(WorkFilter filter)
      {
        if (filter==null) return false;
        if (filter.Dispatcher!=this.Dispatcher)
          throw new WaveException(StringConsts.WRONG_DISPATCHER_FILTER_UNREGISTRATION_ERROR.Args(filter));

        return m_Filters.Unregister(filter);
      }
Exemplo n.º 4
0
      /// <summary>
      /// Handles processing exception by calling ErrorFilter.HandleException(work, error).
      /// All parameters except ERROR can be null - which indicates error that happened during WorkContext dispose
      /// </summary>
      public virtual void HandleException(WorkContext work, WorkFilter filter, WorkHandler handler, Exception error)
      {
         try
         {
            if (m_InstrumentationEnabled) Interlocked.Increment(ref m_Stat_ServerHandleException);

            //work may be null (when WorkContext is already disposed)
            if (work!=null)
              ErrorFilter.HandleException(work, error, m_ErrorShowDumpMatches, m_ErrorLogMatches);
            else
             Log(MessageType.Error,
                 StringConsts.SERVER_DEFAULT_ERROR_WC_NULL_ERROR + error.ToMessageWithType(),
                 "HandleException()",
                 error);
         }
         catch(Exception error2)
         {
            if (m_LogHandleExceptionErrors)
              try
              {
                Log(MessageType.Error,
                     StringConsts.SERVER_DEFAULT_ERROR_HANDLER_ERROR + error2.ToMessageWithType(),
                     "HandleException.catch()",
                     error2,
                     pars: new
                      {
                        OriginalError = error.ToMessageWithType() 
                      }.ToJSON()
                     );
              }
              catch{}
         }
      }
Exemplo n.º 5
0
 public FilterPipelineException(WorkFilter filter, Exception inner) : base(inner.Message, inner)
 {
   Filter = filter;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Handles processing exception - this implementation uses server-wide behavior.
 /// All parameters except ERROR can be null - which indicates error that happened during WorkContext dispose
 /// </summary>
 public virtual void HandleException(WorkContext work, WorkFilter filter, WorkHandler handler, Exception error)
 {
     ComponentDirector.HandleException(work, filter, handler, error);
 }