|
play!为不喜欢传统JEE臃肿框架的程序员提供了一个敏捷的Web开发框架。
www.playframework.org
此次更新主要有:
1.自定义静态文件存放路径
So, to keep serving files from /public directory with the /public path, just add :
GET /public staticDir:public
2. 邮件系统支持
You can now define Mailer in your application. A mailer is subclass of play.mvc.Mailer, where each public static method send an email.
Example :
package notifiers;
import play.*;
import play.mvc.*;
import java.util.*;
public class Notifier extends Mailer {
public static void welcome(User user) {
setSubject("Welcome %s", user.name);
addRecipient(user.email);
addAttachment(Play.getFile("rules.pdf"));
send(user);
}
}
3. JPA重构
We have worked a lot on the JPA integration.
The JPA and JPAContext classes have been merged (JPAContext has been removed). Please replace the JPAContext.getEntityManager() call by JPA.getEntityManager().
A new find method is available in JPAModel :
Users.find().all(); // All results
Users.find().one(); // The first result or null
Users.find().page(1, 10); // First page with page size at 10
You can still set your own query. Either with a shortcut :
Users.find("email", email).one();
Users.find("email = ? and active = true", email).one();
Or by specifying a full JPQL query :
Users.find("from User u where u.email = ?", email).one();
Users.find("select u from User u where u.email = ?", email).one();
You can now count using a query :
Users.count(); // Count all user instances
Users.count("active", true); // Count all active users
Refresh and merge operation are directly available on JPAModel :
User user = User.findById(2L);
user.refresh();
User mergedUser = Cache.get("user", User.class).merge();
You can delete using a query :
Users.delete(); // delete all users
Users.delete("active", false); // delete all inactive users
You can still access the plain entityManager, with em() :
public void delete() {
em().delete(this);
}
4.编译时间优化
The Java compilation process has been optimized and is now faster (especially for large projects).
Moreover, Play! now keep a Bytecode cache for all compiled resources (Java sources and templates). We keep an MD5 hash of the source code with each Bytecode and always compare it before to use a cached Bytecode.
This option is activated by default. You can disable it with :
play.bytecodeCache=false
in the application.conf file.
更多更新消息请看:
http://www.playframework.org/manual/contents/stable4
完整论坛程序下载:
http://www.playframework.org/download/samples/sample-forum.zip
来自:http://www.playframework.org/
|