• 设计模式-模板方法设计模式--Template Method design pattern


    /**
     * Abstract implementation of the {@link org.springframework.context.ApplicationContext}
     * interface. Doesn't mandate the type of storage used for configuration; simply
     * implements common context functionality. Uses the Template Method design pattern,
     * requiring concrete subclasses to implement abstract methods.
     *
     * <p>In contrast to a plain BeanFactory, an ApplicationContext is supposed
     * to detect special beans defined in its internal bean factory:
     * Therefore, this class automatically registers
     * {@link org.springframework.beans.factory.config.BeanFactoryPostProcessor BeanFactoryPostProcessors},
     * {@link org.springframework.beans.factory.config.BeanPostProcessor BeanPostProcessors}
     * and {@link org.springframework.context.ApplicationListener ApplicationListeners}
     * which are defined as beans in the context.
     *
     * <p>A {@link org.springframework.context.MessageSource} may also be supplied
     * as a bean in the context, with the name "messageSource"; otherwise, message
     * resolution is delegated to the parent context. Furthermore, a multicaster
     * for application events can be supplied as "applicationEventMulticaster" bean
     * of type {@link org.springframework.context.event.ApplicationEventMulticaster}
     * in the context; otherwise, a default multicaster of type
     * {@link org.springframework.context.event.SimpleApplicationEventMulticaster} will be used.
     *
     * <p>Implements resource loading through extending
     * {@link org.springframework.core.io.DefaultResourceLoader}.
     * Consequently treats non-URL resource paths as class path resources
     * (supporting full class path resource names that include the package path,
     * e.g. "mypackage/myresource.dat"), unless the {@link #getResourceByPath}
     * method is overwritten in a subclass.
    

     

    今天看spring的代码,AbstractApplicationContext中的注释有提到Template Method design pattern ,就查了一下这种设计模式。

    参考:https://blog.csdn.net/qq_24692041/article/details/60961880

    这种设计模式,就是在父类中定义处理流程的框架,在子类中实现具体的处理方式。我的理解是,父类处理步骤,子类处理数据。其中父类的方法基于里氏转换原则,要final掉。

  • 相关阅读:
    初始化生成linux sysfs(8)
    内存延迟监控系统组件
    数组代码First Missing Positive
    类文件Spring中空值的写法java教程
    状态键盘完美适应iOS中的键盘高度变化
    框架绑定JavaScript MVC框架PK:Angular、Backbone、CanJS与Ember
    域编码jquery的AJAX跨域请求及跨域请求的原理
    数据格式利用GSON接卸JSON数据
    网元查看一个无厘头的core dump问题定位
    类型应用oracle如何显示毫秒?
  • 原文地址:https://www.cnblogs.com/zhizhiyin/p/11051738.html
Copyright © 2020-2023  润新知