How to distinguish between read and write separated data sources in mysql
How to distinguish between read-write separation data sources in mysql? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
The use of @ Aspect in AOP to monitor the execution of the program
The AOP annotations used by Spring are divided into three levels:
The prerequisite is to release it in xml.
1. @ Aspect is placed on top of the class header, using the class as an aspect.
2. @ Pointcut is placed on the method header to define a pointcut expression that can be referenced by other methods.
3. 5 kinds of notices.
3.1, @ Before, pre-notification, put on the method header.
3.2, @ After, post [finally] notification, and put it on the method header.
3.3. @ AfterReturning, followed by [try] notification, put on the method header, and use returning to refer to the method return value.
3.4. @ AfterThrowing, followed by [catch] notification, put on the method header, and use throwing to refer to the thrown exception.
3. 5, @ Around, surround the notification and put it on the head of the method, which determines whether the actual method executes or not and must have a return value.
@ Component
@ Aspect
Public class LogAspect {
/ * *
* the name that defines Pointcut,Pointcut is simplePointcut. This method cannot have a return value, it is just an indication.
, /
@ Pointcut ("execution (public * com.service.impl..*.* (..)")
Public void recordLog () {
}
@ AfterReturning (pointcut = "recordLog ()")
Public void simpleAdvice () {
LogUtil.info ("AOP post-processing succeeded")
}
@ Around ("recordLog ()")
Public Object aroundLogCalls (ProceedingJoinPoint jp) throws Throwable {
LogUtil.info ("normal operation")
Return jp.proceed ()
}
@ Before ("recordLog ()")
Public void before (JoinPoint jp) {
String className = jp.getThis () .toString ()
String methodName = jp.getSignature () .getName (); / / get the method name
LogUtil.info ("at:" + className + "call" + methodName + "() method-start!")
Object [] args = jp.getArgs (); / / get the parameter list
If (args.length