entire process:In this example, the Testweaver class and the Testannotationaspect class are just a simple class, and the Testannotationaspect class labels the @aspectj annotations,This makes it possible for a subsequent third-party program to detect whether the class that owns the @aspect is a slice class.Second, the Dobefore () in the Testannotationaspect class is labeled @before, which means pre-enhancement. The following execution () uses a method of the Pointcut function to match the patter
+behavior.class.php . Note that the class must contain the Run method, and the default run method is the Ingress method.Code contentnamespace Common\Behavior;use Think\Behavior;class TolldetectBehavior extends Behavior{ //方法名必须为run,作为入口文件 public function run($param){ echo "Hello "; }}
Register label (Mount)There are two types of label registration methods in thinkphp, one is manual registration and one is auto-registration.
The following is the source code for the manual registrat
Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run (Springjunit4classrunner.java:191) at Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (Junit4testreference.java:86) at Org.eclipse.jdt.internal.junit.runner.TestExecution.run (Testexecution.java:38) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (Remotetestrunner.java:459) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (Remotetestrunner.java:678) at Org.eclipse.jdt.internal
class.
If a is to call the C function, but C is the member class of B, how should it be designed? (Dimitri)
How to design the class, can do only add code, without modifying the code, what experience (open closed)Solved by design mode.
Computer
Computer networks: TCP/IP, HTTPCDN, SPDY
Computer security: RSA, AES, DES
Operating systems: threads, processes, stacks, deadlocks, scheduling algorithms
New features and Technologies for iOS
IOS7 uidynami
.SpringJUnit4ClassRunner;ImportCom.zte.sound.service.bean.CompactDisc;ImportOrg.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;Importconfigs. Cdplayerconfig; the @RunWith (Springjunit4classrunner.class)//Spring's JUnit test, which creates the spring application context at the beginning of the test@ContextConfiguration (Classes=cdplayerconfig.class)//indicates that the configuration class Public classSpringTest1 {//Automatic Assembly@AutowiredPrivateCompactdisc sp;
custom in the bean ID XML that you need to cross-cut because SPRINGAOPIM implements the SPRINGAOP interface, so the cast must be SPRINGAOP bean.show () with the parent class; Call Method }} Final display ResultsOctober 12:08:04 Morning org.springframework.context.support.AbstractApplicationContext Preparerefresh Info: refreshing org[email protected]6bb9db06:startup Date [Sun Oct 00:08:04 CST]; root of the context hierarchy October 15, 12:08:04 Morning Org.springframework.beans.factory.xml.
= Pjp.proceed ();//Call the target method System.out.println ("This is part of the surround notification!"); return proceed;} Exception notification public void Afterexception () {System.out.println ("Something's wrong!!!!!");} Post-notification public void after () {System.out.println ("This is a post-notification (an exception will also be called)!");}}4) configuration for weaving, weaving notifications into target objects5) Test classpublic class Testdemo { @Test public void func () {
- Aop:aroundPointcut-ref= "Performance"Method= "Aroundperformance"/> define a tangent point for the parameter that exists for the notification - Aop:pointcutexpression= "executionexecution (* * Chapter4.practice1.Performance.play (String)) andArgs (gamename) "ID= "Game"/> introducing new features for audience - aop:declare-parentstypes-matching= "chapter4.practice1.audience+"Implement-interface= "Chapter4.practice2.Enabl
inside the class, and spring cannot intercept the method call.That's one step further, and spring provides us with AOP, aspect-oriented functionality. His principle and the principle of asynchronous annotations are similar:When spring starts the container, it scans the class defined by the slice. When these classes are injected, the surrogate class is injected, and when you call these methods, it is essentially the proxy class that is called.By executing the corresponding method of the parent c
Org.aspectj.lang.joinpoint;import Org.aspectj.lang.ProceedingJoinPoint; Import Org.aspectj.lang.annotation.after;import Org.aspectj.lang.annotation.afterreturning;import Org.aspectj.lang.annotation.afterthrowing;import Org.aspectj.lang.annotation.around;import Org.aspectj.lang.annotation.aspect;import Org.aspectj.lang.annotation.before;import org.springframework.stereotype.component;/* * Steps to use AOP * 1 declares a slice, which must be in an IOC container, so you must add a @component annot
First, the concept of AOPAOP (aspect-oriented programming, aspect-oriented programming), is a technology that can dynamically and uniformly add functionality to a program without modifying the source code, through precompilation and runtime dynamic proxy implementations. It is a new methodology that complements traditional OOP programming. OOP is concerned with dividing the requirements function into different and relatively independent, well-encapsulated classes, and letting them have their own
Java compiler level does is not match the version of the installed Java project facet.
Elipse you can usually right-click on an item-->properties--> and then find the project facets and Java compiler two options to modify the JDK version that it uses. If you do not find the project facets option, you can refer to the following methods:
There is no project facets
Programming with spring-oriented facets1. IntroductionAOP is a complement to OOP and provides another way of thinking about the structure of the program.The modular key unit of OOP is the class.AOP is the aspect facet.AOP divides the logic of the program into separate blocks (called concern center of gravity, Focus point).AOP is used to increase the modularity of the cross-cutting center of gravity (cross-cutting concerns).A cross-cutting concern is a concern that can affect the entire program,
,Implement-interface: New Parent classDefault-impl: New default implementation of parent class Aop:aspect > aop:declare-parents Types-matching= "Main.java.soundsystem.CompactDisc"Implement-interface= "Main.java.soundsystem.Printer"Default-impl= "Main.java.soundsystem.CDPrinter"/>aop:aspect>Add test methods:@Test Public void Testprinter () { new classpathxmlapplicationcontext ("Trackcounterconfig.xml"); Compactdisc cd= (compactdisc) context.getbean ("Blankdisc"); Cd
The Aoplog class is as follows:Import Org.aspectj.lang.ProceedingJoinPoint;public class Aoplog {Front and back calls to method executionPublic Object Runonaround (Proceedingjoinpoint point) throws throwable{SYSTEM.OUT.PRINTLN ("Begin Around");Object object = Point.proceed ();System.out.println ("End Around");return object;}}The reference documentation is as follows:http://zywang.iteye.com/blog/974226http://blog.csdn.net/voyage_mh1987/article/details/5821238Spring AOP
Solution steps:
1, into the project directory, you can see the. project file, open.
2, find
3, in the 2nd step of the code snippet add the following label content and save:
4. Right-click the project on Eclipse and refresh the project.
5, on the project point right key, enter the property (properties)
6, on the left-hand list item Click Select "Project Facets", on the right select "Dynamic Web Module" and "Java", click OK to save.
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.