- 浏览: 550633 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (478)
- lucene (45)
- oracle (19)
- nutch (2)
- blog (2)
- 垂直搜索 (19)
- java综合 (89)
- spring (15)
- Hibernate (9)
- Struts (9)
- Hadoop (16)
- Mysql (12)
- nosql (10)
- Linux (3)
- MyEclipse (4)
- Ant (1)
- 设计模式 (19)
- JBPM (1)
- JSP (1)
- HtmlParser (5)
- SVN (2)
- 插件 (2)
- 收藏 (7)
- Others (1)
- Heritrix (18)
- Solr (4)
- 主题爬虫 (31)
- 内存数据库 (24)
- 分布式与海量数据 (32)
- httpclient (14)
- Tomcat (1)
- 面试宝典 (6)
- Python (14)
- 数据挖掘 (1)
- 算法 (6)
- 其他 (4)
- JVM (12)
- Redis (18)
最新评论
-
hanjiyun:
本人水平还有待提高,进步空间很大,看这些文章给我有很大的指导作 ...
JVM的内存管理 Ⅲ -
liuxinglanyue:
四年后的自己:这种方法 不靠谱。 使用javaagent的方式 ...
计算Java对象占用内存空间的大小(对于32位虚拟机而言) -
jaysoncn:
附件在哪里啊test.NoCertificationHttps ...
使用HttpClient过程中常见的一些问题 -
231fuchenxi:
你好,有redis,memlink,mysql的测试代码吗?可 ...
MemLink 性能测试 -
guyue1015:
[color=orange][/color][size=lar ...
JAVA同步机制
Creational patterns
Abstract factory (recognizeable by creational methods returning an abstract/interface type)
java.util.Calendar#getInstance()
java.util.Arrays#asList()
java.util.ResourceBundle#getBundle()
java.net.URL#openConnection()
java.sql.DriverManager#getConnection()
java.sql.Connection#createStatement()
java.sql.Statement#executeQuery()
java.text.NumberFormat#getInstance()
-
java.lang.management.ManagementFactory
(allgetXXX()
methods) java.nio.charset.Charset#forName()
javax.xml.parsers.DocumentBuilderFactory#newInstance()
javax.xml.transform.TransformerFactory#newInstance()
javax.xml.xpath.XPathFactory#newInstance()
Builder (recognizeable by creational methods returning the instance itself)
-
java.lang.StringBuilder#append()
(unsynchronized) -
java.lang.StringBuffer#append()
(synchronized) -
java.nio.ByteBuffer#put()
(also onCharBuffer
,ShortBuffer
,IntBuffer
,LongBuffer
,FloatBuffer
andDoubleBuffer
) javax.swing.GroupLayout.Group#addComponent()
- All implementations of
java.lang.Appendable
Factory method (recognizeable by creational methods returning a concrete type)
-
java.lang.Object#toString()
(overrideable in all subclasses) java.lang.Class#newInstance()
-
java.lang.Integer#valueOf(String)
(also onBoolean
,Byte
,Character
,Short
,Long
,Float
andDouble
) java.lang.Class#forName()
java.lang.reflect.Array#newInstance()
java.lang.reflect.Constructor#newInstance()
Prototype (recognizeable by creational methods returning a different instance of itself with the same properties)
-
java.lang.Object#clone()
(the class has to implementjava.lang.Cloneable
)
Singleton (recognizeable by creational methods returning the same instance (usually of itself) everytime)
Structural patterns
Adapter (recognizeable by creational methods taking an instance of different abstract/interface type and returning an implementation of own/another abstract/interface type which decorates/overrides the given instance)
-
java.io.InputStreamReader(InputStream)
(returns aReader
) -
java.io.OutputStreamWriter(OutputStream)
(returns aWriter
) -
javax.xml.bind.annotation.adapters.XmlAdapter#marshal()
and#unmarshal()
Bridge (recognizeable by creational methods taking an instance of different abstract/interface type and returning an implementation of own abstract/interface type which delegates/uses the given instance)
- None comes to mind yet. A fictive example would be
new LinkedHashMap(LinkedHashSet<K>, List<V>)
which returns an unmodifiable linked map which doesn't clone the items, but uses them. Thejava.util.Collections#newSetFromMap()
andsingletonXXX()
methods however comes close.
Composite (recognizeable by behavioral methods taking an instance of same abstract/interface type)
java.util.Map#putAll(Map)
java.util.List#addAll(Collection)
java.util.Set#addAll(Collection)
-
java.nio.ByteBuffer#put(ByteBuffer)
(also onCharBuffer
,ShortBuffer
,IntBuffer
,LongBuffer
,FloatBuffer
andDoubleBuffer
) -
java.awt.Container#add(Component)
(practically all over Swing thus)
Decorator (recognizeable by creational methods taking an instance of same abstract/interface type)
- All subclasses of
java.io.InputStream
,OutputStream
,Reader
andWriter
have a constructor taking an instance of same type. - Almost all implementations of
java.util.List
,Set
andMap
have a constructor taking an instance of same type. -
java.util.Collections
, thecheckedXXX()
,synchronizedXXX()
andunmodifiableXXX()
methods. -
javax.servlet.http.HttpServletRequestWrapper
andHttpServletResponseWrapper
Facade (recognizeable by behavioral methods which internally uses instances of different independent abstract/interface types)
-
javax.faces.webapp.FacesServlet
, it internally uses under each the abstract/interface typesServletContext
,LifeCycle
,ViewHandler
,NavigationHandler
and many more without that the enduser has to worry about it (which are however overrideable by injection).
评论
2 楼
liuxinglanyue
2010-12-16
iq527 写道
原创? 求出处~~
http://stackoverflow.com/questions/1673841/examples-of-gof-design-patterns
1 楼
iq527
2010-12-16
原创? 求出处~~
发表评论
-
JDK里的设计模式(二)
2010-12-16 19:45 915Flyweight (recognizeable by ... -
JDK里的设计模式
2010-12-16 19:35 803下面是JDK中有关23个经典设计模式的示例,在stakeo ... -
JDK里的设计模式
2010-11-28 10:42 524下面是JDK中有关23个经典设计模式的示例,在stakeo ... -
设计模式英文手稿(转)
2010-11-15 15:50 896暑期实习的时候做了一次presentation on desi ... -
推拉模式
2010-11-15 15:35 994先来比较两张 UML 图: 推模式 ... -
观察者模式
2010-11-15 15:34 1006作用: 在某一个对象的状态发生变化的时候,某些其它的 ... -
追MM与Java的23种设计模式(转)
2010-11-14 22:21 801我在Java论坛看到这篇文章,作者以轻松的语言比喻了java的 ... -
关于设计模式的非常好的站点
2010-11-14 22:10 739http://www.uml.org.cn/sjms/sjms ... -
Java设计模式之组合模式
2010-11-14 20:54 754COMPOSITE (Object Structural) P ... -
Java设计模式之观察者模式
2010-11-14 20:53 928OBSERVER (Object Behavioral) Pu ... -
Java设计模式之代理模式
2010-11-14 20:53 761PROXY (Object Structural) Purpo ... -
Java设计模式之模板方法模式
2010-11-14 20:52 803TEMPLATE METHOD (Class Behavior ... -
Java设计模式之抽象工厂模式
2010-11-14 20:51 826ABSTRACT FACTORY (Object Creati ... -
Java设计模式之状态模式
2010-11-14 20:51 917STATE (Object Behavioral) Purpo ... -
Java设计模式之策略模式
2010-11-14 20:50 915STRATEGY (Object Behavioral) P ... -
Java设计模式之装饰者模式
2010-11-14 20:49 899DECORATOR (Object Structural) P ... -
Java设计模式之单例模式
2010-11-14 20:48 820SINGLETON (Object Creational ... -
7种坏味道,11种原则,23种模式
2010-11-14 20:46 874(一)7种设计坏味道 1.僵化性: 很难对系统进行改 ...
相关推荐
JAVA设计模式在JDK中的应用JAVA设计模式在JDK中的应用 各种设计模式在JDK当中使用的地方 方便分析源码
jdk中设计模式 归纳了JDK中所包含的设计模式,包括作用和其设计类图
该文档整理了JDK中有关的设计模式,包括创建型、结构型、行为型等模式在JDK中的应用
该文档中包括了JDK中的23中设计模式的介绍,附有实例
JDK中的设计模式应用实例
设计模式在JDK中的应用课设--PPT资源 题目要求: 设计模式在JDK中的应用(结合JDK源码,分析JDK对设计模式的支持与应用)。课设内容包括: (a)用UML类图分析JDK所支持或应用的设计模式的结构,并与GOF的结构加以...
JDK中有关23个经典设计模式的示例 JDK,23个设计模式,示例,网页源码
jdk工具介绍JVM垃圾回收23种设计模式 jdk工具介绍JVM垃圾回收23种设计模式 jdk工具介绍JVM垃圾回收23种设计模式
设计模式实战、jdk源码解读等等 ok
介绍java二十三种设计模式,包括模式的描述,适用性,模式的组成部分,并附带有简单的例子和类图,目的是为了让读者了解二十三种设计模式,并能方便的查阅各种设计模式的用法及注意点,希望对大家有所帮助。...
java 23种设计模式的类图 java 23种设计模式的类图 java 23种设计模式的类图
设计模式之观察者模式Java版本实现和UML类设计图
day40 设计模式、jdk8新特性
里面包括了读观察者模式的详细介绍,这是JDK中的一个非常重要的模式。
java常用设计模式及JDK与CGLIB实现动态代理区别(源码) /** * 使用cglib动态代理 * @author * */ public class BookFacadeProxy implements MethodInterceptor{ private Object target; @Override public...
│ 3.1江湖传言里的设计模式-单例设计模式.mp4 │ 3.2代码实战-单例设计模式中的懒汉实现方式.mp4 │ 3.4单例模式中的饿汉实现和选择问题.mp4 │ 3.5JDK源码里面的单例设计模式.mp4 │ 4.2电商支付应用案例-...
设计模式之责任链模式源码 设计模式之责任链模式源码 设计模式之责任链模式源码