Jakarta EE 10 アップデート

18.2K Views

June 24, 22

スライド概要

2022/06/24 社内勉強会

シェア

またはPlayer版

埋め込む »CMSなどでJSが使えない場合

関連スライド

各ページのテキスト
1.

Jakarta EE 10 アップデート 2022/06/24 Takayuki Maruyama This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 1

2.

Jakarta EE ? Java EE 仕様 の後継となる、エンタープライズJavaアプリケーションフレームワーク が主導していた から、コミュニティ主導のJakarta EEへ 傘下のプロジェクトになった 参照実装 (Reference Implementation) → 互換実装 (Compatible Implementation) Jakarta EE 8: 権利関係を整理して行った最初のリリース 中身はJava EE 8と同じ Jakarta EE 9: javax -> jakarta 名前空間への移行 Jakarta EE 9.1: Java SE 11をターゲットとしたリリース Jakarta EE 10: Jakarta EE 初めての機能向上リリース Oracle Java EE Eclipse Foundation This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 2

3.

https://speakerdeck.com/ivargrimstad/jakarta-ee-10-feature-by-feature?slide=6 より引用 3

4.

https://speakerdeck.com/ivargrimstad/jakarta-ee-10-feature-by-feature?slide=7 より引用 4

5.

https://speakerdeck.com/ivargrimstad/jakarta-ee-10-feature-by-feature?slide=8 より引用 5

6.

Jakarta EE 10 の主な変更内容 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 6

7.

Java SE バージョン ソース: Java 11 API バイナリ (jar): Java 11 API 実行: Java 11+ が独自に、Java 17での実行もサポート可能 TCK (Technology Compatibility Kit) Compatible Implementation Jakarta EE 10 は、Java SE 11が最低要件 にも対応 使用するAPサーバーがサポートしていれば、Java 17の機能をフルに使ったアプ リ開発が可能 JPMS (Java Platform Module System, a.k.a. Project Jigsaw) This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 7

8.

新しいプロファイル: Core Profile マイクロサービス、ネイティブコンパイル (GraalVM) 等、小さなランタイムでの 実行に適した一連の仕様を含むプロファイル This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 8

9.

Specs without feature update や機能に変更はないが、JPMS (Java Platform Module System)サポートのため に module-info.java が追加された API Enterprise Beans 4.0.1 Bean Validation 3.0.1 Transactions 2.0.1 Dependency Injection 2.0.1 変更なし Debugging Support 2.0 Managed Beans 2.0 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 9

10.

Specs with feature update 個の仕様がメジャー or マイナーバージョンアップしている。 (API非互換があればメジャーバージョンが上がっている、ハズ) 22 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 10

11.

Authorization 3.0 2.1 API の追加・互換性を損なわない変更のみ。 Issue#52: Add methods to PolicyConfiguation to read permissions Issue#53: Add getPolicyConfiguration methods without state requirement Issue#105: Generic return value for getContext This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 11

12.

Activation 2.1 以前は、 と実装を1つにまとめたjarしか提供していなかったが、他の 仕様と同様に、API jarを単独で配布するようなった。 2.0 API Jakarta EE CI: Eclipse Angus - Activation https://github.com/eclipse-ee4j/angus-activation This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 12

13.

Batch 2.1 Contexts and Dependency Injection (CDI) Batch Inject との統合 関連クラスが 可能に プロパティ値をInjectする @BatchProperty で、primitive wrapper typeの値を 注入可能に This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 13

14.

Connectors 2.1 と Bug fix Document clean up Bug fix: java.util.Map のみ。 を実装したクラスでジェネリクスを使用、等 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 14

15.

Mail 2.1 API とimplの分離 CI: Eclipse Angus Mail (https://jakarta.ee/eclipse-ee4j/angus-mail) インタフェースを追加 InputStream, OutputStreamといった入出力Streamを生成する処理を提供する 例: BASE64エンコードされた入力をデコードするInputStream API classes内で使用する入出力Stream生成をimplに任せる形に jakarta.mail.util.StreamProvider This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 15

16.

Messaging 3.1 @JMSConnectionFactoryDefinition , @JMSDestinationDefinition @Repeatable に This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. が 16

17.
[beta]
Authentication 3.0

を使用するAPIが @Deprecated(forRemoval=true) に
Java SE 17での変更に追従
ジェネリクスの導入
認証処理中にCDI/Faces contextsがアクティブかどうか判定する手段を追加
認証方式( ServerAuthModule )の追加を容易にするAPI
SecurityManager

// https://arjan-tijms.omnifaces.org/2022/04/whats-new-in-jakarta-security-3.html
// in ServletContextInitializer
@Override
public void contextInitialized(ServletContextEvent sce) {
AuthConfigFactory.getFactory()
.registerServerAuthModule(
new TestServerAuthModule(),
sce.getServletContext()
);
}

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

より

17

18.
[beta]
Concurrency 3.0

で使うForkJoinThreadを、Concurrency管理下の
ThreadFactory( ManagedThreadFactory )を使って生成できるように
JVM全体で共通のスレッドプールではなく、APサーバーで定義したスレッド
プールを利用できる
例 (Javadocより)
Parallel Stream

ManagedThreadFactory threadFactory = InitialContext.doLookup("java:comp/DefaultManagedThreadFactory");
ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), threadFactory, null, false);
ForkJoinTask<Double> totals= pool.submit(() -> orders
.parallelStream()
.map(order -> {
if (order.total == 0.0) {
// lookups require application component namespace:
try (Connection con =
((DataSource)InitialContext.doLookup("java:comp/env/jdbc/ds1"))
.getConnection()) {
order.total = ...
} catch (NamingException | SQLException x) {
throw new CompletionException(x);
}
}
return order.total;
})
.reduce(0.0, Double::sum));
System.out.println("Sum is: " + totals.join()); pool.shutdown();

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

18

19.

Context Dependency Injection 4.0 CDI Lite for Core Profile フル仕様との差分 @SessionScoped , @ConversationScoped , @Decorator bean-discovery-mode が none または annotated のみ を除く 非推奨APIの削除 APIに @Deprecated は指定されていなかったが、仕様として非推奨だったも のが削除されている( @New 等) CDI 1.1で非推奨とされていた This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 19

20.

Expression Language 5.0 ジェネリクスの追加 式中のラムダ式を関数インタフェースとして認識できるように メソッド foo(Predicate<T>) の呼び出しを ${obj.foo(o -> true)} と書け る 4.0以前は IllegalArgumentException その他(主にJakarta Facesに必要な)改善 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 20

21.

Faces 4.0 主な変更点 をJava APIから作成できるように 拡張子( .xhtml )を省略したURLを利用可能にするオプション jakarta.faces.AUTOMATIC_EXTENSIONLESS_MAPPING 追加 web.xmlの <context-param> で指定する。デフォルトは false @ClientWindowScoped 追加 ブラウザウィンドウ・タブ単位のスコープ Facelet This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 21

22.

Faces 4.0 主な破壊的変更 jsf → faces http://xmlns.jcp.org/jsf/ (URL) → jakarta.faces. (URN) 例: jakarta.faces.core , jakarta.faces.composite JSPビューのサポートを削除 @ManagedBeans (CDIを使わないバッキングビーン) の削除 @Deprecated なAPIの削除 ( ValueBinding , MethodBinding 等) This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 22

23.

Security 3.0 認証をサポート 当初予定していた改良の大半が次バージョンに先送りされている DIGEST認証、クライアント証明書認証、etc... OpenID Connect This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 23

24.

Servlet 6.0 が準拠するRFCが RFC 2019 から RFC 6265 に変更 コメント、バージョンが設定不可に (アクセッサは残っているが @Deprecated(forRemoval=true) であり、呼んでも何も起こらない) 任意の属性を Cookie#setAttribute(String, String) で設定可能に セキュリティの関係で属性が追加された時、APIの修正を待たずに対処で きる 現在のリクエスト・ネットワーク接続を一意に識別するIDを取得できるAPIが追加 Cookie ServletConnection#getConnectionId , #getRequestId ログ出力用途を想定 生成される文字列の形式は実装依存 Servlet 5.0までに非推奨となっていたクラス・メソッドを削除 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 24

25.

Standard Tag Libraries 3.0 Rename URI http://xmlns.jcp.org/jsp/jstl/ → jakarta.tags. 例: jakarta.tags.core , jakarta.tags.fmt This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 25

26.

Persistence 3.1 に AutoCloseable インタフェースを実 装 コンテナにインスタンスを管理させているなら問題ないが、自前で生成して いる場合はResource leakの警告が出るようになるため注意 IDやプロパティの型として java.util.UUID をサポート CEILING , EXP , FLOOR , LN , POWER , ROUND , SIGN 関数をJakarta Persistence QL, Criteria APIの双方でサポート EXTRACT 関数をJakarta Persistence QLでサポート EntityManagerFactory , EntityManager This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 26

27.

Server Pages 3.1 で SingleThreadModel が削除されたことに伴い、ページディレクティ ブの属性 isThreadSafe が非推奨に <jsp:plugin> , <jsp:action> , <jsp:fallback> が非推奨、記述しても無視する ように Javaアプレットと組み合わせて使うタグ(らしい)。現時点でJavaアプレット はどのブラウザでも動作しないため不要になった EL式に未定義の識別子が含まれる場合に例外を発生させるオプションが追加 Servlet 6.0 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 27

28.

WebSocket 2.1 任意のタイミングでHTTPからWebSocketに切り替えるAPIを追加 デフォルト設定の ServerEndpointConfig.Configurator を取得するAPIを追加 WebSocketクライアントのSSL/TLS設定APIを追加 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 28

29.

RESTful Web Services 3.1 Java SE Bootstrap API CDI SE とのインテグレーションは 4.0 で対応予定 Multipartサポート ( multipart/form-data ) ContextResolver<Jsonb> をアプリケーション側で実装していればそちらを優先 するように @Context を非推奨としてCDIを使用するように This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 29

30.

RESTful Web Services 3.1 Java SE Bootstrap API class ApiApplication extends Application {} public class Main { public static void main(String... args) { SeBootstrap.start(new ApiApplication(), SeBootstrap.Configuration.builder().build()); } } This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 30

31.

RESTful Web Services 3.1 Demo / Java SE Bootstrap API Web API 換える を提供するアプリケーション(WAR)を、Java SE環境で起動する形に書き Source: https://github.com/maruTA-bis5/slide-sources/blob/master/202206-jakartaee-10-overview/demo/cdi-rest-se-bootstrap This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 31

32.

JSON Processing 2.1 と実装のプロジェクトを分離 実装: Eclipse Parsson (https://github.com/eclipse-ee4j/parsson) プリミティブ値から JsonValue を得るAPI Json.createValue パース中の状態を取得する JsonParser#currentEvent() プロパティ名(キー)が重複した場合の挙動を指定可能に (先勝ち/後勝ち/禁止 API ( JsonException )) This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 32

33.

JSON Binding 3.0 値を JsonValue.NULL としてデシリアライズする {"property": null} のようにプロパティは存在するが値が null のケース プロパティが存在しないケースは単に null となる @JsonbProperty.nillable() が非推奨に。代わりに @JsonbNillable を使う ポリモーフィックな[de]serialize JSONに設定されたキーと @JsonbPolymorphicType で[de]serialize対象クラス を判定する null https://jakarta.ee/specifications/jsonb/3.0/jakarta-jsonb-spec3.0.html#polymorphic-types This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 33

34.

Annotations 2.1 をクラス宣言・引数だけでなく、あらゆる場所で使えるように @Nullable , @NotNull の追加 javax.annotations.Nullable , javax.annotations.NotNull をAnnotations 仕様の一部として追加 @Priority This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 34

35.

Interceptors 2.1 Updated dependencies for Jakarta EE 10 Add JPMS module-info This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 35

36.

Jakarta EE 10 進捗状況 時点 個別のSpecは全てリリースレビュー完了 Core Profile: WildFly 27.0.0.Alpha1をCIとしてリリースレビュー準備中 ※2022/06/18 https://github.com/jakartaee/specifications/pull/495 予定)のGlassFishでTCKがfailing Web Profile, Platform: CI( Web Profile: https://github.com/jakartaee/specifications/pull/497 Platform spec: https://github.com/jakartaee/specifications/pull/498 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 36

37.

その他仕様の紹介 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 37

38.

Jakarta MVC アクション指向のWebアプリケーションフレームワーク like Spring MVC, Struts, Ruby on Rails はコンポーネント指向 パーフェクトJava EEに掲載されたが、Java EE 8のスコープ外になってしまった 悲しい過去を持つ Faces CI: Eclipse Krazo (https://github.com/eclipse-ee4j/krazo) には含まれないが、単独でリリース済のため依存関係を追加 すれば使うことは可能 Jakarta EE Platform This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 38

39.

Jakarta MVC アクション指向のWebアプリケーションフレームワーク like Spring MVC, Struts, Ruby on Rails はコンポーネント指向 パーフェクトJava EEに掲載されたが、Java EE 8のスコープ外になってしまった 悲しい過去を持つ Faces CI: Eclipse Krazo (https://github.com/eclipse-ee4j/krazo) には含まれないが、単独でリリース済のため依存関係を追加 すれば使うことは可能 Jakarta EE Platform This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 39

40.

Jakarta NoSQL 異なるNoSQLデータベース(Redis, Cassandra, Couchbase, etc...)にアクセスする ための統一されたAPIを定義する CI予定: Eclipse JNoSQL (https://github.com/eclipse/jnosql) This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 40

41.

Jakarta Data Persistence, NoSQL を統一的に扱うためのアノテーション・インタフェースを提 供する まだ議論が始まったばかり This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 41

42.

Jakarta RPC のサービス・クライアントをJavaで容易に実装出来るようにする マイクロサービス間の連携に利用できそう gRPC This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 42

43.

Jakarta Config 環境別の設定を、propertiesファイルや環境変数などアプリケーション外部から注 入可能にする Eclipse MicroProfile Configに類似 (MP Configをベースにしている?) 当初はJakarta EE 10に含まれる予定だったが遅延している @Inject @ConfigSource("property.name") // CDI String property; のQualifier This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 43

44.

まとめ は、Jakarta EEとして初めての機能向上リリース 多くの仕様でfeature updateされている 新しいバージョンのJava SE環境で開発・動作する事も可能 新しい仕様も複数提案されており、今後に注目したい Jakarta EE 10 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 44

45.

参考 https://jakarta.ee Jakarta EE 10 - Feature by Feature https://speakerdeck.com/ivargrimstad/jakarta-ee-10-feature-by-feature This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 45