-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jiahui
committed
Aug 22, 2019
1 parent
0195ca1
commit 8023b05
Showing
10 changed files
with
67 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
spring-ioc-mvc/src/main/java/com/xiaohui/ioc/beans/aware/ApplicationContextAware.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package com.xiaohui.ioc.beans.aware; | ||
|
||
import context.app.ApplicationContext; | ||
|
||
import com.xiaohui.ioc.context.ApplicationContext; | ||
|
||
/** | ||
* @author ly | ||
* @create 2019-01-12 16:06 | ||
**/ | ||
* 实现该接口的类可以直接获取spring配置文件中的bean对象。 | ||
*/ | ||
public interface ApplicationContextAware { | ||
void setApplicationContext(ApplicationContext applicationContext); | ||
} |
2 changes: 1 addition & 1 deletion
2
spring-ioc-mvc/src/main/java/com/xiaohui/ioc/beans/aware/Aware.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package com.xiaohui.ioc.beans.aware; | ||
|
||
/** | ||
* Aware接口 用于注入一些需要用到的对象 | ||
* 让bean获取spring容器的服务 | ||
*/ | ||
public interface Aware { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
spring-ioc-mvc/src/main/java/com/xiaohui/ioc/beans/factory/BeanFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.xiaohui.ioc.beans.factory; | ||
|
||
|
||
|
||
/** | ||
* 提供IOC容器最基本的形式,为IOC容器的实现提供了规范 | ||
**/ | ||
public interface BeanFactory { | ||
|
||
Object getBean(String beanName) throws Exception; | ||
} |
12 changes: 12 additions & 0 deletions
12
spring-ioc-mvc/src/main/java/com/xiaohui/ioc/context/ApplicationContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.xiaohui.ioc.context; | ||
|
||
|
||
import com.xiaohui.ioc.beans.factory.BeanFactory; | ||
|
||
/** | ||
* 应用上下文 | ||
* 1. 以通用的方式加载文件资源的能力。2. 将事件发布到注册监听器的功能。3. 解析消息的能力,支持国际化。4. 从父上下文继承的特性 | ||
*/ | ||
public interface ApplicationContext extends BeanFactory { | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
spring-ioc-mvc/src/main/java/com/xiaohui/ioc/support/AbstractApplicationContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.xiaohui.ioc.support; | ||
|
||
|
||
|
||
import com.xiaohui.ioc.beans.factory.BeanFactory; | ||
import com.xiaohui.ioc.context.ApplicationContext; | ||
|
||
|
||
public abstract class AbstractApplicationContext implements ApplicationContext { | ||
|
||
protected BeanFactory beanFactory; | ||
|
||
public AbstractApplicationContext(String location) { | ||
this.beanFactory = new AnnotationBeanFactory(location); | ||
} | ||
|
||
@Override | ||
public Object getBean(String beanName) throws Exception { | ||
return beanFactory.getBean(beanName); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters