1. Traditional proxy mode.
package springAOP;
public class SubjectProxy implements IsubJect {
private ISubject subject;
public String Request(){
//add pre-process logicif neccesary
subject.request();
//add post process if neccesary
}
public ISubject getSubject(){
return subject;
}
public void setSubject(ISubject subject){
this.subject=subject;
}
}
The disadvantage of this approach is to create a separate proxy class for each of the objects that are taken away from the object. It is a disaster when there are many functions that require proxies.
2. Dynamic proxies through the Java reflection mechanism are mainly implemented by the Java.lang.reflect.Proxy and Java.lang.reflect.InvocationHandler interfaces. Refer to other examples for details. The invoke function that the interface must implement can be seen as an advice of the AOP species
3. Dynamically generate bytecode via cglib. That is, using cglib to generate subclasses of the class to be proxied and then overwrite the corresponding method and insert the processing logic
Null
Java EE Miscellaneous-How spring AOP is implemented