JDK里的设计模式(二)
java.lang.Integer#valueOf(int)
?(also on?Boolean
,?Byte
,?Character
,?Short
,?Long
,?Float
and?Double
)java.lang.reflect.Proxy
java.rmi.*
, the whole API actually.The Wikipedia example is IMHO a bit poor, lazy loading has actually completely nothing to do with the proxy pattern at all.
java.util.logging.Logger#log()
javax.servlet.Filter#doFilter()
java.lang.Runnable
javax.swing.Action
java.util.Pattern
java.text.Normalizer
java.text.Format
javax.el.ELResolver
java.util.Iterator
?(thus under each also?java.util.Scanner
!).java.util.Enumeration
java.util.Timer
?(all?scheduleXXX()
?methods)java.util.concurrent.Executor#execute()
java.util.concurrent.ExecutorService
?(the?invokeXXX()
?and?submit()
?methods)java.util.concurrent.ScheduledExecutorService
?(all?scheduleXXX()
?methods)java.lang.reflect.Method#invoke()
java.util.Date
?(the setter methods do that,?Date
?is internally represented by a?long
?value)java.io.Serializable
javax.faces.component.StateHolder
java.util.Observer
/java.util.Observable
?(rarely used in real world though)java.util.EventListener
?(practically all over Swing thus)javax.servlet.http.HttpSessionBindingListener
javax.servlet.http.HttpSessionAttributeListener
javax.faces.event.PhaseListener
java.util.Iterator
javax.faces.lifecycle.LifeCycle#execute()
?(controlled by?FacesServlet
, the behaviour is dependent on current phase (state) of JSF lifecycle)java.util.Comparator#compare()
, executed by under each?Collections#sort()
.javax.servlet.http.HttpServlet
, the?service()
?and all?doXXX()
?methods takeHttpServletRequest
?and?HttpServletResponse
?and the implementor has to process them (and not to get hold of them as instance variables!).javax.servlet.Filter#doFilter()
java.io.InputStream
,?java.io.OutputStream
,?java.io.Reader
and?java.io.Writer
.java.util.AbstractList
,?java.util.AbstractSet
?andjava.util.AbstractMap
.javax.servlet.http.HttpServlet
, all the?doXXX()
?methods by default sends a HTTP 405 "Method Not Allowed" error to the response. You're free to implement none or any of them.javax.lang.model.element.AnnotationValue
?andjavax.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