Ejemplo n.º 1
0
        /// <summary>
        /// Dispatch event.
        /// </summary>
        public void Run()
        {
            CacheEventArgs evt   = CacheEvent;
            INamedCache    cache = (INamedCache)evt.Cache;

            if (cache.IsActive)
            {
                CacheListenerSupport support = CacheListenerSupport;
                if (support == null)
                {
                    Listeners listeners = Listeners;
                    if (listeners == null)
                    {
                        CacheListenerSupport.Dispatch(evt, CacheListener);
                    }
                    else
                    {
                        CacheListenerSupport.Dispatch(evt, listeners, true);
                    }
                }
                else
                {
                    support.FireEvent(evt, true);
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Dispatch the specified <see cref="CacheEvent"/> to all
 /// <see cref="Support.CacheListenerSupport.ISynchronousListener"/>
 /// objects and add to the specified <see cref="Queue"/> for deferred
 /// execution for standard ones.
 /// </summary>
 /// <param name="evt">
 /// <b>CacheEvent</b> to dispatch.
 /// </param>
 /// <param name="listeners">
 /// <b>Listeners</b> to which the event is dispatched.
 /// </param>
 /// <param name="queue">
 /// <b>Queue</b> to which event will be added.
 /// </param>
 public static void DispatchSafe(CacheEventArgs evt, Listeners listeners, Queue queue)
 {
     if (listeners != null)
     {
         object[] listenersArray = listeners.ListenersArray;
         for (int i = 0, c = listenersArray.Length; i < c; i++)
         {
             ICacheListener listener = (ICacheListener)listenersArray[i];
             if (listener is CacheListenerSupport.ISynchronousListener)
             {
                 try
                 {
                     CacheListenerSupport.Dispatch(evt, listener);
                 }
                 catch (Exception e)
                 {
                     CacheFactory.Log("An exception occured while dispatching synchronous event:" + evt,
                                      CacheFactory.LogLevel.Error);
                     CacheFactory.Log(e, CacheFactory.LogLevel.Error);
                     CacheFactory.Log("(The exception has been logged and execution is continuing.)",
                                      CacheFactory.LogLevel.Error);
                 }
             }
             else
             {
                 queue.Add(Instantiate(evt, listener));
             }
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Execute the action specific to the Message implementation.
        /// </summary>
        public override void Run()
        {
            IChannel channel = Channel;

            Debug.Assert(channel != null);

            RemoteNamedCache cache = (RemoteNamedCache)channel.Receiver;

            Debug.Assert(cache != null);

            if (IsTruncate)
            {
                Listeners listeners = cache.DeactivationListeners;
                if (!listeners.IsEmpty)
                {
                    CacheEventArgs evt = new CacheEventArgs(cache, CacheEventType.Updated, null, null, null, false);
                    CacheListenerSupport.Dispatch(evt, listeners, false);
                }
            }
            else
            {
                cache.BinaryCache.Dispatch(EventType, FilterIds, Key, ValueOld, ValueNew,
                                           IsSynthetic, (int)TransformState, IsPriming);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create RunnableCacheEvent instance with specified <b>CacheEvent</b>
        /// and <b>CacheListenerSupport</b> objects.
        /// </summary>
        /// <param name="evt">
        /// <b>CacheEvent</b> object.
        /// </param>
        /// <param name="support">
        /// <b>CacheListenerSupport</b> object.
        /// </param>
        /// <returns>
        /// <b>RunnableCacheEvent</b> instance.
        /// </returns>
        public static RunnableCacheEvent Instantiate(CacheEventArgs evt, CacheListenerSupport support)
        {
            Debug.Assert(evt != null && support != null);

            RunnableCacheEvent task = new RunnableCacheEvent();

            task.CacheEvent           = evt;
            task.CacheListenerSupport = support;
            return(task);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Return true if the provided <b>ICacheListener</b> should receive this event.
 /// </summary>
 /// <param name="listener">
 /// The <b>ICacheListener</b>.
 /// </param>
 /// <since>12.2.1.2</since>
 public bool ShouldDispatch(ICacheListener listener)
 {
     return(!IsPriming || CacheListenerSupport.IsPrimingListener(listener));
 }