stackoverflowにあったものを日本語のリンクに修正したもの。(※JavaEEの部分がまだ英語)
よくコアライブラリのソース読んだほうがいいか聞くけど、闇雲に読みのではなくデザインパターンに着目してみた。今後細かく見るためための備忘録。
1. Abstract factoryパターン
- javax.xml.parsers.DocumentBuilderFactory#newInstance()
- javax.xml.transform.TransformerFactory#newInstance()
- javax.xml.xpath.XPathFactory#newInstance()
2. Builderパターン
- java.lang.StringBuilder#append()
- java.lang.StringBuffer#append()
- java.nio.ByteBuffer#put()
- javax.swing.GroupLayout.Group#addComponent()
- java.lang.Appendable
3. Factory methodパターン
- java.util.Calendar#getInstance()
- java.util.ResourceBundle#getBundle()
- java.text.NumberFormat#getInstance()
- java.nio.charset.Charset#forName()
- java.net.URLStreamHandlerFactory#createURLStreamHandler(String)
- java.util.EnumSet#of()
- javax.xml.bind.JAXBContext#createMarshaller()
4. Prototypeパターン
5. Singletonパターン
6. Adapterパターン
- java.util.Arrays#asList()
- java.util.Collections#list()
- java.util.Collections#enumeration()
- java.io.InputStreamReader(InputStream)
- java.io.OutputStreamWriter(OutputStream)
- javax.xml.bind.annotation.adapters.XmlAdapter#marshal() and #unmarshal()
7. Bridgeパターン
8. Compositeパターン
9. Decoratorパターン
- java.io.InputStream
- java.io.OutputStream
- java.util.Collections checkedXXX(), synchronizedXXX() and unmodifiableXXX()
- javax.servlet.http.HttpServletRequestWrapper and HttpServletResponseWrapper
10. Facadeパターン
- javax.faces.context.FacesContext LifeCycle, ViewHandler, NavigationHandler
- javax.faces.context.ExternalContext ServletContext, HttpSession, HttpServletRequest, HttpServletResponse, etc.
11. Flyweightパターン
12. Proxyパターン
- java.lang.reflect.Proxy
- java.rmi.*
- javax.ejb.EJB
- javax.inject.Inject
- javax.persistence.PersistenceContext
13. Chain of responsibility パターン
14. Commandパターン
15. Interpreterパターン
16. Iteratorパターン
17. Mediatorパターン
- java.util.Timer
- java.util.concurrent.Executor#execute()
- java.util.concurrent.ExecutorService
- java.util.concurrent.ScheduledExecutorService
- java.lang.reflect.Method#invoke()
18. Mementoパターン
19. Observerパターン
- java.util.Observer
- java.util.Observable
- java.util.EventListener
- javax.servlet.http.HttpSessionBindingListener
- javax.servlet.http.HttpSessionAttributeListener
- javax.faces.event.PhaseListener
20. Stateパターン
21. Strategyパターン
22. Template method パターン
- java.io.InputStream
- java.io.OutputStream
- java.io.Reader
- java.io.Writer
- java.util.AbstractList
- java.util.AbstractSet
- java.util.AbstractMap
- javax.servlet.http.HttpServlet
23. Visitorパターン
-
javax.lang.model.element.AnnotationValue and
javax.lang.model.element.AnnotationValueVisitor -
javax.lang.model.element.Element and
javax.lang.model.element.ElementVisitor -
javax.lang.model.type.TypeMirror and
javax.lang.model.type.TypeVisitor -
java.nio.file.FileVisitor and
java.nio.file.SimpleFileVisitor -
javax.faces.component.visit.VisitContext and
javax.faces.component.visit.VisitCallback
参考:https://stackoverflow.com/questions/1673841/examples-of-gof-design-patterns-in-javas-core-libraries