All Projects → zzzzbw → Doodle

zzzzbw / Doodle

Licence: apache-2.0
A Simple Java MVC Framework。提供Bean容器、Ioc、Aop、MVC功能

Programming Languages

java
68154 projects - #9 most used programming language
java8
65 projects

Projects that are alternatives of or similar to Doodle

Koatty
Koa2 + Typescript = Koatty. Use Typescript's decorator implement IOC and AOP.
Stars: ✭ 67 (-25.56%)
Mutual labels:  springboot, ioc, aop
Martian
🎨 Martian 是一个基于NIO的JavaWeb编程框架,可以帮助你快速的开发后端服务
Stars: ✭ 320 (+255.56%)
Mutual labels:  ioc, aop
Jeeplatform
一款企业信息化开发基础平台,拟集成OA(办公自动化)、CMS(内容管理系统)等企业系统的通用业务功能 JeePlatform项目是一款以SpringBoot为核心框架,集ORM框架Mybatis,Web层框架SpringMVC和多种开源组件框架而成的一款通用基础平台,代码已经捐赠给开源中国社区
Stars: ✭ 1,285 (+1327.78%)
Mutual labels:  springboot, aop
Jodd
Jodd! Lightweight. Java. Zero dependencies. Use what you like.
Stars: ✭ 3,616 (+3917.78%)
Mutual labels:  ioc, aop
java-bible
🍌 我的技术摘要
Stars: ✭ 2,950 (+3177.78%)
Mutual labels:  ioc, aop
Java Bible
🍌 我的技术摘要
Stars: ✭ 2,919 (+3143.33%)
Mutual labels:  ioc, aop
Spring Learning
Spring 学习笔记,通过例子展示和剖析实现机制
Stars: ✭ 346 (+284.44%)
Mutual labels:  ioc, aop
CNeptune
CNeptune improve productivity & efficiency by urbanize .net module with meta-code to lay foundation for frameworks
Stars: ✭ 30 (-66.67%)
Mutual labels:  ioc, aop
Swoft
🚀 PHP Microservice Full Coroutine Framework
Stars: ✭ 5,420 (+5922.22%)
Mutual labels:  springboot, aop
Hasor
Hasor是一套基于 Java 语言的开发框架,区别于其它框架的是 Hasor 有着自己一套完整的体系,同时还可以和先有技术体系做到完美融合。它包含:IoC/Aop容器框架、Web框架、Jdbc框架、RSF分布式RPC框架、DataQL引擎,等几块。
Stars: ✭ 713 (+692.22%)
Mutual labels:  ioc, aop
Frankie
A frankenstein framework - middleware and annotation based
Stars: ✭ 19 (-78.89%)
Mutual labels:  annotation, aop
tsioc
AOP, Ioc container, Boot framework, unit testing framework , activities workflow framework.
Stars: ✭ 15 (-83.33%)
Mutual labels:  ioc, aop
Online-Testing-Platform
在线考试系统 colleges online examination system base on spring-boot and MyBatis
Stars: ✭ 21 (-76.67%)
Mutual labels:  aop, springboot
Blog.core
💖 ASP.NET Core 6.0 全家桶教程,前后端分离后端接口,vue教程姊妹篇,官方文档:
Stars: ✭ 3,542 (+3835.56%)
Mutual labels:  ioc, aop
Spring5Certification
Spring Certification: This repository contains my examples and some best references to prepare the Spring 5 certification
Stars: ✭ 30 (-66.67%)
Mutual labels:  aop, springboot
Summer
这是一个支持分布式和集群的java游戏服务器框架,可用于开发棋牌、回合制等游戏。基于netty实现高性能通讯,支持tcp、http、websocket等协议。支持消息加解密、攻击拦截、黑白名单机制。封装了redis缓存、mysql数据库的连接与使用。轻量级,便于上手。
Stars: ✭ 336 (+273.33%)
Mutual labels:  ioc, aop
Farseer.Net
Provides consistent standard use of common components of the .Net Core language
Stars: ✭ 42 (-53.33%)
Mutual labels:  ioc, aop
thinking-in-spring
Spring source code reading
Stars: ✭ 105 (+16.67%)
Mutual labels:  ioc, aop
Codeguide
📚 本代码库是作者小傅哥多年从事一线互联网 Java 开发的学习历程技术汇总,旨在为大家提供一个清晰详细的学习教程,侧重点更倾向编写Java核心内容。如果本仓库能为您提供帮助,请给予支持(关注、点赞、分享)!
Stars: ✭ 6,750 (+7400%)
Mutual labels:  springboot, aop
Spring Examples
SpringBoot Examples
Stars: ✭ 67 (-25.56%)
Mutual labels:  springboot, aop

Doodle

Build Status Maven Central License

简介

doodle是一个简易的Java MVC框架,它提供了类似于spring 的Bean容器、IOC、AOP、MVC等功能

代码简洁、轻量,适合用于参考学习spring

  • 一行代码即可启动服务,内置Tomcat容器
  • DispatcherServlet请求逻辑处理采用责任链模式,方便增加修改规则
  • 不使用XML配置,完全注解开发
  • IOC容器,解决循环依赖注入问题
  • 支持多AOP增强,切点支持aspectj表达式

Http请求访问设计图:

示例代码

  1. git clone https://github.com/zzzzbw/doodle.git 或直接下载代码到本地

  2. 将项目导入到IDE中,这是maven工程,确保你已经安装maven

  3. 执行doodle-example/src/main/java下的github.zzzzbw.App类的main()方法即可启动Tomcat服务器

  4. 浏览器访问http://localhost:9090/user/listhttp://localhost:9090/user/detail?id=1链接

  5. 通过'Postman'等工具用post方式请求到链接http://localhost:9090/user/add?name=zzzzbwhttp://localhost:9090/user/delete?id=1修改数据

使用方式

引入依赖

创建一个 maven 项目,引入核心依赖

<dependency>
  <groupId>com.github.zzzzbw</groupId>
  <artifactId>doodle-core</artifactId>
  <version>0.1</version>
</dependency>

启动类:

public class App {
    public static void main(String[] args) {
        Doodle.run(App.class, 9090);
    }
}

IOC使用

使用方式与spring基本一致,不过只支持类型注入,即如果被注入对象为类,则注入其实例,如果被注入对象为接口,则注入其实现类。

@Component
public class EmailComponent {
    // do something
}

UserController注入EmailComponent

@Controller
public class UserController {
    @Autowired
    private EmailComponent emailComponent;
    // do something
}

AOP使用

  • 增强处理类必须实现MethodBeforeAdvice,AfterReturningAdvice,ThrowsAdvice,AroundAdvice中的一个或者多个接口
  • 增强处理类被@Aspect注解,且有正确的aspectj切点表达式
  • (可选)@Order注解来决定增强处理类的先后顺序
@Order(1)
@Aspect(pointcut = "@within(Controller)")
public class Aspect1 implements AroundAdvice {
    @Override
    public void afterReturning(Class<?> clz, Object returnValue, Method method, Object[] args) throws Throwable {
        // do something
    }
    @Override
    public void before(Class<?> clz, Method method, Object[] args) throws Throwable {
        // do something
    }
    @Override
    public void afterThrowing(Class<?> clz, Method method, Object[] args, Throwable e) {
        // do something
    }
}
@Order(2)
@Aspect(pointcut = "@within(Controller)")
public class Aspect2 implements AroundAdvice {
    @Override
    public void afterReturning(Class<?> clz, Object returnValue, Method method, Object[] args) throws Throwable {
        // do something
    }

    @Override
    public void before(Class<?> clz, Method method, Object[] args) throws Throwable {
        // do something
    }

    @Override
    public void afterThrowing(Class<?> clz, Method method, Object[] args, Throwable e) {
        // do something
    }
}

上面两个增强处理类Aspect1Aspect2,会增强被@Controller注解的类下的方法,且顺序为:

[email protected]()->[email protected]()->method.invoke()->[email protected]()->[email protected]()

Controller使用

使用几乎与spring一致

返回String类型的则返回jsp页面的路径,返回ModelAndView则在其view中设置jsp页面路径,同时可以传一些参数给jsp页面

@ResponseBody注解的则返回的是json格式数据

@Controller
@RequestMapping(value = "/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public ModelAndView getUserList() {
        List<User> list = userService.getUser();
        return new ModelAndView().setView("user_list.jsp").addObject("list", list);
    }

    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public ModelAndView getUser(@RequestParam(value = "id") long id) {
        User user = userService.getUserById(id);
        return new ModelAndView().setView("user_detail.jsp").addObject("user", user);
    }

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ResponseBody
    public Result<User> addUser(@RequestParam(value = "name") String name) {
        User user = userService.addUser(name);
        return new Result<>(user, 0, "");
    }

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ResponseBody
    public Result<String> deleteUser(@RequestParam(value = "id") long id) {
        userService.deleteUser(id);
        return new Result<>("success", 0, "");
    }
}

约束

doodle暂时功能没有完善,在使用过程中有一些约束条件

  • 被Bean容器接管的类都有无参的构造方法且构造方法不是私有的
  • @Component只应用于类,应用于接口或抽象类将无效
  • 每个Controller@RequestMapping标注的方法,其参数必须必须被@RequestParam注解,且参数必须是java的基本数据类型或者基本数据的包装类(如int,Integer等)

详解

结语

本项目不仅参考了spring-boot,同时还参考了:

这些都是国人写的更轻量而且也很优秀的框架,相比spring-boot来说阅读源码的难度会小一些。感谢这些框架给我提供学习的思路,同时给我们更多的选择。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].