Giter VIP home page Giter VIP logo

spring-light's Introduction

更新记录

spring-light

分支 bean-definition

主要改动

  • 新增BeanDefinition类(主要功能是保存bean信息)
  • 新增BeanDefinitionRegistry接口(定义对 BeanDefinition 的各种增删改操作)
  • 默认的ioc容器实现BeanDefinitionRegistry接口
  • ioc容器的基本实现

Test代码

public class DefaultListableBeanFactoryTest {
    @Test
    public void testDefaultListableBeanFactoryWithBeanDefinition() {
        DefaultListableBeanFactory defaultListableBeanFactory = new DefaultListableBeanFactory();
        BeanDefinition beanDefinition = new BeanDefinition();
        beanDefinition.setClazz(HelloBeanDefinition.class);
        defaultListableBeanFactory.registerBeanDefinition("helloBeanDefinition", beanDefinition);
        Object helloBeanDefinition = defaultListableBeanFactory.getBean("helloBeanDefinition");
        assertNotNull(helloBeanDefinition);
        assertEquals(((HelloBeanDefinition)helloBeanDefinition).sayHello(),"Hello BeanDefinition");
    }
}

`class HelloBeanDefinition {

    public String sayHello() {
        System.out.println("Hello BeanDefinition");
        return "Hello BeanDefinition";
    }
}

分支 bean-definition-parse

主要改动

  • 新增InputStreamResource和Resource接口和其实现(对资源的获取和扩展)
  • 新增BeanDefinitionReader接口和实现(将Resource资源转换为BeanDefinition)
  • 新增DocumentLoader接口(将Resource资源转换为Document)
  • 新增抽象类AbstractBeanDefinitionReader默认实现BeanDefinitionReader接口并提供注册BeanDefinition

Test代码

public class XmlBeanFactoryTest {
    @Test
    public void testXmlBeanFactory() {
        ClasspathResource resource = new ClasspathResource("hello.xml");
        XmlBeanFactory xmlBeanFactory = new XmlBeanFactory(resource);
        BeanDefinition bd = xmlBeanFactory.getBeanDefinition("person");
        assertEquals(bd.getClazz(), Person.class);
    }

}

spring-light's People

Contributors

ksssssssss avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  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.