代码拉取完成,页面将自动刷新
同步操作将从 不行就再写一个/pond 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
##Pond - 灵活,快速的web开发框架 (基于java 8)
###pond-common 提供了一些函数式编程特性和一些有用的工具类
Code Example:
//debug
S._debug(logger, log -> {
Thread.sleep(3000) // do some heavy job
log.debug("xxxxx");
}
//PATH
assertEquals(PATH.classpathRoot(), S.class.getResource("/").getPath());
//S.array -- easy creation
Array<String> arr = S.array("This", "is", "A", "GOOD", "Day");
assertArrayEquals(arr.map(str -> str.toUpperCase()).join(),
S.array("THIS", "IS", "A", "GOOD", "DAY").join());
//Array#reduce -- fold function
Array<Integer> arr = S.array(1, 23, 4, 5, 6, 7, 8, 9);
assertEquals((long) arr.reduce((acc, cur) -> acc + cur), (1 + 23 + 4 + 5 + 6 + 7 + 8 + 9));
//Array#filter -- filter function
Array<Integer> arr = S.array(1, 23, 4, 5, 6, 7, 8, 9);
assertArrayEquals(new int[]{23}, (int[]) Convert.toPrimitiveArray(arr.filter(x -> x > 20).join()));
###pond-web 面向web的快速开发工具
Code Example:
//basic & config
Pond.init(p -> p.loadConfig(new Properties()),
p -> p.get("/123", (req, res) -> res.send("123"))
.get("/234", (req, res) -> res.send("234")),
p -> p.get("/.*", p._static("www"))
).listen();
//static
Pond.init(p -> {
p.get("/static/.*", p._static("www"));
}).listen(9090);
//uploadfile
System.setProperty(BaseServer.PORT, "9090");
Pond.init(p -> {
p.post("/multipart", (req, resp) -> {
Request.UploadFile f = req.file("content");
resp.render(json("<pre>" + dump(req) + "</pre><br><pre>" + dump(f) + "</pre>"));
resp.send(200, "OK");
}).get("/.*", p._static("www"));
}).listen();
//debug
S._debug_on(Pond.class, BaseServer.class);
System.setProperty(BaseServer.PORT, "9090");
Pond.init(p -> {
p.post("/utf8test", (req, resp) -> {
S.echo(S.dump(req.params()));
resp.render(Render.dump(req.params()));
}).get("/.*", p._static("www"));
}).listen();
//Session
Mid session = Session.install();
app.cleanAndBind(p -> {
p.get("/require",
session,
Mid.wrap((req, resp) -> resp.send(200, "pass")).require(session)
);
p.get("/requireFail",
Mid.wrap((req, resp) -> resp.send(200, "pass")).require(session)
);
});
TestUtil.assertContentEqualsForGet("pass", "http://localhost:9090/require");
HTTP.get("http://localhost:9090/requireFail", http -> {
assertNotSame(200, http.getStatusLine().getStatusCode());
});
###pond-db - 数据库处理相关(默认提供mysql)
Code Example:
//Model Definition
public class BonusService extends Model{
{
db(App.getInstance().getDb());
table("t_bonus_service");
id("id");
field("name");
field("price");
}
//...
//Model-based data retrieving
List<Model> m = db.get(t -> t.query(Model.class, "select * from t_model"));
//Concurrent Test
Holder.AccumulatorInt val = new Holder.AccumulatorInt(0);
ExecutorService executorService = Executors.newFixedThreadPool(20);
List<CompletableFuture> futures = new ArrayList<>();
long s = S.now();
S._repeat(() -> {
futures.add(CompletableFuture.runAsync(
() -> {
db.post(tmpl -> {
tmpl.exec("USE POND_DB_TEST;");
for (int i = 0; i < 400; i++)
tmpl.exec("INSERT INTO test values(?,?)",
String.valueOf(Math.random()), String.valueOf(val.accum()));
});
}, executorService));
}, 1000);
try {
CompletableFuture.allOf(S._for(futures).join()).thenRun(() -> {
long beforeSelect = S.now();
S._for((List<Record>) db.get(t -> {
t.exec("USE POND_DB_TEST;");
return t.query("SELECT * FROM test");
}));
S.echo("Query time:" + (S.now() - beforeSelect));
S.echo("ALL FINISHED : time usage " + (S.now() - s));
}).get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
###详情请参考项目内测试代码和注释 遇到坑了 ==> 请联系 edwinyxc@outlook.com QQ && WEIXIN: 326436387
欢迎大家一起来提修改意见 :) QQ群:206693019
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。