通知类型
来源:互联网 发布:全国城市经纬度数据库 编辑:程序博客网 时间:2024/05/17 23:42
通知类型
前置通知、后置通知、异常通知、环绕通知、引入通知
BeforeAdvice
public interface Reception{
public void serveCustomer(String customerName);
}
public class ConcreteReception implements Reception{
public void serveCustomer(String customerName){
System.out.println("我正在服务客户:"+customerName);
}
}
public interface MethodBeforeAdvice{
void before (Method method,Object [] args,Object target);
//method目标类的方法,args目标实例的方法的入参,target为目标实例对象
}
import javal.lang.reflect.Method;
import org.springframework.aop.MethodBeforeAdvice;
public class GreetingBeforeAdvice implements MethodBeforeAdvice{
public void before(Method method,Object [] args,Object obj) throws Throweable{
String customerName=(String)args[0];
System.out.println("见到您真高兴:"+customerName+",请跟我来!");
}
}
public class TestBeforeAdvice{
public static void main(String args[]){
Reception target=new ConcreteReception();
BeforeAdvice advice=new GreetingBeforeAdvice();//前置通知
ProxyFactory pf=new ProxyFactory();//Spring代理工厂
pf.setTarget(target);
pf.addAdvice(advice);
Reception proxy=(Recception)pf.getProxy();//生成代理实例
proxy.serveCustomer("ACC");
}
}
前置通知、后置通知、异常通知、环绕通知、引入通知
BeforeAdvice
public interface Reception{
public void serveCustomer(String customerName);
}
public class ConcreteReception implements Reception{
public void serveCustomer(String customerName){
System.out.println("我正在服务客户:"+customerName);
}
}
public interface MethodBeforeAdvice{
void before (Method method,Object [] args,Object target);
//method目标类的方法,args目标实例的方法的入参,target为目标实例对象
}
import javal.lang.reflect.Method;
import org.springframework.aop.MethodBeforeAdvice;
public class GreetingBeforeAdvice implements MethodBeforeAdvice{
public void before(Method method,Object [] args,Object obj) throws Throweable{
String customerName=(String)args[0];
System.out.println("见到您真高兴:"+customerName+",请跟我来!");
}
}
public class TestBeforeAdvice{
public static void main(String args[]){
Reception target=new ConcreteReception();
BeforeAdvice advice=new GreetingBeforeAdvice();//前置通知
ProxyFactory pf=new ProxyFactory();//Spring代理工厂
pf.setTarget(target);
pf.addAdvice(advice);
Reception proxy=(Recception)pf.getProxy();//生成代理实例
proxy.serveCustomer("ACC");
}
}
- 通知类型
- 键盘通知的类型
- Spring通知类型
- AOP的通知类型
- AOP通知类型
- RILNotifyCallBack中的通知消息类型
- VC控件通知消息类型
- spring aop的五种通知类型
- Spring 配置使用 - AOP 通知类型
- spring aop的五种通知类型
- spring aop的五种通知类型
- spring aop的五种通知类型
- 通知
- 通知
- 通知
- 通知
- 通知
- 通知
- vb中换行的几种方法
- Linux 下面修改MAC的方法
- 工作
- php的IP转换成整型函数ip2long()易出现负数
- iPhone开发--NSData年、月、星期、日、时、分、秒和毫秒获取及NSDataToNSString方法
- 通知类型
- 【源码备份】C++数字雨
- 把Android源代码加入SDK
- 俞军PM12条以及人才的选用育留
- eclipse 下SVN的安装
- 单独获取当前的年,月,日,时,分,秒
- 黑马程序员学习笔记之18天-01-其他对象(System)
- WebSphere 服务集成总线
- C/C++代码小技巧【持续更新】