一、AspectJProxyFactory
XML文件:
    <bean id="helloWorldDao" class="cn.aop.aspect.dao.HelloWorldDaoImpl"  p:helloworld="helloworldDao" />
  <bean id="helloworldService" class="cn.aop.aspect.service.HelloWorldServiceImpl"    p:helloWorldDao-ref="helloWorldDao" />
java Main 函数
  ListableBeanFactory factory    = new ClassPathXmlApplicationContext("aspectAop.xml");
    GenericBeanFactoryAccessor gbf = new GenericBeanFactoryAccessor(factory);
    IHelloWorldService hw = gbf.getBean("helloworldService");
    log.info(hw.getContext("哈哈"));
    log.info("==========================before==============================");
    AspectJProxyFactory ajpFactory = new AspectJProxyFactory(gbf.getBean("helloworldService"));
    ajpFactory.addAspect(LoggingBeforeAspect.class);
    IHelloWorldService hw2 = ajpFactory.getProxy();
    log.info(hw2.getContext("哈哈"));
输出:
AspectAOPMain(AspectAOPMain.java:27) -0        [main]    - helloworldDao    哈哈
AspectAOPMain(AspectAOPMain.java:28) -2        [main]    - ==========================before==============================
LoggingBeforeAspect(LoggingBeforeAspect.java:21) -218    [main]    - org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint: execution(getContext)
LoggingBeforeAspect(LoggingBeforeAspect.java:22) -219    [main]    - 哈哈
LoggingBeforeAspect(LoggingBeforeAspect.java:23) -219    [main]    - cn.aop.aspect.service.HelloWorldServiceImpl@7a1576
LoggingBeforeAspect(LoggingBeforeAspect.java:24) -219    [main]    - cn.aop.aspect.service.HelloWorldServiceImpl@7a1576
AspectAOPMain(AspectAOPMain.java:32) -220    [main]    - helloworldDao    哈哈