76
Seasar Conference Seasar Conference 2008 A t 2008 A t 2008 Autumn 2008 Autumn Ymir Ymirを使ってかんたん を使ってかんたんWeb Webアプリ開発 アプリ開発 Ymir Ymirを使ってかんたん を使ってかんたんWeb Webアプリ開発 アプリ開発 Ymirプロジェクト プロジェクトリーダ (株)ア クシステム (株)アクシステム 横田 健彦(a.k.a. Skirnir1 Seasar Conference Seasar Conference 2008 Autumn 2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

Seasar ConferenceSeasar Conference2008 A t2008 A t2008 Autumn2008 Autumn

YmirYmirを使ってかんたんを使ってかんたんWebWebアプリ開発アプリ開発YmirYmirを使ってかんたんを使ってかんたんWebWebアプリ開発アプリ開発

Ymirプロジェクト プロジェクトリーダ

(株)ア クシステム(株)アークシステム

横田 健彦(a.k.a. Skirnir)

1Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 2: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

自己紹介自己紹介

• 横田 健彦(よこた たけひこ)• 横田 健彦(よこた たけひこ)

– ネット上ではSkirnir(すきーるにる)と名乗っています

– (株)アークシステム所属

• Javaや.NETのWeb系技術者募集中!

– プラグイン機構がウリのCMS「Kvasir/Sora」を開発

• 2006年度上期IPA未踏ソフトウェア創造事業に採択2006年度上期IPA未踏ソフトウ ア創造事業に採択

– 北欧神話好き

• Skirnir Kvasir Ymirも北欧神話のキャラクタの名前です• Skirnir、Kvasir、Ymirも北欧神話のキャラクタの名前です

– 阪神タイガース好き

今シ ズンは比較的精神状態良好 ☺だがここ 近

2Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

• 今シーズンは比較的精神状態良好 ☺だがここ 近…

Page 3: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

今日お話しすること今日お話しすること

• Ymirの目指すもの• Ymirの目指すもの

• Ymirとは

• 新機能

• ロ ドマップ• ロードマップ

3Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 4: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

Ymirとはとは

4Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 5: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

YmirYmirとはとは

• フィルタ指向のシンプルなWebアプリケーション• フィルタ指向のシンプルなWebアプリケーションフレームワーク

– 読み方は「ゆみる」

• 北欧神話に出てくる巨人。血肉が世界の元となった。

– 公式サイト:http://ymir.sandbox.seasar.org/• このサイトはKvasir/Soraで作られていますサイ 作 れ ます

– 元々はCMS(Kvasir/Sora)への組み込み用に作ったものをWebアプリ開発用に拡張たものをWebアプリ開発用に拡張

– J2SE5以降+ServletAPI2.4で動作

S 2 4ベ ス5

Seasar ConferenceSeasar Conference2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

– Seasar2.4ベース

Page 6: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

特徴特徴

6Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 7: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

特徴特徴

• MVCモデルのCの部分を担当• MVCモデルのCの部分を担当

– お勧め構成はYmir+FreyjaのZPT実装+DBFluteプ• Freyja…XMLテンプレートエンジン構築F/W。ZPT実装を

持っている。htt // ki i t/ d t/f j /– http://www.skirnir.net/product/freyja/

• フィルタ指向

• URLとアクションの対応付けを柔軟に定義可

• 強力な自動生成機構(ymir extension)• 強力な自動生成機構(ymir-extension)

– Seasar2.4のHOT deploy対応

7Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 8: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

特徴特徴

フィルタ指向

8Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 9: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

フィルタ指向フィルタ指向

• 画面レンダリングの前に処理を挟み込む• 画面レンダリングの前に処理を挟み込む

– サーブレットフィルタとして実装

– Transitive Path Strategyに基づくWebアプリケーション開発が可能

9Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 10: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

特徴特徴

フィルタ指向

Transitive Path Strategy

10Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 11: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

Transitive Path StrategyTransitive Path Strategy

• URLとリソースの物理配置を対応付ける戦略• URLとリソースの物理配置を対応付ける戦略

• Webサーバを使って静的リソースを公開する場合の基本形

11Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 12: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

Transitive Path StrategyTransitive Path Strategy((22))

http://www.hoe.com/app/product/list.html

http://www hoe com/ www hoe comhttp://www.hoe.com/

app

product

www.hoe.com

var

wwwproduct

list.html app

d t

www

同じ構造のまま対応

product

list.html

URLの階層構造 ファイルシステムの階層構造

12Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 13: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

Transitive Path StrategyTransitive Path Strategy((33))

• CGI登場• CGI登場

– コンテンツを動的に生成

→ URLに対応する物理リソースが存在しないケースが増加(ex. path-info)

13Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 14: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

Transitive Path StrategyTransitive Path Strategy((44))

http://www.hoe.com/app/product.py/list

http://www hoe com/ www hoe com

path-info

http://www.hoe.com/

app

product py

www.hoe.com

var

wwwリソ スがない!product.py

listapp

wwwリソースがない!

dproduct.py

list

URLの階層構造 ファイルシステムの階層構造

14Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 15: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

Transitive Path StrategyTransitive Path Strategy((55))

• Javaでよく見る光景• Javaでよく見る光景

15Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 16: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

Transitive Path StrategyTransitive Path Strategy((66))

http://www.hoe.com/app/product/list.dohtt // h / / / d t

http://www.hoe.com/

app

www.hoe.com

var

http://www.hoe.com/app/css/product.css

app

product

app

var

webapps

list.do構造が一致しない! WEB-INF

jspcss

product.csscss

productList.jsp

URLの階層構造 ファイルシステムの階層構造

product.css

16Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

URLの階層構造 ファイルシステムの階層構造

Page 17: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

Transitive Path StrategyTransitive Path Strategy((77))

• URLとテンプレート(JSP)のパスが一致しない• URLとテンプレート(JSP)のパスが一致しない

→ ぱっと見で分かりにくい!

→ クライアントコードもすっきりしない

public ActionForward execute( ) {public ActionForward execute(…) {…return mapping.findForward(“success”); // ←”success”って何?

}

public String execute(…) {…return “/WEB-INF/jsp/productList.jsp”; // ←テンプレートにスルーさせたいだけなのに…

}

17Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 18: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

Transitive Path StrategyTransitive Path Strategy((88))

• JavaでTransitive Path Strategyを使うために• JavaでTransitive Path Strategyを使うために

– テンプレートエンジンサーブレットをURLとマッピング

– ロジック呼び出し/レンダリングの前処理はサーブレットフィルタで

– 処理後はフィルタチェインの次フィルタに処理を委譲

18Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 19: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

Transitive Path StrategyTransitive Path Strategy((99))

http://www.hoe.com/app/product/list.html

http://www hoe com/ www hoe comロジック呼び出し

/レンダリングの前処理http://www.hoe.com/

app

product

www.hoe.com

var

webapps ListPage java

/レンダリングの前処理

チェインの先に処理を委譲product

list.html app

d t

webapps ListPage.java 処理を委譲

product

同じ構造 ☺ list.html

テンプレートからHTMLをレンダリング

URLの階層構造 ファイルシステムの階層構造

19Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 20: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

Transitive Path StrategyTransitive Path Strategy((1010))

• クライアントコードもすっきり• クライアントコードもすっきり

public void _get() {…

}

20Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 21: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

特徴特徴

URLとアクションの対応付け

21Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 22: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

URLURLとアクションの対応付けとアクションの対応付け

• 呼び出すロジックはどう決定するか?• 呼び出すロジックはどう決定するか?

– URLとHTTPメソッドから決定

– URLパターンとPage名の構築式とアクションメソッド名の構築式の組(パスマッピング)を登録しておく

– リクエストURLにマッチするパスマッピングについて、Page名の構築式とアクションメソッド名の構築式かg 名 構築 名 構築ら処理対象のPageクラスと呼び出すべきメソッドを決定決定

22Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 23: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

URLURLとアクションの対応付け(とアクションの対応付け(22))

URLパターン:

^/([a-zA-Z_][a-zA-Z_0-9]*)/([a-zA-Z_][a-zA-Z_0-9]*)¥.html$

${1} ${2}P

Page名の構築式:

${1}_${2}Page

${method}

アクションメソッド名の構築式:

_${ et od}

リクエストHTTPメソッド/URL:コンテキストパス以降とマッチング

http://www.hoe.com/app/product/list.html

P 名とアクシ ンメソ ド名

マッチ:${1}=“product”, ${2}=“list”

GET

Page名とアクションメソッド名:

“product_listPage”, “_get” →

Page名→FQCN変換はS 2による

com.hoe.web.product.ListPage#_get()

23Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Seasar2による

Page 24: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

特徴特徴

動作のまとめ

24Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 25: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

動作のまとめ動作のまとめ

/product/list.htmlURL:^/(…)/(…)¥.html$Page名:${1}_${2}Page

①URLがマッチするかチェック

Webブラウザ アクション名:_${method}

パスマッピング②マッチした!② ッコンポーネント名:product_listPageメソッド名:_get()

Seasar2

product_listPage→com.hoe.web

product ListPage

③product_listPageコンポーネントを取り出し、 .product.ListPage

④ListPage#_get()を呼び出すを呼び出す

テンプレートエンジン

⑤サーブレット(テンプレートエンジン)

レスポンス

25Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

ンジン(ex. Freyja)

テンプレートエンジン)がレスポンスを返す

Page 26: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

特徴特徴

自動生成機能

26Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 27: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

自動生成機能自動生成機能

• リクエスト駆動• リクエスト駆動

– アプリケーションを実際に動作させる中でJavaコードを生成を生成

– 生成に関してWebブラウザ上で指示

• 自動生成できない部分はEclipse上で開発

HOT deploy機能によって自動生成フェーズと手動– HOT deploy機能によって自動生成フェーズと手動開発フェーズをシームレスに結合

27Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 28: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

開発の流れ開発の流れ

28Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 29: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

開発の流れ開発の流れ

• アプリケーションスケルトンをダウンロード• アプリケーションスケルトンをダウンロード

– http://maven.seasar.org/maven2/org/seasar/ymir/ i k l t /0 9 6/ i k l t 0 9 6 i/ymir-skeleton/0.9.6/ymir-skeleton-0.9.6.zip

• Eclipseへインポートp• Tomcatに配備

T tを起動• Tomcatを起動

• ブラウザでアクセスブラウザでアクセ

– 初期設定画面が表示されるので初期設定を行なう

T tを再起動( 初だけ)29

Seasar ConferenceSeasar Conference2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

• Tomcatを再起動( 初だけ)

Page 30: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

初期設定画面初期設定画面

30Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 31: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

開発の流れ(開発の流れ(22))

• http://localhost:8080/example/ にアクセス• http://localhost:8080/example/ にアクセス

– URLに対応するPageクラスがないのでPageクラス生成画面が表示される生成画面が表示される

– 「/index.html」にリダイレクトするように設定して「設定」ボタンを押す

31Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 32: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

PagePageクラス生成画面クラス生成画面

32Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 33: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

PagePageクラス生成画面(クラス生成画面(22))

33Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 34: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

開発の流れ(開発の流れ(33))

• http://localhost:8080/example/index html にリ• http://localhost:8080/example/index.html にリダイレクトされる

プ– URLに対応するHTMLテンプレートがないのでHTMLテンプレート生成画面が表示される

34Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 35: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

HTMLHTMLテンプレート生成画面(テンプレート生成画面(11))

35Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 36: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

HTMLHTMLテンプレート生成画面(テンプレート生成画面(22))

36Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 37: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

開発の流れ(開発の流れ(44))

• HTMLテンプレートが生成されたことが検出され• HTMLテンプレートが生成されたことが検出される

プ– HTMLテンプレートからPageクラスを生成するための画面が表示される

37Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 38: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

PagePageクラス生成画面クラス生成画面

38Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 39: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

PagePageクラス生成画面(クラス生成画面(22))

39Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 40: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

出力出力

40Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 41: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

開発の流れ(開発の流れ(55))

• Eclipse上でPageクラスを変更• Eclipse上でPageクラスを変更

• ブラウザで再度アクセス

41Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 42: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

PagePageクラスの変更クラスの変更

42Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 43: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

PagePageクラスの変更(クラスの変更(22))

43Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 44: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

出力出力

44Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 45: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

開発の流れ(開発の流れ(66))

• WARファイルの生成• WARファイルの生成

– コマンドラインからmvn packageするだけ

45Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 46: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

新機能新機能

46Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 47: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

新機能新機能

• 新バージョン(0 9 6)で実現された主な機能• 新バージョン(0.9.6)で実現された主な機能

– クラスタリング対応

– 複数ウィンドウ対応

– アノテーションの別名定義テ シ 別名定義

– プラグイン機能

自動生成機能の強化– 自動生成機能の強化

• Converterの自動生成機能

自動生成機能のG i 対応• 自動生成機能のGenerics対応

• その他自動生成機能周りの細かな改善

47Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 48: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

新機能新機能

クラスタリング対応

48Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 49: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

クラスタリング対応クラスタリング対応

• セッションレプリケーションが行なわれるクラスタ• セッションレプリケーションが行なわれるクラスタリング環境でも動作

• セッションにバインドしたオブジェクトを外部で変更しても自動的に他ノードに通知更しても自動的に他 ドに通知

– MapをHttpSession#getAttribute()して書き換えた後に通知のためにHttpSession#setAttribute(Map)後に通知のためにHttpSession#setAttribute(Map)する処理をフレームワークが自動実行

49Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 50: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

新機能新機能

複数ウィンドウ対応

50Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 51: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

複数ウィンドウ対応複数ウィンドウ対応

• フレーム使うタイプのアプリケーションや別ウィ• フレーム使うタイプのアプリケーションや別ウィンドウを開くタイプのアプリケーションに対応

– リクエストパラメータとしてウィンドウのIDを渡すことでウィンドウを区別

• それぞれのウィンドウを開く際にウィンドウのIDをつけるようにする必要あり

51Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 52: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

新機能新機能

アノテーションの別名定義

52Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 53: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

アノテーションの別名定義アノテーションの別名定義

• アノテーションに別名をつけたり束ねたりするこ• アノテーションに別名をつけたり束ねたりすることが可能

– エイリアスアノテーション

– コレクションアノテーション

53Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 54: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

エイリアスアノテーションエイリアスアノテーション

• 単一のアノテーションに別名をつける• 単一のアノテーションに別名をつける

@In(scopeClass=RequestParameterScope.class)

@Param

54Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 55: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

エイリアスアノテーション(エイリアスアノテーション(22))

@Retention(RetentionPolicy.RUNTIME)@T t(El tT METHOD)@Target(ElementType.METHOD)@Aliaspublic @interface Param {

I li () d f lt @I ( Cl R tP t S l )

エイリアスアノテーションであることを宣言する

In z_alias() default @In(scopeClass = RequestParameterScope.class);

String name() default "";}

エイリアスの内容を書く

}可変にしたいプロパティを書く

55Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 56: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

エイリアスアノテーション(エイリアスアノテーション(33))

• 可変プロパティも定義可能• 可変プロパティも定義可能

@Param(name=“paramName”)

展開

@In(scopeClass=RequestParameterScope.class, name=“paramName”)

56Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 57: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

コレクションアノテーションコレクションアノテーション

• 複数のアノテーションを束ねる• 複数のアノテーションを束ねる

@ In(scopeClass=SessionScope.class)@ In(scopeClass=RequestScope.class)

@SessionOrRequest

57Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 58: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

コレクションアノテーション(コレクションアノテーション(22))

@Retention(RetentionPolicy.RUNTIME)@T t(El tT METHOD)@Target(ElementType.METHOD)@Collectionpublic @interface SessionOrRequest {

In[] value() default {@In(SessionScope class) @In(RequestScope class);

コレクションアノテーションであることを宣言する

In[] value() default {@In(SessionScope.class), @In(RequestScope.class);}

内容を書く

58Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 59: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

新機能新機能

自動生成機能の強化

59Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 60: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

自動生成機能の強化自動生成機能の強化

• Converterの自動生成機能• Converterの自動生成機能

– S2Dxoの代わりに利用可能

• リフレクションベースのS2Dxoだとデグレが心配、後でソースコードを見ても分かりにくい…という場合に利用

• 自動生成機能のGenerics対応

– プロパティ型などに型パラメータつき型を指定可能プ ティ型などに型 ラ タ き型を指定可能

– List → List<String>その他自動生成機能周りの細かな改善• その他自動生成機能周りの細かな改善

60Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 61: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

ロードマップド ッ

61Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 62: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

ロードマップロードマップ

• http://ymir.sandbox.seasar.org/roadmapp y g p• 0.9.x系

– 0.9.6リリース(2008年9月)0 9 6で 後 以降はメンテナンスリリース– 0.9.6で 後。以降はメンテナンスリリース

• 1.0.x系– 廃止予定の機能を廃止など全般的な整理を行なう– 初のバージョンのリリースは2008年10月頃を予定

• 1.1.x系(構想レベル)– 純粋なWebアプリフレームワーク化純粋なWebアプリフレ ムワ ク化

• 組み込み用途のための機能を取り除く

– DIコンテナを差し替え可能に– HOT deploy機能の廃止– HOT deploy機能の廃止

• ハマりポイントなので…• リロードでも十分なのでは?

– 初のバージョンのリリースは2009年夏頃の予定

62Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

初のバ ジョンのリリ スは2009年夏頃の予定

Page 63: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

ご清聴清聴ありがとうございましたあり う

63Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 64: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

付録付録

64Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 65: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

ZPT

65Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 66: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

ZPTZPT

• Zope Page Template• Zope Page Template• Python(Zope)の世界で生まれたテンプレート

言語

• 独自属性(TAL METAL)でHTMLの書き換え独自属性(TAL、METAL)でHTMLの書き換え指示を記述

66Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 67: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

ZPTZPTの例の例

<html><html><body><h1 tal:content=“self/title”>題名</h1><h1 tal:content= self/title >題名</h1><ul tal:condition=“self/messages”><li tal:repeat=“message self/messages”<li tal:repeat= message self/messages

tal:content=“message”>繰り返しメッセージ</li></ul></ul>

</body></html></html>

67Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 68: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

ZPTZPTの属性の属性

• tal:attributes…属性を置き換えtal:attributes…属性を置き換え

– <img tal:attributes=“alt string:aaa” />→ <img alt=“aaa” />

• tal:content…タグの中身を置き換え

– <span tal:content=“string:aaa”>題名</span><span>aaa</span>→ <span>aaa</span>

• tal:replace…タグ全体を置き換え

<span tal:replace=“string:aaa”>題名</span>– <span tal:replace= string:aaa >題名</span>→ aaa

• tal:omit-tag…値が真ならタグだけ除去g 値 真な タグ け除去

– <strong tal:omit-tag=“isOmitted”>内容</strong>→ 内容

68Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 69: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

ZPTZPTの属性(の属性(22))

• tal:repeat…繰り返しtal:repeat…繰り返し

– <p tal:repeat=“name names” tal:content=“name”>中身</p>

名前1 / 名前2 / 名前3 /→<p>名前1</p><p>名前2</p><p>名前3</p>

tal:condition 値が真なら描画• tal:condition…値が真なら描画

– <p tal:condition=“isError” tal:content=“errorMessage”>エラーメッセージ</p>ラ メッセ ジ /p→<p>実際のエラーメッセージ</p>

• tal:define…変数を定義

– <div tal:define=“c a/b/c”><span tal:content=“c”></span></div>→<div><span>”a/b/c”の評価結果</span></div>

69Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

→<div><span> a/b/c の評価結果</span></div>

Page 70: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

適用事例適用事例

70Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 71: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

適用事例適用事例

• Kvasir/Soraのアプリケーションプラグイン• Kvasir/Soraのアプリケーションプラグイン

– 管理ツール、イベント申し込み受付機能、…• 業務アプリケーション

– 某リソース予約サイト(B2C系、国際化対応あり)某リソ ス予約サイト(B2C系、国際化対応あり)

• 約50画面規模×4アプリ(携帯アプリ含)

71Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 72: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

あると便利なツール達あると便利なツ ル達

72Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

Page 73: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

あると便利なツール達あると便利なツール達

• 低限用意したいもの• 低限用意したいもの– サーブレットコンテナ

Webブラウザ– Webブラウザ

– Eclipse– Maven2

• あると便利なもの– ResourceSynchronizer– WebLauncherWebLauncher– m2eclipseプラグイン

Maven2 Additionalプラグイン

73Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

– Maven2 Additionalプラグイン

Page 74: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

あると便利なツール達(あると便利なツール達(22))

• サーブレットコンテナ• サ ブレットコンテナ

– 動作確認のために必要

WebLauncher(後述)があれば不要– WebLauncher(後述)があれば不要

• Webブラウザ

動作確認 自動生成 ために必要– 動作確認・自動生成のために必要• Eclipseの組み込みブラウザでもできなくはないが…

E li• Eclipse– 自動生成+HOT deployを活用するには必須

ド修 自動ビ ド• コード修正→即自動ビルド

• Maven2

74Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

– 開発中は不要だが手軽にWARを生成するために必要

Page 75: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

あると便利なツール達(あると便利なツール達(33))

• ResourceSynchronizerResourceSynchronizer– Eclipseの管轄外で行なわれたリソースの変更に関する通知

を受けて内部情報を同期してくれるEclipseプラグインhttp //eclipse seasar org/ pdates/3 3/• http://eclipse.seasar.org/updates/3.3/

– 自動生成後にEclipseのプロジェクトを手動で同期する必要がなくなる

• WebLauncher– Webアプリケーションをサーブレットコンテナに配備して動作

させてくれるEclipseプラグインさせてくれるEclipseプラグイン• http://werkzeugkasten.googlecode.com/svn/trunk/werkzeugkaste

n.update/S d T tプラグインと違い1アプリ 1 ンテナで起動し– Sysdeo Tomcatプラグインと違い1アプリ:1コンテナで起動してくれる

– WTPより手軽

75Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.

WTPより手軽

Page 76: Ymirを使ってかんたんWebアプリ開発 · Seasar Conference 2008 A t2008 Autumn Ymirを使ってかんたんWebアプリ開発 Ymirプロジェクトプロジェクトリーダ

あると便利なツール達(あると便利なツール達(44))

• m2eclipseプラグイン• m2eclipseプラグイン

– EclipseにMaven2を統合するためのEclipseプラグイン• http://m2eclipse codehaus org/update/ (0 0 12系)• http://m2eclipse.codehaus.org/update/ (0.0.12系)

• 0.9.5系(http://m2eclipse.sonatype.org/update/)は若干不安定&Maven2 Additionalプラグインと相性が悪いかも

– JARの依存関係をpom.xmlで一元管理可能

• Maven2 Additionalプラグイン

– 依存するJARをWEB-INF/libにコピーしてくれるEclipseプラグイン

• http://www.skirnir.net/eclipse/updates/3.2/

– WebLauncherとの組み合わせで威力を発揮

76Seasar ConferenceSeasar Conference

2008 Autumn2008 Autumn © The Skirnir Project and the others 2008. all rights reserved.