随笔分类 -  java设计模式

摘要:1 //饿汉式:资源利用率较低(无论是否需要都会创建),性能较高(使用前无需判断实例是否存在,可直接使用) 2 public class EagerSingleton{ 3 private static final EagerSingleton instance=new EagerSingleton(); 4 private EagerSingleton(){} 5 pu... 阅读全文
posted @ 2017-05-31 10:22 xiongjiawei 阅读(168) 评论(0) 推荐(0)
摘要:1 package com.tn.pattern; 2 3 public class Client { 4 public static void main(String[] args) { 5 Director director=Director.getInstance(); 6 director.construct(new Concrete... 阅读全文
posted @ 2017-05-26 18:08 xiongjiawei 阅读(210) 评论(0) 推荐(0)
摘要:1 package com.tn.pattern; 2 3 public class Client { 4 public static void main(String[] args) { 5 AbstractFactory factory=LinuxFactory.getInstance(); 6 factory.butt... 阅读全文
posted @ 2017-05-25 17:05 xiongjiawei 阅读(149) 评论(0) 推荐(0)
摘要:1 package com.tn.pattern; 2 3 public class Client { 4 public static void main(String[] args) { 5 AbstractClass c1=new ConcreteClass1(); 6 c1.templateMethod(); 7 ... 阅读全文
posted @ 2017-05-15 13:40 xiongjiawei 阅读(220) 评论(0) 推荐(0)
摘要:1 package com.tn.pattern; 2 3 public class Client { 4 public static void main(String[] args) { 5 Object[] objs={"飞","雪","连","天","射","白","鹿","笑","书","神"}; 6 Aggregate aggreg... 阅读全文
posted @ 2017-05-12 16:31 xiongjiawei 阅读(224) 评论(0) 推荐(0)
摘要:1 package com.tn.pattern; 2 3 import java.util.Vector; 4 5 public class Client { 6 public static void main(String[] args) { 7 Component china=new Composite("中国"); 8 ... 阅读全文
posted @ 2017-05-12 13:43 xiongjiawei 阅读(198) 评论(0) 推荐(0)
摘要:1 public class Client { 2 public static void main(String[] args) { 3 Component component=new ConcreteComponent(); 4 component=new ConcreteDecoratorA(component); 5 com... 阅读全文
posted @ 2017-05-11 14:11 xiongjiawei 阅读(144) 评论(0) 推荐(0)
摘要:1 package com.tn.策略模式; 2 3 public class Client { 4 private Strategy strategy; 5 public void setStrategy(Strategy strategy){ 6 this.strategy=strategy; 7 } 8 public voi... 阅读全文
posted @ 2017-05-10 20:45 xiongjiawei 阅读(204) 评论(0) 推荐(0)
摘要:1 public class Test { 2 public static void main(String[] args){ 3 Creator ca=new ConcreteCreatorA(); 4 ca.create().doSth(); 5 Creator cb=new ConcreteCreatorB(); 6 ... 阅读全文
posted @ 2017-05-10 16:35 xiongjiawei 阅读(158) 评论(0) 推荐(0)
摘要:1 public class Test { 2 public static void main(String[] args){ 3 try{ 4 Factory.factory("A").doSth(); 5 Factory.factory("B").doSth(); 6 Factory.... 阅读全文
posted @ 2017-05-10 13:35 xiongjiawei 阅读(204) 评论(0) 推荐(0)
摘要:可以随时添加过滤器,并在主方法中添加删除: Main MsgProcessor FilterChain Filter HTMLFilter SensitiveFilter SmileFaceFilter 顺序处理request,逆序处理response: Main FilterChain Filte 阅读全文
posted @ 2017-05-06 18:27 xiongjiawei 阅读(160) 评论(0) 推荐(0)