First test Spring AOP

xiaoxiao2021-03-06  58

Gigix said that J2EE's world is like a magical forest, countless new concept and Open Source Framework, so that new students are very dizzy. Gigix also said that AOP is becoming the next Holy Cup for software development, huh, I think of the holy cup in the Empire Times, the monks have a way to collect, can improve the spiritual power ...

When you go back to the DAO framework for learning IBATI, it is mentioned that AOP is also supported in Spring Framework, which is also a dynamic proxy method using JDK1.3. But the configuration is more elegant.

I took the simple example, which is based on the org.springframework.aop.methodbeforeadvice interface to implement the interceptor. Now online AOP, the example is always log, fainting. Transaction parcels in iBatis can also be considered a typical usage.

When using Spring's AOP, in addition to Spring.jar, remember to introduce the following packages:

AopAlliance.jar2. ComMMons-logging.jar

3.jakarta-orom-2.0.8.jar This is more concealment because this compile period is not reported.

Then you have to understand the three concepts, you can write a AOP module.

Advice I want to inject the code that is injected within the other class, that is, you pay attention to the aspect;

PointCut defines a location that needs to be injected into the Advice, which is usually a PUBLIC method for a particular class.

Advisor is the PointCut and Advice assembler, you need to indicate two properties in the configuration file: Advice and Pattern, the former is the class you write, do something such as plus log, judgment if there is permission, Pattern You need to intercept the interface and its methods.

Org.chage.springtest.bean theadvisor theadvisor2 < / value> org /. Chage / .springte / .bean / .execute Note that the two blue markers are required, and the previous description can be given to the request bean to add multiple interceptor classes, the order here is more important, which is the order in which the execution is actually called. The method of listening is described later, paying attention to writing. Finally, come to talk nonsense. These two days of learning is very high, absorbing a lot of stuff during the day, lying in the bed in bed, still in the ruminant, I feel like a small role in a rpg game in the monster level, Hoho, and the experience value is rising. Full of joy, enrichment. I am eager to become the next "Maruqi" (Note: Korean movie "Arra Han" said that there is a very high-day practitioner suddenly enlightenment for Maruqi)

转载请注明原文地址:https://www.9cbs.com/read-82745.html

New Post(0)