20090522 Scalaユーザー会#1
-
Upload
tomohito-ozaki -
Category
Technology
-
view
1.179 -
download
0
Transcript of 20090522 Scalaユーザー会#1
![Page 1: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/1.jpg)
Liftってなにっ?
なんなのっ?!
2009年5月22日金曜日
![Page 2: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/2.jpg)
自己紹介
• 尾崎 智仁
• ID:yuroyoro(はてな、twitter、wassr)
• フリーエンジニア
• JavaとかScalaとかpythonとか
2009年5月22日金曜日
![Page 3: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/3.jpg)
Blog
2009年5月22日金曜日
![Page 4: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/4.jpg)
コミュニティ
• java-ja (自重しません)
• wicket-ja (wicketイカス)
• django-ja (最近です)
• shibuya-trac (p lugin書いたり)
2009年5月22日金曜日
![Page 5: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/5.jpg)
コミュニティ
• java-ja (自重しません)
• wicket-ja (wicketイカス)
• django-ja (最近です)
• shibuya-trac (p lugin書いたり)
•Scalaユーザー会
2009年5月22日金曜日
![Page 6: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/6.jpg)
好きなキャラに脳内で変換して
聞いてください・・・
2009年5月22日金曜日
![Page 7: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/7.jpg)
それでは・・・
2009年5月22日金曜日
![Page 8: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/8.jpg)
今日は
小松フォークリフトの話をします。
2009年5月22日金曜日
![Page 9: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/9.jpg)
だって、ググっても出てこないんだもん。。。
2009年5月22日金曜日
![Page 10: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/10.jpg)
2009年5月22日金曜日
![Page 11: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/11.jpg)
“scala lift”でググると。。。
2009年5月22日金曜日
![Page 12: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/12.jpg)
そろそろまじめにやります
・・・
2009年5月22日金曜日
![Page 13: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/13.jpg)
今日の内容
•Liftの紹介っ!
•ざっくりアーキテクチャ!
•デモっ!
•まとめっ!
2009年5月22日金曜日
![Page 14: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/14.jpg)
Liftの紹介っ!
2009年5月22日金曜日
![Page 15: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/15.jpg)
Liftの特徴
•Scalaです!
•フルスタックです!
•いいとこどりしてます!
2009年5月22日金曜日
![Page 16: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/16.jpg)
Liftの特徴
•現在のVersion 1.0
•scala 2.7.3
•Githubにソース
•チーフコミッタ David
Pollak
2009年5月22日金曜日
![Page 17: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/17.jpg)
2009年5月22日金曜日
![Page 18: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/18.jpg)
Liftの特徴
•Scalaの関数型言語や
型推論に加え、既存の
java資産が利用できるん
です!
2009年5月22日金曜日
![Page 19: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/19.jpg)
Liftの特徴
•インストールやサーバ
の起動はrailsみたいに
Mavenコマンド一発。
•組み込みDB (Derby)
2009年5月22日金曜日
![Page 20: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/20.jpg)
Liftの特徴
•設定はCocとScala
コード。XMLなし!
•SiteMapやACL
•アプリのテンプレート
2009年5月22日金曜日
![Page 21: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/21.jpg)
Liftの特徴
•jQueryによるAjax!
•Commetを簡単に!
•各種Widgetがあるよ!
•GAE/Jでも動くよ!
2009年5月22日金曜日
![Page 22: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/22.jpg)
ざっくりアーキテクチャ!
2009年5月22日金曜日
![Page 23: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/23.jpg)
Liftのアーキテクチャ
Model
LiftFilter
LiftServlet
Boot
LiftRule
LiftSession
RequestState
Snippet
HTML Template
Requestを受けるfilter
URLのDispatchなどのルール
DBなどの動作環境の設定情報
Reqeustの種類(Commet,Ajax)による振り分け
Sessionを扱うRequestの処理。
RequestとResponseの情報。
XHTMLでのテンプレート
Viewへの出力やModelの操作など
KeyedMapper
KeyedMetaMapperORMでのtrait
CRUD関連処理を継承
フォームの入力値などを参照
Modelの操作
XHTMLタグでSnippetを埋め込む
URLなどからTemplateを検索
URLによる振り分け
2009年5月22日金曜日
![Page 24: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/24.jpg)
LiftのアーキテクチャLiftはscalaで実装されたフルスタックのWebアプリケーションフレームワーク
であり近年のフレームワークのエッセンスを取り入れている。Liftのアーキテ
クチャはView Firstでありリクエストに対しての (開発者が意識すべき) コント
ローラというものは存在しない。リクエストに対してはtemplateのレンダリン
グの過程でbindされたsnipetをliftが呼び出すことで出力が行われる。snipet
は、後述するmodelを利用した動的な出力の生成などを行う。また、snipetで
出力を生成する際に、特定のHTML上のコンポーネントに対してのイベントハ
ンドラを独自に用意したFunctionオブジェクトに割り当てる(Function
Mapping)ことが可能であり、さらに、snipet自体がstateを保持することが可
能になっているおかげで、snipet=コンポーネントという形での開発スタイル
が確立されている。このようなアーキテクチャを拡張する形で、近年のwebア
プリケーション開発では必須ともいえるajaxのサポートが提供されており、
簡便なAPIで出力上のHTMLエレメントに対してのajaxイベントを特定の
functionに割り当て、動的なjavascriptやjsonを簡単に出力できる。このajax
を利用したcometを実現するsnipetも提供されており、今はすでに無きLingrの
ようなインタラクティブなwebアプリケーションを少ない行数で実現すること
が出来るのである。さらに、LiftのORMライブラリはActiveRecordを意識した
2009年5月22日金曜日
![Page 25: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/25.jpg)
2009年5月22日金曜日
![Page 26: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/26.jpg)
開発者がつくるもの
•設定 Boot (scala)
•テンプレート(XHTML)
• Snipet(scala)
• Model(scala)
2009年5月22日金曜日
![Page 27: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/27.jpg)
LiftのView
2009年5月22日金曜日
![Page 28: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/28.jpg)
LiftのView
•Snipetアプローチ
classHelloWorld{
defhowdy=<span>Welcometohelloworldat
{new_root_.java.util.Date}</span>
}
Snipet(scala)
<p><lift:helloWorld.howdy/></p>Template
2009年5月22日金曜日
![Page 29: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/29.jpg)
LiftのView
•コントローラが中心で
はなく、Viewを中心
としたアーキテクチャ
2009年5月22日金曜日
![Page 30: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/30.jpg)
LiftのView
•テンプレートは
XHTML。独自の名前
空間のXMLタグと
Snippetを結合!
2009年5月22日金曜日
![Page 31: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/31.jpg)
LiftのView
•Wicketのようなコン
ポーネントが可能に!
2009年5月22日金曜日
![Page 32: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/32.jpg)
LiftのView
•テンプレートの例
<p>
<lift:helloWorld.howdy/>
</p>snipetのクラス名
メソッド名
2009年5月22日金曜日
![Page 33: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/33.jpg)
LiftのView
• snipetの例classHelloWorld{
defhowdy=
<span>
Welcometohelloworldat
{new_root_.java.util.Date}
</span>
}
snipetクラス
メソッド
日付を埋め込んだXMLを返す
2009年5月22日金曜日
![Page 34: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/34.jpg)
LiftのView
•テンプレートの例 (Form)
<lift:SampleSnipet.addform="POST">
<entry:description/>
<entry:amount/><br/>
<entry:submit/>
</lift:SampleSnipet.add>
2009年5月22日金曜日
![Page 35: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/35.jpg)
LiftのView
• Snipetの例 (Form)classSampleSnipet
defadd(xhtml:NodeSeq):NodeSeq={
vardesc=""
varamount="0"
defprocessEntryAdd(){...}
bind("entry",xhtml,
"description"->SHtml.text(desc,desc=_),
"amount"->SHtml.text(amount,amount=_),
"submit"->SHtml.submit(Add,
processEntryAdd))
}
}
submitされたときにprocessEntryAddメソッドを呼び出す
2009年5月22日金曜日
![Page 36: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/36.jpg)
LiftのModel
2009年5月22日金曜日
![Page 37: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/37.jpg)
LiftのModel
•MappingはCoC
•schemifyによる同期
•動的SQL
•(ActiveRecord的な…)
•CRUDify(trait)2009年5月22日金曜日
![Page 38: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/38.jpg)
LiftのModel
•Mapper (trait)‣ entityクラス
‣ カラムの定義
‣ crud操作 (save,update,delete)
•MetaMapper (trait)‣ sigleton、Maperのファクトリ
‣ findなどのメソッド
‣ ユーティリティ(order定義、form生成,validate…)
2009年5月22日金曜日
![Page 39: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/39.jpg)
LiftのModel
•Mapperの例 classExpenseextendsLongKeyedMapper[Expense]withIdPK{
defgetSingleton=Expense
objectdateOfextendsMappedDateTime(this)
objectdescriptionextendsMappedString(this,100)
objectamountextendsMappedDecimal(this,
MathContext.DECIMAL64,2)
objectaccountextends
MappedLongForeignKey(this,Account)
}
KeyedMapperを継承
PK
カラムの定義(型、桁数…)
外部キーリレーション
2009年5月22日金曜日
![Page 40: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/40.jpg)
LiftのModel
•MetaMapperの例 objectExpenseextendsExpensewithLongKeyedMetaMapper[Expense]{
overridedeffieldOrder=
List(dateOf,description,amount)
}
Mapperを継承
KeyedMetamapper
並び順(form生成など)
2009年5月22日金曜日
![Page 41: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/41.jpg)
LiftのModel
•検索するときは…
valmyEntries1=Expense.findAll
valmyEntries2=Expense.findAll(By_>(Expense.amout,5))
valrecentEntries=Expense.findAll(
BySql("dateOf>(CURRENT_DATE-interval’30days’)",
IHaveValidatedThisSQL("dchenbecker","2008-12-03"))
全件検索
amount >5 で検索
SQLで検索
2009年5月22日金曜日
![Page 42: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/42.jpg)
LiftのModel
• entityの操作は…varmyEntr=Expense.create
myEntry.dateOf(newDate).description("Asampleentry")
myEntry.amount(BigDecimal("127.20"))
myEntry.save
myEntry.delete
2009年5月22日金曜日
![Page 43: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/43.jpg)
デモっ!
2009年5月22日金曜日
![Page 44: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/44.jpg)
demo
• Liftの真骨頂はcometにあり!
• scalaのactorを利用したsinpet
•TwitterのTimelineを流すデモ
•ソースはGithubhttp://github.com/yuroyoro/scala-ja-01-example/tree/master
2009年5月22日金曜日
![Page 45: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/45.jpg)
まとめっ!
2009年5月22日金曜日
![Page 46: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/46.jpg)
まとめ
• Liftはフルスタック!
• scalaのパワーをwebアプリ
ケーションへ
• Snipetアプローチ!
• ajax/commetが強み!
2009年5月22日金曜日
![Page 47: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/47.jpg)
情報源
•公式サイトhttp://liftweb.net/
•Google Group Lifthttp://groups.google.com/group/liftweb
•The Lift bookhttp://groups.google.com/group/liftweb
2009年5月22日金曜日
![Page 48: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/48.jpg)
宣伝っ!
2009年5月22日金曜日
![Page 49: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/49.jpg)
Seasar Conference 2009 Spring
でLift
の話をします。2009年5月22日金曜日
![Page 50: 20090522 Scalaユーザー会#1](https://reader036.fdocuments.us/reader036/viewer/2022062313/55878b23d8b42a42318b4737/html5/thumbnails/50.jpg)
ご静聴ありがとうございました!
2009年5月22日金曜日