内容简介:没有及时发布新闻,真是不好意思。今天打个新闻批发,把 Act 1.7.0 到 1.8.1 中值得注意的更新给大家汇报一下。 Act-1.8.1 - 2018-03-11 支持 Request Forward @GetAction("shortcut/{shortUrl}") public voi...
没有及时发布新闻,真是不好意思。今天打个新闻批发,把 Act 1.7.0 到 1.8.1 中值得注意的更新给大家汇报一下。
Act-1.8.1 - 2018-03-11
支持 Request Forward
@GetAction("shortcut/{shortUrl}")
public void shortUrlHandler(String shortUrl, UrlMapper urlMapper) {
String longUrl = urlMapper.get(shortUrl);
Controller.Util.forward(longUrl);
}forward 和 redirect 的区别:forward 不会发回 303 给浏览器,而是在应用内部直接分派到相关请求响应器。注意:forward 只支持 HTTP GET 请求
Act-1.8.0 - 2018-03-04
实现了新的响应输出模型,大大优化响应输出的内存,对大字节内容输出性能上有少量提升
项目布局支持 gradle-groovy
CacheService 注入支持 @Named
// Before
private CacheService fooCache = Act.app().cache("foo");
// After
@Named("bar")
@Inject
private barCache;timestamp auditing 支持在 base class 上定义的 timestamp 字段
@MappedSuperClass
public class BaseModel {
@CreatedAt public Date created;
@LastModifiedAt public Date lastModified;
}@Configuration 支持 static 字段
@Configuration("foo.bar")
public static String fooBar;Act-1.7.2 - 2018-02-25
支持 Timestamp Audting
public class User {
public String username;
...
@CreatedAt
public Date created;
@LastModified
public Date lastModified;
}Act-1.7.1 - 2018-02-21
允许用户定义 action handler 支持 Partial Path
@GetAction("/file/...")
public File handleFileRequest(@PartialPath String filePath) {
// filePath should be anything in the URL path that after `/file/`
}Act-1.7.0 - 2018-02-19
静态资源支持 DirectoryIndex - 自动查找目录下的 index.html 文件
API Doc TOC 以 HTTP Method 和 URL 组织
@Sensitive 数据字段支持
// creditCardNo 字段内容会被框架加密处理后存入数据库
// 从数据库取出数据时会自动解密
public class User {
public String firstName;
public String lastName;
public String email;
public String mobile;
@Sensitive
public String creditCardNo;
}简化密码字段处理
// 老办法
public class User {
public String username;
private String passhash;
public void setPassword(String password) {
passhash = Act.crypto().passwordHash(password);
}
}
// 新办法
public class User {
public String username;
@Password
public String password;
}简化方法执行的测量
// 老方式
public class Foo {
private Metric metric = Act.metricPlugin().metric("app");
// measure bar1 execution time
public void bar1() {
Timer timer = metric.startTimer("bar1");
try {
...
} finally {
timer.stop();
}
}
// measure bar2 execution count
public void bar2() {
metric.countOnce("bar2");
...
}
}
// 新方式
// define measure namespace.
// `("foo")` is optional and can be inferred from class name
@MetricLabel("foo")
public class Foo {
@MeasureTime("bar1") // ("bar1") is optional and can be inferred from method name
public void bar1() {
...
}
@MeasureCount("bar2") // `("bar2")` is optional and can be inferred from method name
public void bar2() {
...
}
}AppEvent 重命名为 SysEvent, AppEventId 重命名为 SysEventId
支持 JAX-RS 方式定义 Controller Action Handler
public class TestController {
// Act Style
@GetAction("foo")
public String foo() {return "foo";}
// JAX-RS style
@GET @PATH("bar")
public String bar() {return "bar";}
}public class Demo {
@LoadResource("name.list")
public List<String> nameList
@LoadResource("name.list")
public File nameListFile
@LoadResource("name.list")
public Set<String> uniqNameList;
@LoadResource("pojo.json")
public MyPojo myPojo;
}【声明】文章转载自:开源中国社区 [http://www.oschina.net]
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- Swoole + Laravel 实现高性能框架
- 高性能异步框架Celery入坑指南
- python高性能微服务框架japronto
- 腾讯高性能的图片框架 LKImageKit 正式开源
- 轻量级高性能PHP框架ycroute
- go-netty 高性能网络框架
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Introduction to Programming in Java
Robert Sedgewick、Kevin Wayne / Addison-Wesley / 2007-7-27 / USD 89.00
By emphasizing the application of computer programming not only in success stories in the software industry but also in familiar scenarios in physical and biological science, engineering, and appli......一起来看看 《Introduction to Programming in Java》 这本书的介绍吧!