python ioc框架_自己动手写Spring框架--IOC、MVC

对于一名Java开发人员,我相信没有人不知道 Spring 框架,而且也能够轻松就说出 Spring 的特性-- IOC、MVC、AOP、ORM(batis)。

看那么多 Spring 源码分析,不如自己动手写 个轻量的 Spring 框架。

下面我想简单介绍一下我写的轻量级的 Spring 框架(swift-framework),并且进行核心逻辑的分析,和使用说明。

提示:以下有大量图片,可以在新页面查看图片。

目录:

自己动手写Spring框架--IOC、MVC

-- 跟着 debug 走流程

自己动手写Spring框架--AOP、ORM

-- 敬请期待

下载jar包,引入到自己的新项目中。再要做的就是很简单了。

示例:

@Controller 注解:标注controller类。

@Inject 注解:依赖注入类,自动注入依赖的实现类。

@Action(value = "get:/hello") 注解:标注访问行为,‘get’是请求类型,‘/hello’是请求路径。

(暂时先介绍这三个注解类)

配置文件:

这里需要注意:

1.配置文件名称一定要是 “swift.properties” 。

2. #扫描类的根目录

swift.framework.app.base_package=org.swift.chapter

一定需要配置根目录。

跟着 debug 走流程

下面大致介绍一下处理的逻辑流程,详细的代码可以去 github上查看。

处理逻辑的入口:DispatcherServlet

这一次可以看一下,

ClassHelper,BeanHelper,ControllerHelper ,IocHelper 这四个类都干了些什么。

BeanHelper

ControllerHelper (在 ACTION_REGISTER 中,存放 【请求类型、请求路径】 对应的 【执行类、执行方法】)

到此为止,已经做好了IOC、MVC 的准备工作,现在就是使用的时候。

以上就是一次从前端的请求,在 swift-framework 框架中的执行过程的分析的大致过程,如果需要观看源码,可以去 GIT 下载。

下一章文章,将会分析 swift-framework 框架的 ORM、AOP 的实现分析。

自己动手写Spring框架--AOP、ORM

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
# Author: Greg Lee Turnquist # Paperback: 264 pages # Publisher: Packt Publishing; 1st New edition edition (May 21, 2010) # Language: English # ISBN-10: 1849510660 # ISBN-13: 978-1849510660 Amazon 的介紹: http://www.amazon.com/Spring-Python-1-1-Greg-Turnquist/dp/1849510660 Spring Python captures the concepts of the Spring Framework and Spring Security and brings them to the world of Python and provides many functional parts to assemble applications. Spring Python is all about using the many useful features of Spring to the fullest and making these features available when working with Python. Get to grips with all of the concepts of Spring and apply these to the language and environment of Python to develop powerful applications for your own personal requirements. The book provides an introduction to Spring Python and steadily takes you towards the advanced features that this integration has to offer. Spring uses the Java programming language. Spring Python, the first Spring extension to go live, allows developers to make maximum use of Spring features in Python. This book starts off by introducing each of the core building blocks of Spring Python using real code examples and high-level diagrams. It explores the various concepts of Spring Python with the help of examples and case studies and focuses on vital Spring Python features to make the lives of Python and Java developers simple. The early chapters cover simple applications with simple operations including data access, and then subsequent chapters scale up to multi-node, secured, transactional applications stopping short of very advanced level complexity. This book will help you to scale your applications without having to add unnecessary complexity

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值