Giter Club home page Giter Club logo

spring-ripper's Introduction

spring-ripper

Bean lifecycle

  • Создаются BeanDefinition (xml парсится, ищутся по аннотациям или java-конфигам)
  • BeanFactoryPostProcessor обрабатывают BeanDefinition
  • BeanFactory начинает создавать бины
  • BBP применяют postProcessBeforeInitialization
  • вызывается init-метод бина
  • BBP применяют postProcessAfterInitialization
  • Создается событие обновление контекста, на которое можно подписаться

Трехфазовый конструктор

  • Constructor (java)
  • @PostConstruct (BPP)
  • @PostProxy (ContextListener)

BeanPostProcessor

  • Позволяет настраивать бины до того, как они попадают в контейнер
  • У этого интерфейса 2 метода (первый вызывается до init-метода, второй - после): Object postProcessBeforeInitialization(Object bean, String beanName) Object postProcessAfterInitialization(Object bean, String beanName)
  • Между ними вызывается init метод
    • init-метод
    • afterPropertiesSet
    • @PostConstruct

ApplicationListener

Умеет слушать контекст спринга, т.е. все события спринга

  • ContextStartedEvent (начал построение, после вызовет refresh)
  • ContextStoppedEvent
  • ContextRefreshedEvent
  • ContextClosedEvent

Из любого ивента можно вытащить контекст

BeanFactoryPostProcessor

Позволяет настраивать BeanDefinition, до того как BeanFactory начнет создавать бины

ClassPathBeanDefinitionScanner

  • Создает BeanDefinition, из классов, над которыми стоит @Component, или другая аннотация аннотированная @Component

Java Config

  • new AnnotationConfigApplicationContext(JavaConfig.class)
  • Казалось бы его должен парсировать какой-нибудь BeanDefinitionReader, как это было с XML
  • И класс его называется схоже: AnnotatedBeanDefinitionReader
  • Но нет, AnnotatedBeanDefinitionReader вообще ни чего не имплементирует
  • Он просто является частью ApplicationContext
  • Он только регистрирует все JavaConfig

ConfigurationClassPostProcessor (особый BeanFactoryPostProcessor)

  • Обрабатывает JavaConfig'и
  • Его регистрирует AnnotationConfigApplicationContext, как BeanFactoryPostProcessor
  • Он создает BeanDefinition по @Bean

Groovy Config

  • new GenericGroovyApplicationContext("context.groovy")
  • Парсируется GroovyBeanDefinitionReader

spring-ripper's People

Contributors

ortex avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.