java bubble_bubble

简介

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为例

All Session:
${Global["allsession"]}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted. The algorithm, which is a comparison sort, is named for the way smaller or larger elements "bubble" to the top of the list. Here is the Java code for Bubble Sort: ``` public class BubbleSort { public static void main(String[] args) { int[] arr = {5, 2, 7, 3, 1}; bubbleSort(arr); for(int i=0; i<arr.length; i++){ System.out.print(arr[i] + " "); } } public static void bubbleSort(int[] arr){ int n = arr.length; int temp = 0; for(int i=0; i < n; i++){ for(int j=1; j < (n-i); j++){ if(arr[j-1] > arr[j]){ temp = arr[j-1]; arr[j-1] = arr[j]; arr[j] = temp; } } } } } ``` In this code, we have an array of integers that we want to sort using Bubble Sort. We define a method called `bubbleSort` that takes an array as input and sorts it using the Bubble Sort algorithm. The outer loop iterates through the array from the first element to the last element. The inner loop iterates through the array from the second element to the last element. Inside the inner loop, we compare the current element with the previous element. If the current element is smaller than the previous element, we swap them. After the inner loop completes, the largest element is at the end of the array. We repeat this process until the entire array is sorted. Finally, we print the sorted array using a for loop.

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值