├── .gitignore ├── LICENSE ├── README.md ├── doc ├── book-01.png ├── book.png └── user.sql ├── spring-step-01 ├── pom.xml └── src │ ├── main │ └── java │ │ └── cn │ │ └── bugstack │ │ └── springframework │ │ ├── BeanDefinition.java │ │ └── BeanFactory.java │ └── test │ └── java │ └── cn │ └── bugstack │ └── springframework │ └── test │ ├── ApiTest.java │ └── bean │ └── UserService.java ├── spring-step-02 ├── pom.xml └── src │ ├── main │ └── java │ │ └── cn │ │ └── bugstack │ │ └── springframework │ │ └── beans │ │ ├── BeansException.java │ │ └── factory │ │ ├── BeanFactory.java │ │ ├── config │ │ ├── BeanDefinition.java │ │ └── SingletonBeanRegistry.java │ │ └── support │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ ├── AbstractBeanFactory.java │ │ ├── BeanDefinitionRegistry.java │ │ ├── DefaultListableBeanFactory.java │ │ └── DefaultSingletonBeanRegistry.java │ └── test │ └── java │ └── cn │ └── bugstack │ └── springframework │ └── test │ ├── ApiTest.java │ └── bean │ └── UserService.java ├── spring-step-03 ├── pom.xml └── src │ ├── main │ └── java │ │ └── cn │ │ └── bugstack │ │ └── springframework │ │ └── beans │ │ ├── BeansException.java │ │ └── factory │ │ ├── BeanFactory.java │ │ ├── config │ │ ├── BeanDefinition.java │ │ └── SingletonBeanRegistry.java │ │ └── support │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ ├── AbstractBeanFactory.java │ │ ├── BeanDefinitionRegistry.java │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ ├── DefaultListableBeanFactory.java │ │ ├── DefaultSingletonBeanRegistry.java │ │ ├── InstantiationStrategy.java │ │ └── SimpleInstantiationStrategy.java │ └── test │ └── java │ └── cn │ └── bugstack │ └── springframework │ └── test │ ├── ApiTest.java │ └── bean │ └── UserService.java ├── spring-step-04 ├── pom.xml └── src │ ├── main │ └── java │ │ └── cn │ │ └── bugstack │ │ └── springframework │ │ └── beans │ │ ├── BeansException.java │ │ ├── PropertyValue.java │ │ ├── PropertyValues.java │ │ └── factory │ │ ├── BeanFactory.java │ │ ├── config │ │ ├── BeanDefinition.java │ │ ├── BeanReference.java │ │ └── SingletonBeanRegistry.java │ │ └── support │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ ├── AbstractBeanFactory.java │ │ ├── BeanDefinitionRegistry.java │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ ├── DefaultListableBeanFactory.java │ │ ├── DefaultSingletonBeanRegistry.java │ │ ├── InstantiationStrategy.java │ │ └── SimpleInstantiationStrategy.java │ └── test │ └── java │ └── cn │ └── bugstack │ └── springframework │ └── test │ ├── ApiTest.java │ └── bean │ ├── UserDao.java │ └── UserService.java ├── spring-step-05 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── core │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ └── util │ │ │ └── ClassUtils.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ └── bean │ │ │ ├── UserDao.java │ │ │ └── UserService.java │ │ └── resources │ │ ├── important.properties │ │ └── spring.xml └── target │ └── test-classes │ ├── important.properties │ └── spring.xml ├── spring-step-06 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ └── ClassPathXmlApplicationContext.java │ │ │ ├── core │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ └── util │ │ │ └── ClassUtils.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ ├── bean │ │ │ ├── UserDao.java │ │ │ └── UserService.java │ │ │ └── common │ │ │ ├── MyBeanFactoryPostProcessor.java │ │ │ └── MyBeanPostProcessor.java │ │ └── resources │ │ ├── important.properties │ │ ├── spring.xml │ │ └── springPostProcessor.xml └── target │ └── test-classes │ ├── important.properties │ ├── spring.xml │ └── springPostProcessor.xml ├── spring-step-07 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ └── ClassPathXmlApplicationContext.java │ │ │ ├── core │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ └── util │ │ │ └── ClassUtils.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ └── bean │ │ │ ├── UserDao.java │ │ │ └── UserService.java │ │ └── resources │ │ └── spring.xml └── target │ └── test-classes │ └── spring.xml ├── spring-step-08 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── Aware.java │ │ │ │ ├── BeanClassLoaderAware.java │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── BeanFactoryAware.java │ │ │ │ ├── BeanNameAware.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ApplicationContextAware.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ │ └── ClassPathXmlApplicationContext.java │ │ │ ├── core │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ └── util │ │ │ └── ClassUtils.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ └── bean │ │ │ ├── UserDao.java │ │ │ └── UserService.java │ │ └── resources │ │ └── spring.xml └── target │ └── test-classes │ └── spring.xml ├── spring-step-09 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── Aware.java │ │ │ │ ├── BeanClassLoaderAware.java │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── BeanFactoryAware.java │ │ │ │ ├── BeanNameAware.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── FactoryBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── FactoryBeanRegistrySupport.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ApplicationContextAware.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ │ └── ClassPathXmlApplicationContext.java │ │ │ ├── core │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ └── util │ │ │ └── ClassUtils.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ └── bean │ │ │ ├── IUserDao.java │ │ │ ├── ProxyBeanFactory.java │ │ │ └── UserService.java │ │ └── resources │ │ └── spring.xml └── target │ └── test-classes │ └── spring.xml ├── spring-step-10 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── Aware.java │ │ │ │ ├── BeanClassLoaderAware.java │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── BeanFactoryAware.java │ │ │ │ ├── BeanNameAware.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── FactoryBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── FactoryBeanRegistrySupport.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ApplicationContextAware.java │ │ │ ├── ApplicationEvent.java │ │ │ ├── ApplicationEventPublisher.java │ │ │ ├── ApplicationListener.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ ├── event │ │ │ │ ├── AbstractApplicationEventMulticaster.java │ │ │ │ ├── ApplicationContextEvent.java │ │ │ │ ├── ApplicationEventMulticaster.java │ │ │ │ ├── ContextClosedEvent.java │ │ │ │ ├── ContextRefreshedEvent.java │ │ │ │ └── SimpleApplicationEventMulticaster.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ │ └── ClassPathXmlApplicationContext.java │ │ │ ├── core │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ └── util │ │ │ └── ClassUtils.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ └── event │ │ │ ├── ContextClosedEventListener.java │ │ │ ├── ContextRefreshedEventListener.java │ │ │ ├── CustomEvent.java │ │ │ └── CustomEventListener.java │ │ └── resources │ │ └── spring.xml └── target │ └── test-classes │ └── spring.xml ├── spring-step-11 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── aop │ │ │ ├── AdvisedSupport.java │ │ │ ├── ClassFilter.java │ │ │ ├── MethodMatcher.java │ │ │ ├── Pointcut.java │ │ │ ├── TargetSource.java │ │ │ ├── aspectj │ │ │ │ └── AspectJExpressionPointcut.java │ │ │ └── framework │ │ │ │ ├── AopProxy.java │ │ │ │ ├── Cglib2AopProxy.java │ │ │ │ ├── JdkDynamicAopProxy.java │ │ │ │ └── ReflectiveMethodInvocation.java │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── Aware.java │ │ │ │ ├── BeanClassLoaderAware.java │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── BeanFactoryAware.java │ │ │ │ ├── BeanNameAware.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── FactoryBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── FactoryBeanRegistrySupport.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ApplicationContextAware.java │ │ │ ├── ApplicationEvent.java │ │ │ ├── ApplicationEventPublisher.java │ │ │ ├── ApplicationListener.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ ├── event │ │ │ │ ├── AbstractApplicationEventMulticaster.java │ │ │ │ ├── ApplicationContextEvent.java │ │ │ │ ├── ApplicationEventMulticaster.java │ │ │ │ ├── ContextClosedEvent.java │ │ │ │ ├── ContextRefreshedEvent.java │ │ │ │ └── SimpleApplicationEventMulticaster.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ │ └── ClassPathXmlApplicationContext.java │ │ │ ├── core │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ └── util │ │ │ └── ClassUtils.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ └── bean │ │ │ ├── IUserService.java │ │ │ ├── UserService.java │ │ │ └── UserServiceInterceptor.java │ │ └── resources │ │ └── spring.xml └── target │ └── test-classes │ └── spring.xml ├── spring-step-12 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── aop │ │ │ ├── AdvisedSupport.java │ │ │ ├── Advisor.java │ │ │ ├── BeforeAdvice.java │ │ │ ├── ClassFilter.java │ │ │ ├── MethodBeforeAdvice.java │ │ │ ├── MethodMatcher.java │ │ │ ├── Pointcut.java │ │ │ ├── PointcutAdvisor.java │ │ │ ├── TargetSource.java │ │ │ ├── aspectj │ │ │ │ ├── AspectJExpressionPointcut.java │ │ │ │ └── AspectJExpressionPointcutAdvisor.java │ │ │ └── framework │ │ │ │ ├── AopProxy.java │ │ │ │ ├── Cglib2AopProxy.java │ │ │ │ ├── JdkDynamicAopProxy.java │ │ │ │ ├── ProxyFactory.java │ │ │ │ ├── ReflectiveMethodInvocation.java │ │ │ │ ├── adapter │ │ │ │ └── MethodBeforeAdviceInterceptor.java │ │ │ │ └── autoproxy │ │ │ │ └── DefaultAdvisorAutoProxyCreator.java │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── Aware.java │ │ │ │ ├── BeanClassLoaderAware.java │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── BeanFactoryAware.java │ │ │ │ ├── BeanNameAware.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── FactoryBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ ├── InstantiationAwareBeanPostProcessor.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── FactoryBeanRegistrySupport.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ApplicationContextAware.java │ │ │ ├── ApplicationEvent.java │ │ │ ├── ApplicationEventPublisher.java │ │ │ ├── ApplicationListener.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ ├── event │ │ │ │ ├── AbstractApplicationEventMulticaster.java │ │ │ │ ├── ApplicationContextEvent.java │ │ │ │ ├── ApplicationEventMulticaster.java │ │ │ │ ├── ContextClosedEvent.java │ │ │ │ ├── ContextRefreshedEvent.java │ │ │ │ └── SimpleApplicationEventMulticaster.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ │ └── ClassPathXmlApplicationContext.java │ │ │ ├── core │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ └── util │ │ │ └── ClassUtils.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ └── bean │ │ │ ├── IUserService.java │ │ │ ├── UserService.java │ │ │ ├── UserServiceBeforeAdvice.java │ │ │ └── UserServiceInterceptor.java │ │ └── resources │ │ └── spring.xml └── target │ └── test-classes │ └── spring.xml ├── spring-step-13 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── aop │ │ │ ├── AdvisedSupport.java │ │ │ ├── Advisor.java │ │ │ ├── BeforeAdvice.java │ │ │ ├── ClassFilter.java │ │ │ ├── MethodBeforeAdvice.java │ │ │ ├── MethodMatcher.java │ │ │ ├── Pointcut.java │ │ │ ├── PointcutAdvisor.java │ │ │ ├── TargetSource.java │ │ │ ├── aspectj │ │ │ │ ├── AspectJExpressionPointcut.java │ │ │ │ └── AspectJExpressionPointcutAdvisor.java │ │ │ └── framework │ │ │ │ ├── AopProxy.java │ │ │ │ ├── Cglib2AopProxy.java │ │ │ │ ├── JdkDynamicAopProxy.java │ │ │ │ ├── ProxyFactory.java │ │ │ │ ├── ReflectiveMethodInvocation.java │ │ │ │ ├── adapter │ │ │ │ └── MethodBeforeAdviceInterceptor.java │ │ │ │ └── autoproxy │ │ │ │ └── DefaultAdvisorAutoProxyCreator.java │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── Aware.java │ │ │ │ ├── BeanClassLoaderAware.java │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── BeanFactoryAware.java │ │ │ │ ├── BeanNameAware.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── FactoryBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── PropertyPlaceholderConfigurer.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ ├── InstantiationAwareBeanPostProcessor.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── FactoryBeanRegistrySupport.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ApplicationContextAware.java │ │ │ ├── ApplicationEvent.java │ │ │ ├── ApplicationEventPublisher.java │ │ │ ├── ApplicationListener.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ ├── annotation │ │ │ │ ├── ClassPathBeanDefinitionScanner.java │ │ │ │ ├── ClassPathScanningCandidateComponentProvider.java │ │ │ │ └── Scope.java │ │ │ ├── event │ │ │ │ ├── AbstractApplicationEventMulticaster.java │ │ │ │ ├── ApplicationContextEvent.java │ │ │ │ ├── ApplicationEventMulticaster.java │ │ │ │ ├── ContextClosedEvent.java │ │ │ │ ├── ContextRefreshedEvent.java │ │ │ │ └── SimpleApplicationEventMulticaster.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ │ └── ClassPathXmlApplicationContext.java │ │ │ ├── core │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ ├── stereotype │ │ │ └── Component.java │ │ │ └── util │ │ │ └── ClassUtils.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ └── bean │ │ │ ├── IUserService.java │ │ │ └── UserService.java │ │ └── resources │ │ ├── spring-property.xml │ │ ├── spring-scan.xml │ │ └── token.properties └── target │ └── test-classes │ ├── spring-property.xml │ ├── spring-scan.xml │ └── token.properties ├── spring-step-14 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── aop │ │ │ ├── AdvisedSupport.java │ │ │ ├── Advisor.java │ │ │ ├── BeforeAdvice.java │ │ │ ├── ClassFilter.java │ │ │ ├── MethodBeforeAdvice.java │ │ │ ├── MethodMatcher.java │ │ │ ├── Pointcut.java │ │ │ ├── PointcutAdvisor.java │ │ │ ├── TargetSource.java │ │ │ ├── aspectj │ │ │ │ ├── AspectJExpressionPointcut.java │ │ │ │ └── AspectJExpressionPointcutAdvisor.java │ │ │ └── framework │ │ │ │ ├── AopProxy.java │ │ │ │ ├── Cglib2AopProxy.java │ │ │ │ ├── JdkDynamicAopProxy.java │ │ │ │ ├── ProxyFactory.java │ │ │ │ ├── ReflectiveMethodInvocation.java │ │ │ │ ├── adapter │ │ │ │ └── MethodBeforeAdviceInterceptor.java │ │ │ │ └── autoproxy │ │ │ │ └── DefaultAdvisorAutoProxyCreator.java │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── Aware.java │ │ │ │ ├── BeanClassLoaderAware.java │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── BeanFactoryAware.java │ │ │ │ ├── BeanNameAware.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── FactoryBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── PropertyPlaceholderConfigurer.java │ │ │ │ ├── annotation │ │ │ │ ├── Autowired.java │ │ │ │ ├── AutowiredAnnotationBeanPostProcessor.java │ │ │ │ ├── Qualifier.java │ │ │ │ └── Value.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ ├── InstantiationAwareBeanPostProcessor.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── FactoryBeanRegistrySupport.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ApplicationContextAware.java │ │ │ ├── ApplicationEvent.java │ │ │ ├── ApplicationEventPublisher.java │ │ │ ├── ApplicationListener.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ ├── annotation │ │ │ │ ├── ClassPathBeanDefinitionScanner.java │ │ │ │ ├── ClassPathScanningCandidateComponentProvider.java │ │ │ │ └── Scope.java │ │ │ ├── event │ │ │ │ ├── AbstractApplicationEventMulticaster.java │ │ │ │ ├── ApplicationContextEvent.java │ │ │ │ ├── ApplicationEventMulticaster.java │ │ │ │ ├── ContextClosedEvent.java │ │ │ │ ├── ContextRefreshedEvent.java │ │ │ │ └── SimpleApplicationEventMulticaster.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ │ └── ClassPathXmlApplicationContext.java │ │ │ ├── core │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ ├── stereotype │ │ │ └── Component.java │ │ │ └── util │ │ │ ├── ClassUtils.java │ │ │ └── StringValueResolver.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ └── bean │ │ │ ├── IUserService.java │ │ │ ├── UserDao.java │ │ │ └── UserService.java │ │ └── resources │ │ ├── spring.xml │ │ └── token.properties └── target │ └── test-classes │ ├── spring.xml │ └── token.properties ├── spring-step-15 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── aop │ │ │ ├── AdvisedSupport.java │ │ │ ├── Advisor.java │ │ │ ├── BeforeAdvice.java │ │ │ ├── ClassFilter.java │ │ │ ├── MethodBeforeAdvice.java │ │ │ ├── MethodMatcher.java │ │ │ ├── Pointcut.java │ │ │ ├── PointcutAdvisor.java │ │ │ ├── TargetSource.java │ │ │ ├── aspectj │ │ │ │ ├── AspectJExpressionPointcut.java │ │ │ │ └── AspectJExpressionPointcutAdvisor.java │ │ │ └── framework │ │ │ │ ├── AopProxy.java │ │ │ │ ├── Cglib2AopProxy.java │ │ │ │ ├── JdkDynamicAopProxy.java │ │ │ │ ├── ProxyFactory.java │ │ │ │ ├── ReflectiveMethodInvocation.java │ │ │ │ ├── adapter │ │ │ │ └── MethodBeforeAdviceInterceptor.java │ │ │ │ └── autoproxy │ │ │ │ └── DefaultAdvisorAutoProxyCreator.java │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── Aware.java │ │ │ │ ├── BeanClassLoaderAware.java │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── BeanFactoryAware.java │ │ │ │ ├── BeanNameAware.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── FactoryBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── PropertyPlaceholderConfigurer.java │ │ │ │ ├── annotation │ │ │ │ ├── Autowired.java │ │ │ │ ├── AutowiredAnnotationBeanPostProcessor.java │ │ │ │ ├── Qualifier.java │ │ │ │ └── Value.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ ├── InstantiationAwareBeanPostProcessor.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── FactoryBeanRegistrySupport.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ApplicationContextAware.java │ │ │ ├── ApplicationEvent.java │ │ │ ├── ApplicationEventPublisher.java │ │ │ ├── ApplicationListener.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ ├── annotation │ │ │ │ ├── ClassPathBeanDefinitionScanner.java │ │ │ │ ├── ClassPathScanningCandidateComponentProvider.java │ │ │ │ └── Scope.java │ │ │ ├── event │ │ │ │ ├── AbstractApplicationEventMulticaster.java │ │ │ │ ├── ApplicationContextEvent.java │ │ │ │ ├── ApplicationEventMulticaster.java │ │ │ │ ├── ContextClosedEvent.java │ │ │ │ ├── ContextRefreshedEvent.java │ │ │ │ └── SimpleApplicationEventMulticaster.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ │ └── ClassPathXmlApplicationContext.java │ │ │ ├── core │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ ├── stereotype │ │ │ └── Component.java │ │ │ └── util │ │ │ ├── ClassUtils.java │ │ │ └── StringValueResolver.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ └── bean │ │ │ ├── IUserService.java │ │ │ ├── UserService.java │ │ │ └── UserServiceBeforeAdvice.java │ │ └── resources │ │ ├── spring.xml │ │ └── token.properties └── target │ └── test-classes │ ├── META-INF │ └── spring-step-15.kotlin_module │ ├── spring.xml │ └── token.properties ├── spring-step-16 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── aop │ │ │ ├── AdvisedSupport.java │ │ │ ├── Advisor.java │ │ │ ├── BeforeAdvice.java │ │ │ ├── ClassFilter.java │ │ │ ├── MethodBeforeAdvice.java │ │ │ ├── MethodMatcher.java │ │ │ ├── Pointcut.java │ │ │ ├── PointcutAdvisor.java │ │ │ ├── TargetSource.java │ │ │ ├── aspectj │ │ │ │ ├── AspectJExpressionPointcut.java │ │ │ │ └── AspectJExpressionPointcutAdvisor.java │ │ │ └── framework │ │ │ │ ├── AopProxy.java │ │ │ │ ├── Cglib2AopProxy.java │ │ │ │ ├── JdkDynamicAopProxy.java │ │ │ │ ├── ProxyFactory.java │ │ │ │ ├── ReflectiveMethodInvocation.java │ │ │ │ ├── adapter │ │ │ │ └── MethodBeforeAdviceInterceptor.java │ │ │ │ └── autoproxy │ │ │ │ └── DefaultAdvisorAutoProxyCreator.java │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── Aware.java │ │ │ │ ├── BeanClassLoaderAware.java │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── BeanFactoryAware.java │ │ │ │ ├── BeanNameAware.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── FactoryBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── ObjectFactory.java │ │ │ │ ├── PropertyPlaceholderConfigurer.java │ │ │ │ ├── annotation │ │ │ │ ├── Autowired.java │ │ │ │ ├── AutowiredAnnotationBeanPostProcessor.java │ │ │ │ ├── Qualifier.java │ │ │ │ └── Value.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ ├── InstantiationAwareBeanPostProcessor.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── FactoryBeanRegistrySupport.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ApplicationContextAware.java │ │ │ ├── ApplicationEvent.java │ │ │ ├── ApplicationEventPublisher.java │ │ │ ├── ApplicationListener.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ ├── annotation │ │ │ │ ├── ClassPathBeanDefinitionScanner.java │ │ │ │ ├── ClassPathScanningCandidateComponentProvider.java │ │ │ │ └── Scope.java │ │ │ ├── event │ │ │ │ ├── AbstractApplicationEventMulticaster.java │ │ │ │ ├── ApplicationContextEvent.java │ │ │ │ ├── ApplicationEventMulticaster.java │ │ │ │ ├── ContextClosedEvent.java │ │ │ │ ├── ContextRefreshedEvent.java │ │ │ │ └── SimpleApplicationEventMulticaster.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ │ └── ClassPathXmlApplicationContext.java │ │ │ ├── core │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ ├── stereotype │ │ │ └── Component.java │ │ │ └── util │ │ │ ├── ClassUtils.java │ │ │ └── StringValueResolver.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ ├── CircleTest.java │ │ │ └── bean │ │ │ ├── Husband.java │ │ │ ├── HusbandMother.java │ │ │ ├── IMother.java │ │ │ ├── SpouseAdvice.java │ │ │ └── Wife.java │ │ └── resources │ │ └── spring.xml └── target │ └── test-classes │ └── spring.xml ├── spring-step-17 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── aop │ │ │ ├── AdvisedSupport.java │ │ │ ├── Advisor.java │ │ │ ├── BeforeAdvice.java │ │ │ ├── ClassFilter.java │ │ │ ├── MethodBeforeAdvice.java │ │ │ ├── MethodMatcher.java │ │ │ ├── Pointcut.java │ │ │ ├── PointcutAdvisor.java │ │ │ ├── TargetSource.java │ │ │ ├── aspectj │ │ │ │ ├── AspectJExpressionPointcut.java │ │ │ │ └── AspectJExpressionPointcutAdvisor.java │ │ │ └── framework │ │ │ │ ├── AopProxy.java │ │ │ │ ├── Cglib2AopProxy.java │ │ │ │ ├── JdkDynamicAopProxy.java │ │ │ │ ├── ProxyFactory.java │ │ │ │ ├── ReflectiveMethodInvocation.java │ │ │ │ ├── adapter │ │ │ │ └── MethodBeforeAdviceInterceptor.java │ │ │ │ └── autoproxy │ │ │ │ └── DefaultAdvisorAutoProxyCreator.java │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── Aware.java │ │ │ │ ├── BeanClassLoaderAware.java │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── BeanFactoryAware.java │ │ │ │ ├── BeanNameAware.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── FactoryBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── ObjectFactory.java │ │ │ │ ├── PropertyPlaceholderConfigurer.java │ │ │ │ ├── annotation │ │ │ │ ├── Autowired.java │ │ │ │ ├── AutowiredAnnotationBeanPostProcessor.java │ │ │ │ ├── Qualifier.java │ │ │ │ └── Value.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ ├── InstantiationAwareBeanPostProcessor.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── FactoryBeanRegistrySupport.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ApplicationContextAware.java │ │ │ ├── ApplicationEvent.java │ │ │ ├── ApplicationEventPublisher.java │ │ │ ├── ApplicationListener.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ ├── annotation │ │ │ │ ├── ClassPathBeanDefinitionScanner.java │ │ │ │ ├── ClassPathScanningCandidateComponentProvider.java │ │ │ │ └── Scope.java │ │ │ ├── event │ │ │ │ ├── AbstractApplicationEventMulticaster.java │ │ │ │ ├── ApplicationContextEvent.java │ │ │ │ ├── ApplicationEventMulticaster.java │ │ │ │ ├── ContextClosedEvent.java │ │ │ │ ├── ContextRefreshedEvent.java │ │ │ │ └── SimpleApplicationEventMulticaster.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ │ ├── ClassPathXmlApplicationContext.java │ │ │ │ └── ConversionServiceFactoryBean.java │ │ │ ├── core │ │ │ ├── convert │ │ │ │ ├── ConversionService.java │ │ │ │ ├── converter │ │ │ │ │ ├── Converter.java │ │ │ │ │ ├── ConverterFactory.java │ │ │ │ │ ├── ConverterRegistry.java │ │ │ │ │ └── GenericConverter.java │ │ │ │ └── support │ │ │ │ │ ├── DefaultConversionService.java │ │ │ │ │ ├── GenericConversionService.java │ │ │ │ │ └── StringToNumberConverterFactory.java │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ ├── stereotype │ │ │ └── Component.java │ │ │ └── util │ │ │ ├── ClassUtils.java │ │ │ ├── NumberUtils.java │ │ │ └── StringValueResolver.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ ├── bean │ │ │ └── Husband.java │ │ │ └── converter │ │ │ ├── ConvertersFactoryBean.java │ │ │ ├── StringToIntegerConverter.java │ │ │ └── StringToLocalDateConverter.java │ │ └── resources │ │ └── spring.xml └── target │ └── test-classes │ └── spring.xml ├── spring-step-18 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── aop │ │ │ ├── AdvisedSupport.java │ │ │ ├── Advisor.java │ │ │ ├── BeforeAdvice.java │ │ │ ├── ClassFilter.java │ │ │ ├── MethodBeforeAdvice.java │ │ │ ├── MethodMatcher.java │ │ │ ├── Pointcut.java │ │ │ ├── PointcutAdvisor.java │ │ │ ├── TargetSource.java │ │ │ ├── aspectj │ │ │ │ ├── AspectJExpressionPointcut.java │ │ │ │ └── AspectJExpressionPointcutAdvisor.java │ │ │ └── framework │ │ │ │ ├── AopProxy.java │ │ │ │ ├── Cglib2AopProxy.java │ │ │ │ ├── JdkDynamicAopProxy.java │ │ │ │ ├── ProxyFactory.java │ │ │ │ ├── ReflectiveMethodInvocation.java │ │ │ │ ├── adapter │ │ │ │ └── MethodBeforeAdviceInterceptor.java │ │ │ │ └── autoproxy │ │ │ │ └── DefaultAdvisorAutoProxyCreator.java │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── Aware.java │ │ │ │ ├── BeanClassLoaderAware.java │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── BeanFactoryAware.java │ │ │ │ ├── BeanNameAware.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── FactoryBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── ObjectFactory.java │ │ │ │ ├── PropertyPlaceholderConfigurer.java │ │ │ │ ├── annotation │ │ │ │ ├── Autowired.java │ │ │ │ ├── AutowiredAnnotationBeanPostProcessor.java │ │ │ │ ├── Qualifier.java │ │ │ │ └── Value.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ ├── InstantiationAwareBeanPostProcessor.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── FactoryBeanRegistrySupport.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ApplicationContextAware.java │ │ │ ├── ApplicationEvent.java │ │ │ ├── ApplicationEventPublisher.java │ │ │ ├── ApplicationListener.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ ├── annotation │ │ │ │ ├── ClassPathBeanDefinitionScanner.java │ │ │ │ ├── ClassPathScanningCandidateComponentProvider.java │ │ │ │ └── Scope.java │ │ │ ├── event │ │ │ │ ├── AbstractApplicationEventMulticaster.java │ │ │ │ ├── ApplicationContextEvent.java │ │ │ │ ├── ApplicationEventMulticaster.java │ │ │ │ ├── ContextClosedEvent.java │ │ │ │ ├── ContextRefreshedEvent.java │ │ │ │ └── SimpleApplicationEventMulticaster.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ │ ├── ClassPathXmlApplicationContext.java │ │ │ │ └── ConversionServiceFactoryBean.java │ │ │ ├── core │ │ │ ├── convert │ │ │ │ ├── ConversionService.java │ │ │ │ ├── converter │ │ │ │ │ ├── Converter.java │ │ │ │ │ ├── ConverterFactory.java │ │ │ │ │ ├── ConverterRegistry.java │ │ │ │ │ └── GenericConverter.java │ │ │ │ └── support │ │ │ │ │ ├── DefaultConversionService.java │ │ │ │ │ ├── GenericConversionService.java │ │ │ │ │ └── StringToNumberConverterFactory.java │ │ │ └── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ ├── jdbc │ │ │ ├── core │ │ │ │ ├── ColumnMapRowMapper.java │ │ │ │ ├── JdbcOperations.java │ │ │ │ ├── JdbcTemplate.java │ │ │ │ ├── ResultSetExtractor.java │ │ │ │ ├── RowMapper.java │ │ │ │ ├── RowMapperResultSetExtractor.java │ │ │ │ ├── SqlProvider.java │ │ │ │ └── StatementCallback.java │ │ │ ├── datasource │ │ │ │ └── DataSourceUtils.java │ │ │ └── support │ │ │ │ ├── JdbcAccessor.java │ │ │ │ └── JdbcUtils.java │ │ │ ├── stereotype │ │ │ └── Component.java │ │ │ └── util │ │ │ ├── ClassUtils.java │ │ │ ├── NumberUtils.java │ │ │ └── StringValueResolver.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ └── ApiTest.java │ │ └── resources │ │ └── spring.xml ├── target │ └── test-classes │ │ └── spring.xml └── user.sql ├── spring-step-19 ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ ├── aop │ │ │ ├── AdvisedSupport.java │ │ │ ├── Advisor.java │ │ │ ├── BeforeAdvice.java │ │ │ ├── ClassFilter.java │ │ │ ├── MethodBeforeAdvice.java │ │ │ ├── MethodMatcher.java │ │ │ ├── Pointcut.java │ │ │ ├── PointcutAdvisor.java │ │ │ ├── TargetSource.java │ │ │ ├── aspectj │ │ │ │ ├── AspectJExpressionPointcut.java │ │ │ │ └── AspectJExpressionPointcutAdvisor.java │ │ │ └── framework │ │ │ │ ├── AopProxy.java │ │ │ │ ├── Cglib2AopProxy.java │ │ │ │ ├── JdkDynamicAopProxy.java │ │ │ │ ├── ProxyFactory.java │ │ │ │ ├── ReflectiveMethodInvocation.java │ │ │ │ ├── adapter │ │ │ │ └── MethodBeforeAdviceInterceptor.java │ │ │ │ └── autoproxy │ │ │ │ └── DefaultAdvisorAutoProxyCreator.java │ │ │ ├── beans │ │ │ ├── BeansException.java │ │ │ ├── PropertyValue.java │ │ │ ├── PropertyValues.java │ │ │ └── factory │ │ │ │ ├── Aware.java │ │ │ │ ├── BeanClassLoaderAware.java │ │ │ │ ├── BeanFactory.java │ │ │ │ ├── BeanFactoryAware.java │ │ │ │ ├── BeanNameAware.java │ │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ │ ├── DisposableBean.java │ │ │ │ ├── FactoryBean.java │ │ │ │ ├── HierarchicalBeanFactory.java │ │ │ │ ├── InitializingBean.java │ │ │ │ ├── ListableBeanFactory.java │ │ │ │ ├── ObjectFactory.java │ │ │ │ ├── PropertyPlaceholderConfigurer.java │ │ │ │ ├── annotation │ │ │ │ ├── Autowired.java │ │ │ │ ├── AutowiredAnnotationBeanPostProcessor.java │ │ │ │ ├── Qualifier.java │ │ │ │ └── Value.java │ │ │ │ ├── config │ │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ │ ├── BeanDefinition.java │ │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ │ ├── BeanPostProcessor.java │ │ │ │ ├── BeanReference.java │ │ │ │ ├── ConfigurableBeanFactory.java │ │ │ │ ├── InstantiationAwareBeanPostProcessor.java │ │ │ │ └── SingletonBeanRegistry.java │ │ │ │ ├── support │ │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ │ ├── AbstractBeanFactory.java │ │ │ │ ├── BeanDefinitionReader.java │ │ │ │ ├── BeanDefinitionRegistry.java │ │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ │ ├── DefaultListableBeanFactory.java │ │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ │ ├── DisposableBeanAdapter.java │ │ │ │ ├── FactoryBeanRegistrySupport.java │ │ │ │ ├── InstantiationStrategy.java │ │ │ │ └── SimpleInstantiationStrategy.java │ │ │ │ └── xml │ │ │ │ └── XmlBeanDefinitionReader.java │ │ │ ├── context │ │ │ ├── ApplicationContext.java │ │ │ ├── ApplicationContextAware.java │ │ │ ├── ApplicationEvent.java │ │ │ ├── ApplicationEventPublisher.java │ │ │ ├── ApplicationListener.java │ │ │ ├── ConfigurableApplicationContext.java │ │ │ ├── annotation │ │ │ │ ├── ClassPathBeanDefinitionScanner.java │ │ │ │ ├── ClassPathScanningCandidateComponentProvider.java │ │ │ │ └── Scope.java │ │ │ ├── event │ │ │ │ ├── AbstractApplicationEventMulticaster.java │ │ │ │ ├── ApplicationContextEvent.java │ │ │ │ ├── ApplicationEventMulticaster.java │ │ │ │ ├── ContextClosedEvent.java │ │ │ │ ├── ContextRefreshedEvent.java │ │ │ │ └── SimpleApplicationEventMulticaster.java │ │ │ └── support │ │ │ │ ├── AbstractApplicationContext.java │ │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ │ ├── ClassPathXmlApplicationContext.java │ │ │ │ └── ConversionServiceFactoryBean.java │ │ │ ├── core │ │ │ ├── BridgeMethodResolver.java │ │ │ ├── GraalDetector.java │ │ │ ├── MethodClassKey.java │ │ │ ├── MethodParameter.java │ │ │ ├── ResolvableType.java │ │ │ ├── SerializableTypeWrapper.java │ │ │ ├── annotation │ │ │ │ ├── AbstractAliasAwareAnnotationAttributeExtractor.java │ │ │ │ ├── AliasFor.java │ │ │ │ ├── AnnotatedElementUtils.java │ │ │ │ ├── AnnotationAttributeExtractor.java │ │ │ │ ├── AnnotationAttributes.java │ │ │ │ ├── AnnotationConfigurationException.java │ │ │ │ ├── AnnotationUtils.java │ │ │ │ ├── DefaultAnnotationAttributeExtractor.java │ │ │ │ ├── SynthesizedAnnotation.java │ │ │ │ └── SynthesizedAnnotationInvocationHandler.java │ │ │ ├── convert │ │ │ │ ├── ConversionService.java │ │ │ │ ├── converter │ │ │ │ │ ├── Converter.java │ │ │ │ │ ├── ConverterFactory.java │ │ │ │ │ ├── ConverterRegistry.java │ │ │ │ │ └── GenericConverter.java │ │ │ │ └── support │ │ │ │ │ ├── DefaultConversionService.java │ │ │ │ │ ├── GenericConversionService.java │ │ │ │ │ └── StringToNumberConverterFactory.java │ │ │ ├── io │ │ │ │ ├── ClassPathResource.java │ │ │ │ ├── DefaultResourceLoader.java │ │ │ │ ├── FileSystemResource.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── UrlResource.java │ │ │ └── util │ │ │ │ ├── ConcurrentReferenceHashMap.java │ │ │ │ ├── ObjectUtils.java │ │ │ │ └── StringUtils.java │ │ │ ├── jdbc │ │ │ ├── CannotGetJdbcConnectionException.java │ │ │ ├── UncategorizedSQLException.java │ │ │ ├── core │ │ │ │ ├── ColumnMapRowMapper.java │ │ │ │ ├── JdbcOperations.java │ │ │ │ ├── JdbcTemplate.java │ │ │ │ ├── ResultSetExtractor.java │ │ │ │ ├── RowMapper.java │ │ │ │ ├── RowMapperResultSetExtractor.java │ │ │ │ ├── SqlProvider.java │ │ │ │ └── StatementCallback.java │ │ │ ├── datasource │ │ │ │ ├── ConnectionHandle.java │ │ │ │ ├── ConnectionHolder.java │ │ │ │ ├── DataSourceTransactionManager.java │ │ │ │ ├── DataSourceUtils.java │ │ │ │ ├── JdbcTransactionObjectSupport.java │ │ │ │ └── SimpleConnectionHandle.java │ │ │ └── support │ │ │ │ ├── JdbcAccessor.java │ │ │ │ └── JdbcUtils.java │ │ │ ├── stereotype │ │ │ └── Component.java │ │ │ ├── tx │ │ │ └── transaction │ │ │ │ ├── CannotCreateTransactionException.java │ │ │ │ ├── NestedTransactionNotSupportedException.java │ │ │ │ ├── PlatformTransactionManager.java │ │ │ │ ├── SavepointManager.java │ │ │ │ ├── TransactionDefinition.java │ │ │ │ ├── TransactionException.java │ │ │ │ ├── TransactionExecution.java │ │ │ │ ├── TransactionStatus.java │ │ │ │ ├── annotation │ │ │ │ ├── AnnotationTransactionAttributeSource.java │ │ │ │ ├── SpringTransactionAnnotationParser.java │ │ │ │ ├── TransactionAnnotationParser.java │ │ │ │ └── Transactional.java │ │ │ │ ├── interceptor │ │ │ │ ├── AbstractFallbackTransactionAttributeSource.java │ │ │ │ ├── DefaultTransactionAttribute.java │ │ │ │ ├── DelegatingTransactionAttribute.java │ │ │ │ ├── RollbackRuleAttribute.java │ │ │ │ ├── RuleBasedTransactionAttribute.java │ │ │ │ ├── TransactionAspectSupport.java │ │ │ │ ├── TransactionAttribute.java │ │ │ │ ├── TransactionAttributeSource.java │ │ │ │ └── TransactionInterceptor.java │ │ │ │ └── support │ │ │ │ ├── AbstractPlatformTransactionManager.java │ │ │ │ ├── AbstractTransactionStatus.java │ │ │ │ ├── DefaultTransactionDefinition.java │ │ │ │ ├── DefaultTransactionStatus.java │ │ │ │ ├── DelegatingTransactionDefinition.java │ │ │ │ └── TransactionSynchronizationManager.java │ │ │ └── util │ │ │ ├── ClassUtils.java │ │ │ ├── NumberUtils.java │ │ │ ├── ReflectionUtils.java │ │ │ └── StringValueResolver.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── springframework │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ ├── JdbcTest.java │ │ │ └── bean │ │ │ └── JdbcService.java │ │ └── resources │ │ └── spring.xml ├── target │ ├── classes │ │ └── META-INF │ │ │ └── spring-step-19.kotlin_module │ └── test-classes │ │ └── spring.xml └── user.sql ├── spring-step-20 ├── pom.xml ├── spring.sql ├── src │ ├── main │ │ └── java │ │ │ └── cn │ │ │ └── bugstack │ │ │ └── middleware │ │ │ └── mybatis │ │ │ ├── Configuration.java │ │ │ ├── DefaultSqlSession.java │ │ │ ├── DefaultSqlSessionFactory.java │ │ │ ├── Resources.java │ │ │ ├── SqlSession.java │ │ │ ├── SqlSessionFactory.java │ │ │ ├── SqlSessionFactoryBuilder.java │ │ │ └── XNode.java │ └── test │ │ ├── java │ │ └── cn │ │ │ └── bugstack │ │ │ └── middleware │ │ │ └── mybatis │ │ │ └── test │ │ │ ├── ApiTest.java │ │ │ ├── dao │ │ │ └── IUserDao.java │ │ │ └── po │ │ │ └── User.java │ │ └── resources │ │ ├── mapper │ │ └── User_Mapper.xml │ │ └── mybatis-config-datasource.xml ├── target │ ├── maven-archiver │ │ └── pom.properties │ ├── maven-status │ │ └── maven-compiler-plugin │ │ │ ├── compile │ │ │ └── default-compile │ │ │ │ ├── createdFiles.lst │ │ │ │ └── inputFiles.lst │ │ │ └── testCompile │ │ │ └── default-testCompile │ │ │ ├── createdFiles.lst │ │ │ └── inputFiles.lst │ ├── surefire-reports │ │ ├── TEST-cn.bugstack.middleware.mybatis.test.ApiTest.xml │ │ └── cn.bugstack.middleware.mybatis.test.ApiTest.txt │ └── test-classes │ │ ├── mapper │ │ └── User_Mapper.xml │ │ └── mybatis-config-datasource.xml └── user.sql └── spring-step-21 ├── pom.xml ├── src ├── main │ └── java │ │ └── cn │ │ └── bugstack │ │ └── springframework │ │ ├── aop │ │ ├── AdvisedSupport.java │ │ ├── Advisor.java │ │ ├── BeforeAdvice.java │ │ ├── ClassFilter.java │ │ ├── MethodBeforeAdvice.java │ │ ├── MethodMatcher.java │ │ ├── Pointcut.java │ │ ├── PointcutAdvisor.java │ │ ├── TargetSource.java │ │ ├── aspectj │ │ │ ├── AspectJExpressionPointcut.java │ │ │ └── AspectJExpressionPointcutAdvisor.java │ │ └── framework │ │ │ ├── AopProxy.java │ │ │ ├── Cglib2AopProxy.java │ │ │ ├── JdkDynamicAopProxy.java │ │ │ ├── ProxyFactory.java │ │ │ ├── ReflectiveMethodInvocation.java │ │ │ ├── adapter │ │ │ └── MethodBeforeAdviceInterceptor.java │ │ │ └── autoproxy │ │ │ └── DefaultAdvisorAutoProxyCreator.java │ │ ├── beans │ │ ├── BeansException.java │ │ ├── PropertyValue.java │ │ ├── PropertyValues.java │ │ └── factory │ │ │ ├── Aware.java │ │ │ ├── BeanClassLoaderAware.java │ │ │ ├── BeanFactory.java │ │ │ ├── BeanFactoryAware.java │ │ │ ├── BeanNameAware.java │ │ │ ├── ConfigurableListableBeanFactory.java │ │ │ ├── DisposableBean.java │ │ │ ├── FactoryBean.java │ │ │ ├── HierarchicalBeanFactory.java │ │ │ ├── InitializingBean.java │ │ │ ├── ListableBeanFactory.java │ │ │ ├── ObjectFactory.java │ │ │ ├── PropertyPlaceholderConfigurer.java │ │ │ ├── annotation │ │ │ ├── Autowired.java │ │ │ ├── AutowiredAnnotationBeanPostProcessor.java │ │ │ ├── Qualifier.java │ │ │ └── Value.java │ │ │ ├── config │ │ │ ├── AutowireCapableBeanFactory.java │ │ │ ├── BeanDefinition.java │ │ │ ├── BeanFactoryPostProcessor.java │ │ │ ├── BeanPostProcessor.java │ │ │ ├── BeanReference.java │ │ │ ├── ConfigurableBeanFactory.java │ │ │ ├── InstantiationAwareBeanPostProcessor.java │ │ │ └── SingletonBeanRegistry.java │ │ │ ├── support │ │ │ ├── AbstractAutowireCapableBeanFactory.java │ │ │ ├── AbstractBeanDefinitionReader.java │ │ │ ├── AbstractBeanFactory.java │ │ │ ├── BeanDefinitionReader.java │ │ │ ├── BeanDefinitionRegistry.java │ │ │ ├── BeanDefinitionRegistryPostProcessor.java │ │ │ ├── CglibSubclassingInstantiationStrategy.java │ │ │ ├── DefaultListableBeanFactory.java │ │ │ ├── DefaultSingletonBeanRegistry.java │ │ │ ├── DisposableBeanAdapter.java │ │ │ ├── FactoryBeanRegistrySupport.java │ │ │ ├── InstantiationStrategy.java │ │ │ └── SimpleInstantiationStrategy.java │ │ │ └── xml │ │ │ └── XmlBeanDefinitionReader.java │ │ ├── context │ │ ├── ApplicationContext.java │ │ ├── ApplicationContextAware.java │ │ ├── ApplicationEvent.java │ │ ├── ApplicationEventPublisher.java │ │ ├── ApplicationListener.java │ │ ├── ConfigurableApplicationContext.java │ │ ├── annotation │ │ │ ├── ClassPathBeanDefinitionScanner.java │ │ │ ├── ClassPathScanningCandidateComponentProvider.java │ │ │ └── Scope.java │ │ ├── event │ │ │ ├── AbstractApplicationEventMulticaster.java │ │ │ ├── ApplicationContextEvent.java │ │ │ ├── ApplicationEventMulticaster.java │ │ │ ├── ContextClosedEvent.java │ │ │ ├── ContextRefreshedEvent.java │ │ │ └── SimpleApplicationEventMulticaster.java │ │ └── support │ │ │ ├── AbstractApplicationContext.java │ │ │ ├── AbstractRefreshableApplicationContext.java │ │ │ ├── AbstractXmlApplicationContext.java │ │ │ ├── ApplicationContextAwareProcessor.java │ │ │ ├── ClassPathXmlApplicationContext.java │ │ │ └── ConversionServiceFactoryBean.java │ │ ├── core │ │ ├── BridgeMethodResolver.java │ │ ├── GraalDetector.java │ │ ├── MethodClassKey.java │ │ ├── MethodParameter.java │ │ ├── ResolvableType.java │ │ ├── SerializableTypeWrapper.java │ │ ├── annotation │ │ │ ├── AbstractAliasAwareAnnotationAttributeExtractor.java │ │ │ ├── AliasFor.java │ │ │ ├── AnnotatedElementUtils.java │ │ │ ├── AnnotationAttributeExtractor.java │ │ │ ├── AnnotationAttributes.java │ │ │ ├── AnnotationConfigurationException.java │ │ │ ├── AnnotationUtils.java │ │ │ ├── DefaultAnnotationAttributeExtractor.java │ │ │ ├── SynthesizedAnnotation.java │ │ │ └── SynthesizedAnnotationInvocationHandler.java │ │ ├── convert │ │ │ ├── ConversionService.java │ │ │ ├── converter │ │ │ │ ├── Converter.java │ │ │ │ ├── ConverterFactory.java │ │ │ │ ├── ConverterRegistry.java │ │ │ │ └── GenericConverter.java │ │ │ └── support │ │ │ │ ├── DefaultConversionService.java │ │ │ │ ├── GenericConversionService.java │ │ │ │ └── StringToNumberConverterFactory.java │ │ ├── io │ │ │ ├── ClassPathResource.java │ │ │ ├── DefaultResourceLoader.java │ │ │ ├── FileSystemResource.java │ │ │ ├── Resource.java │ │ │ ├── ResourceLoader.java │ │ │ └── UrlResource.java │ │ ├── type │ │ │ └── classreading │ │ │ │ └── MetadataReader.java │ │ └── util │ │ │ ├── ConcurrentReferenceHashMap.java │ │ │ ├── ObjectUtils.java │ │ │ └── StringUtils.java │ │ ├── jdbc │ │ ├── CannotGetJdbcConnectionException.java │ │ ├── UncategorizedSQLException.java │ │ ├── core │ │ │ ├── ColumnMapRowMapper.java │ │ │ ├── JdbcOperations.java │ │ │ ├── JdbcTemplate.java │ │ │ ├── ResultSetExtractor.java │ │ │ ├── RowMapper.java │ │ │ ├── RowMapperResultSetExtractor.java │ │ │ ├── SqlProvider.java │ │ │ └── StatementCallback.java │ │ ├── datasource │ │ │ ├── ConnectionHandle.java │ │ │ ├── ConnectionHolder.java │ │ │ ├── DataSourceTransactionManager.java │ │ │ ├── DataSourceUtils.java │ │ │ ├── JdbcTransactionObjectSupport.java │ │ │ └── SimpleConnectionHandle.java │ │ └── support │ │ │ ├── JdbcAccessor.java │ │ │ └── JdbcUtils.java │ │ ├── mybatis │ │ ├── MapperFactoryBean.java │ │ ├── MapperScannerConfigurer.java │ │ └── SqlSessionFactoryBean.java │ │ ├── stereotype │ │ └── Component.java │ │ ├── tx │ │ └── transaction │ │ │ ├── CannotCreateTransactionException.java │ │ │ ├── NestedTransactionNotSupportedException.java │ │ │ ├── PlatformTransactionManager.java │ │ │ ├── SavepointManager.java │ │ │ ├── TransactionDefinition.java │ │ │ ├── TransactionException.java │ │ │ ├── TransactionExecution.java │ │ │ ├── TransactionStatus.java │ │ │ ├── annotation │ │ │ ├── AnnotationTransactionAttributeSource.java │ │ │ ├── SpringTransactionAnnotationParser.java │ │ │ ├── TransactionAnnotationParser.java │ │ │ └── Transactional.java │ │ │ ├── interceptor │ │ │ ├── AbstractFallbackTransactionAttributeSource.java │ │ │ ├── DefaultTransactionAttribute.java │ │ │ ├── DelegatingTransactionAttribute.java │ │ │ ├── RollbackRuleAttribute.java │ │ │ ├── RuleBasedTransactionAttribute.java │ │ │ ├── TransactionAspectSupport.java │ │ │ ├── TransactionAttribute.java │ │ │ ├── TransactionAttributeSource.java │ │ │ └── TransactionInterceptor.java │ │ │ └── support │ │ │ ├── AbstractPlatformTransactionManager.java │ │ │ ├── AbstractTransactionStatus.java │ │ │ ├── DefaultTransactionDefinition.java │ │ │ ├── DefaultTransactionStatus.java │ │ │ ├── DelegatingTransactionDefinition.java │ │ │ └── TransactionSynchronizationManager.java │ │ └── util │ │ ├── ClassUtils.java │ │ ├── NumberUtils.java │ │ ├── ReflectionUtils.java │ │ └── StringValueResolver.java └── test │ ├── java │ └── cn │ │ └── bugstack │ │ └── springframework │ │ └── test │ │ ├── ApiTest.java │ │ ├── dao │ │ └── IUserDao.java │ │ └── po │ │ └── User.java │ └── resources │ ├── mapper │ └── User_Mapper.xml │ ├── mybatis-config-datasource.xml │ └── spring.xml ├── target ├── maven-status │ └── maven-compiler-plugin │ │ ├── compile │ │ └── default-compile │ │ │ ├── createdFiles.lst │ │ │ └── inputFiles.lst │ │ └── testCompile │ │ └── default-testCompile │ │ ├── createdFiles.lst │ │ └── inputFiles.lst ├── surefire-reports │ ├── TEST-cn.bugstack.springframework.test.ApiTest.xml │ └── cn.bugstack.springframework.test.ApiTest.txt └── test-classes │ ├── mapper │ └── User_Mapper.xml │ ├── mybatis-config-datasource.xml │ └── spring.xml └── user.sql /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | *.pdf 22 | 23 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 24 | hs_err_pid* 25 | 26 | /.idea/ 27 | 28 | /*/*.iml 29 | -------------------------------------------------------------------------------- /doc/book-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuzhengwei/book-small-spring/59f207f334f311c5f3adc3bbadf99209532862cf/doc/book-01.png -------------------------------------------------------------------------------- /doc/book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuzhengwei/book-small-spring/59f207f334f311c5f3adc3bbadf99209532862cf/doc/book.png -------------------------------------------------------------------------------- /spring-step-01/src/main/java/cn/bugstack/springframework/BeanDefinition.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework; 2 | 3 | /** 4 | * @description Bean 对象信息定义 5 | * 6 | * 7 | * 8 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 9 | * @date 2022/2/9 10 | * 11 | * 12 | */ 13 | public class BeanDefinition { 14 | 15 | private Object bean; 16 | 17 | public BeanDefinition(Object bean) { 18 | this.bean = bean; 19 | } 20 | 21 | public Object getBean() { 22 | return bean; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-01/src/test/java/cn/bugstack/springframework/test/bean/UserService.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 模拟用户 Bean 对象 9 | * @date 2022/2/9 10 | * 11 | * 12 | */ 13 | public class UserService { 14 | 15 | public void queryUserInfo(){ 16 | System.out.println("查询用户信息"); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-02/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-02/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 定义 Bean 工厂接口 11 | * @date 2022/03/07 12 | * 13 | * 14 | */ 15 | public interface BeanFactory { 16 | 17 | /** 18 | * 返回 Bean 的实例对象 19 | * @param name 要检索的bean的名称 20 | * @return 实例化的 Bean 对象 21 | * @throws BeansException 不能获取 Bean 对象,则抛出异常 22 | */ 23 | Object getBean(String name) throws BeansException; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-02/src/test/java/cn/bugstack/springframework/test/bean/UserService.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 模拟用户 Bean 对象 9 | * @date 2022/03/07 10 | * 11 | * 12 | */ 13 | public class UserService { 14 | 15 | public void queryUserInfo() { 16 | System.out.println("查询用户信息"); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-03/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-04/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-04/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-05/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-05/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Sub-interface implemented by bean factories that can be part 9 | * of a hierarchy. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface HierarchicalBeanFactory extends BeanFactory { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-05/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-05/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 资源处理接口 12 | * @date 2022/3/9 13 | * 14 | * 15 | */ 16 | public interface Resource { 17 | 18 | InputStream getInputStream() throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-05/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 资源加载器 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface ResourceLoader { 14 | 15 | /** 16 | * Pseudo URL prefix for loading from the class path: "classpath:" 17 | */ 18 | String CLASSPATH_URL_PREFIX = "classpath:"; 19 | 20 | Resource getResource(String location); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-05/src/test/resources/important.properties: -------------------------------------------------------------------------------- 1 | # Config File 2 | system.key=OLpj9823dZ -------------------------------------------------------------------------------- /spring-step-05/src/test/resources/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /spring-step-05/target/test-classes/important.properties: -------------------------------------------------------------------------------- 1 | # Config File 2 | system.key=OLpj9823dZ -------------------------------------------------------------------------------- /spring-step-05/target/test-classes/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /spring-step-06/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-06/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Sub-interface implemented by bean factories that can be part 9 | * of a hierarchy. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface HierarchicalBeanFactory extends BeanFactory { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-06/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-06/src/main/java/cn/bugstack/springframework/context/ApplicationContext.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.factory.ListableBeanFactory; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 应用上下文接口 Central interface to provide configuration for an application. 11 | * This is read-only while the application is running, but may be 12 | * reloaded if the implementation supports this. 13 | * @date 2022/3/10 14 | * 15 | * 16 | */ 17 | public interface ApplicationContext extends ListableBeanFactory { 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-06/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 资源处理接口 12 | * @date 2022/3/9 13 | * 14 | * 15 | */ 16 | public interface Resource { 17 | 18 | InputStream getInputStream() throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-06/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 资源加载器 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface ResourceLoader { 14 | 15 | /** 16 | * Pseudo URL prefix for loading from the class path: "classpath:" 17 | */ 18 | String CLASSPATH_URL_PREFIX = "classpath:"; 19 | 20 | Resource getResource(String location); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-06/src/test/resources/important.properties: -------------------------------------------------------------------------------- 1 | # Config File 2 | system.key=OLpj9823dZ -------------------------------------------------------------------------------- /spring-step-06/src/test/resources/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-step-06/target/test-classes/important.properties: -------------------------------------------------------------------------------- 1 | # Config File 2 | system.key=OLpj9823dZ -------------------------------------------------------------------------------- /spring-step-06/target/test-classes/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-step-07/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-07/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Sub-interface implemented by bean factories that can be part 9 | * of a hierarchy. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface HierarchicalBeanFactory extends BeanFactory { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-07/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface InitializingBean { 14 | 15 | /** 16 | * Bean 处理了属性填充后调用 17 | * 18 | * @throws Exception 19 | */ 20 | void afterPropertiesSet() throws Exception; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-07/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-07/src/main/java/cn/bugstack/springframework/context/ApplicationContext.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.factory.ListableBeanFactory; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 应用上下文接口 Central interface to provide configuration for an application. 11 | * This is read-only while the application is running, but may be 12 | * reloaded if the implementation supports this. 13 | * @date 2022/3/10 14 | * 15 | * 16 | */ 17 | public interface ApplicationContext extends ListableBeanFactory { 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-07/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 资源处理接口 12 | * @date 2022/3/9 13 | * 14 | * 15 | */ 16 | public interface Resource { 17 | 18 | InputStream getInputStream() throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-07/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 资源加载器 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface ResourceLoader { 14 | 15 | /** 16 | * Pseudo URL prefix for loading from the class path: "classpath:" 17 | */ 18 | String CLASSPATH_URL_PREFIX = "classpath:"; 19 | 20 | Resource getResource(String location); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-07/src/test/resources/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /spring-step-07/target/test-classes/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-step-08/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-08/src/main/java/cn/bugstack/springframework/beans/factory/Aware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 标记类接口,实现该接口可以被Spring容器感知 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface Aware { 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-08/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Callback that allows a bean to be aware of the bean 9 | * {@link ClassLoader class loader}; that is, the class loader used by the 10 | * present bean factory to load bean classes. 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanClassLoaderAware extends Aware { 16 | 17 | void setBeanClassLoader(ClassLoader classLoader); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-08/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 实现此接口,既能感知到所属的 BeanFactory 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanFactoryAware extends Aware { 16 | 17 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-08/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Sub-interface implemented by bean factories that can be part 9 | * of a hierarchy. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface HierarchicalBeanFactory extends BeanFactory { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-08/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface InitializingBean { 14 | 15 | /** 16 | * Bean 处理了属性填充后调用 17 | * 18 | * @throws Exception 19 | */ 20 | void afterPropertiesSet() throws Exception; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-08/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-08/src/main/java/cn/bugstack/springframework/context/ApplicationContext.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.factory.ListableBeanFactory; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 应用上下文接口 Central interface to provide configuration for an application. 11 | * This is read-only while the application is running, but may be 12 | * reloaded if the implementation supports this. 13 | * @date 2022/3/10 14 | * 15 | * 16 | */ 17 | public interface ApplicationContext extends ListableBeanFactory { 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-08/src/main/java/cn/bugstack/springframework/context/ApplicationContextAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.Aware; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 实现此接口,既能感知到所属的 ApplicationContext 12 | * @date 2022/3/11 13 | * /CodeDesignTutorials 14 | * 15 | */ 16 | public interface ApplicationContextAware extends Aware { 17 | 18 | void setApplicationContext(ApplicationContext applicationContext) throws BeansException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-08/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 资源处理接口 12 | * @date 2022/3/9 13 | * 14 | * 15 | */ 16 | public interface Resource { 17 | 18 | InputStream getInputStream() throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-08/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 资源加载器 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface ResourceLoader { 14 | 15 | /** 16 | * Pseudo URL prefix for loading from the class path: "classpath:" 17 | */ 18 | String CLASSPATH_URL_PREFIX = "classpath:"; 19 | 20 | Resource getResource(String location); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-08/src/test/resources/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-step-08/target/test-classes/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-step-09/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-09/src/main/java/cn/bugstack/springframework/beans/factory/Aware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 标记类接口,实现该接口可以被Spring容器感知 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface Aware { 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-09/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Callback that allows a bean to be aware of the bean 9 | * {@link ClassLoader class loader}; that is, the class loader used by the 10 | * present bean factory to load bean classes. 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanClassLoaderAware extends Aware { 16 | 17 | void setBeanClassLoader(ClassLoader classLoader); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-09/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 实现此接口,既能感知到所属的 BeanFactory 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanFactoryAware extends Aware { 16 | 17 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-09/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Sub-interface implemented by bean factories that can be part 9 | * of a hierarchy. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface HierarchicalBeanFactory extends BeanFactory { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-09/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface InitializingBean { 14 | 15 | /** 16 | * Bean 处理了属性填充后调用 17 | * 18 | * @throws Exception 19 | */ 20 | void afterPropertiesSet() throws Exception; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-09/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-09/src/main/java/cn/bugstack/springframework/context/ApplicationContext.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.factory.ListableBeanFactory; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 应用上下文接口 Central interface to provide configuration for an application. 11 | * This is read-only while the application is running, but may be 12 | * reloaded if the implementation supports this. 13 | * @date 2022/3/10 14 | * 15 | * 16 | */ 17 | public interface ApplicationContext extends ListableBeanFactory { 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-09/src/main/java/cn/bugstack/springframework/context/ApplicationContextAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.Aware; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 实现此接口,既能感知到所属的 ApplicationContext 12 | * @date 2022/3/11 13 | * /CodeDesignTutorials 14 | * 15 | */ 16 | public interface ApplicationContextAware extends Aware { 17 | 18 | void setApplicationContext(ApplicationContext applicationContext) throws BeansException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-09/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 资源处理接口 12 | * @date 2022/3/9 13 | * 14 | * 15 | */ 16 | public interface Resource { 17 | 18 | InputStream getInputStream() throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-09/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 资源加载器 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface ResourceLoader { 14 | 15 | /** 16 | * Pseudo URL prefix for loading from the class path: "classpath:" 17 | */ 18 | String CLASSPATH_URL_PREFIX = "classpath:"; 19 | 20 | Resource getResource(String location); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-09/src/test/java/cn/bugstack/springframework/test/bean/IUserDao.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | public interface IUserDao { 4 | 5 | String queryUserName(String uId); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /spring-step-09/src/test/resources/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-step-09/target/test-classes/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-step-10/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-10/src/main/java/cn/bugstack/springframework/beans/factory/Aware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 标记类接口,实现该接口可以被Spring容器感知 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface Aware { 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-10/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Callback that allows a bean to be aware of the bean 9 | * {@link ClassLoader class loader}; that is, the class loader used by the 10 | * present bean factory to load bean classes. 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanClassLoaderAware extends Aware { 16 | 17 | void setBeanClassLoader(ClassLoader classLoader); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-10/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 实现此接口,既能感知到所属的 BeanFactory 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanFactoryAware extends Aware { 16 | 17 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-10/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Sub-interface implemented by bean factories that can be part 9 | * of a hierarchy. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface HierarchicalBeanFactory extends BeanFactory { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-10/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface InitializingBean { 14 | 15 | /** 16 | * Bean 处理了属性填充后调用 17 | * 18 | * @throws Exception 19 | */ 20 | void afterPropertiesSet() throws Exception; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-10/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-10/src/main/java/cn/bugstack/springframework/context/ApplicationContextAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.Aware; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 实现此接口,既能感知到所属的 ApplicationContext 12 | * @date 2022/3/11 13 | * /CodeDesignTutorials 14 | * 15 | */ 16 | public interface ApplicationContextAware extends Aware { 17 | 18 | void setApplicationContext(ApplicationContext applicationContext) throws BeansException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-10/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 资源处理接口 12 | * @date 2022/3/9 13 | * 14 | * 15 | */ 16 | public interface Resource { 17 | 18 | InputStream getInputStream() throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-10/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 资源加载器 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface ResourceLoader { 14 | 15 | /** 16 | * Pseudo URL prefix for loading from the class path: "classpath:" 17 | */ 18 | String CLASSPATH_URL_PREFIX = "classpath:"; 19 | 20 | Resource getResource(String location); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-10/src/test/java/cn/bugstack/springframework/test/event/ContextClosedEventListener.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.event; 2 | 3 | import cn.bugstack.springframework.context.ApplicationListener; 4 | import cn.bugstack.springframework.context.event.ContextClosedEvent; 5 | 6 | public class ContextClosedEventListener implements ApplicationListener { 7 | 8 | @Override 9 | public void onApplicationEvent(ContextClosedEvent event) { 10 | System.out.println("关闭事件:" + this.getClass().getName()); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-step-10/src/test/java/cn/bugstack/springframework/test/event/ContextRefreshedEventListener.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.event; 2 | 3 | import cn.bugstack.springframework.context.ApplicationListener; 4 | import cn.bugstack.springframework.context.event.ContextRefreshedEvent; 5 | 6 | public class ContextRefreshedEventListener implements ApplicationListener { 7 | 8 | @Override 9 | public void onApplicationEvent(ContextRefreshedEvent event) { 10 | System.out.println("刷新事件:" + this.getClass().getName()); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-step-10/src/test/java/cn/bugstack/springframework/test/event/CustomEventListener.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.event; 2 | 3 | import cn.bugstack.springframework.context.ApplicationListener; 4 | 5 | import java.util.Date; 6 | 7 | public class CustomEventListener implements ApplicationListener { 8 | 9 | @Override 10 | public void onApplicationEvent(CustomEvent event) { 11 | System.out.println("收到:" + event.getSource() + "消息;时间:" + new Date()); 12 | System.out.println("消息:" + event.getId() + ":" + event.getMessage()); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-step-10/src/test/resources/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /spring-step-10/target/test-classes/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/aop/ClassFilter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * Filter that restricts matching of a pointcut or introduction to 5 | * a given set of target classes. 6 | * 7 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 8 | * 公众号:bugstack虫洞栈 9 | * Create by 小傅哥(fustack) 10 | */ 11 | public interface ClassFilter { 12 | 13 | /** 14 | * Should the pointcut apply to the given interface or target class? 15 | * @param clazz the candidate target class 16 | * @return whether the advice should apply to the given target class 17 | */ 18 | boolean matches(Class clazz); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/aop/MethodMatcher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * Part of a {@link Pointcut}: Checks whether the target method is eligible for advice. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface MethodMatcher { 13 | 14 | /** 15 | * Perform static checking whether the given method matches. If this 16 | * @return whether or not this method matches statically 17 | */ 18 | boolean matches(Method method, Class targetClass); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/aop/framework/AopProxy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop.framework; 2 | 3 | /** 4 | * Delegate interface for a configured AOP proxy, allowing for the creation 5 | * of actual proxy objects. 6 | * 7 | *

Out-of-the-box implementations are available for JDK dynamic proxies 8 | * and for CGLIB proxies, as applied by DefaultAopProxyFactory 9 | * 10 | * AOP 代理的抽象 11 | * 12 | *

13 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 14 | * 公众号:bugstack虫洞栈 15 | * Create by 小傅哥(fustack) 16 | */ 17 | public interface AopProxy { 18 | 19 | Object getProxy(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/beans/factory/Aware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 标记类接口,实现该接口可以被Spring容器感知 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface Aware { 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Callback that allows a bean to be aware of the bean 9 | * {@link ClassLoader class loader}; that is, the class loader used by the 10 | * present bean factory to load bean classes. 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanClassLoaderAware extends Aware { 16 | 17 | void setBeanClassLoader(ClassLoader classLoader); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 实现此接口,既能感知到所属的 BeanFactory 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanFactoryAware extends Aware { 16 | 17 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Sub-interface implemented by bean factories that can be part 9 | * of a hierarchy. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface HierarchicalBeanFactory extends BeanFactory { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface InitializingBean { 14 | 15 | /** 16 | * Bean 处理了属性填充后调用 17 | * 18 | * @throws Exception 19 | */ 20 | void afterPropertiesSet() throws Exception; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/beans/factory/config/SingletonBeanRegistry.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 单例 Bean 注册表 9 | * @date 2022/03/07 10 | * 11 | * 12 | */ 13 | public interface SingletonBeanRegistry { 14 | 15 | /** 16 | * 返回在给定名称下注册的(原始)单例对象。 17 | * @param beanName 要查找的bean的名称 18 | * @return 返回注册的单例对象 19 | */ 20 | Object getSingleton(String beanName); 21 | 22 | void registerSingleton(String beanName, Object singletonObject); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/context/ApplicationContextAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.Aware; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 实现此接口,既能感知到所属的 ApplicationContext 12 | * @date 2022/3/11 13 | * /CodeDesignTutorials 14 | * 15 | */ 16 | public interface ApplicationContextAware extends Aware { 17 | 18 | void setApplicationContext(ApplicationContext applicationContext) throws BeansException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 资源处理接口 12 | * @date 2022/3/9 13 | * 14 | * 15 | */ 16 | public interface Resource { 17 | 18 | InputStream getInputStream() throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-11/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 资源加载器 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface ResourceLoader { 14 | 15 | /** 16 | * Pseudo URL prefix for loading from the class path: "classpath:" 17 | */ 18 | String CLASSPATH_URL_PREFIX = "classpath:"; 19 | 20 | Resource getResource(String location); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-11/src/test/java/cn/bugstack/springframework/test/bean/IUserService.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | public interface IUserService { 4 | 5 | String queryUserInfo(); 6 | 7 | String register(String userName); 8 | } 9 | -------------------------------------------------------------------------------- /spring-step-11/src/test/resources/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /spring-step-11/target/test-classes/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/aop/BeforeAdvice.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import org.aopalliance.aop.Advice; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description Common marker interface for before advice, such as {@link MethodBeforeAdvice}. 11 | * @date 2022/3/14 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeforeAdvice extends Advice { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/aop/ClassFilter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * Filter that restricts matching of a pointcut or introduction to 5 | * a given set of target classes. 6 | * 7 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 8 | * 公众号:bugstack虫洞栈 9 | * Create by 小傅哥(fustack) 10 | */ 11 | public interface ClassFilter { 12 | 13 | /** 14 | * Should the pointcut apply to the given interface or target class? 15 | * @param clazz the candidate target class 16 | * @return whether the advice should apply to the given target class 17 | */ 18 | boolean matches(Class clazz); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/aop/MethodMatcher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * Part of a {@link Pointcut}: Checks whether the target method is eligible for advice. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface MethodMatcher { 13 | 14 | /** 15 | * Perform static checking whether the given method matches. If this 16 | * @return whether or not this method matches statically 17 | */ 18 | boolean matches(Method method, Class targetClass); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/aop/PointcutAdvisor.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Superinterface for all Advisors that are driven by a pointcut. 9 | * This covers nearly all advisors except introduction advisors, 10 | * for which method-level matching doesn't apply. 11 | * @date 2022/3/14 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface PointcutAdvisor extends Advisor { 16 | 17 | /** 18 | * Get the Pointcut that drives this advisor. 19 | */ 20 | Pointcut getPointcut(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/aop/framework/AopProxy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop.framework; 2 | 3 | /** 4 | * Delegate interface for a configured AOP proxy, allowing for the creation 5 | * of actual proxy objects. 6 | * 7 | *

Out-of-the-box implementations are available for JDK dynamic proxies 8 | * and for CGLIB proxies, as applied by DefaultAopProxyFactory 9 | * 10 | * AOP 代理的抽象 11 | * 12 | *

13 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 14 | * 公众号:bugstack虫洞栈 15 | * Create by 小傅哥(fustack) 16 | */ 17 | public interface AopProxy { 18 | 19 | Object getProxy(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/beans/factory/Aware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 标记类接口,实现该接口可以被Spring容器感知 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface Aware { 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Callback that allows a bean to be aware of the bean 9 | * {@link ClassLoader class loader}; that is, the class loader used by the 10 | * present bean factory to load bean classes. 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanClassLoaderAware extends Aware { 16 | 17 | void setBeanClassLoader(ClassLoader classLoader); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 实现此接口,既能感知到所属的 BeanFactory 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanFactoryAware extends Aware { 16 | 17 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Sub-interface implemented by bean factories that can be part 9 | * of a hierarchy. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface HierarchicalBeanFactory extends BeanFactory { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface InitializingBean { 14 | 15 | /** 16 | * Bean 处理了属性填充后调用 17 | * 18 | * @throws Exception 19 | */ 20 | void afterPropertiesSet() throws Exception; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/beans/factory/config/SingletonBeanRegistry.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 单例 Bean 注册表 9 | * @date 2022/03/07 10 | * 11 | * 12 | */ 13 | public interface SingletonBeanRegistry { 14 | 15 | /** 16 | * 返回在给定名称下注册的(原始)单例对象。 17 | * @param beanName 要查找的bean的名称 18 | * @return 返回注册的单例对象 19 | */ 20 | Object getSingleton(String beanName); 21 | 22 | void registerSingleton(String beanName, Object singletonObject); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/context/ApplicationContextAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.Aware; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 实现此接口,既能感知到所属的 ApplicationContext 12 | * @date 2022/3/11 13 | * /CodeDesignTutorials 14 | * 15 | */ 16 | public interface ApplicationContextAware extends Aware { 17 | 18 | void setApplicationContext(ApplicationContext applicationContext) throws BeansException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 资源处理接口 12 | * @date 2022/3/9 13 | * 14 | * 15 | */ 16 | public interface Resource { 17 | 18 | InputStream getInputStream() throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-12/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 资源加载器 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface ResourceLoader { 14 | 15 | /** 16 | * Pseudo URL prefix for loading from the class path: "classpath:" 17 | */ 18 | String CLASSPATH_URL_PREFIX = "classpath:"; 19 | 20 | Resource getResource(String location); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-12/src/test/java/cn/bugstack/springframework/test/bean/IUserService.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | public interface IUserService { 4 | 5 | String queryUserInfo(); 6 | 7 | String register(String userName); 8 | } 9 | -------------------------------------------------------------------------------- /spring-step-12/src/test/java/cn/bugstack/springframework/test/bean/UserServiceBeforeAdvice.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | import cn.bugstack.springframework.aop.MethodBeforeAdvice; 4 | 5 | import java.lang.reflect.Method; 6 | 7 | public class UserServiceBeforeAdvice implements MethodBeforeAdvice { 8 | 9 | @Override 10 | public void before(Method method, Object[] args, Object target) throws Throwable { 11 | System.out.println("拦截方法:" + method.getName()); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/aop/BeforeAdvice.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import org.aopalliance.aop.Advice; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description Common marker interface for before advice, such as {@link MethodBeforeAdvice}. 11 | * @date 2022/3/14 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeforeAdvice extends Advice { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/aop/ClassFilter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * Filter that restricts matching of a pointcut or introduction to 5 | * a given set of target classes. 6 | * 7 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 8 | * 公众号:bugstack虫洞栈 9 | * Create by 小傅哥(fustack) 10 | */ 11 | public interface ClassFilter { 12 | 13 | /** 14 | * Should the pointcut apply to the given interface or target class? 15 | * @param clazz the candidate target class 16 | * @return whether the advice should apply to the given target class 17 | */ 18 | boolean matches(Class clazz); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/aop/MethodMatcher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * Part of a {@link Pointcut}: Checks whether the target method is eligible for advice. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface MethodMatcher { 13 | 14 | /** 15 | * Perform static checking whether the given method matches. If this 16 | * @return whether or not this method matches statically 17 | */ 18 | boolean matches(Method method, Class targetClass); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/aop/PointcutAdvisor.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Superinterface for all Advisors that are driven by a pointcut. 9 | * This covers nearly all advisors except introduction advisors, 10 | * for which method-level matching doesn't apply. 11 | * @date 2022/3/14 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface PointcutAdvisor extends Advisor { 16 | 17 | /** 18 | * Get the Pointcut that drives this advisor. 19 | */ 20 | Pointcut getPointcut(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/aop/framework/AopProxy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop.framework; 2 | 3 | /** 4 | * Delegate interface for a configured AOP proxy, allowing for the creation 5 | * of actual proxy objects. 6 | * 7 | *

Out-of-the-box implementations are available for JDK dynamic proxies 8 | * and for CGLIB proxies, as applied by DefaultAopProxyFactory 9 | * 10 | * AOP 代理的抽象 11 | * 12 | *

13 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 14 | * 公众号:bugstack虫洞栈 15 | * Create by 小傅哥(fustack) 16 | */ 17 | public interface AopProxy { 18 | 19 | Object getProxy(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/beans/factory/Aware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 标记类接口,实现该接口可以被Spring容器感知 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface Aware { 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Callback that allows a bean to be aware of the bean 9 | * {@link ClassLoader class loader}; that is, the class loader used by the 10 | * present bean factory to load bean classes. 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanClassLoaderAware extends Aware { 16 | 17 | void setBeanClassLoader(ClassLoader classLoader); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 实现此接口,既能感知到所属的 BeanFactory 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanFactoryAware extends Aware { 16 | 17 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Sub-interface implemented by bean factories that can be part 9 | * of a hierarchy. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface HierarchicalBeanFactory extends BeanFactory { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface InitializingBean { 14 | 15 | /** 16 | * Bean 处理了属性填充后调用 17 | * 18 | * @throws Exception 19 | */ 20 | void afterPropertiesSet() throws Exception; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/beans/factory/config/SingletonBeanRegistry.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 单例 Bean 注册表 9 | * @date 2022/03/07 10 | * 11 | * 12 | */ 13 | public interface SingletonBeanRegistry { 14 | 15 | /** 16 | * 返回在给定名称下注册的(原始)单例对象。 17 | * @param beanName 要查找的bean的名称 18 | * @return 返回注册的单例对象 19 | */ 20 | Object getSingleton(String beanName); 21 | 22 | void registerSingleton(String beanName, Object singletonObject); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/context/ApplicationContextAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.Aware; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 实现此接口,既能感知到所属的 ApplicationContext 12 | * @date 2022/3/11 13 | * /CodeDesignTutorials 14 | * 15 | */ 16 | public interface ApplicationContextAware extends Aware { 17 | 18 | void setApplicationContext(ApplicationContext applicationContext) throws BeansException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/context/annotation/Scope.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | @Target({ElementType.TYPE, ElementType.METHOD}) 6 | @Retention(RetentionPolicy.RUNTIME) 7 | @Documented 8 | public @interface Scope { 9 | 10 | String value() default "singleton"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 资源处理接口 12 | * @date 2022/3/9 13 | * 14 | * 15 | */ 16 | public interface Resource { 17 | 18 | InputStream getInputStream() throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-13/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 资源加载器 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface ResourceLoader { 14 | 15 | /** 16 | * Pseudo URL prefix for loading from the class path: "classpath:" 17 | */ 18 | String CLASSPATH_URL_PREFIX = "classpath:"; 19 | 20 | Resource getResource(String location); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-13/src/test/java/cn/bugstack/springframework/test/bean/IUserService.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | public interface IUserService { 4 | 5 | String queryUserInfo(); 6 | 7 | String register(String userName); 8 | } 9 | -------------------------------------------------------------------------------- /spring-step-13/src/test/resources/spring-scan.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /spring-step-13/src/test/resources/token.properties: -------------------------------------------------------------------------------- 1 | token=RejDlI78hu223Opo983Ds -------------------------------------------------------------------------------- /spring-step-13/target/test-classes/spring-scan.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /spring-step-13/target/test-classes/token.properties: -------------------------------------------------------------------------------- 1 | token=RejDlI78hu223Opo983Ds -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/aop/BeforeAdvice.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import org.aopalliance.aop.Advice; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description Common marker interface for before advice, such as {@link MethodBeforeAdvice}. 11 | * @date 2022/3/14 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeforeAdvice extends Advice { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/aop/ClassFilter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * Filter that restricts matching of a pointcut or introduction to 5 | * a given set of target classes. 6 | * 7 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 8 | * 公众号:bugstack虫洞栈 9 | * Create by 小傅哥(fustack) 10 | */ 11 | public interface ClassFilter { 12 | 13 | /** 14 | * Should the pointcut apply to the given interface or target class? 15 | * @param clazz the candidate target class 16 | * @return whether the advice should apply to the given target class 17 | */ 18 | boolean matches(Class clazz); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/aop/MethodMatcher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * Part of a {@link Pointcut}: Checks whether the target method is eligible for advice. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface MethodMatcher { 13 | 14 | /** 15 | * Perform static checking whether the given method matches. If this 16 | * @return whether or not this method matches statically 17 | */ 18 | boolean matches(Method method, Class targetClass); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/aop/PointcutAdvisor.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Superinterface for all Advisors that are driven by a pointcut. 9 | * This covers nearly all advisors except introduction advisors, 10 | * for which method-level matching doesn't apply. 11 | * @date 2022/3/14 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface PointcutAdvisor extends Advisor { 16 | 17 | /** 18 | * Get the Pointcut that drives this advisor. 19 | */ 20 | Pointcut getPointcut(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/aop/framework/AopProxy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop.framework; 2 | 3 | /** 4 | * Delegate interface for a configured AOP proxy, allowing for the creation 5 | * of actual proxy objects. 6 | * 7 | *

Out-of-the-box implementations are available for JDK dynamic proxies 8 | * and for CGLIB proxies, as applied by DefaultAopProxyFactory 9 | * 10 | * AOP 代理的抽象 11 | * 12 | *

13 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 14 | * 公众号:bugstack虫洞栈 15 | * Create by 小傅哥(fustack) 16 | */ 17 | public interface AopProxy { 18 | 19 | Object getProxy(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/beans/factory/Aware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 标记类接口,实现该接口可以被Spring容器感知 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface Aware { 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Callback that allows a bean to be aware of the bean 9 | * {@link ClassLoader class loader}; that is, the class loader used by the 10 | * present bean factory to load bean classes. 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanClassLoaderAware extends Aware { 16 | 17 | void setBeanClassLoader(ClassLoader classLoader); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 实现此接口,既能感知到所属的 BeanFactory 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanFactoryAware extends Aware { 16 | 17 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Sub-interface implemented by bean factories that can be part 9 | * of a hierarchy. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface HierarchicalBeanFactory extends BeanFactory { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface InitializingBean { 14 | 15 | /** 16 | * Bean 处理了属性填充后调用 17 | * 18 | * @throws Exception 19 | */ 20 | void afterPropertiesSet() throws Exception; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/beans/factory/config/SingletonBeanRegistry.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 单例 Bean 注册表 9 | * @date 2022/03/07 10 | * 11 | * 12 | */ 13 | public interface SingletonBeanRegistry { 14 | 15 | /** 16 | * 返回在给定名称下注册的(原始)单例对象。 17 | * @param beanName 要查找的bean的名称 18 | * @return 返回注册的单例对象 19 | */ 20 | Object getSingleton(String beanName); 21 | 22 | void registerSingleton(String beanName, Object singletonObject); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/context/ApplicationContextAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.Aware; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 实现此接口,既能感知到所属的 ApplicationContext 12 | * @date 2022/3/11 13 | * /CodeDesignTutorials 14 | * 15 | */ 16 | public interface ApplicationContextAware extends Aware { 17 | 18 | void setApplicationContext(ApplicationContext applicationContext) throws BeansException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/context/annotation/Scope.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | @Target({ElementType.TYPE, ElementType.METHOD}) 6 | @Retention(RetentionPolicy.RUNTIME) 7 | @Documented 8 | public @interface Scope { 9 | 10 | String value() default "singleton"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 资源处理接口 12 | * @date 2022/3/9 13 | * 14 | * 15 | */ 16 | public interface Resource { 17 | 18 | InputStream getInputStream() throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 资源加载器 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface ResourceLoader { 14 | 15 | /** 16 | * Pseudo URL prefix for loading from the class path: "classpath:" 17 | */ 18 | String CLASSPATH_URL_PREFIX = "classpath:"; 19 | 20 | Resource getResource(String location); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-14/src/main/java/cn/bugstack/springframework/util/StringValueResolver.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.util; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Simple strategy interface for resolving a String value. 9 | * Used by {@link cn.bugstack.springframework.beans.factory.config.ConfigurableBeanFactory}. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface StringValueResolver { 15 | 16 | String resolveStringValue(String strVal); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-14/src/test/java/cn/bugstack/springframework/test/bean/IUserService.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | public interface IUserService { 4 | 5 | String queryUserInfo(); 6 | 7 | String register(String userName); 8 | } 9 | -------------------------------------------------------------------------------- /spring-step-14/src/test/java/cn/bugstack/springframework/test/bean/UserDao.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | import cn.bugstack.springframework.stereotype.Component; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | @Component 9 | public class UserDao { 10 | 11 | private static Map hashMap = new HashMap<>(); 12 | 13 | static { 14 | hashMap.put("10001", "小傅哥,北京,亦庄"); 15 | hashMap.put("10002", "八杯水,上海,尖沙咀"); 16 | hashMap.put("10003", "阿毛,香港,铜锣湾"); 17 | } 18 | 19 | public String queryUserName(String uId) { 20 | return hashMap.get(uId); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-14/src/test/resources/token.properties: -------------------------------------------------------------------------------- 1 | token=RejDlI78hu223Opo983Ds -------------------------------------------------------------------------------- /spring-step-14/target/test-classes/token.properties: -------------------------------------------------------------------------------- 1 | token=RejDlI78hu223Opo983Ds -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/aop/BeforeAdvice.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import org.aopalliance.aop.Advice; 4 | 5 | /** 6 | * Common marker interface for before advice, such as {@link MethodBeforeAdvice}. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface BeforeAdvice extends Advice { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/aop/ClassFilter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * Filter that restricts matching of a pointcut or introduction to 5 | * a given set of target classes. 6 | * 7 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 8 | * 公众号:bugstack虫洞栈 9 | * Create by 小傅哥(fustack) 10 | */ 11 | public interface ClassFilter { 12 | 13 | /** 14 | * Should the pointcut apply to the given interface or target class? 15 | * @param clazz the candidate target class 16 | * @return whether the advice should apply to the given target class 17 | */ 18 | boolean matches(Class clazz); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/aop/MethodMatcher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * Part of a {@link Pointcut}: Checks whether the target method is eligible for advice. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface MethodMatcher { 13 | 14 | /** 15 | * Perform static checking whether the given method matches. If this 16 | * @return whether or not this method matches statically 17 | */ 18 | boolean matches(Method method, Class targetClass); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/aop/PointcutAdvisor.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * Superinterface for all Advisors that are driven by a pointcut. 5 | * This covers nearly all advisors except introduction advisors, 6 | * for which method-level matching doesn't apply. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface PointcutAdvisor extends Advisor { 13 | 14 | /** 15 | * Get the Pointcut that drives this advisor. 16 | */ 17 | Pointcut getPointcut(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/aop/framework/AopProxy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop.framework; 2 | 3 | /** 4 | * Delegate interface for a configured AOP proxy, allowing for the creation 5 | * of actual proxy objects. 6 | * 7 | *

Out-of-the-box implementations are available for JDK dynamic proxies 8 | * and for CGLIB proxies, as applied by DefaultAopProxyFactory 9 | * 10 | * AOP 代理的抽象 11 | * 12 | *

13 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 14 | * 公众号:bugstack虫洞栈 15 | * Create by 小傅哥(fustack) 16 | */ 17 | public interface AopProxy { 18 | 19 | Object getProxy(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 5 | * 公众号:bugstack虫洞栈 6 | * Create by 小傅哥(fustack) 7 | */ 8 | public class BeansException extends RuntimeException { 9 | 10 | public BeansException(String msg) { 11 | super(msg); 12 | } 13 | 14 | public BeansException(String msg, Throwable cause) { 15 | super(msg, cause); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * Callback that allows a bean to be aware of the bean 5 | * {@link ClassLoader class loader}; that is, the class loader used by the 6 | * present bean factory to load bean classes. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface BeanClassLoaderAware extends Aware{ 13 | 14 | void setBeanClassLoader(ClassLoader classLoader); 15 | 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 7 | * 公众号:bugstack虫洞栈 8 | * Create by 小傅哥(fustack) 9 | */ 10 | public interface BeanFactory { 11 | 12 | Object getBean(String name) throws BeansException; 13 | 14 | Object getBean(String name, Object... args) throws BeansException; 15 | 16 | T getBean(String name, Class requiredType) throws BeansException; 17 | 18 | T getBean(Class requiredType) throws BeansException; 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * Interface to be implemented by beans that wish to be aware of their 7 | * owning {@link BeanFactory}. 8 | * 9 | * 实现此接口,既能感知到所属的 BeanFactory 10 | * 11 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 12 | * 公众号:bugstack虫洞栈 13 | * Create by 小傅哥(fustack) 14 | */ 15 | public interface BeanFactoryAware extends Aware { 16 | 17 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/beans/factory/DisposableBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * Interface to be implemented by beans that want to release resources 5 | * on destruction. A BeanFactory is supposed to invoke the destroy 6 | * method if it disposes a cached singleton. An application context 7 | * is supposed to dispose all of its singletons on close. 8 | * 9 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 10 | * 公众号:bugstack虫洞栈 11 | * Create by 小傅哥(fustack) 12 | */ 13 | public interface DisposableBean { 14 | 15 | void destroy() throws Exception; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * Sub-interface implemented by bean factories that can be part 5 | * of a hierarchy. 6 | */ 7 | public interface HierarchicalBeanFactory extends BeanFactory { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 5 | * 公众号:bugstack虫洞栈 6 | * Create by 小傅哥(fustack) 7 | * 8 | * Bean 的引用 9 | */ 10 | public class BeanReference { 11 | 12 | private final String beanName; 13 | 14 | public BeanReference(String beanName) { 15 | this.beanName = beanName; 16 | } 17 | 18 | public String getBeanName() { 19 | return beanName; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/beans/factory/config/SingletonBeanRegistry.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 5 | * 公众号:bugstack虫洞栈 6 | * Create by 小傅哥(fustack) 7 | *

8 | * 单例注册表 9 | */ 10 | public interface SingletonBeanRegistry { 11 | 12 | Object getSingleton(String beanName); 13 | 14 | void registerSingleton(String beanName, Object singletonObject); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/context/annotation/Scope.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | @Target({ElementType.TYPE, ElementType.METHOD}) 6 | @Retention(RetentionPolicy.RUNTIME) 7 | @Documented 8 | public @interface Scope { 9 | 10 | String value() default "singleton"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | public interface Resource { 7 | 8 | InputStream getInputStream() throws IOException; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | public interface ResourceLoader { 4 | 5 | /** 6 | * Pseudo URL prefix for loading from the class path: "classpath:" 7 | */ 8 | String CLASSPATH_URL_PREFIX = "classpath:"; 9 | 10 | Resource getResource(String location); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/stereotype/Component.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.stereotype; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * Indicates that an annotated class is a "component". 7 | * Such classes are considered as candidates for auto-detection 8 | * when using annotation-based configuration and classpath scanning. 9 | */ 10 | @Target(ElementType.TYPE) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Documented 13 | public @interface Component { 14 | 15 | String value() default ""; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-15/src/main/java/cn/bugstack/springframework/util/StringValueResolver.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.util; 2 | 3 | /** 4 | * Simple strategy interface for resolving a String value. 5 | * Used by {@link cn.bugstack.springframework.beans.factory.config.ConfigurableBeanFactory}. 6 | *

7 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 8 | * 公众号:bugstack虫洞栈 9 | * Create by 小傅哥(fustack) 10 | */ 11 | public interface StringValueResolver { 12 | 13 | String resolveStringValue(String strVal); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-step-15/src/test/java/cn/bugstack/springframework/test/bean/IUserService.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | public interface IUserService { 4 | 5 | String queryUserInfo(); 6 | 7 | String register(String userName); 8 | } 9 | -------------------------------------------------------------------------------- /spring-step-15/src/test/java/cn/bugstack/springframework/test/bean/UserServiceBeforeAdvice.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | import cn.bugstack.springframework.aop.MethodBeforeAdvice; 4 | 5 | import java.lang.reflect.Method; 6 | 7 | public class UserServiceBeforeAdvice implements MethodBeforeAdvice { 8 | 9 | @Override 10 | public void before(Method method, Object[] args, Object target) throws Throwable { 11 | System.out.println("拦截方法:" + method.getName()); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-15/src/test/resources/token.properties: -------------------------------------------------------------------------------- 1 | token=RejDlI78hu223Opo983Ds -------------------------------------------------------------------------------- /spring-step-15/target/test-classes/META-INF/spring-step-15.kotlin_module: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /spring-step-15/target/test-classes/token.properties: -------------------------------------------------------------------------------- 1 | token=RejDlI78hu223Opo983Ds -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/aop/BeforeAdvice.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import org.aopalliance.aop.Advice; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description Common marker interface for before advice, such as {@link MethodBeforeAdvice}. 11 | * @date 2022/3/14 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeforeAdvice extends Advice { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/aop/ClassFilter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * Filter that restricts matching of a pointcut or introduction to 5 | * a given set of target classes. 6 | * 7 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 8 | * 公众号:bugstack虫洞栈 9 | * Create by 小傅哥(fustack) 10 | */ 11 | public interface ClassFilter { 12 | 13 | /** 14 | * Should the pointcut apply to the given interface or target class? 15 | * @param clazz the candidate target class 16 | * @return whether the advice should apply to the given target class 17 | */ 18 | boolean matches(Class clazz); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/aop/MethodMatcher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * Part of a {@link Pointcut}: Checks whether the target method is eligible for advice. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface MethodMatcher { 13 | 14 | /** 15 | * Perform static checking whether the given method matches. If this 16 | * @return whether or not this method matches statically 17 | */ 18 | boolean matches(Method method, Class targetClass); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/aop/PointcutAdvisor.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Superinterface for all Advisors that are driven by a pointcut. 9 | * This covers nearly all advisors except introduction advisors, 10 | * for which method-level matching doesn't apply. 11 | * @date 2022/3/14 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface PointcutAdvisor extends Advisor { 16 | 17 | /** 18 | * Get the Pointcut that drives this advisor. 19 | */ 20 | Pointcut getPointcut(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/aop/framework/AopProxy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop.framework; 2 | 3 | /** 4 | * Delegate interface for a configured AOP proxy, allowing for the creation 5 | * of actual proxy objects. 6 | * 7 | *

Out-of-the-box implementations are available for JDK dynamic proxies 8 | * and for CGLIB proxies, as applied by DefaultAopProxyFactory 9 | * 10 | * AOP 代理的抽象 11 | * 12 | *

13 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 14 | * 公众号:bugstack虫洞栈 15 | * Create by 小傅哥(fustack) 16 | */ 17 | public interface AopProxy { 18 | 19 | Object getProxy(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/beans/factory/Aware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 标记类接口,实现该接口可以被Spring容器感知 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface Aware { 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Callback that allows a bean to be aware of the bean 9 | * {@link ClassLoader class loader}; that is, the class loader used by the 10 | * present bean factory to load bean classes. 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanClassLoaderAware extends Aware { 16 | 17 | void setBeanClassLoader(ClassLoader classLoader); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 实现此接口,既能感知到所属的 BeanFactory 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanFactoryAware extends Aware { 16 | 17 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Sub-interface implemented by bean factories that can be part 9 | * of a hierarchy. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface HierarchicalBeanFactory extends BeanFactory { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface InitializingBean { 14 | 15 | /** 16 | * Bean 处理了属性填充后调用 17 | * 18 | * @throws Exception 19 | */ 20 | void afterPropertiesSet() throws Exception; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/beans/factory/ObjectFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description Defines a factory which can return an Object instance (possibly shared or independent) when invoked. 11 | * @date 2022/3/16 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface ObjectFactory { 16 | 17 | T getObject() throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/beans/factory/config/SingletonBeanRegistry.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 单例 Bean 注册表 9 | * @date 2022/03/07 10 | * 11 | * 12 | */ 13 | public interface SingletonBeanRegistry { 14 | 15 | /** 16 | * 返回在给定名称下注册的(原始)单例对象。 17 | * @param beanName 要查找的bean的名称 18 | * @return 返回注册的单例对象 19 | */ 20 | Object getSingleton(String beanName); 21 | 22 | void registerSingleton(String beanName, Object singletonObject); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/context/ApplicationContextAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.Aware; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 实现此接口,既能感知到所属的 ApplicationContext 12 | * @date 2022/3/11 13 | * /CodeDesignTutorials 14 | * 15 | */ 16 | public interface ApplicationContextAware extends Aware { 17 | 18 | void setApplicationContext(ApplicationContext applicationContext) throws BeansException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/context/annotation/Scope.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | @Target({ElementType.TYPE, ElementType.METHOD}) 6 | @Retention(RetentionPolicy.RUNTIME) 7 | @Documented 8 | public @interface Scope { 9 | 10 | String value() default "singleton"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 资源处理接口 12 | * @date 2022/3/9 13 | * 14 | * 15 | */ 16 | public interface Resource { 17 | 18 | InputStream getInputStream() throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 资源加载器 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface ResourceLoader { 14 | 15 | /** 16 | * Pseudo URL prefix for loading from the class path: "classpath:" 17 | */ 18 | String CLASSPATH_URL_PREFIX = "classpath:"; 19 | 20 | Resource getResource(String location); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-16/src/main/java/cn/bugstack/springframework/util/StringValueResolver.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.util; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Simple strategy interface for resolving a String value. 9 | * Used by {@link cn.bugstack.springframework.beans.factory.config.ConfigurableBeanFactory}. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface StringValueResolver { 15 | 16 | String resolveStringValue(String strVal); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-16/src/test/java/cn/bugstack/springframework/test/bean/Husband.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | public class Husband { 4 | 5 | private Wife wife; 6 | 7 | public String queryWife(){ 8 | return "Husband.wife"; 9 | } 10 | 11 | public Wife getWife() { 12 | return wife; 13 | } 14 | 15 | public void setWife(Wife wife) { 16 | this.wife = wife; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-16/src/test/java/cn/bugstack/springframework/test/bean/IMother.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | public interface IMother { 4 | 5 | String callMother(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /spring-step-16/src/test/java/cn/bugstack/springframework/test/bean/SpouseAdvice.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.bean; 2 | 3 | import cn.bugstack.springframework.aop.MethodBeforeAdvice; 4 | 5 | import java.lang.reflect.Method; 6 | 7 | public class SpouseAdvice implements MethodBeforeAdvice { 8 | 9 | @Override 10 | public void before(Method method, Object[] args, Object target) throws Throwable { 11 | System.out.println("关怀小两口(切面):" + method); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/aop/BeforeAdvice.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import org.aopalliance.aop.Advice; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description Common marker interface for before advice, such as {@link MethodBeforeAdvice}. 11 | * @date 2022/3/14 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeforeAdvice extends Advice { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/aop/ClassFilter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * Filter that restricts matching of a pointcut or introduction to 5 | * a given set of target classes. 6 | * 7 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 8 | * 公众号:bugstack虫洞栈 9 | * Create by 小傅哥(fustack) 10 | */ 11 | public interface ClassFilter { 12 | 13 | /** 14 | * Should the pointcut apply to the given interface or target class? 15 | * @param clazz the candidate target class 16 | * @return whether the advice should apply to the given target class 17 | */ 18 | boolean matches(Class clazz); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/aop/MethodMatcher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * Part of a {@link Pointcut}: Checks whether the target method is eligible for advice. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface MethodMatcher { 13 | 14 | /** 15 | * Perform static checking whether the given method matches. If this 16 | * @return whether or not this method matches statically 17 | */ 18 | boolean matches(Method method, Class targetClass); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/aop/PointcutAdvisor.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Superinterface for all Advisors that are driven by a pointcut. 9 | * This covers nearly all advisors except introduction advisors, 10 | * for which method-level matching doesn't apply. 11 | * @date 2022/3/14 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface PointcutAdvisor extends Advisor { 16 | 17 | /** 18 | * Get the Pointcut that drives this advisor. 19 | */ 20 | Pointcut getPointcut(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/aop/framework/AopProxy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop.framework; 2 | 3 | /** 4 | * Delegate interface for a configured AOP proxy, allowing for the creation 5 | * of actual proxy objects. 6 | * 7 | *

Out-of-the-box implementations are available for JDK dynamic proxies 8 | * and for CGLIB proxies, as applied by DefaultAopProxyFactory 9 | * 10 | * AOP 代理的抽象 11 | * 12 | *

13 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 14 | * 公众号:bugstack虫洞栈 15 | * Create by 小傅哥(fustack) 16 | */ 17 | public interface AopProxy { 18 | 19 | Object getProxy(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 定义 Bean 异常 9 | * @date 2022/3/7 10 | * 11 | * 12 | */ 13 | public class BeansException extends RuntimeException{ 14 | 15 | public BeansException(String msg) { 16 | super(msg); 17 | } 18 | 19 | public BeansException(String msg, Throwable cause) { 20 | super(msg, cause); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/beans/factory/Aware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 标记类接口,实现该接口可以被Spring容器感知 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface Aware { 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Callback that allows a bean to be aware of the bean 9 | * {@link ClassLoader class loader}; that is, the class loader used by the 10 | * present bean factory to load bean classes. 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanClassLoaderAware extends Aware { 16 | 17 | void setBeanClassLoader(ClassLoader classLoader); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description 实现此接口,既能感知到所属的 BeanFactory 11 | * @date 2022/3/11 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface BeanFactoryAware extends Aware { 16 | 17 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Sub-interface implemented by bean factories that can be part 9 | * of a hierarchy. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface HierarchicalBeanFactory extends BeanFactory { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface InitializingBean { 14 | 15 | /** 16 | * Bean 处理了属性填充后调用 17 | * 18 | * @throws Exception 19 | */ 20 | void afterPropertiesSet() throws Exception; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/beans/factory/ObjectFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * 8 | * 9 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 10 | * @description Defines a factory which can return an Object instance (possibly shared or independent) when invoked. 11 | * @date 2022/3/16 12 | * /CodeDesignTutorials 13 | * 14 | */ 15 | public interface ObjectFactory { 16 | 17 | T getObject() throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Bean 引用 9 | * @date 2022/3/9 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class BeanReference { 14 | 15 | private final String beanName; 16 | 17 | public BeanReference(String beanName) { 18 | this.beanName = beanName; 19 | } 20 | 21 | public String getBeanName() { 22 | return beanName; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/beans/factory/config/SingletonBeanRegistry.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 单例 Bean 注册表 9 | * @date 2022/03/07 10 | * 11 | * 12 | */ 13 | public interface SingletonBeanRegistry { 14 | 15 | /** 16 | * 返回在给定名称下注册的(原始)单例对象。 17 | * @param beanName 要查找的bean的名称 18 | * @return 返回注册的单例对象 19 | */ 20 | Object getSingleton(String beanName); 21 | 22 | void registerSingleton(String beanName, Object singletonObject); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/context/ApplicationContextAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.Aware; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 实现此接口,既能感知到所属的 ApplicationContext 12 | * @date 2022/3/11 13 | * /CodeDesignTutorials 14 | * 15 | */ 16 | public interface ApplicationContextAware extends Aware { 17 | 18 | void setApplicationContext(ApplicationContext applicationContext) throws BeansException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/context/annotation/Scope.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | @Target({ElementType.TYPE, ElementType.METHOD}) 6 | @Retention(RetentionPolicy.RUNTIME) 7 | @Documented 8 | public @interface Scope { 9 | 10 | String value() default "singleton"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/core/convert/converter/Converter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.convert.converter; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 类型转换处理接口 9 | * @date 2022/3/16 10 | * 11 | * 12 | */ 13 | public interface Converter { 14 | 15 | /** Convert the source object of type {@code S} to target type {@code T}. */ 16 | T convert(S source); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * 9 | * 10 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 11 | * @description 资源处理接口 12 | * @date 2022/3/9 13 | * 14 | * 15 | */ 16 | public interface Resource { 17 | 18 | InputStream getInputStream() throws IOException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description 资源加载器 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface ResourceLoader { 14 | 15 | /** 16 | * Pseudo URL prefix for loading from the class path: "classpath:" 17 | */ 18 | String CLASSPATH_URL_PREFIX = "classpath:"; 19 | 20 | Resource getResource(String location); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-17/src/main/java/cn/bugstack/springframework/util/StringValueResolver.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.util; 2 | 3 | /** 4 | * 5 | * 6 | * 7 | * 作者:DerekYRC https://github.com/DerekYRC/mini-spring 8 | * @description Simple strategy interface for resolving a String value. 9 | * Used by {@link cn.bugstack.springframework.beans.factory.config.ConfigurableBeanFactory}. 10 | * @date 2022/3/9 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface StringValueResolver { 15 | 16 | String resolveStringValue(String strVal); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-17/src/test/java/cn/bugstack/springframework/test/converter/StringToIntegerConverter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.converter; 2 | 3 | import cn.bugstack.springframework.core.convert.converter.Converter; 4 | 5 | /** 6 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 7 | * 公众号:bugstack虫洞栈 8 | * Create by 小傅哥(fustack) 9 | */ 10 | public class StringToIntegerConverter implements Converter { 11 | 12 | @Override 13 | public Integer convert(String source) { 14 | return Integer.valueOf(source); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/aop/BeforeAdvice.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import org.aopalliance.aop.Advice; 4 | 5 | /** 6 | * 7 | * @description Common marker interface for before advice, such as {@link MethodBeforeAdvice}. 8 | * @date 2022/3/14 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface BeforeAdvice extends Advice { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/aop/ClassFilter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * Filter that restricts matching of a pointcut or introduction to 5 | * a given set of target classes. 6 | * 7 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 8 | * 公众号:bugstack虫洞栈 9 | * Create by 小傅哥(fustack) 10 | */ 11 | public interface ClassFilter { 12 | 13 | /** 14 | * Should the pointcut apply to the given interface or target class? 15 | * @param clazz the candidate target class 16 | * @return whether the advice should apply to the given target class 17 | */ 18 | boolean matches(Class clazz); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/aop/MethodMatcher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * Part of a {@link Pointcut}: Checks whether the target method is eligible for advice. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface MethodMatcher { 13 | 14 | /** 15 | * Perform static checking whether the given method matches. If this 16 | * @return whether or not this method matches statically 17 | */ 18 | boolean matches(Method method, Class targetClass); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/aop/PointcutAdvisor.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * 5 | * @description Superinterface for all Advisors that are driven by a pointcut. 6 | * This covers nearly all advisors except introduction advisors, 7 | * for which method-level matching doesn't apply. 8 | * @date 2022/3/14 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface PointcutAdvisor extends Advisor { 13 | 14 | /** 15 | * Get the Pointcut that drives this advisor. 16 | */ 17 | Pointcut getPointcut(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/aop/framework/AopProxy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop.framework; 2 | 3 | /** 4 | * Delegate interface for a configured AOP proxy, allowing for the creation 5 | * of actual proxy objects. 6 | * 7 | *

Out-of-the-box implementations are available for JDK dynamic proxies 8 | * and for CGLIB proxies, as applied by DefaultAopProxyFactory 9 | * 10 | * AOP 代理的抽象 11 | * 12 | *

13 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 14 | * 公众号:bugstack虫洞栈 15 | * Create by 小傅哥(fustack) 16 | */ 17 | public interface AopProxy { 18 | 19 | Object getProxy(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * @description 定义 Bean 异常 6 | * @date 2022/3/7 7 | * 8 | * 9 | */ 10 | public class BeansException extends RuntimeException{ 11 | 12 | public BeansException(String msg) { 13 | super(msg); 14 | } 15 | 16 | public BeansException(String msg, Throwable cause) { 17 | super(msg, cause); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/factory/Aware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description 标记类接口,实现该接口可以被Spring容器感知 6 | * @date 2022/3/11 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface Aware { 11 | } 12 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Callback that allows a bean to be aware of the bean 6 | * {@link ClassLoader class loader}; that is, the class loader used by the 7 | * present bean factory to load bean classes. 8 | * @date 2022/3/11 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface BeanClassLoaderAware extends Aware { 13 | 14 | void setBeanClassLoader(ClassLoader classLoader); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * @description 实现此接口,既能感知到所属的 BeanFactory 8 | * @date 2022/3/11 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface BeanFactoryAware extends Aware { 13 | 14 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/factory/BeanNameAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Interface to be implemented by beans that want to be aware of their 6 | * bean name in a bean factory. Note that it is not usually recommended 7 | * that an object depend on its bean name, as this represents a potentially 8 | * brittle dependence on external configuration, as well as a possibly 9 | * unnecessary dependence on a Spring API. 10 | * @date 2022/3/11 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface BeanNameAware { 15 | 16 | void setBeanName(String name); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/factory/DisposableBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Interface to be implemented by beans that want to release resources 6 | * on destruction. A BeanFactory is supposed to invoke the destroy 7 | * method if it disposes a cached singleton. An application context 8 | * is supposed to dispose all of its singletons on close. 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface DisposableBean { 14 | 15 | void destroy() throws Exception; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/factory/FactoryBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Interface to be implemented by objects used within a {@link BeanFactory} 6 | * which are themselves factories. If a bean implements this interface, 7 | * it is used as a factory for an object to expose, not directly as a bean 8 | * instance that will be exposed itself. 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface FactoryBean { 14 | 15 | T getObject() throws Exception; 16 | 17 | Class getObjectType(); 18 | 19 | boolean isSingleton(); 20 | 21 | } -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Sub-interface implemented by bean factories that can be part 6 | * of a hierarchy. 7 | * @date 2022/3/9 8 | * /CodeDesignTutorials 9 | * 10 | */ 11 | public interface HierarchicalBeanFactory extends BeanFactory { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 6 | * @date 2022/3/10 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface InitializingBean { 11 | 12 | /** 13 | * Bean 处理了属性填充后调用 14 | * 15 | * @throws Exception 16 | */ 17 | void afterPropertiesSet() throws Exception; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/factory/ObjectFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * @description Defines a factory which can return an Object instance (possibly shared or independent) when invoked. 8 | * @date 2022/3/16 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface ObjectFactory { 13 | 14 | T getObject() throws BeansException; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * @description Bean 引用 6 | * @date 2022/3/9 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public class BeanReference { 11 | 12 | private final String beanName; 13 | 14 | public BeanReference(String beanName) { 15 | this.beanName = beanName; 16 | } 17 | 18 | public String getBeanName() { 19 | return beanName; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/factory/config/SingletonBeanRegistry.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * @description 单例 Bean 注册表 6 | * @date 2022/03/07 7 | * 8 | * 9 | */ 10 | public interface SingletonBeanRegistry { 11 | 12 | /** 13 | * 返回在给定名称下注册的(原始)单例对象。 14 | * @param beanName 要查找的bean的名称 15 | * @return 返回注册的单例对象 16 | */ 17 | Object getSingleton(String beanName); 18 | 19 | void registerSingleton(String beanName, Object singletonObject); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/beans/factory/support/InstantiationStrategy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.support; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.config.BeanDefinition; 5 | 6 | import java.lang.reflect.Constructor; 7 | 8 | /** 9 | * 10 | * @description Bean 实例化策略接口 11 | * @date 2022/03/08 12 | * 13 | * 14 | */ 15 | public interface InstantiationStrategy { 16 | 17 | Object instantiate(BeanDefinition beanDefinition, String beanName, Constructor ctor, Object[] args) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/context/ApplicationContextAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.Aware; 5 | 6 | /** 7 | * 8 | * @description 实现此接口,既能感知到所属的 ApplicationContext 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface ApplicationContextAware extends Aware { 14 | 15 | void setApplicationContext(ApplicationContext applicationContext) throws BeansException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/context/ApplicationEventPublisher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | /** 4 | * 5 | * @description 事件发布者接口 6 | * @date 2022/3/13 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface ApplicationEventPublisher { 11 | 12 | /** 13 | * Notify all listeners registered with this application of an application 14 | * event. Events may be framework events (such as RequestHandledEvent) 15 | * or application-specific events. 16 | * @param event the event to publish 17 | */ 18 | void publishEvent(ApplicationEvent event); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/context/annotation/Scope.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | @Target({ElementType.TYPE, ElementType.METHOD}) 6 | @Retention(RetentionPolicy.RUNTIME) 7 | @Documented 8 | public @interface Scope { 9 | 10 | String value() default "singleton"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/core/convert/converter/Converter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.convert.converter; 2 | 3 | /** 4 | * 5 | * @description 类型转换处理接口 6 | * @date 2022/3/16 7 | * 8 | * 9 | */ 10 | public interface Converter { 11 | 12 | /** Convert the source object of type {@code S} to target type {@code T}. */ 13 | T convert(S source); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/core/convert/converter/ConverterFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.convert.converter; 2 | 3 | /** 4 | * 5 | * @description 类型转换工厂 6 | * @date 2022/3/16 7 | * 8 | * 9 | */ 10 | public interface ConverterFactory{ 11 | 12 | /** 13 | * Get the converter to convert from S to target type T, where T is also an instance of R. 14 | * @param the target type 15 | * @param targetType the target type to convert to 16 | * @return a converter from S to T 17 | */ 18 | Converter getConverter(Class targetType); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * @description 资源处理接口 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface Resource { 14 | 15 | InputStream getInputStream() throws IOException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * @description 资源加载器 6 | * @date 2022/3/9 7 | * 8 | * 9 | */ 10 | public interface ResourceLoader { 11 | 12 | /** 13 | * Pseudo URL prefix for loading from the class path: "classpath:" 14 | */ 15 | String CLASSPATH_URL_PREFIX = "classpath:"; 16 | 17 | Resource getResource(String location); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/jdbc/core/ResultSetExtractor.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.core; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | 6 | /** 7 | * 8 | * @description Callback interface used by {@link JdbcTemplate}'s query methods. 9 | * @date 2022/3/16 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface ResultSetExtractor { 14 | 15 | T extractData(ResultSet rs) throws SQLException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/jdbc/core/RowMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.core; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | 6 | /** 7 | * 8 | * @description An interface used by {@link JdbcTemplate} for mapping rows of a 9 | * {@link java.sql.ResultSet} on a per-row basis. 10 | * @date 2022/3/16 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface RowMapper { 15 | 16 | T mapRow(ResultSet rs, int rowNum) throws SQLException; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/jdbc/core/SqlProvider.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.core; 2 | 3 | /** 4 | * 5 | * @description Interface to be implemented by objects that can provide SQL strings. 6 | * @date 2022/3/16 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface SqlProvider { 11 | 12 | String getSql(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/jdbc/core/StatementCallback.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.core; 2 | 3 | import java.sql.SQLException; 4 | import java.sql.Statement; 5 | 6 | /** 7 | * 8 | * @description Generic callback interface for code that operates on a JDBC Statement. 9 | * @date 2022/3/16 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface StatementCallback { 14 | 15 | T doInStatement(Statement statement) throws SQLException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/stereotype/Component.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.stereotype; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * 7 | * @description Indicates that an annotated class is a "component". 8 | * Such classes are considered as candidates for auto-detection 9 | * when using annotation-based configuration and classpath scanning. 10 | * @date 2022/3/14 11 | * 12 | * 13 | */ 14 | @Target(ElementType.TYPE) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | @Documented 17 | public @interface Component { 18 | 19 | String value() default ""; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-18/src/main/java/cn/bugstack/springframework/util/StringValueResolver.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.util; 2 | 3 | /** 4 | * 5 | * @description Simple strategy interface for resolving a String value. 6 | * Used by {@link cn.bugstack.springframework.beans.factory.config.ConfigurableBeanFactory}. 7 | * @date 2022/3/9 8 | * /CodeDesignTutorials 9 | * 10 | */ 11 | public interface StringValueResolver { 12 | 13 | String resolveStringValue(String strVal); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/aop/BeforeAdvice.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import org.aopalliance.aop.Advice; 4 | 5 | /** 6 | * 7 | * @description Common marker interface for before advice, such as {@link MethodBeforeAdvice}. 8 | * @date 2022/3/14 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface BeforeAdvice extends Advice { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/aop/MethodMatcher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * Part of a {@link Pointcut}: Checks whether the target method is eligible for advice. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface MethodMatcher { 13 | 14 | /** 15 | * Perform static checking whether the given method matches. If this 16 | * @return whether or not this method matches statically 17 | */ 18 | boolean matches(Method method, Class targetClass); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/aop/PointcutAdvisor.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * 5 | * @description Superinterface for all Advisors that are driven by a pointcut. 6 | * This covers nearly all advisors except introduction advisors, 7 | * for which method-level matching doesn't apply. 8 | * @date 2022/3/14 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface PointcutAdvisor extends Advisor { 13 | 14 | /** 15 | * Get the Pointcut that drives this advisor. 16 | */ 17 | Pointcut getPointcut(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/aop/framework/AopProxy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop.framework; 2 | 3 | /** 4 | * Delegate interface for a configured AOP proxy, allowing for the creation 5 | * of actual proxy objects. 6 | * 7 | *

Out-of-the-box implementations are available for JDK dynamic proxies 8 | * and for CGLIB proxies, as applied by DefaultAopProxyFactory 9 | * 10 | * AOP 代理的抽象 11 | * 12 | *

13 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 14 | * 公众号:bugstack虫洞栈 15 | * Create by 小傅哥(fustack) 16 | */ 17 | public interface AopProxy { 18 | 19 | Object getProxy(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * @description 定义 Bean 异常 6 | * @date 2022/3/7 7 | * 8 | * 9 | */ 10 | public class BeansException extends RuntimeException{ 11 | 12 | public BeansException(String msg) { 13 | super(msg); 14 | } 15 | 16 | public BeansException(String msg, Throwable cause) { 17 | super(msg, cause); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/factory/Aware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description 标记类接口,实现该接口可以被Spring容器感知 6 | * @date 2022/3/11 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface Aware { 11 | } 12 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Callback that allows a bean to be aware of the bean 6 | * {@link ClassLoader class loader}; that is, the class loader used by the 7 | * present bean factory to load bean classes. 8 | * @date 2022/3/11 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface BeanClassLoaderAware extends Aware { 13 | 14 | void setBeanClassLoader(ClassLoader classLoader); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * @description 实现此接口,既能感知到所属的 BeanFactory 8 | * @date 2022/3/11 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface BeanFactoryAware extends Aware { 13 | 14 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/factory/BeanNameAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Interface to be implemented by beans that want to be aware of their 6 | * bean name in a bean factory. Note that it is not usually recommended 7 | * that an object depend on its bean name, as this represents a potentially 8 | * brittle dependence on external configuration, as well as a possibly 9 | * unnecessary dependence on a Spring API. 10 | * @date 2022/3/11 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface BeanNameAware { 15 | 16 | void setBeanName(String name); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/factory/DisposableBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Interface to be implemented by beans that want to release resources 6 | * on destruction. A BeanFactory is supposed to invoke the destroy 7 | * method if it disposes a cached singleton. An application context 8 | * is supposed to dispose all of its singletons on close. 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface DisposableBean { 14 | 15 | void destroy() throws Exception; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/factory/FactoryBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Interface to be implemented by objects used within a {@link BeanFactory} 6 | * which are themselves factories. If a bean implements this interface, 7 | * it is used as a factory for an object to expose, not directly as a bean 8 | * instance that will be exposed itself. 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface FactoryBean { 14 | 15 | T getObject() throws Exception; 16 | 17 | Class getObjectType(); 18 | 19 | boolean isSingleton(); 20 | 21 | } -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Sub-interface implemented by bean factories that can be part 6 | * of a hierarchy. 7 | * @date 2022/3/9 8 | * /CodeDesignTutorials 9 | * 10 | */ 11 | public interface HierarchicalBeanFactory extends BeanFactory { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 6 | * @date 2022/3/10 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface InitializingBean { 11 | 12 | /** 13 | * Bean 处理了属性填充后调用 14 | * 15 | * @throws Exception 16 | */ 17 | void afterPropertiesSet() throws Exception; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/factory/ObjectFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * @description Defines a factory which can return an Object instance (possibly shared or independent) when invoked. 8 | * @date 2022/3/16 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface ObjectFactory { 13 | 14 | T getObject() throws BeansException; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * @description Bean 引用 6 | * @date 2022/3/9 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public class BeanReference { 11 | 12 | private final String beanName; 13 | 14 | public BeanReference(String beanName) { 15 | this.beanName = beanName; 16 | } 17 | 18 | public String getBeanName() { 19 | return beanName; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/factory/config/SingletonBeanRegistry.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * @description 单例 Bean 注册表 6 | * @date 2022/03/07 7 | * 8 | * 9 | */ 10 | public interface SingletonBeanRegistry { 11 | 12 | /** 13 | * 返回在给定名称下注册的(原始)单例对象。 14 | * @param beanName 要查找的bean的名称 15 | * @return 返回注册的单例对象 16 | */ 17 | Object getSingleton(String beanName); 18 | 19 | void registerSingleton(String beanName, Object singletonObject); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/beans/factory/support/InstantiationStrategy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.support; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.config.BeanDefinition; 5 | 6 | import java.lang.reflect.Constructor; 7 | 8 | /** 9 | * 10 | * @description Bean 实例化策略接口 11 | * @date 2022/03/08 12 | * 13 | * 14 | */ 15 | public interface InstantiationStrategy { 16 | 17 | Object instantiate(BeanDefinition beanDefinition, String beanName, Constructor ctor, Object[] args) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/context/ApplicationContextAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.Aware; 5 | 6 | /** 7 | * 8 | * @description 实现此接口,既能感知到所属的 ApplicationContext 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface ApplicationContextAware extends Aware { 14 | 15 | void setApplicationContext(ApplicationContext applicationContext) throws BeansException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/context/ApplicationEventPublisher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | /** 4 | * 5 | * @description 事件发布者接口 6 | * @date 2022/3/13 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface ApplicationEventPublisher { 11 | 12 | /** 13 | * Notify all listeners registered with this application of an application 14 | * event. Events may be framework events (such as RequestHandledEvent) 15 | * or application-specific events. 16 | * @param event the event to publish 17 | */ 18 | void publishEvent(ApplicationEvent event); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/context/annotation/Scope.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | @Target({ElementType.TYPE, ElementType.METHOD}) 6 | @Retention(RetentionPolicy.RUNTIME) 7 | @Documented 8 | public @interface Scope { 9 | 10 | String value() default "singleton"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/core/annotation/SynthesizedAnnotation.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.annotation; 2 | 3 | public @interface SynthesizedAnnotation { 4 | } 5 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/core/convert/converter/Converter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.convert.converter; 2 | 3 | /** 4 | * 5 | * @description 类型转换处理接口 6 | * @date 2022/3/16 7 | * 8 | * 9 | */ 10 | public interface Converter { 11 | 12 | /** Convert the source object of type {@code S} to target type {@code T}. */ 13 | T convert(S source); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/core/convert/converter/ConverterFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.convert.converter; 2 | 3 | /** 4 | * 5 | * @description 类型转换工厂 6 | * @date 2022/3/16 7 | * 8 | * 9 | */ 10 | public interface ConverterFactory{ 11 | 12 | /** 13 | * Get the converter to convert from S to target type T, where T is also an instance of R. 14 | * @param the target type 15 | * @param targetType the target type to convert to 16 | * @return a converter from S to T 17 | */ 18 | Converter getConverter(Class targetType); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * @description 资源处理接口 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface Resource { 14 | 15 | InputStream getInputStream() throws IOException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * @description 资源加载器 6 | * @date 2022/3/9 7 | * 8 | * 9 | */ 10 | public interface ResourceLoader { 11 | 12 | /** 13 | * Pseudo URL prefix for loading from the class path: "classpath:" 14 | */ 15 | String CLASSPATH_URL_PREFIX = "classpath:"; 16 | 17 | Resource getResource(String location); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/jdbc/UncategorizedSQLException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc; 2 | 3 | /** 4 | * 5 | * @description Exception thrown when we can't classify an SQLException into 6 | * one of our generic data access exceptions. 7 | * @date 2022/3/16 8 | * /CodeDesignTutorials 9 | * 10 | */ 11 | public class UncategorizedSQLException extends RuntimeException{ 12 | 13 | public UncategorizedSQLException(String message) { 14 | super(message); 15 | } 16 | 17 | public UncategorizedSQLException(String task,String sql, Throwable cause) { 18 | super(sql, cause); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/jdbc/core/ResultSetExtractor.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.core; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | 6 | /** 7 | * 8 | * @description Callback interface used by {@link JdbcTemplate}'s query methods. 9 | * @date 2022/3/16 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface ResultSetExtractor { 14 | 15 | T extractData(ResultSet rs) throws SQLException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/jdbc/core/RowMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.core; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | 6 | /** 7 | * 8 | * @description An interface used by {@link JdbcTemplate} for mapping rows of a 9 | * {@link ResultSet} on a per-row basis. 10 | * @date 2022/3/16 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface RowMapper { 15 | 16 | T mapRow(ResultSet rs, int rowNum) throws SQLException; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/jdbc/core/SqlProvider.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.core; 2 | 3 | /** 4 | * 5 | * @description Interface to be implemented by objects that can provide SQL strings. 6 | * @date 2022/3/16 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface SqlProvider { 11 | 12 | String getSql(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/jdbc/core/StatementCallback.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.core; 2 | 3 | import java.sql.SQLException; 4 | import java.sql.Statement; 5 | 6 | /** 7 | * 8 | * @description Generic callback interface for code that operates on a JDBC Statement. 9 | * @date 2022/3/16 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface StatementCallback { 14 | 15 | T doInStatement(Statement statement) throws SQLException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/jdbc/datasource/ConnectionHandle.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.datasource; 2 | 3 | import java.sql.Connection; 4 | 5 | /** 6 | * 7 | * @description Simple interface to be implemented by handles for a JDBC Connection. 8 | * @date 2022/3/16 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface ConnectionHandle { 13 | 14 | Connection getConnection(); 15 | 16 | default void releaseConnection(Connection con) { 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/stereotype/Component.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.stereotype; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * 7 | * @description Indicates that an annotated class is a "component". 8 | * Such classes are considered as candidates for auto-detection 9 | * when using annotation-based configuration and classpath scanning. 10 | * @date 2022/3/14 11 | * 12 | * 13 | */ 14 | @Target(ElementType.TYPE) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | @Documented 17 | public @interface Component { 18 | 19 | String value() default ""; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/tx/transaction/TransactionException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.tx.transaction; 2 | 3 | /** 4 | * 5 | * @description Exception thrown when a transaction can't be created using an 6 | * underlying transaction API such as JTA. 7 | * @date 2022/3/16 8 | * /CodeDesignTutorials 9 | * 10 | */ 11 | public class TransactionException extends RuntimeException{ 12 | 13 | public TransactionException(String message) { 14 | super(message); 15 | } 16 | 17 | public TransactionException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/tx/transaction/annotation/TransactionAnnotationParser.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.tx.transaction.annotation; 2 | 3 | import cn.bugstack.springframework.tx.transaction.interceptor.TransactionAttribute; 4 | 5 | import java.lang.reflect.AnnotatedElement; 6 | 7 | /** 8 | * 9 | * @description 用于解析已知事务注释类型的策略接口 10 | * @date 2022/3/16 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface TransactionAnnotationParser { 15 | 16 | /** 17 | * 基于该解析器理解的注释类型,解析给定方法或类的事务属性。 18 | */ 19 | TransactionAttribute parseTransactionAnnotation(AnnotatedElement element); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/tx/transaction/annotation/Transactional.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.tx.transaction.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * 事务注解 7 | */ 8 | @Target({ElementType.METHOD, ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Inherited 11 | @Documented 12 | public @interface Transactional { 13 | 14 | Class[] rollbackFor() default {}; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/tx/transaction/interceptor/RollbackRuleAttribute.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.tx.transaction.interceptor; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 7 | * @description Rule determining whether or not a given exception (and any subclasses) 8 | * should cause a rollback. 9 | * @date 2022/3/16 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class RollbackRuleAttribute implements Serializable { 14 | 15 | private final String exceptionName; 16 | 17 | public RollbackRuleAttribute(Class clazz) { 18 | this.exceptionName = clazz.getName(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/tx/transaction/interceptor/TransactionAttribute.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.tx.transaction.interceptor; 2 | 3 | 4 | import cn.bugstack.springframework.tx.transaction.TransactionDefinition; 5 | 6 | /** 7 | * 8 | * @description This interface adds a {@code rollbackOn} specification to {@link TransactionDefinition}. 9 | * @date 2022/3/16 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface TransactionAttribute extends TransactionDefinition { 14 | 15 | boolean rollbackOn(Throwable ex); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/tx/transaction/interceptor/TransactionAttributeSource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.tx.transaction.interceptor; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * 7 | * @description Strategy interface used by {@link TransactionInterceptor} for metadata retrieval. 8 | * @date 2022/3/16 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface TransactionAttributeSource { 13 | 14 | TransactionAttribute getTransactionAttribute(Method method, Class targetClass); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-19/src/main/java/cn/bugstack/springframework/util/StringValueResolver.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.util; 2 | 3 | /** 4 | * 5 | * @description Simple strategy interface for resolving a String value. 6 | * Used by {@link cn.bugstack.springframework.beans.factory.config.ConfigurableBeanFactory}. 7 | * @date 2022/3/9 8 | * /CodeDesignTutorials 9 | * 10 | */ 11 | public interface StringValueResolver { 12 | 13 | String resolveStringValue(String strVal); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-step-19/target/classes/META-INF/spring-step-19.kotlin_module: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /spring-step-20/src/main/java/cn/bugstack/middleware/mybatis/SqlSession.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.middleware.mybatis; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 7 | * @description SqlSession 接口 8 | * @date 2022/3/16 9 | * 10 | * 11 | */ 12 | public interface SqlSession { 13 | 14 | T selectOne(String statement); 15 | 16 | T selectOne(String statement, Object parameter); 17 | 18 | List selectList(String statement); 19 | 20 | List selectList(String statement, Object parameter); 21 | 22 | void close(); 23 | } 24 | -------------------------------------------------------------------------------- /spring-step-20/src/main/java/cn/bugstack/middleware/mybatis/SqlSessionFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.middleware.mybatis; 2 | 3 | /** 4 | * 5 | * @description SqlSessionFactory 6 | * @date 2022/3/16 7 | * 8 | * 9 | */ 10 | public interface SqlSessionFactory { 11 | 12 | SqlSession openSession(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-20/src/test/java/cn/bugstack/middleware/mybatis/test/dao/IUserDao.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.middleware.mybatis.test.dao; 2 | 3 | import cn.bugstack.middleware.mybatis.test.po.User; 4 | 5 | public interface IUserDao { 6 | 7 | User queryUserInfoById(Long id); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /spring-step-20/target/maven-archiver/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven 2 | #Fri Mar 18 15:04:07 CST 2022 3 | version=1.0-SNAPSHOT 4 | groupId=cn.bugstack.springframework 5 | artifactId=spring-step-20 6 | -------------------------------------------------------------------------------- /spring-step-20/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst: -------------------------------------------------------------------------------- 1 | cn/bugstack/middleware/mybatis/XNode.class 2 | cn/bugstack/middleware/mybatis/DefaultSqlSessionFactory.class 3 | cn/bugstack/middleware/mybatis/SqlSessionFactoryBuilder.class 4 | cn/bugstack/middleware/mybatis/Configuration.class 5 | cn/bugstack/middleware/mybatis/SqlSessionFactory.class 6 | cn/bugstack/middleware/mybatis/SqlSession.class 7 | cn/bugstack/middleware/mybatis/Resources.class 8 | cn/bugstack/middleware/mybatis/DefaultSqlSession.class 9 | -------------------------------------------------------------------------------- /spring-step-20/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst: -------------------------------------------------------------------------------- 1 | cn/bugstack/middleware/mybatis/test/dao/IUserDao.class 2 | cn/bugstack/middleware/mybatis/test/ApiTest.class 3 | cn/bugstack/middleware/mybatis/test/po/User.class 4 | -------------------------------------------------------------------------------- /spring-step-20/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst: -------------------------------------------------------------------------------- 1 | /Users/fuzhengwei/1024/SpringTutorials/spring-step-20/src/test/java/cn/bugstack/middleware/mybatis/test/dao/IUserDao.java 2 | /Users/fuzhengwei/1024/SpringTutorials/spring-step-20/src/test/java/cn/bugstack/middleware/mybatis/test/ApiTest.java 3 | /Users/fuzhengwei/1024/SpringTutorials/spring-step-20/src/test/java/cn/bugstack/middleware/mybatis/test/po/User.java 4 | -------------------------------------------------------------------------------- /spring-step-20/target/surefire-reports/cn.bugstack.middleware.mybatis.test.ApiTest.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | Test set: cn.bugstack.middleware.mybatis.test.ApiTest 3 | ------------------------------------------------------------------------------- 4 | Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.487 sec 5 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/aop/BeforeAdvice.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import org.aopalliance.aop.Advice; 4 | 5 | /** 6 | * 7 | * @description Common marker interface for before advice, such as {@link MethodBeforeAdvice}. 8 | * @date 2022/3/14 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface BeforeAdvice extends Advice { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/aop/MethodMatcher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * Part of a {@link Pointcut}: Checks whether the target method is eligible for advice. 7 | * 8 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 9 | * 公众号:bugstack虫洞栈 10 | * Create by 小傅哥(fustack) 11 | */ 12 | public interface MethodMatcher { 13 | 14 | /** 15 | * Perform static checking whether the given method matches. If this 16 | * @return whether or not this method matches statically 17 | */ 18 | boolean matches(Method method, Class targetClass); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/aop/PointcutAdvisor.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop; 2 | 3 | /** 4 | * 5 | * @description Superinterface for all Advisors that are driven by a pointcut. 6 | * This covers nearly all advisors except introduction advisors, 7 | * for which method-level matching doesn't apply. 8 | * @date 2022/3/14 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface PointcutAdvisor extends Advisor { 13 | 14 | /** 15 | * Get the Pointcut that drives this advisor. 16 | */ 17 | Pointcut getPointcut(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/aop/framework/AopProxy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.aop.framework; 2 | 3 | /** 4 | * Delegate interface for a configured AOP proxy, allowing for the creation 5 | * of actual proxy objects. 6 | * 7 | *

Out-of-the-box implementations are available for JDK dynamic proxies 8 | * and for CGLIB proxies, as applied by DefaultAopProxyFactory 9 | * 10 | * AOP 代理的抽象 11 | * 12 | *

13 | * 博客:https://bugstack.cn - 沉淀、分享、成长,让自己和他人都能有所收获! 14 | * 公众号:bugstack虫洞栈 15 | * Create by 小傅哥(fustack) 16 | */ 17 | public interface AopProxy { 18 | 19 | Object getProxy(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/BeansException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans; 2 | 3 | /** 4 | * 5 | * @description 定义 Bean 异常 6 | * @date 2022/3/7 7 | * 8 | * 9 | */ 10 | public class BeansException extends RuntimeException{ 11 | 12 | public BeansException(String msg) { 13 | super(msg); 14 | } 15 | 16 | public BeansException(String msg, Throwable cause) { 17 | super(msg, cause); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/factory/Aware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description 标记类接口,实现该接口可以被Spring容器感知 6 | * @date 2022/3/11 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface Aware { 11 | } 12 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/factory/BeanClassLoaderAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Callback that allows a bean to be aware of the bean 6 | * {@link ClassLoader class loader}; that is, the class loader used by the 7 | * present bean factory to load bean classes. 8 | * @date 2022/3/11 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface BeanClassLoaderAware extends Aware { 13 | 14 | void setBeanClassLoader(ClassLoader classLoader); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/factory/BeanFactoryAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * @description 实现此接口,既能感知到所属的 BeanFactory 8 | * @date 2022/3/11 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface BeanFactoryAware extends Aware { 13 | 14 | void setBeanFactory(BeanFactory beanFactory) throws BeansException; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/factory/BeanNameAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Interface to be implemented by beans that want to be aware of their 6 | * bean name in a bean factory. Note that it is not usually recommended 7 | * that an object depend on its bean name, as this represents a potentially 8 | * brittle dependence on external configuration, as well as a possibly 9 | * unnecessary dependence on a Spring API. 10 | * @date 2022/3/11 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface BeanNameAware { 15 | 16 | void setBeanName(String name); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/factory/DisposableBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Interface to be implemented by beans that want to release resources 6 | * on destruction. A BeanFactory is supposed to invoke the destroy 7 | * method if it disposes a cached singleton. An application context 8 | * is supposed to dispose all of its singletons on close. 9 | * @date 2022/3/10 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface DisposableBean { 14 | 15 | void destroy() throws Exception; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/factory/FactoryBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Interface to be implemented by objects used within a {@link BeanFactory} 6 | * which are themselves factories. If a bean implements this interface, 7 | * it is used as a factory for an object to expose, not directly as a bean 8 | * instance that will be exposed itself. 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface FactoryBean { 14 | 15 | T getObject() throws Exception; 16 | 17 | Class getObjectType(); 18 | 19 | boolean isSingleton(); 20 | 21 | } -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/factory/HierarchicalBeanFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description Sub-interface implemented by bean factories that can be part 6 | * of a hierarchy. 7 | * @date 2022/3/9 8 | * /CodeDesignTutorials 9 | * 10 | */ 11 | public interface HierarchicalBeanFactory extends BeanFactory { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/factory/InitializingBean.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | /** 4 | * 5 | * @description 实现此接口的 Bean 对象,会在 BeanFactory 设置属性后作出相应的处理,如:执行自定义初始化,或者仅仅检查是否设置了所有强制属性。 6 | * @date 2022/3/10 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface InitializingBean { 11 | 12 | /** 13 | * Bean 处理了属性填充后调用 14 | * 15 | * @throws Exception 16 | */ 17 | void afterPropertiesSet() throws Exception; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/factory/ObjectFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | 5 | /** 6 | * 7 | * @description Defines a factory which can return an Object instance (possibly shared or independent) when invoked. 8 | * @date 2022/3/16 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface ObjectFactory { 13 | 14 | T getObject() throws BeansException; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/factory/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * @description Bean 引用 6 | * @date 2022/3/9 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public class BeanReference { 11 | 12 | private final String beanName; 13 | 14 | public BeanReference(String beanName) { 15 | this.beanName = beanName; 16 | } 17 | 18 | public String getBeanName() { 19 | return beanName; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/factory/config/SingletonBeanRegistry.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.config; 2 | 3 | /** 4 | * 5 | * @description 单例 Bean 注册表 6 | * @date 2022/03/07 7 | * 8 | * 9 | */ 10 | public interface SingletonBeanRegistry { 11 | 12 | /** 13 | * 返回在给定名称下注册的(原始)单例对象。 14 | * @param beanName 要查找的bean的名称 15 | * @return 返回注册的单例对象 16 | */ 17 | Object getSingleton(String beanName); 18 | 19 | void registerSingleton(String beanName, Object singletonObject); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/beans/factory/support/InstantiationStrategy.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.beans.factory.support; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.config.BeanDefinition; 5 | 6 | import java.lang.reflect.Constructor; 7 | 8 | /** 9 | * 10 | * @description Bean 实例化策略接口 11 | * @date 2022/03/08 12 | * 13 | * 14 | */ 15 | public interface InstantiationStrategy { 16 | 17 | Object instantiate(BeanDefinition beanDefinition, String beanName, Constructor ctor, Object[] args) throws BeansException; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/context/ApplicationContextAware.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | import cn.bugstack.springframework.beans.BeansException; 4 | import cn.bugstack.springframework.beans.factory.Aware; 5 | 6 | /** 7 | * 8 | * @description 实现此接口,既能感知到所属的 ApplicationContext 9 | * @date 2022/3/11 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface ApplicationContextAware extends Aware { 14 | 15 | void setApplicationContext(ApplicationContext applicationContext) throws BeansException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/context/ApplicationEventPublisher.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context; 2 | 3 | /** 4 | * 5 | * @description 事件发布者接口 6 | * @date 2022/3/13 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface ApplicationEventPublisher { 11 | 12 | /** 13 | * Notify all listeners registered with this application of an application 14 | * event. Events may be framework events (such as RequestHandledEvent) 15 | * or application-specific events. 16 | * @param event the event to publish 17 | */ 18 | void publishEvent(ApplicationEvent event); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/context/annotation/Scope.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.context.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | @Target({ElementType.TYPE, ElementType.METHOD}) 6 | @Retention(RetentionPolicy.RUNTIME) 7 | @Documented 8 | public @interface Scope { 9 | 10 | String value() default "singleton"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/core/annotation/SynthesizedAnnotation.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.annotation; 2 | 3 | public @interface SynthesizedAnnotation { 4 | } 5 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/core/convert/ConversionService.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.convert; 2 | 3 | /** 4 | * 5 | * @description 类型转换抽象接口 6 | * @date 2022/3/16 7 | * 8 | * 9 | */ 10 | public interface ConversionService { 11 | 12 | /** Return {@code true} if objects of {@code sourceType} can be converted to the {@code targetType}. */ 13 | boolean canConvert(Class sourceType, Class targetType); 14 | 15 | /** Convert the given {@code source} to the specified {@code targetType}. */ 16 | T convert(Object source, Class targetType); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/core/convert/converter/Converter.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.convert.converter; 2 | 3 | /** 4 | * 5 | * @description 类型转换处理接口 6 | * @date 2022/3/16 7 | * 8 | * 9 | */ 10 | public interface Converter { 11 | 12 | /** Convert the source object of type {@code S} to target type {@code T}. */ 13 | T convert(S source); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/core/convert/converter/ConverterFactory.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.convert.converter; 2 | 3 | /** 4 | * 5 | * @description 类型转换工厂 6 | * @date 2022/3/16 7 | * 8 | * 9 | */ 10 | public interface ConverterFactory{ 11 | 12 | /** 13 | * Get the converter to convert from S to target type T, where T is also an instance of R. 14 | * @param the target type 15 | * @param targetType the target type to convert to 16 | * @return a converter from S to T 17 | */ 18 | Converter getConverter(Class targetType); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/core/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 8 | * @description 资源处理接口 9 | * @date 2022/3/9 10 | * 11 | * 12 | */ 13 | public interface Resource { 14 | 15 | InputStream getInputStream() throws IOException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/core/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.io; 2 | 3 | /** 4 | * 5 | * @description 资源加载器 6 | * @date 2022/3/9 7 | * 8 | * 9 | */ 10 | public interface ResourceLoader { 11 | 12 | /** 13 | * Pseudo URL prefix for loading from the class path: "classpath:" 14 | */ 15 | String CLASSPATH_URL_PREFIX = "classpath:"; 16 | 17 | Resource getResource(String location); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/core/type/classreading/MetadataReader.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.core.type.classreading; 2 | 3 | /** 4 | * 5 | * @description Simple facade for accessing class metadata 6 | * @date 2022/3/18 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface MetadataReader { 11 | 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/jdbc/UncategorizedSQLException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc; 2 | 3 | /** 4 | * 5 | * @description Exception thrown when we can't classify an SQLException into 6 | * one of our generic data access exceptions. 7 | * @date 2022/3/16 8 | * /CodeDesignTutorials 9 | * 10 | */ 11 | public class UncategorizedSQLException extends RuntimeException{ 12 | 13 | public UncategorizedSQLException(String message) { 14 | super(message); 15 | } 16 | 17 | public UncategorizedSQLException(String task,String sql, Throwable cause) { 18 | super(sql, cause); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/jdbc/core/ResultSetExtractor.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.core; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | 6 | /** 7 | * 8 | * @description Callback interface used by {@link JdbcTemplate}'s query methods. 9 | * @date 2022/3/16 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface ResultSetExtractor { 14 | 15 | T extractData(ResultSet rs) throws SQLException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/jdbc/core/RowMapper.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.core; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | 6 | /** 7 | * 8 | * @description An interface used by {@link JdbcTemplate} for mapping rows of a 9 | * {@link ResultSet} on a per-row basis. 10 | * @date 2022/3/16 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface RowMapper { 15 | 16 | T mapRow(ResultSet rs, int rowNum) throws SQLException; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/jdbc/core/SqlProvider.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.core; 2 | 3 | /** 4 | * 5 | * @description Interface to be implemented by objects that can provide SQL strings. 6 | * @date 2022/3/16 7 | * /CodeDesignTutorials 8 | * 9 | */ 10 | public interface SqlProvider { 11 | 12 | String getSql(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/jdbc/core/StatementCallback.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.core; 2 | 3 | import java.sql.SQLException; 4 | import java.sql.Statement; 5 | 6 | /** 7 | * 8 | * @description Generic callback interface for code that operates on a JDBC Statement. 9 | * @date 2022/3/16 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface StatementCallback { 14 | 15 | T doInStatement(Statement statement) throws SQLException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/jdbc/datasource/ConnectionHandle.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.jdbc.datasource; 2 | 3 | import java.sql.Connection; 4 | 5 | /** 6 | * 7 | * @description Simple interface to be implemented by handles for a JDBC Connection. 8 | * @date 2022/3/16 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface ConnectionHandle { 13 | 14 | Connection getConnection(); 15 | 16 | default void releaseConnection(Connection con) { 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/stereotype/Component.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.stereotype; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * 7 | * @description Indicates that an annotated class is a "component". 8 | * Such classes are considered as candidates for auto-detection 9 | * when using annotation-based configuration and classpath scanning. 10 | * @date 2022/3/14 11 | * 12 | * 13 | */ 14 | @Target(ElementType.TYPE) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | @Documented 17 | public @interface Component { 18 | 19 | String value() default ""; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/tx/transaction/TransactionException.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.tx.transaction; 2 | 3 | /** 4 | * 5 | * @description Exception thrown when a transaction can't be created using an 6 | * underlying transaction API such as JTA. 7 | * @date 2022/3/16 8 | * /CodeDesignTutorials 9 | * 10 | */ 11 | public class TransactionException extends RuntimeException{ 12 | 13 | public TransactionException(String message) { 14 | super(message); 15 | } 16 | 17 | public TransactionException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/tx/transaction/annotation/TransactionAnnotationParser.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.tx.transaction.annotation; 2 | 3 | import cn.bugstack.springframework.tx.transaction.interceptor.TransactionAttribute; 4 | 5 | import java.lang.reflect.AnnotatedElement; 6 | 7 | /** 8 | * 9 | * @description 用于解析已知事务注释类型的策略接口 10 | * @date 2022/3/16 11 | * /CodeDesignTutorials 12 | * 13 | */ 14 | public interface TransactionAnnotationParser { 15 | 16 | /** 17 | * 基于该解析器理解的注释类型,解析给定方法或类的事务属性。 18 | */ 19 | TransactionAttribute parseTransactionAnnotation(AnnotatedElement element); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/tx/transaction/annotation/Transactional.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.tx.transaction.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * 事务注解 7 | */ 8 | @Target({ElementType.METHOD, ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Inherited 11 | @Documented 12 | public @interface Transactional { 13 | 14 | Class[] rollbackFor() default {}; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/tx/transaction/interceptor/RollbackRuleAttribute.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.tx.transaction.interceptor; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 7 | * @description Rule determining whether or not a given exception (and any subclasses) 8 | * should cause a rollback. 9 | * @date 2022/3/16 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public class RollbackRuleAttribute implements Serializable { 14 | 15 | private final String exceptionName; 16 | 17 | public RollbackRuleAttribute(Class clazz) { 18 | this.exceptionName = clazz.getName(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/tx/transaction/interceptor/TransactionAttribute.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.tx.transaction.interceptor; 2 | 3 | 4 | import cn.bugstack.springframework.tx.transaction.TransactionDefinition; 5 | 6 | /** 7 | * 8 | * @description This interface adds a {@code rollbackOn} specification to {@link TransactionDefinition}. 9 | * @date 2022/3/16 10 | * /CodeDesignTutorials 11 | * 12 | */ 13 | public interface TransactionAttribute extends TransactionDefinition { 14 | 15 | boolean rollbackOn(Throwable ex); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/tx/transaction/interceptor/TransactionAttributeSource.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.tx.transaction.interceptor; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * 7 | * @description Strategy interface used by {@link TransactionInterceptor} for metadata retrieval. 8 | * @date 2022/3/16 9 | * /CodeDesignTutorials 10 | * 11 | */ 12 | public interface TransactionAttributeSource { 13 | 14 | TransactionAttribute getTransactionAttribute(Method method, Class targetClass); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-step-21/src/main/java/cn/bugstack/springframework/util/StringValueResolver.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.util; 2 | 3 | /** 4 | * 5 | * @description Simple strategy interface for resolving a String value. 6 | * Used by {@link cn.bugstack.springframework.beans.factory.config.ConfigurableBeanFactory}. 7 | * @date 2022/3/9 8 | * /CodeDesignTutorials 9 | * 10 | */ 11 | public interface StringValueResolver { 12 | 13 | String resolveStringValue(String strVal); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-step-21/src/test/java/cn/bugstack/springframework/test/dao/IUserDao.java: -------------------------------------------------------------------------------- 1 | package cn.bugstack.springframework.test.dao; 2 | 3 | import cn.bugstack.springframework.test.po.User; 4 | 5 | public interface IUserDao { 6 | 7 | User queryUserInfoById(Long id); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /spring-step-21/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst: -------------------------------------------------------------------------------- 1 | cn/bugstack/springframework/test/ApiTest.class 2 | cn/bugstack/springframework/test/dao/IUserDao.class 3 | cn/bugstack/springframework/test/po/User.class 4 | -------------------------------------------------------------------------------- /spring-step-21/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst: -------------------------------------------------------------------------------- 1 | /Users/fuzhengwei/1024/SpringTutorials/spring-step-21/src/test/java/cn/bugstack/springframework/test/dao/IUserDao.java 2 | /Users/fuzhengwei/1024/SpringTutorials/spring-step-21/src/test/java/cn/bugstack/springframework/test/po/User.java 3 | /Users/fuzhengwei/1024/SpringTutorials/spring-step-21/src/test/java/cn/bugstack/springframework/test/ApiTest.java 4 | --------------------------------------------------------------------------------