definite point in the execution of a program, usually a call to a method3,advice (Notification): The enhanced processing that AOP performs on a particular pointcut, with Before,after,afterreturning,afterthrowing,around4,pointcut (entry point): Is the connection point with the notification, in the program is mainly embodied in the writing pointcut expression5,AOP Proxy: An object created by the
return value, exception objects together, if the joinpoint is not in the first parameter position, then spring will report a failure to bind the pointcut error At:: 0 formal Unbound in pointcut. For example: public void doafterreturning (Joinpoint jp,string name,object rvt), both Joinpoint and Pointcut method parameters, as well as Pointcut method return, Joinpoint Must be in the first place)5) Get the par
5.3 three key concepts of AOP
Because the concept of AOP is difficult to understand, I first explained the Java Dynamic proxy mechanism, so that readers can gradually understand the idea of AOP.
The key to learning AOP is to understand the idea of AOP and be able to use it.
automatically created by the AOP framework. AOP proxies are divided into two main categories:1. Static proxies: Compile using the commands provided by the AOP framework to generate an AOP proxy class at compile-time, and therefore also known as a compiler-only enhancement; a static proxy is represented by a aspectj.2.
application is running. Spring AOP uses the runtime proxy. The spring container creates all the bean instances through objectfactory and adds a layer of dynamic proxies outside the instance. SPRINGAOP implementation mainly involves the reflection mechanism of proxy.newproxyinstance and Invocationhandler, in the subsequent JVM articles will be described in detail
What are the implementations of AOPCommon implementations of AOP are:
Spring AOP
Aspectj
Guice AOP
Jboss AOP
such asWhat is AOP Alliance, why does Spring
is called Newinterface, the implementation class of the new interface is called Defaultimplementation.The reader can simply interpret introduction as: Copy the interface implementation code from defaultimplementation to Oldclass and add implements Newinterface in the Oldclass class declaration.Finally, there is a concept called aspect, which is used to put together the concepts mentioned above. Aspect itself is meaningless, just as a container exists.Summary: When using
1. Overview of AOP2. Spring AOP principle3. Spring AOP Architecture ParsingI. Overview of AOPJava programmers often write code by using the new object class to describe business features, and then through the object of inheritance, composition, extension and other means to achieve business requirements, which is typica
order in which the Aroundadvice, Beforeadvice, Afteradvice, Returningadvice are executed is determined by the order of the annotations. But sometimes the order is changed, and the result is not changed, possibly because of the cache. I had this problem a few days ago, but I tested it again today and found that the order of execution was consistent with the order of the annotations.Both XML and Annotation annotations can be configured as configuration items to manage
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
Solution:
Http://forum.springsource.org/showthread.php? 85016-illegalargumentexception-with-applicationcontextaware-proxy
Add proxy-target-class = "true" to the configuration file"
Or:
My configuration file is as follows:
Explanation:
Dynamic proxies used by AOP c
Here's an example of a calculator development1 Setting up the environment-with a good spring AOP development environmentImport the following packages:2 Building a class of core processing modulesArithmeticcalculator:Package Com.jeremy.spring.aspectj;public interface Arithmeticcalculator {int add (int i,int j); int sub (int i,int j); int mu L (int i,int j); int di
. * (..)) is the class name or interface name, as in the example above joinpointobjp2.* (..)) Any class in the Pointcutexp package. Within (com.test.spring.aop.pointcutexp.*) POINTCUTEXP package and any class in all child packages. Within ( Com.test.spring.aop.pointcutexp. *) implements all classes of the MyInterface interface, if MyInterface is not an interface, qualifies MyInterface a single class. This (com.test.spring.aop.pointcutexp.MyInterface)
can define a point cut to capture calls to related methods.3 Advice (Notification): Is the execution code for point cut, which is the specific logic for performing "facets".4 aspect (aspect): Point cut and advice are combined as aspect, which resembles a class defined in OOP, but it represents more of a horizontal relationship between objects.5 introduce (introduced): introduces an additional method or property for an object, thus achieving the purpose of modifying the object structure. Some
adapter supports a specific Advice boolean supportsadvice (Advice Advice);
The This interface allows you to extend the Spring AOP framework to handle new advice or advisor types that can fit certain advice types into the methodinterceptor defined by the AOP Federation and in spring These notification types are enab
The previous blog post goes deep into spring (2)In the detailed description of IOC, I briefly introduced IOC in the core content of the Spring framework. Next we will continue to explain another core AOP (Aspect Oriented Programming), that is, Aspect-Oriented Programming.
1. Oop Review
Before introducing AOP, let's rev
In this chapter we go on to the core concept of spring---AOP, which is one of the most central concepts in the spring framework.PS: This blog source download link: http://pan.baidu.com/s/1skZjg7r Password: dn421. What is AOP?AOP (Aspect oriented Programming), commonly referr
as a slice class, it is necessary to initialize this class to join spring's administration when initializing;@Befoe: The logic of the Pointcut (Advice)Execution ...: pointcut syntax
The second type: XML configuration AOP
Instances above: Just different configuration files
The following
xmlns
is the default XML document parsing format, the beans of spring. The address is Http://www.springframe
called crosscutting concerns.2. Slice (aspect)A class is an abstraction of an object's characteristics, and a facet is an abstraction of a crosscutting concern.3, Connection point (Joinpoint)The point that is intercepted, because spring only supports connection points of the method type, so the connection point in spring refers to the method being intercepted, in fact the connection point can also be a fie
Configuration files are very different from the way they are annotated, with a very large number of configuration items.Beans2.xml>Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:context= "Http://www.springframework.org/schema/context"xmlns:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"Xsi:schemalocation= "Http://www.springframework.org/schema/beansHttp://www.springframework.org/schema/beans/spring
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.