欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Spring-揭秘书籍--再揭秘

程序员文章站 2022-06-05 23:22:30
...

 

  闲暇无聊 也很久没有 看spring

 

  听说中国巨子写了spring 揭秘 幸福 因为作者 最早在 网上的那几篇我觉得不错;

 

 就china-pub下载了第九章看了看

 

 不看不知道 ,看了吓一跳

 

 怎么这样熟悉,和我讲课一样

 

 在想 我讲课参考的是pro spring

 

 我进行了spring揭秘第九章 与 pro spring对比

 

 感叹!

 

 连类名都一样!StopWatch

 

整个第九章 几乎 完全可以从pro spring 整段看到

 

感觉前2,3章不错,估计是作者用心了

后面就开始 糊弄了

 

 public interface MethodMatcher {
boolean matches(Method m, Class targetClass);
boolean isRuntime();
boolean matches(Method m, Class targetClass, Object[] args);
}
Spring supports two different types of MethodMatcher, static and dynamic, determined by the
return value of isRuntime(). Before using a MethodMatcher, Spring calls isRuntime() to determine
whether the MethodMatcher is static, indicated by a return value of false, or dynamic, indicated by
a return value of true.
For a static pointcut, Spring calls the matches(Method, Class) method of the MethodMatcher
once for every method on the target, caching the return value for subsequent invocations of those
methods. In this way, the check for method applicability is performed only once for each method
and subsequent invocations of a method do not result in an invocation of matches().
With dynamic pointcuts, Spring still performs a static check using matches(Method, Class)
the first time amethod is invoked to determine the overall applicability of a method. However, in
addition to this and provided that the static check returned true, Spring performs a further check
for each invocation of a method using the matches(Method, Class, Object[]) method. In this way,
a dynamic MethodMatcher can determine whether a pointcut should apply based on a particular
invocation of a method, not just on the method itself.
Clearly, static pointcuts—that is, pointcuts whose MethodMatcher is static—perform much
better than dynamic pointcuts, because they avoid the need for an additional check per invocation.
That said, dynamic pointcuts provide a greater level of flexibility for deciding whether to apply advice.
In general, we recommend that you use static pointcuts wherever you can. However, in cases where
your advice adds substantial overhead, it may be wise to avoid any unnecessary invocations of your
advice by using a dynamic pointcut.
In general, you rarely create your own Pointcut implementations from scratch, because Spring
provides abstract base classes for both static and dynamic pointcuts. We look at these base classes,
along with other Pointcut implementations, over the next few sections.

 

这段 我觉得 几乎是翻译 然后口水话一哈!

 

 

 

 简直就是 pro spring的加强翻译版!

 

 不知道如果在大学教授 这个算不算学术造假!

 

 关键这个 揭秘名字有点假

 

 

 建议 买此书前看看pro spring【也有中文版,翻译怎么样不知道,我看的的free版本的英文版】在决定买不买【价格差不多】

 

 

相关标签: Spring