In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you what the role of DefaultAopProxyFactory in SpringFramework is, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
For DefaultAopProxyFactory in Springaop, the previous picture is shown in figure 1 below.
Figure 1
DefaultAopProxyFactory is used in Springaop to create a proxy, which determines when to use the JDK or Cglib proxy, as shown in the following List-1:
List-1
Public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {@ Override public AopProxy createAopProxy (AdvisedSupport config) throws AopConfigException {if (config.isOptimize () | | config.isProxyTargetClass () | | hasNoUserSuppliedProxyInterfaces (config)) {Class targetClass = config.getTargetClass () If (targetClass = = null) {throw new AopConfigException ("TargetSource cannot determine target class:" + "Either an interface or a target is required for proxy creation.") } if (targetClass.isInterface () | | Proxy.isProxyClass (targetClass)) {return new JdkDynamicAopProxy (config);} return new ObjenesisCglibAopProxy (config) } else {return new JdkDynamicAopProxy (config);} / * Determine whether the supplied {@ link AdvisedSupport} has only the * {@ link org.springframework.aop.SpringProxy} interface specified * (or no proxy interfaces specified at all). * / private boolean hasNoUserSuppliedProxyInterfaces (AdvisedSupport config) {Class [] ifcs = config.getProxiedInterfaces (); return (ifcs.length = = 0 | (ifcs.length = = 1 & & SpringProxy.class.isAssignableFrom (IFCs [0]));}}
In List-1, if the target object has an interface implementation and proxyTargetClass=true is not set, the JDK proxy is used. In addition, if the target object is an interface or proxy class, use JDK proxy, otherwise use Cglib. Some people say that if ProxyTargetClass=true is set up, JDK proxy will be used, which is normally correct, but not necessarily from the point of view of the source code-- even if ProxyTargetClass=true is set, if the target object class is an interface or proxy class. The JDK proxy is used.
The above content is what is the role of DefaultAopProxyFactory in SpringFramework. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.