/// <summary> /// Gets the list of <see cref="AopAlliance.Intercept.IInterceptor"/> and /// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/> /// instances for the supplied <paramref name="proxy"/>. /// </summary> /// <param name="advised">The proxy configuration object.</param> /// <param name="proxy">The object proxy.</param> /// <param name="method"> /// The method for which the interceptors are to be evaluated. /// </param> /// <param name="targetType"> /// The <see cref="System.Type"/> of the target object. /// </param> /// <returns> /// The list of <see cref="AopAlliance.Intercept.IInterceptor"/> and /// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/> /// instances for the supplied <paramref name="proxy"/>. /// </returns> public IList GetInterceptors(IAdvised advised, object proxy, MethodInfo method, Type targetType) { IList cached = (IList)this.methodCache[method]; if (cached == null) { // recalculate... cached = AdvisorChainFactoryUtils.CalculateInterceptors(advised, proxy, method, targetType); this.methodCache[method] = cached; } return(cached); }
/// <summary> /// Gets the list of <see cref="AopAlliance.Intercept.IInterceptor"/> and /// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/> /// instances for the supplied <paramref name="proxy"/>. /// </summary> /// <param name="advised">The proxy configuration object.</param> /// <param name="proxy">The object proxy.</param> /// <param name="method"> /// The method for which the interceptors are to be evaluated. /// </param> /// <param name="targetType"> /// The <see cref="System.Type"/> of the target object. /// </param> /// <returns> /// The list of <see cref="AopAlliance.Intercept.IInterceptor"/> and /// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/> /// instances for the supplied <paramref name="proxy"/>. /// </returns> public IList <object> GetInterceptors(IAdvised advised, object proxy, MethodInfo method, Type targetType) { IList <object> cached; if (!this.methodCache.TryGetValue(method, out cached)) { // recalculate... cached = AdvisorChainFactoryUtils.CalculateInterceptors(advised, proxy, method, targetType); this.methodCache[method] = cached; } return(cached); }
/// <summary> /// Gets the list of <see cref="AopAlliance.Intercept.IInterceptor"/> and /// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/> /// instances for the supplied <paramref name="proxy"/>. /// </summary> /// <param name="advised">The proxy configuration object.</param> /// <param name="proxy">The object proxy.</param> /// <param name="method"> /// The method for which the interceptors are to be evaluated. /// </param> /// <param name="targetType"> /// The <see cref="System.Type"/> of the target object. /// </param> /// <returns> /// The list of <see cref="AopAlliance.Intercept.IInterceptor"/> and /// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/> /// instances for the supplied <paramref name="proxy"/>. /// </returns> public IList <object> GetInterceptors(IAdvised advised, object proxy, MethodInfo method, Type targetType) { if (!methodCache.TryGetValue(method, out var interceptors)) { lock (methodCache) { if (!methodCache.TryGetValue(method, out interceptors)) { interceptors = AdvisorChainFactoryUtils.CalculateInterceptors(advised, proxy, method, targetType); methodCache[method] = interceptors; } } } return(interceptors); }
/// <summary> /// Gets the list of <see cref="AopAlliance.Intercept.IInterceptor"/> and /// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/> /// instances for the supplied <paramref name="proxy"/>. /// </summary> /// <param name="advised">The proxy configuration object.</param> /// <param name="proxy">The object proxy.</param> /// <param name="method"> /// The method for which the interceptors are to be evaluated. /// </param> /// <param name="targetType"> /// The <see cref="System.Type"/> of the target object. /// </param> /// <returns> /// The list of <see cref="AopAlliance.Intercept.IInterceptor"/> and /// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/> /// instances for the supplied <paramref name="proxy"/>. /// </returns> public IList <object> GetInterceptors(IAdvised advised, object proxy, MethodInfo method, Type targetType) { #if !NET_4_0 IList <object> cached; cacheLock.EnterReadLock(); try { if (this.methodCache.TryGetValue(method, out cached)) { return(cached); } } finally { cacheLock.ExitReadLock(); } // Apparently not in the cache - calculate the value outside of any locks then enter upgradeable read lock and check again IList <object> calculated = AdvisorChainFactoryUtils.CalculateInterceptors(advised, proxy, method, targetType); cacheLock.EnterUpgradeableReadLock(); try { if (!this.methodCache.TryGetValue(method, out cached)) { // Still not in the cache - enter write lock and add the pre-calculated value cacheLock.EnterWriteLock(); try { cached = calculated; this.methodCache[method] = cached; } finally { cacheLock.ExitWriteLock(); } } } finally { cacheLock.ExitUpgradeableReadLock(); } return(cached); #else return(methodCache.GetOrAdd(method, m => AdvisorChainFactoryUtils.CalculateInterceptors(advised, proxy, m, targetType))); #endif }
/// <summary> /// Gets the list of <see cref="AopAlliance.Intercept.IInterceptor"/> and /// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/> /// instances for the supplied <paramref name="proxy"/>. /// </summary> /// <param name="advised">The proxy configuration object.</param> /// <param name="proxy">The object proxy.</param> /// <param name="method"> /// The method for which the interceptors are to be evaluated. /// </param> /// <param name="targetType"> /// The <see cref="System.Type"/> of the target object. /// </param> /// <returns> /// The list of <see cref="AopAlliance.Intercept.IInterceptor"/> and /// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/> /// instances for the supplied <paramref name="proxy"/>. /// </returns> public IList <object> GetInterceptors(IAdvised advised, object proxy, MethodInfo method, Type targetType) { return(methodCache.GetOrAdd(method, m => AdvisorChainFactoryUtils.CalculateInterceptors(advised, proxy, m, targetType))); }