静态实现(AspectJ)
来源:互联网 发布:印巴分治原因知乎 编辑:程序博客网 时间:2024/06/06 16:29
本方式实现主要在于配置
包:
aspectjrt.jar
asm-2.2.3.jar
asm-commons-2.2.3.jar
asm-util-2.2.3.jar
spring.jar
cglib-nodep-2.1_3.jar
log4j-1.2.11.jar
commons-logging-1.0.4.jar
配置:AOP.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<aop:config proxy-target-class="true">
<aop:aspect ref="aspect">
<aop:before
pointcut="target(aopimp5.WaiterImp) and execution(* sayHello(..))"
method="pointCutFun" />
</aop:aspect>
</aop:config>
<bean id="aspect" class="aopimp5.TestAspect" />
<bean id="waiter" class="aopimp5.WaiterImp" />
</beans>
1.
public interface Waiter {
void sayHello(String str);
}
2.
public class WaiterImp implements Waiter {
public void sayHello(String str) {
System.out.println("+++++++++++ Hello "+str+" ++++++++++++=");
}
}
3.
public class TestAspect {
public void pointCutFun(){
System.out.println("====== this is point cut =============");
}
}
4.
public class Main {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("/AOP.xml"); //只能用ApplicationContext方式
Waiter w = (Waiter)ctx.getBean("waiter");
w.sayHello("Bill");
}
}
- 静态实现(AspectJ)
- Spring 的AOP-AspectJ静态实现
- 几个有用的静态方面,用于审查代码(aspectJ实现)
- AOP注解实现(AspectJ)
- 动态代理实现(AspectJ)
- Spring详解(五)------AspectJ 实现AOP
- Spring详解(五)------AspectJ 实现AOP
- AspectJ对AOP的实现(xml)
- AspectJ实现AOP(xml配置方式)
- AspectJ实现AOP(注解方式)
- AspectJ如何实现AOP
- AspectJ AOP实现
- AspectJ框架实现原理
- Spring @AspectJ 实现AOP
- AspectJ框架实现AOP
- 基于AspectJ实现AOP
- AspectJ实现设计模式(一)——观察者模式
- AspectJ实现设计模式(二)——策略模式
- 条款43:学习处理模板化基类内的名称
- AOP注解实现(AspectJ)
- 动态代理实现(AspectJ)
- GridView控件的批量删除操作
- Mendeley -paper管理软件
- 静态实现(AspectJ)
- 世上不可能有真正的完美,但应该有一个追求完美的心态
- java面试题选编
- 有向图的强连通分量算法
- C#水晶报表显示sqlserver2000储存的图片 C#水晶报表动态显示sqlserver储存的图片
- 采用JAX-WS Annotated Services from Java+JAXB发布获取web service
- Spring Hibernater
- 阴阳历转换
- Spring JDBC