what is aspect-oriented programming? Read some articles, I do not know whether the article is not clear or I do not understand clearly, read or do not know what it is useful and how to use, please say again to the boss.
what is aspect-oriented programming? Read some articles, I do not know whether the article is not clear or I do not understand clearly, read or do not know what it is useful and how to use, please say again to the boss.
about my understanding of
1.oop, all the required classes are written before compilation, and the code can't be moved at run time.
2.aop refers to dynamically generating code into your class during compilation and execution.
an analogy (just pointing out the difference)
oop
aop
in short, creating a code snippet that can generate code is called a tangent, and creating a code snippet that can be cut into the code is called a pointcut. Taken together, it's called aspect-oriented
advantage: the code is more concise, and if you add time control, it will become more flexible.
disadvantage: I think it is not mature yet. If aop does not have a strict specification, its readability will be very poor and it will be difficult to maintain.
like AOP
in springboot
for example, now I have a Web project, and now I want to type log.info
when a user requests each path, and now my approach is to add log.info ("..")
to each method, which is a lot of work
, or I use @ RequestMapping ()
as a pointcut, write a piece of code, cut into it, and don't have to change the original. Code reuse is realized, which reduces the degree of coupling between various business logic
imagine that there are functional modules, layer by layer, data is transmitted from top to bottom, and modules with the same function are placed on the same layer. Now I have made a very thin section to insert the gap between layers. Pull out
at any time when you don't need it. https://www.cnblogs.com/liuru.
Baidu aop, or surf the Internet to find an example. Or find a back end to ask
take a look at this https://codeshelper.com/a/11.
burying points / piling / inserting holes, so simply understand.
treats similar points as aop, for example, if I insert a row of eyes in a wild area, but the opposite widow dares not come over, then this row of eyes is like a wall.
logging I can embed the output in each method, but I can also reflect and inject the logging code into these methods (actually proxies), so that I can create a wheel of non-intrusive burying points, such as spring aop
Previous: Using firebase in weex
Next: A situation in which an object has a key value of undefined is encountered in a deep copy.
expectation: define an annotation yourself using SpringBoot + AOP, and intercept the method of placing annotations through AOP. has a problem: it can be intercepted when annotations are placed on methods with controller entry annotations such as GetMap...
@Pointcut("execution(public * com.hellobj.tool.data.megersch.controller.Result.*(..))") public void webLog(){} @Before("webLog()") public void doBefore(JoinPoint joinPoint) throws Throwable { LOGGER.info(&quo...
SpringBoot uses AOP to intercept the JSON of the request to obtain object parameters for example Entity class: public class Company { private Integer id; private String companyName; private Integer companyState; public Company(Int...
The project uses springboot to provide interface services. The original business is: all data submitted by consumers are all encrypted information , for example: 127.0.0.1 serviceencrypted data1 = ciphertext & data2= ciphertext & data3= ciphertext ...
comparison of advantages and disadvantages of aop framework aspectj, asm and javassist recently, I have been working on the development of java and aop, and have come into contact with the three frameworks of aspectj, asm and javassist. Have any great...
springboot project, and then write a custom aop, to put aop into the tools project, and then how the springboot project uses the aop?? of the tools project At present, the corresponding notes are used, but there is no effect, ask for the answer! ...
Maven project structure is as follows pom.xml and SpringBoot related content <parent> <groupId>org.springframework.boot< groupId> <artifactId>spring-boot-starter-parent< artifactId> <version>1.5.8.REL...
the name of the Spring AOP interceptor notification is as follows: MethodBeforeAdviceInterceptor () AspectJAfterThrowingAdvice () AspectJAfterAdvice () AfterReturningAdviceInterceptor () I would like to ask you, why do some end in Interceptor and o...
I want to use facets to manage all methods with the first parameter HttpServletRequest request under the controller package. Here is my code: @Pointcut("execution(* com.belfry.bequank.controller.*.*(..))&&args(request,..)") public voi...
input parameter format is JSON instead of ordinary string, such as: { "REQUEST": { "page": "1", "rows":"20" } } the JSON input parameter can be parsed th...
use two annotations on one method, and use two different sections to deal with the values in the two annotations respectively. The join point method is as follows: @CacheFetch(cacheName = CacheManager.CACHE_DATASOURCE_INFO) @TenantAware(method = Operat...
wants to monitor all methods that enter controller, but the aop class written by myself doesn t work tried to do it using the profile method and the annotation method, but did not enter the method. related codes package com.detain.system.aop; imp...
problem description writes a section to intercept methods that contain specified annotations. The runtime finds that if a subclass An inherits the abstract parent class B and implements the parent s abstract method, adding a specified comment to the...
such as the title. Ask the boss to answer. ...
< H2 > the code is as follows < H2 > Thank you very much! ...