Copyright © 2012, Oracle and/or its affiliates. All rights reserved.1
Yoshio TeradaJava Evangelisthttp://yoshio3.com, Twitter : @yoshioterada
Java EE Update2012/10
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.2
以下の事項は、弊社の一般的な製品の方向性に関する概要を説明するものです。また、情報提供を唯一の目的とするものであり、いかなる契約にも組み込むことはできません。以下の事項は、マテリアルやコード、機能を提供することをコミットメント(確約)するものではないため、購買決定を行う際の判断材料になさらないで下さい。オラクル製品に関して記載されている機能の開発、リリースおよび時期については、弊社の裁量により決定されます。
Oracle は、米国オラクルコーポレーション及びその子会社、関連会社の米国及びその他の国における登録商標です。文中の社名、商品名等は各社の商標または登録商標である場合があります。
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3
JavaOne 2012San Francisco
09/30-10/4
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4
Make the Future Java(Java の未来を創造 )
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5
May 1998
Enterprise Java Platform
Dec 199910 specs
Robustness
Sep 20110 13 specs
Web Services
Nov 200320 specs
Ease ofDevelopment
May 200623 specs
Lightweight
Dec 200928 specs
JPEProject
J2EE 1.3
CMP,ConnectorArchitecture
Java EE 5
Ease of Development,Annotations,EJB 3.0, JPA, JSF, UpdatedWeb Services
J2EE 1.4Web Services Mgmt, Deployment,AsyncConnector
Java EE 6
Pruning,ExtensibilityEase of Dev,CDI, JAX-RS
Web Profile
Servlet 3.0, EJB 3.1 Lite
J2EE 1.2Servlet, JSP,EJB, JMSRMI/IIOP
Java EE の歴史
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6
Java EE 7 moving
今年の 8 月まで Java EE 7 のテーマ
into CloudHTML5 & シンプル化
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7
Java EE 7 を 2013 年春リリース Java EE 8 でクラウド対応
クラウド機能について
Java EE のロードマップについて
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8
ロードマップに対するフィードバック
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16
Java EE はパッケージ方法、配備、移植性の面に注目すると既に 90% がクラウド対応になっていると言えるでしょう。クラウド環境で必要な残り 10% の満たされてない事になると、経験を積んだ時に明らかになるため、
まだ標準化を行う段階ではありません。ベンダーによる技術革新と総合して標準化を行います。我々は現時点でまだこの分野において技術革新を行っていません。David Blevins, Apache TomEE, Geronimo
Apache
ロードマップに対するフィードバック
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16
正しい判断です。クラウドの標準化は市場に対して、非常に大きな変化を与え悪い動きになります。( 支持 48%)
twiigs
ロードマップに対するフィードバック
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16
コミュニティの要望に応えるため Java EE 7 を再編成する事は、
エキスパートグループの勇敢で誠実な英断です。2015 年の春に予定されている Java EE 8 でクラウドと PaaS 機能の実装を再度試みてください。
Markus Eisele, Java EE Consultanthttp://blog.eisele.net
Java EEConsultant
ロードマップに対するフィードバック
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16
Java EE の実装者として申し上げるならば、
我々 (RedHat) はこの決断に対し多いに支持しています。私たちはかねてから Java EE コミュニティはまだクラウドの標準化の準備ができていない事を提唱してきました。そしてこれは私たちが提供するクラウドサービスである OpenShift の実績によって感じています。 OpenShift は Java EE 6 とうまく適合しています。
Pete Muir, RedHat
redhat
ロードマップに対するフィードバック
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13
末長く使われる技術の標準化には準備期間が必要
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14
Java EE 7– HTML 5 とシンプル化にフォーカス
Java EE 8– クラウド対応とモジュール化対応への
継続的な投資
Java EE の今後Java EE
Hasan Rizvi
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15
May 1998
Enterprise Java Platform
Dec 199910 specs
Robustness
Sep 20110 13 specs
Web Services
Nov 200320 specs
Ease ofDevelopment
May 200623 specs
Lightweight
Dec 200928 specs
Simplicity& HTML5
CY 201333+ specs
JPEProject
J2EE 1.3
CMP,ConnectorArchitecture
Java EE 5
Ease of Development,Annotations,EJB 3.0, JPA, JSF, UpdatedWeb Services
J2EE 1.4Web Services Mgmt, Deployment,AsyncConnector
Java EE 6
Pruning,ExtensibilityEase of Dev,CDI, JAX-RS
Web Profile
Servlet 3.0, EJB 3.1 Lite
Java EE 7
JMS 2.0, Batch, JCache, TX Interceptors
HTML5: WebSocket, JSONWeb Profile
JAX-RS 2.0
J2EE 1.2Servlet, JSP,EJB, JMSRMI/IIOP
Java EE の歴史
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16
トピック
Java EE 7 の Web Profile に
JAX-RS 2.0 が導入
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17
Java EE 7 へ含まれる予定の JSR 一覧
Connector1.6
JPA 2.1 JTA 1.2 JMS 2.0
Managed Bean 1.0 EJB 3.2
Common Annotations
1.1
Interceptors 1.1
CDI 1.1
PortableExtensio
ns Servlet 3.1
JSP 2.2JSF 2.2
JAX-RS 2.0
EL 3.0
Bean
Valid
atio
n1
.1
Java CachingAPI (JSR-
107)Batch
Application(JSR-352)
Java API forJSON
(JSR-353)
Java API forWebSocket(JSR-356)
新規追加 大幅な更新 通常の更新
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18
Java EE 7 の注目技術
WebSocket ( 新 )JSON ( 新 )Batch ( 新 )Cache ( 新 )
JAX-RS 2.0JSF 2.2JMS 2.0EL 3.0
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19
今日ご紹介する内容
JSON ( 新 )Batch ( 新 )
JMS 2.0EL 3.0
シンプル化に関するテーマ
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20
WebSocket の詳細は明日の JJUG CCC で !!
でも少しだけ、デモ
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21
Singleton
WebSocket Twitter TimeLine アプリ
Remote Endpoint
RE
RE
RE
Session
Session
Session
WebSocketEndpoint
Twitter4J
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22
今日ご紹介する内容
JSON ( 新 )
シンプル化に関するテーマ
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23
JSR 353 : Java API for Processing JSON
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.24
RFC 4627 The application/json Media Type for JavaScript Object Notation
軽量、テキストベース、プログラミング言語に非依存移植性が高く、構造化されたデータ交換フォーマット
{“name”:”Bob”,”age”:20,”phone”:[“276 1234”,”124 4567”]}
JSON とは
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.25
JSR 353 : Java API for Processing JSON
Streaming API–低レベル– JSON の解析や生成の効率的な方法
Object Model API–高レベル– Streaming よりもかんたんに実装可能– Streaming API 上に実装
Streaming & Object Model
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.26
JSON API のアーキテクチャ
JSON プロバイダ
SPI
Streaming API
Object ModelAPI
APP1 APP2 APP n・・・
便利な機能
低レベル API
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.27
{
"firstName": "John", "lastName": "Smith",
"age": 25,
"phoneNumber": [
{ "type": "home", "number": "212 555-1234" },
{ "type": "fax", "number": "646 555-4567" }
]
}
JSON データのサンプル
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.28
Object Model API (扱い易い : DOM ライクな実装 )
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.29
Object Model API (扱い易い API)
JsonObject JsonArray
JsonBuilder
JsonReader/JsonWriter
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.30
JSonObject
Key / Value のペアで操作
Map <String, JsonValue> で操作可能
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.31
JsonObject jobj = ...
Map<String, JsonValue> map = jobj.getValues();
if (map.containsKey(“firstName”)) {
JsonString jstring = jobj.getValue(“firstName”,
JsonString.class);
String lastName = jstring.getValue();
}
JSonObject から特定 Key の Value を取得Key と Value の型が分かっている場合に有効
{ "firstName": "Yoshio", ……}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.32
if (map.containsKey("phoneNumber")) {
JsonArray jarray = jobj.getValue("phoneNumber",
JsonArray.class);
for (int i = 0; i < jarray.size(); i++) {
JsonValue jvalue = jarray.getValue(i);
if (jvalue.getValueType() == JsonValueType.OBJECT) {
JsonObject jobj2 = jarray.getValue(i, JsonObject.class);
"phoneNumber": [ { "type": "home”, ..}, { "type": "home”, ..} …… ]
JSonObject から特定 Array を取得
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.33
JSonBuilder から JsonObject の生成
JsonObject jsono = new JsonBuilder().
beginObject().
add("KEY1", "VALUE1").
beginArray("KEY2").
beginObject().
add("KEY3", "VALUE3").
endObject().
endArray().
endObject().
build();
{"KEY1":"VALUE1","KEY2":[{"KEY3","VALUE3”}]}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.34
try (JsonReader reader = new JsonReader(
new FileReader("/tmp/json.dat"));) {
JsonObject jobj = reader.readObject();
Person person = json2Person(jobj);
printPerson(person);
} catch (IOException ioe) {
ioe.printStackTrace();
}
I/O から JSonObject の読み込み
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.35
try (FileWriter f = new FileWriter(
"/tmp/jsonout.dat");
JsonWriter writer = new JsonWriter(f)) {
writer.writeObject(jsono);
}catch(IOException ioe){
ioe.printStackTrace();
}
I/O へ JSonObject の書き込み
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.36
今日ご紹介する内容
Batch ( 新 )
シンプル化に関するテーマ
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.37
JSR 352: Batch Applications for the Java Platform
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.38
バッチ処理用のフレームワーク Java SE / EE 環境で利用可能 バッチ処理に必要な、入力、処理、出力の実装を標準化 シーケンシャル、並列処理に対応
機能の一覧
jbatch
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.39
jbatch のアーキテクチャ
Job Repository
JobOperator
Item Reader
Item Processor
Item Writer
Job Step1 *
1
1
1 11
1
全体アーキテクチャ
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.40
JobOperator
Job Repository
JobOperator
Item Reader
Item Processor
Item Writer
Job Step1 *
1
1
1 11
1
ジョブ処理の全体を管理(起動・停止・再起動・レポジトリ情報取得など)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.41
Job
Job Repository
JobOperator
Item Reader
Item Processor
Item Writer
Job Step1 *
1
1
1 11
1
バッチの処理内容を隠蔽JSL( ジョブ仕様記述言語 ) で記載した内容と関連付け
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.42
Step
Job Repository
JobOperator
Item Reader
Item Processor
Item Writer
Job Step1 *
1
1
1 11
1
バッチの処理内容を隠蔽JSL( ジョブ仕様記述言語 ) で記載した内容と関連付け方式: chunk, batchlet
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.43
<job id="job1" xmlns="http://batch.jsr351/js1">
<split id="split1">
<flow id="flow1" next="flow2">
<step id="step1" next="step2">
<batchlet ref="MyBatchlet"/>
</step>
<step id="step2" next="stepDONE">
<batchlet ref="MyBatchlet2"/>
</step>
</flow>… </job>
Job Specification Language(JSL : ジョブ仕様記述言語 )
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.44
<flow id="flow2">
<step id="step3">
<chunk reader="MyReader" processor="MyProcessor"
write="MyWriter” commit-interval=“2”>
<properties>
<property name="audit" value="true"/>
</properties>
</chunk>
</step>
</flow></split></job>
Job Specification Language(JSL : ジョブ仕様記述言語 )
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.45
chunk 方式
Job Repository
JobOperator
Item Reader
Item Processor
Item Writer
Job Step1 *
1
1
1 11
1
バッチをアイテム(入力、処理、出力)毎に分けて実装ItemReader : データの入力ItemProcessor : データの処理ItemWriter : データの出力
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.46
chunk 方式のシーケンス図の例
commit-interval =“2” の場合
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.47
package javax.batch.api;
import java.io.Externalizable;
public interface ItemReader <T> {
public void open(Externalizable checkpoint) throws Exception;
public void close() throws Exception;
public T readItem() throws Exception;
public Externalizable checkpointInfo() throws Exception;
}
ItemReader インタフェース
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.48
import javax.batch.api.ItemReader;
@Named
public class MyReader implements ItemReader {
...
}
ItemReader の実装例 (インタフェース実装有 )
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.49
ItemReader の実装例 (インタフェース実装無 )
import javax.batch.annotation.*;
@Named
public class MyReader {
@Open void open(MyCheckpointData checkpoint)
throws Exception {...}
@Close void close() throws Exception {...}
@ReadItem MyBatchInputRecord read() throws Exception {...}
@CheckpointInfo Externalizable MyCheckpointData getChkpt()
throws Exception {...}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.50
package javax.batch.api;
public interface ItemProcessor <T, R> {
public R processItem(T item) throws Exception;
}
ItemProcessor インタフェース
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.51
ItemReader と同様
●インタフェースの実装有 ●インタフェースの実装無 (メソッドレベル・アノテーション)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.52
package javax.batch.api;
import java.io.Externalizable;
import java.util.List;
public interface ItemWriter <T> {
public void open(Externalizable checkpoint) throws Exception;
public void close() throws Exception;
public void writeItems(List<T> items) throws Exception;
public Externalizable checkpointInfo() throws Exception;
}
ItemWriter インタフェース
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.53
ItemReader と同様
●インタフェースの実装 ●インタフェースの未実装 (メソッドレベル・アノテーション)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.54
Batchlet
Batchlet 方式
Job Repository
JobOperator
Job Step1 *
1 1
バッチを1つのタスクとして実装一旦処理を実行すると最後まで処理を続行
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.55
package javax.batch.api;
public interface Batchlet {
public String process() throws Exception;
public void stop() throws Exception;
}
Batchlet インタフェース
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.56
package javax.batch.api;
public interface Batchlet {
public String process() throws Exception;
public void stop() throws Exception;
}
Batchlet インタフェース
@Named
public class MyBatchLet{
@Process String process() throws Exception {...}
@Stop void stopMe() throws Exception {...}
}
インタフェース実装有
インタフェース実装無
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.57
Job Repository
Job Repository
JobOperator
Item Reader
Item Processor
Item Writer
Job Step1 *
1
1
1 11
1
Job に関する現在・過去の情報を保持
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.58
今日ご紹介する内容
JMS 2.0
シンプル化に関するテーマ
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.59
JSR 343: Java™ Message Service 2.0
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.60
かんたんに実装できるようになった API– JMSContext, JMSProducer, JMSConsumer の追加
例外の実装方法の変更 既存 API に対する改善 CDI を利用した冗長コードの排除
クラウド機能は Java EE 8 へ
新機能の一覧
JMS 2.0
注意:去年の JavaOne 2011, JavaOne Tokyo 2012 の内容から若干変更あり
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.61
@Resource( mappedName="jms/MyConnectionFactory” )
private static ConnectionFactory connectionFactory;
@Resource( mappedName="jms/mySampleQueue” )
private static Queue queue;
public void sendMessage(String text){
Connection con = connectionFactory.createConnection();
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = session.createProducer(queue);
TextMessage message = session.createTextMessage(text);
message.setText(message);
prod.send(message);
con.close();}
既存のメッセージ送信コード
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.62
@Resource( mappedName="jms/MyConnectionFactory” )
private static ConnectionFactory connectionFactory;
@Resource( mappedName="jms/mySampleQueue” )
private static Queue queue;
public void sendMessage(String text){
Connection con = connectionFactory.createConnection();
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = session.createProducer(queue);
TextMessage message = session.createTextMessage(text);
message.setText(message);
prod.send(message);
con.close();}
既存のコードの課題
単なるメッセージ送信に中間オブジェクトが必要
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.63
@Resource( mappedName="jms/MyConnectionFactory” )
private static ConnectionFactory connectionFactory;
@Resource( mappedName="jms/mySampleQueue” )
private static Queue queue;
public void sendMessage(String text){
Connection con = connectionFactory.createConnection();
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = session.createProducer(queue);
TextMessage message = session.createTextMessage(text);
message.setText(message);
prod.send(message);
con.close();}
既存のコードの課題
定型的なコード
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.64
javax.jms.JMSContext インタフェース
JMSContext
Connection Session
• 別々のクラスを1つに統合– Connection– Session
• JMSProducer の提供• JMSConsumer の提供
新規に JMSContext インタフェースを提供
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.65
JMScontext = conFactory.createContext();
TextMessage textMsg = context.createTextMessage(message);
context.createProducer(). send(queue, textMsg);
JMSContext context = conFactory.
createContext(AUTO_ACKNOWLEDGE);
MessageListener mListener = new MyMsgListener();
context.createConsumer(dest).setMessageListener(mListener);
メッセージ送信例
メッセージ受信
JMSContext を利用した実装例
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.66
MessageProducer producer = session.createProducer();
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
producer.setPriority(1);
producer.setTimeToLive(1000);
producer.send(destination,message);
context.createProducer().setDeliveryMode(DeliveryMode.NON_
PERSISTENT). setPriority(1).setTimeToLive(1000).send(
destination,message);
JMS 1.1
JMS 2.0
JMSProducer の利用例 ( メソッド・チェーンによる設定 )
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.67
public void sendMessage(String text){
Connection con = null;
try{
con = connectionFactory.createConnection(); Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer prod = session.createProducer(queue); TextMessage message = session.createTextMessage(text); message.setText(message); prod.send(message); }finally{
con.close(); }
使用後コネクションのクローズが必要
送信コードにおける既存のコードの課題
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.68
AutoCloseable による実装 (close() の実装が不要 )
public void sendMessage(String text){
try(JMSContext context = conFactory.createContext();){
TextMessage message = session.createTextMessage(text);
context.createProducer().send(outQueue,message);
message.sendText(outQueue,message);
}
}
Java SE 7 try-with-resource に対応
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.69
public void sendMessage(String text){
try{
…… // 送信処理 prod.send(message); }catch(JMSException jmse){ // 例外処理 }finally{ try{ if(con != null) con.close(); }catch (JMSException jmse2){ // 例外処理 }}}
例外処理の実装が必要
送信コードにおける既存のコードの課題
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.70
チェック例外から非チェック例外へ
過去の例外クラス 今後の例外クラスJMSException JMSRuntimeException
TransactionRolledBackException TransactionRolledBackRuntimeException
IllegalStateException IllegalStateRuntimeException
InvalidDestinationException IllegalDestinationRuntimeException
InvalidSelectorException InvalidSelectorRuntimeException
MessageFormatException MessageFormatRuntimeException
例外の実装方法が変更
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.71
例外が RuntimeException に変更 public void sendMessage(String text){
try{
……// 送信処理
prod.send(message);
} catch (JMSRuntimeException ex) {
Logger.getLogger(getClass().getName()).
log(Level.SEVERE, null, ex);
}
}
例外の実装方法が変更
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.72
JNDI ルックアップでコンテナの接続ファクトリを使用– コネクション・プール等を利用可能
JNDI 名を未指定時、システムのデフォルト使用
JMSContext に対する注入 @Inject
@JMSConnectionFactory(“jms/MyConFactory”)
private JMSContext context;
アノテーションを利用した依存性注入
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.73
JMSContext に対する注入 @Inject
@JMSConnectionFactory(“jms/MyConFactory”)
@JMSPasswordCredential(userName=“admin”,password=“admin”)
@JMSSessionMode(JMSContext.AUTO_ACKNOWLEDGE)
private JMSContext context;
パスワードやセッションモードの設定
アノテーションを利用した依存性注入
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.74
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.75
@Resource( mappedName="jms/MyConnectionFactory” )
private static ConnectionFactory connectionFactory;
@Resource( mappedName="jms/mySampleQueue” )
private static Queue queue;
public void sendMessage(String text){
Connection con = connectionFactory.createConnection();
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = session.createProducer(queue);
TextMessage message = session.createTextMessage(text);
message.setText(message);
prod.send(message);
con.close();
Java EE 6 までのメッセージ送信コード
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.76
@Inject
@JMSConnectionFactory(“jms/MyConFactory”)
private JMSContext context;
@Resource(mappedName = “jms/queue”)
private Queue queue;
public void sendNewMessage(String msg){
context.createProducer().send(queue, msg);
}
Java EE 7 からのメッセージ送信コード
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.77
今日ご紹介する内容
EL 3.0
シンプル化に関するテーマ
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.78
JSR 341:
Expression Language 3.0
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.79
Lambda 式対応– Array, List, Map の構成
コレクションに対するクエリ演算子 (LINQ式 ) Java SE 環境で利用するための API を提供デフォルトの EL 実行環境マネージャの追加 クラス (static) 変数、クラス (static) メソッド、 enum 定数対応 クラス、パッケージのインポート
新機能の一覧
EL 3.0
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.80
名前空間を持つ Name– reference, import
関数定義 コンストラクタ 新しい演算子
– 文字列連結演算子、変数割当用演算子型変換表記の評価用のリスナー
新機能の一覧
EL 3.0
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.81
Java EE 7 : 2013 年 春頃提供開始予定
テーマ:HTML5 と開発生産性の向上
Java EE 7 SDK の提供開始
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.82
http://www.oracle.com/javaone09/22-09/26
See You Next Year
JavaOne 2013
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.83
New Announcement2013 年 春頃Java イベント開催予定
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.84
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.85
Top Related