zoukankan      html  css  js  c++  java
  • 设计模式-模板方法设计模式--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掉。

  • 相关阅读:
    Core3.0部署后访问接口提示500.30
    Core3.0返回的Json数据大小写格式问题
    linux内核分析之fork()
    【转】【机器人学:运动规划】OMPL开源运动规划库的安装和demo
    【转】毫米波雷达和激光雷达的对比
    [转]开发者需要的 9 款代码比较工具
    [转]关于特征点法、直接法、光流法slam的对比
    [转]【视觉 SLAM-2】 视觉SLAM- ORB 源码详解 2
    [转]ORB特征提取-----FAST角点检测
    [转]图像金字塔
  • 原文地址:https://www.cnblogs.com/zhizhiyin/p/11051738.html
Copyright © 2011-2022 走看看