javaone2015報告会@名古屋 java ee 8 work in progress
TRANSCRIPT
JavaOne 2015 Feedback Java EE 8: Work in Progress
日本オラクル株式会社 クラウド・テクノロジー事業統括 Fusion Middleware事業統括本部 伊藤 敬 Dec 12, 2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
2
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Java EE 8の進捗状況についての簡単な振り返り
Java EE 8主要テーマと仕様策定・検討状況
仕様策定に関与・貢献するには
1
2
3
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Java Specification Request ステータス
JSR 366 – Java EE 8 Platform Early Draft Review (EDR)
JSR 369 – Servlet 4.0 – HTTP/2 EDR
JSR 365 – CDI 2.0 – CDI for Java SE, modularity & events EDR 完了
JSR 367 – JSON-B 1.0 – JSON Binding for Java Objects EDR 完了
JSR 371 – MVC 1.0 – Model View Controller, Action-Based, HTML framework EDR
JSR 368 – JMS 2.1 – MDB Improvements, CDI Managed Bean integration EDR
JSR 372 – JSF 2.3 – Integration with WebSocket, MVC, CDI, Java 8 Date&Time EDR
JSR 374 – JSON-P 1.1 – Query enhancements, Java SE 8 improvements EDR 完了
JSR 375 – Security 1.0 – Simplifications, Cloud enhancements Early Draft策定中
JSR 370 – JAX-RS 2.1 – NIO, Server-Sent Events Early Draft策定中
JSR 373 – Management 2.0 – REST based Management Early Draft策定中
Java EE 8 仕様策定の状況
4
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Java EE 8 – 全世界のコミュニティからのフィードバック
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Java EE 8 主要テーマ
• HTML5 / Web Tier 機能拡張
•開発をより容易に / CDI のさらなる活用
• クラウドの実行・管理環境化
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
HTML5のサポート / Web Tier機能拡張
• JSON Binding
• JSON Processing 機能拡張
• Action-based MVC
• HTTP/2のサポート – Servlet 4.0
• Server-sent Events
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-B
• Javaオブジェクト / JSON間のマーシャル/アンマーシャルを実現するAPI – XMLのJAXBランタイムAPIと類似
•既存のJSON Binding実装の成果を活用 – MOXy, Jackson, GSON, Genson, Xstream, …
– JSON Bindingプロバイダの変更を可能にする
8
Java API for JSON Binding
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 9
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-B 1.0
@Entity public class Person {
@Id String name;
String gender;
@ElementCollection Map<String,String> phones;
... // getters and setters
}
Person duke = new Person();
duke.setName("Duke");
duke.setGender("M");
phones = new HashMap<String,String>();
phones.put("home", "650-123-4567");
phones.put("mobile", "650-234-5678");
duke.setPhones(phones);
Jsonb jsonb = JsonbBuilder.create();
jsonb.toJson(duke, System.out) ;
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650-123-4567",
"mobile":"650-234-5678"}
}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-P 1.1
• JSON-P の継続的な更新を維持
•新しい標準への対応
• JsonObject、JsonArrayに編集機能を追加する
• Java SE 8のStream処理を使いやすくするHelperクラス、メソッドの追加
Java API for JSON Processing
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-P 1.1
• JSON-Pointer – IETF RFC 6901
– JSON文書の中の特定の値を参照するための文字列の構文を規定する
"/0/phones/mobile"
新しい標準への対応
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-P 1.1
JsonArray contacts = Json.createArrayBuilder()
.add(Json.createObjectBuilder()
.add("name", "Duke")
.add("gender", "M")
.add("phones", Json.createObjectBuilder()
.add("home", "650-123-4567")
.add("mobile", "650-234-5678")))
.add(Json.createObjectBuilder()
.add("name", "Jane")
.add("gender", "F")
.add("phones", Json.createObjectBuilder()
.add("mobile", "707-555-9999")))
.build();
[
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650-123-4567",
"mobile":"650-234-5678"}},
{
"name":"Jane",
"gender":"F",
"phones":{
"mobile":"707-555-9999"}}
]
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-P 1.1
JsonArray contacts = ...;
JsonPointer p =
new JsonPointer("/0/phones/mobile");
JsonValue v = p.getValue(contacts);
[
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650-123-4567",
"mobile":"650-234-5678"}},
{
"name":"Jane",
"gender":"F",
"phones":{
"mobile":"707-555-9999"}}
]
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-P 1.1
JsonArray contacts = ...;
JsonPointer p =
new JsonPointer("/0/phones/mobile");
contacts = p.replace(contacts, "650-555-1212");
[
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650-123-4567",
"mobile":"650-234-5678"}},
{
"name":"Jane",
"gender":"F",
"phones":{
"mobile":"707-555-9999"}}
]
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-P 1.1
JsonArray contacts = ...;
JsonPointer p =
new JsonPointer("/0/phones/mobile");
contacts = p.replace(contacts, "650-555-1212");
[
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650-123-4567",
"mobile":"650-555-1212"}},
{
"name":"Jane",
"gender":"F",
"phones":{
"mobile":"707-555-9999"}}
]
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-P 1.1
• JSON-Patch – IETF RFC 6902
• Patch is a JSON document
– JSONドキュメントを修整するためのオブジェクト / 処理の配列
– add, replace, remove, move, copy, test
–必ず “op” フィールドと “path” フィールドが必要
[
{"op":"replace", "path":"/0/phones/mobile", "value":"650-111-2222"},
{"op":"remove", "path":"/1"}
]
新しい標準への対応
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-P 1.1
JsonPatchBuilder builder = new JsonPatchBuilder();
JsonArray patch =
builder.replace("0/phones/mobile", "650-111-2222")
.remove("/1")
.build();
[
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650-123-4567",
"mobile":"650-234-5678"}},
{
"name":"Jane",
"gender":"F",
"phones":{
"mobile":"707-555-9999"}}
]
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-P 1.1
JsonPatchBuilder builder = new JsonPatchBuilder();
JsonArray patch =
builder.replace("0/phones/mobile", "650-111-2222")
.remove("/1")
.build();
JsonArray result = patch.apply(contacts);
[
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650-123-4567",
"mobile":"650-111-2222"}},
{
"name":"Jane",
"gender":"F",
"phones":{
"mobile":"707-555-9999"}}
]
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-P 1.1
JsonPatchBuilder builder = new JsonPatchBuilder();
JsonArray patch =
builder.replace("0/phones/mobile", "650-111-2222")
.remove("/1")
.build();
JsonArray result = patch.apply(contacts);
[
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650-123-4567",
"mobile":"650-111-2222"}}
]
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Model View Controller (MVC)
• Component-based MVC
–コンポーネントフレームワークを活用するタイプ
– Controller はフレームワークが提供する
– JSF, Wicket, Tapestry…
• Action-based MVC
– Controllerはアプリケーションで定義される
– Struts 2, Spring MVC…
2つのタイプ
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MVC 1.0
• アクション・ベースのModel-View-Controller アーキテクチャの追加
• Java EEテクノロジーを組み合わせて実現: – Model
• CDI, Bean Validation, JPA
– View • Facelets, JSP
– Controller • JAX-RS リソースメソッド
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 23
JSP, Facelets CDI Bean
JAX-RS Resource Methods
Bean Validation
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MVC 1.0
@Path("hello")
public class HelloController {
@Inject
private Greeting greeting;
@GET
@Controller
public String hello() {
greeting.setMessage("Hello there!");
return "hello.jsp";
}
}
JAX-RS controller
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MVC 1.0
@Path("hello")
public class HelloController {
@Inject
private Greeting greeting;
@GET
@Controller
public String hello() {
greeting.setMessage("Hello there!");
return "hello.jsp";
}
}
JAX-RS controller Model
@Named
@RequestScoped
public class Greeting {
private String message;
public String getMessage() {
return message;
}
public void setMessage(message) {
this.message = message;
}
}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MVC 1.0
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>${greeting.message}</h1>
</body>
</html>
View
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
HTTP/2
• 一つのTCP接続を多重化
• リクエストは “Stream"と呼ばれるデータ単位で送受信
– 多重化
– Stream単位で重み付け
• バイナリフレームレイヤ
–Server Push
• ヘッダ圧縮
Multiplexed Binary Frames POST /upload HTTP/1.1 Host: www.test.com Content-Type: application/json Content-Length: 15 {“name”:“duke”}
HTTP 1.1 HTTP/2
HEADERS frame
DATA frame
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
HTTP/2 サーバプッシュ
client server
.html
.js
.png
.css
• SSE/WebSocketとは用途が異なる
• 関連リソースをサーバプッシュ
• htmlの要求がきたら
• 関連のjs, png, css もプッシュする
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Servlet 4.0 HTTP/2 サーバプッシュのサンプル
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { PushBuilder builder = request.getPushBuilder(); builder.setPath(“/style.css”); builder.push(); res.setContentType(“text/html”); PrintWriter out = res.getPrintWriter(); out.println(“<html>”); out.println(“<head>”) out.println(“<link rel=¥”stylesheet¥” type=¥”text/css¥” href=¥“style.css¥”>”); … }
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JAX-RS 2.1
• Server-sent Events
• CDIとの連携強化
• JSON-Bとの連携
• JAX-RSリソースメソッドをMVCのコントローラとして活用
• NIO support in providers (filters, interceptors, …)
• Reactive API
• …
32
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Server-sent Events
• HTML5仕様に属するAPIの一つ
•サーバからクライアントへのテキストデータのストリーミング
• HTTP 1.1 / Content type: text/event-stream
• HTTPコネクションが維持される (Cometとの違い) –クライアントからコネクションを生成
–サーバからクライアントへ更新の通知を送信
–通常は定期的な更新やイベントドリブンな更新を伝える一方向の伝達に用いる
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 34
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 35
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 36
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 37
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
開発をより容易に
• CDI 活用範囲の拡大
• Security インターセプタ
• JMS : Message-Briven Beanのメッセージ処理を簡素化
• JAX-RS injection の導入
• WebSocket スコープ
• Pruning - EJB 2.x client view, IIOPとの互換性
38
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CDI 2.0
• Modularity
• Java SE support
• Asynchronous Events
• Event ordering
• …
利用範囲の拡大と機能強化
39
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Java EE Security 1.0
@IsAuthorized("hasRoles('Manager') && schedule.officeHrs")
void transferFunds()
@IsAuthorized("hasRoles('Manager') && hasAttribute('directReports', employee.id)")
double getSalary(long employeeId);
@IsAuthorized(ruleSourceName="java:app/payrollAuthRules", rule="report")
void displayReport();
CDI インターセプタを用いた認証処理
40
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JMS 2.1
• JMS 2.0から始まった「使いやすさのための改善」を継続
• メッセージを非同期に受け取るAPIの改良 – JMS MDBの改良
– JMS MDBに対する選択肢となる別なテクノロジーの提供
非同期にメッセージを受け取るための新たなAPI
41
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
インフラのモダナイズ
• Java EE Management 2.0
–管理・運用環境へのRESTベースのAPI提供
• Java EE Security 1.0
– Authorization
– Password Aliasing
– User Management
– Role Mapping
– Authentication
– REST Authentication
オンプレミスでもクラウドでも
42
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Java EE 8 JSRs
• Java EE 8 Platform (JSR 366)
• CDI 2.0 (JSR 365)
• JSON Binding 1.0 (JSR 367)
• JMS 2.1 (JSR 368)
• Java Servlet 4.0 (JSR 369)
• JAX-RS 2.1 (JSR 370)
• MVC 1.0 (JSR 371)
• JSF 2.3 (JSR 372)
• Java EE Management 2.0 (JSR 373)
• JSON-P 1.1 (JSR 374)
• Java EE Security 1.0 (JSR 375)
43
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
策定状況の開示
• Java EE 8 JSRは java.net にて公開されています – http://javaee-spec.java.net
– https://java.net/projects/javaee-spec/pages/Specifications
• Expert Groupのメールアーカイブも見ることができます – Users observer lists gets all copies
• Issue tracker / JIRAも公開されています
• …
Commitment to JCP transparent processes
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Java EE仕様策定に貢献しませんか??
• Adopt a JSR
– http://glassfish.org/adoptajsr
• Join an Expert Group project
– http://javaee-spec.java.net
– https://java.net/projects/javaee-spec/pages/Specifications
• The Aquarium
– http://blogs.oracle.com/theaquarium
• Java EE 8 Reference Implementation
– http://glassfish.org
興味ある方は是非参画ください!!!