Java regular loop view and reverse reference functions and Usage Details, java loop view Usage Details
This example describes the functions and usage of Java regular loop view and reverse reference. We will share this with you for your reference. The details are as follows:
View
1. View Concept
Loop view, also known as zero-width assertions, is short for assertions.
The highlighted position (front or back) of the surround view must match the
@ Componentpublic class SystemLogAspect {// inject Service to save the Log Database @ Resource // here I use resource annotation, generally, @ Autowired is used. If they have time, I will write private SystemLogService systemLogService in my blog; private static final Logger logger = LoggerFactory. getLogger (SystemLogAspect. class); // Controller layer cut point @ Pointcut ("execution (* com. gcx. controller .. *. *(..)) ") public void controllerAspect () {}/ *** pre-notification is used to in
Spring framework study Note 5: SpringAOP example, springspringaop
1. Import package:
Import the two packages in spring
Import other packages (download them online ):
2. Prepare the target object:
Package service; public class UserServiceImpl implements UserService {@ Override public void save () {System. out. println ("save User! ") ;}@ Override public void delete () {System. out. println (" delete a user! ") ;}@ Override public void update () {System. out. println (" update user! ") ;}@ Ove
object, that is, the final enhanced object is generated by the AOP framework, not new by developers. The solution is to implement a custom class loader and enhance a class when it is loaded. JBoss implements the AOP function in this way.(4) Code GenerationUse tools to generate new code based on existing code. You can add any cross-cutting code to implement AOP.(5) Language extensionsThe constructor and attribute assignment operations can be enhanced. AspectJ is a common Java Language extension
after return (After returning advice): At a connection point (join point) after normal completion of the notification: for example, a method does not throw any exceptions, normal return. notifies when an exception is thrown (after throwing advice): the notification that is executed when the method throws an unexpected exit. Notification (after (finally) advice): A notification that is executed when a connection point exits (whether it is a normal return or an abnormal exit).
(finally) advice): A notification that is executed when a connection point exits (whether it is a normal return or an unexpected exit).
Surround notification (Around Advice): A notification that encloses a connection point, such as a method call. This is the most powerful type of notification. Surround notifications can accomplish custom behavior before and after a method call. It also chooses whether
completed normally, excluding the case where an exception was thrown. The XML is declared using the D Surround Notification (Around advice): A notification that surrounds a connection point, similar to the Dofilter method of the filter in the servlet specification in the Web. You can customize the behavior before and after the call to the method, or you can choose not to execute. The XML is declared using the E-Notification After an exception is thro
pure Java AOP frameworks, completes weaving at run time. Notification method: 1. Pre-notification (before advice): A notification that is executed before a connection point, but this notification does not block the execution process before the connection point (unless it throws an exception). 2. Post notification (after returning advice): Notification performed after a connection point is completed: For example, a method does not throw any exceptions and returns normally. 3. Exception notificat
addition to the pointcut expression, which can be specified by the parameter nameTo access the exception object thrown in the target method(4) After: Does the enhancement after the target method is complete, regardless of the target method when it is completed successfully. @After can specify a pointcut expression(5) Around: Surround notification, before and after the target method is done to enhance processing,
before the method:@AfterThrowing (value= "Execution (matching target method)", throwing= "variable name")(3) Add the exception type variable name (which corresponds to the variable name in the annotation) in the parameter of the method to access the exception thrown by the target method within the exception notification method
Order of execution of the four notifications above
Back-to-front notification with exception--
Surround
1. Using ASPECTJ for AOP development
to use the Aspectjs procedure:
1) Add Class Library: Aspectjrt.jar and Aspectjweaver.jar
2) Add an AOP schema.
3) Defining XML Elements:
4) Write the Java class and use the @aspect annotation as the notification
ASPECTJ supports 5 types of notification annotations:
@Before: Pre-notification , executed before method execution
@After: Post notification , executed after method execution
@AfterReturning: Returns a notification that executes after the method retur
After the Fedora9 system is installed, the system cannot hear the sound, and the problem cannot be solved. The system only finds a method for help. Solution: Enable the sound preference, select surround, and enable surround to enable the sound switch to hear a sound.
After installing the Fedora 9 system, I couldn't hear the sound, and I couldn't do it well. I only needed help. I found a method.
Solution:
.8. Special characters: Copyright symbol: copy, small e:eacute,9.URL (Uniform Resource Locator) Uniform Resource Locator. The first part becomes the pattern. The mode has HTTP and FTP (file Transfer Protocol) files Transfer protocol and so on. The second part is the name of the host where the file resides. Part Three pathMode of HTTPMode hostname Path" http :// www.site.com / tofu/index.html "Mode of FTPMode hostname Path" FTP ://Ftp.site.com/pub/index.pdf"URLs for e-mail addresses include mailt
is thrown (after throwing advice): the notification that is executed when the method throws an exception exits.
Post notification (after (finally) advice): A notification that is executed when a connection point exits (whether it is a normal return or an unexpected exit).
Surround notification (Around Advice): A notification that encloses a connection point, such as a method call. This is the most powerful type of notification.
talk about some very important dry goods!
AspectJ expression:Syntax: execution (expression)Through the execution function, you can define the cut point method.
Execution (
For example
Execution (public ** (...) matches all public methods
Execution (* cn. study. dao... * (...) matches all class methods in the specified package, excluding sub-packages.
Execution (* cn. study. dao... * (...)... * indicates the package and all classes under the Child package.
Execution (* cn. study. service.
examples that you'll be familiar with. I'll also show you a new display value that you might need when you understand BFC.
What is BFC
A simple floating example can understand the behavior of BFC, in the following example we create a box element that wraps a piece of text and a floating picture. If the text is more than the text will surround the entire floating picture, box's border will wrap them all up.
. outer { border:5px dotted rgb (21
Spring AOP (aspect-oriented programming) framework for crosscutting concerns in modularity. Simply put, it's just an interceptor that intercepts some process, for example, when a method executes, Spring AOP can hijack an execution method, adding additional functionality before or after the method executes. In spring AOP, there are 4 types of notification (advices) support:
Notification (Advice) before-the method is run before execution
After the notification (Advice) is returned – a
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.