# bubble
**Repository Path**: T-9800/bubble
## Basic Information
- **Project Name**: bubble
- **Description**: 轻量级 Java WEB 框架.
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 2
- **Created**: 2017-04-16
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
简介
-----------
Bubble是一个基于Java Servlet的全栈Web框架。
Bubble结合了性能和开发效率,只需具备基础的Java WEB开发知识就可快速上手。
Bubble高度模块化,采用无状态设计,具备多级缓存能力;是开发高性能,可伸缩Web Application的理想框架!
组成模块
-----------
1.3-tier : 三层架构.
2.ORM : 持久化模块.
3.View : 支持JSP, JSON, Beetl, Velocity
4.Container : 简易IOC容器.
5.AOP : 准面向切面编程.
6.Session : 无状态Session.提供In-Memory RDBMS Struts, In-Memory RDBMS, Redis三种版本
7.Cache : 缓存系统.支持文件, 内存, 数据库缓存.内存支持Map, Redis, Memcache, Guava Cache, Ehcache.
8.Staticize : 页面静态化, 支持页面缓存到Cache模块.
9.Log : 高并发日志记录模块.
10.OGNL : 简易的对象导航访问工具.
11.security : 安全令牌, 验证码, SQL检查, XSS检查, 蜘蛛检查.
12.plug-in : 插件系统,支持运行期间安装卸载.
13.crontab : 计划任务模块,还未完成技术验证.
14.Miscellaneous: WEB开发中经常碰到的问题.
下载使用
-----------
### 环境准备
JDK:JDK1.8+
WEB容器:支持Servlet 3.1标准的WEB容器.推荐使用Apache Tomcat Version 8.0.23+
数据库:推荐使用支持In-Memory技术的RDBMS。推荐使用MySQL 5.5+, Oracle 12c, SQL Server 2014
IDE:推荐使用IntelliJ IDEA 14.1.5+
### 详细步骤
1.创建WEB开发项目,项目编码格式UTF-8,修改WebContent目录为"web",配置相关运行环境
2.将源码包中的文件拷贝到对应目录
3.创建数据库,导入sql文件内对应类型的SQL
4.修改配置文件/web/config/c3p0-config.xml中“jdbcUrl”,“user”,“password”配置项
注意: Bubble默认开启FileCache和Log,所产生的文件保存在WEB容器启动目录。可通过/web/config/GlobalConfig.json更改文件保存位置
5.编译运行
快速入门
-----------
Bubble采用三层架构解耦
1.编写访问控制层代码
```
@WebServlet(name = "SimpleServlet", urlPatterns = "/simple/*")
public class SimpleServlet extends HttpServlet {
public static final String[] RES_ARRAY = {
"", "index.htm", "show.htm",
};
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Container.creatApp(request, response);
String resName = (String) Container.app().Global.get("res");
String moduleName = (ArraysHelper.inArrays(RES_ARRAY, resName) && !resName.equals("") ? resName : "index").replaceAll(GlobalConfig.RES_SUFFIX, "");
try {
Container.app().init();
Class moduleClass = Class.forName(GlobalConfig.SOURCE_PATH + ".module.simple.Simple" + moduleName);
moduleClass.getMethod("run").invoke(null);
} catch (Exception e) {
ExceptionHandler.handling(e);
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doGet(request, response);
}
}
```
2.编写数据操作层代码
```
public class common_session_struct extends Table {
public common_session_struct() {
super("common_session_struct", "sessionid");
}
public Map fetchAll() throws SQLException {
String sql = "SELECT * FROM " + DB.getRealTableName(this.tableName);
return DB.queryAll(sql);
}
}
```
3.编写业务模块
```
public class Simpleindex {
public static void run() throws Exception {
// 两种写法
Container.app().Global.put("allsession", ((common_session_struct) Container.table("common_session_struct")).fetchAll());
Container.app().Global.put("allsession", Container.table("common_session_struct").call("fetchAll"));
Core.forward("/simple/index.jsp");
}
}
```
4.编写展示层代码
以JSP为例
```