随笔 - 0, 文章 - 11, 评论 - 0, 引用 - 0
数据加载中……

代理模式 简单模拟 ActionProxy

结构图:

Action Interface :
public interface Action {
    
public String execute () ;
}

DispacherAction :
public class DispacherAction implements Action {
    
public String execute() {
        System.out.println(
"DispacherAction TODO somethin.");
        
return "result";
    }
}

ActionProxy:
public class ActionProxy implements Action {
    
private DispacherAction dispacherAction = new DispacherAction();
    
public String execute() {
        String result ;
        System.out.println(
"begin ActionProxy TODO somethin.");
        result 
= dispacherAction.execute() ;
        System.out.println(
"end ActionProxy TODO somethin.");
        
return result;
    }
}

执行结果:
begin ActionProxy TODO somethin.
DispacherAction TODO somethin.
end ActionProxy TODO somethin.

posted on 2014-05-14 17:47 00001000 阅读(216) 评论(0)  编辑  收藏 所属分类: 设计模式


只有注册用户登录后才能发表评论。


网站导航: