Upload
yu-sudo
View
1.753
Download
3
Embed Size (px)
DESCRIPTION
Groovy&Grails eXchange 2012@ロンドン 報告! 2013/01/18開催のG*ワークショップ 2013新春SPでの発表資料です。
Citation preview
Groovy&Grails eXchange 2012 @London 報告!
2013/01/18 G*Workshop
http://skillsmatter.com/event/groovy-grails/groovy-grails-exchange-2012
Who am I ?
NTT ソフトウェアGrails 推進室Grails Advocate
須藤 悠
Grails を用いたファイルアップローダ作成http://www.ntts.co.jp/publish/column/tec/java_02/
JGGUG サポートスタッフ (2012/11/23 ~ )
Grails ドキュメント和訳https://github.com/nttsoft/grails-doc-src-ja/network/members
About me
ずっと Track2(Grails 関連 ) にいました。Track1(Grails 以外の G*) を期待してた人ごめんなさい。本資料の写真は以下の公開アルバムからの引用です。- 2012.12.13-14 GGX 2012 London
- http://www.flickr.com/photos/y___u/sets/72157632240118573/
- Skills Matter's Groovy & Grails eXchange- http://www.flickr.com/photos/skillsmatter/sets/72157632277265626/
本資料の写真以外の画像は元スライドからの引用です。
Note
本発表の資料はこちらhttp://bit.ly/GGX2012report
各発表のスライド・ビデオへのリンク集のみhttp://bit.ly/GGX2012abst
旅行記と GGX2013 の紹介http://bit.ly/GGX2012tour
Note
Day 12012/12/13Photo http://instagram.com/p/TK_QY_GwQL/
Groovy Keynote- Guillaume Laforge
Photo from http://www.flickr.com/photos/y___u/8270793291/
Slide:http://www.slideshare.net/glaforge/groovy-2-and-beyond
https://speakerdeck.com/glaforge/groovy-2-dot-0-and-beyond
Video:http://skillsmatter.com/podcast/groovy-grails/keynote-speech
Groovy エコシステムの新しい仲間GVM: Groovy enVironment Managerhttp://gvmtool.net/
複数バージョンの開発環境を管理する、 RVM の G* 版Groovy, Grails, Griffon, Gradle, Vert.x をサポートLinux, MacOS, Cygwin, Solaris, FreeBSD で使えるよ
Groovy Keynote
Groovy 2.0 のトピック :- モジュール性の向上と core の小型化- 静的型チェックと CompileStatic- JDK 7 対応開始 (invoke dynamic と project coin)- indy 対応はまだ完全ではない
日本語では Guillaume の書いた記事の翻訳版が InfoQにhttp://www.infoq.com/jp/articles/new-groovy-20
Groovy Keynote
Groovy 2.0 については他にも…
プログラミング GROOVY 別冊 : 第 8 章 Groovy 2.0 の新機能http://bit.ly/8Groovy2
Groovy2.0 の新機能 疾きこと CompileStatic のごとしhttp://www.slideshare.net/uehaj/new-feature-of-groovy20-gworkshop
Groovy Keynote
CompileStatic のパフォーマンス
Groovy Keynote
元スライドから引用
今後の Groovy のロードマップ
Groovy Keynote
元スライドから引用
Groovy 2.1:- invoke dynamic サポートを完全に- @DelegatesTo(DSL の静的型チェック )- Type checker extension( 静的型チェックのカスタ
マイズ )- Alias annotation( アノテーションで interface の
チェック )
Groovy Keynote
Groovy 3.0:- MOP2( 新しい Meta-Object Protocol)
Groovy 4.0:- Antlr 4 を使った新しい文法- JDK 8 ラムダ式
Groovy Keynote
Grails For Hipsters- Robert Fletcher
Photo from http://www.flickr.com/photos/skillsmatter/8284468042/
Slide:http://www.slideshare.net/rfletcher/grails-for-hipsters
Video:http://skillsmatter.com/podcast/groovy-grails/grails-for-hipsters
Grails + Vert.x なアプリ Hipsteroid のデモhttps://github.com/robfletcher/hipsteroid
複数ウインドウで作業するとそれぞれ同期されるアプリ
Grails For Hipsters
元スライドから引用 元スライドから引用
Hipsteroid アプリの構成要素- Grails 2.1.2- Vert.x- MongoDB- ImageMagick- CoffeeScript- LESS- Handlebars
Grails For Hipsters
操作のミラーリングには UrlMappings と CoffeeScript(hipsteroid-router.coffee) を利用
LESS+CoffeeScript は CodeKit を使って CSS+JS にhttp://incident57.com/codekit/
Handlebars プラグインいいよ!http://grails.org/plugin/handlebars
Grails For Hipsters
Hipster ってなん JARO ?
【名】 〈俗〉進んでいる人、流行に敏感な人◆ 1930 年代か
ら存在した言葉だが、 1950 年代になりジャズファンを指す言葉として使われるようになった。
ヒップスター◆インディーロックなどを聴き、本や芸術などについて語る人たち。独特な服装をしている。
http://eow.alc.co.jp/search?q=Hipster
Grails For Hipsters
Grails Platform Core- Marc Palmer
Photo from http://www.flickr.com/photos/y___u/8271858922/
Slide:https://speakerdeck.com/marcpalmer/using-grails-platform-core
Video:http://skillsmatter.com/podcast/groovy-grails/using-grails-platform-core
Grails プラグインすてき!- 多くのユーザを惹きつける- そうしてより良いプラグインができていく
Grails はフレームワークで、プラットフォームではないが…- もっと便利な機能も内包してくれると嬉しい- Low maintenance を目指したい
Grails Platform Core
ナイスなプラグインの紹介- email-confirmation
admin UI あるよ- resources
mode UI つくりましょう ( 本体に統合済み )- fresh-security
SpringSecurity のラッパー、 UI と mail confirmation- weceem
イベント処理と UI の統合としてなかなか良い
Grails Platform Core
Platform-Core プラグイン作ったよ!http://grails.org/plugin/platform-core
- Configuration API- Security API- UI Extensions- Navigation API- Events API
をまとめたもの
Grails Platform Core
compile ":platform-core:1.0.RC4“
で導入可能- 4 つの API- 35( 以上 ) のタグリブ- 20( 以上 ) の動的メソッドとプロパティ- 2 つの Artefact 、 1 つの Bean 群、 1 つの Grails
コマンドなどを内包している※Artefact についてはここ : http://grails.org/Developer+-+Artefact+API
Grails Platform Core
- Configuration APIプラグイン名つきの Config 名前空間、 Config のマージConfig のバリデーションとデフォルト値設定
- Security API基本的なセキュリティ機能の抽象化
- UI Extensionsタグとヘルパプロパティとファンクションのセット
- Navigation APIナビゲーションのための Artefact と DSL 、それにタグリブ
- Events API任意のイベントの実装を接続できる標準的なイベントバスアプリ内でのメッセージングのための軽量デフォルトプロバイダ
Grails Platform Core
時間切れになっちゃったけどほんとにすげーんだぜ!> grails update-header コマンドも用意してあるよみなさんのプラグインも migrate してくれると嬉しいなチートシート用意してあるよhttp://bit.ly/platform-core-cheat
SPOKEnPHOTO をローンチしたよ (※iOS アプリ )http://www.spoketechnologies.com/spokenphoto/
Grails Platform Core
Using Spring In Grails - Burt Beckwith
Photo from http://www.flickr.com/photos/y___u/8270792917/
Slide:http://www.slideshare.net/burtbeckwith/under-the-hood-using-spring-in-grails-15633030
Video:http://skillsmatter.com/podcast/groovy-grails/under-the-hood-using-spring-in-grails
Test や Resources で Service を利用する際の- 参照・設定する例- Transactional にする例
トランザクション処理に関わるヘルパメソッドSpring SpEL を使った複雑な依存性の設定
Using Spring In Grails
Bean のスコープBean の init() や destroy() やafterPropertiesSet()
Bean ポストプロセッサBean エイリアスSpring MVC の機能の使い方
Using Spring In Grails
オライリーの Programming Grails を執筆Early Release したよhttp://shop.oreilly.com/product/0636920024750.do
Using Spring In Grails
Photo from http://www.flickr.com/photos/y___u/8271858922/
Slide:https://speakerdeck.com/marcpalmer/themeing-and-uis-with-grails-platform-ui
Video:http://skillsmatter.com/podcast/groovy-grails/theming-and-user-interfaces-with-grails-platform-ui
Theming & UIs With
Grails Platform UI- Marc Palmer
Grails での rapid development のためにout of the box でイケてる画面を用意できる機構が必要
themetrust.com や themeforest.net を見てみてWordpress みたいなテーマ欲しいよね
UI セットとテーマは分かれているべきテーマは複数の UI セットをまとめたものと考える
Grails Platform UI
Platform-UI プラグインhttp://grails.org/plugin/platform-ui
Platform-Core 環境において- UI セットの変更- テーマの変更が可能になるようにしたものBootstrap-Theme / Bootstrap-UI プラグインを利用Resources プラグインと連携する
Grails Platform UI
runtime ":platform-ui:1.0.RC3“
runtime ":bootstrap-theme:1.0.RC3“
runtime ":bootstrap-ui:1.0.RC4“
で導入可能- 55( 以上 ) のタグリブ- 2 つの Bean- 4 つの Grails コマンドを内包している
Grails Platform UI
UI セットは GSP テンプレート +Resources で実現テーマは SiteMesh+GSP テンプレート +Resources
2 つのタグリブで階層的に記述する- <theme:layoutZone>- <theme:zone>
テーマ設定は default/config/set at runtime が可能リクエストごとにテーマを変えることもできる
Grails Platform UI
Grails.org のサイトを例に、 GSP で zone を組み立てる例
Grails Platform UI
元スライドから引用 元スライドから引用
UI セットやテーマをつくるのは Grails コマンドで> grails create-ui-set
> grails fork-ui-set
> grails create-theme
> grails fork-theme
Grails Platform UI
チートシート用意してあるよhttp://bit.ly/platform-ui-cheat
デモとして Showcase アプリ用意してあるよhttps://github.com/grailsrocks/grails-platform-ui-showcase
Platform-UI のテーマチャレンジ開催してるよhttp://bit.ly/platform-ui-challenge
Grails Platform UI
テーマチャレンジの作例 :昔Geocities にあったサイト風
Grails Platform UI
Photo from http://www.flickr.com/photos/y___u/8389051645/
テーマチャレンジの作例 :昔Geocities にあったサイト風
Grails Platform UI
Photo from http://www.flickr.com/photos/y___u/8389051833/
Photo from http://www.flickr.com/photos/y___u/8270792817/
Slide:http://www.slideshare.net/burtbeckwith/under-the-hood-using-spring-in-grails-15633030
Video:http://skillsmatter.com/podcast/groovy-grails/under-the-hood-using-spring-in-grails
Leveraging Social Media
In Grails
- Bobby Warner
OAuth のライブラリ- Signpost OAuth 1.0a (not 2.0)- SpringSecurity OAuth 1.0a + 2.0- Scribe OAuth 1.0a + 2.0
spring-security-oauth プラグインはこれを利用- Google OAuth 1.0a + 2.0
Grails プラグインは無い
Leveraging Social Media
OAuth の API ラッパーは- 特定の OAuth プロバイダ用ライブラリ- OAuth プロバイダ非依存のフレームワークにわかれる
Grails では oauth プラグイン (Scribe を利用 ) が最もシンプルでよくメンテナンスされてる2 つ以上の OAuthネットワークを使うなら、 spring-social-* プラグインがオススメ
Leveraging Social Media
Photo from http://www.flickr.com/photos/y___u/8271858798/
Video:http://skillsmatter.com/podcast/groovy-grails/park-bench-discussion-3650
Park Bench Discussion
Day 22012/12/14Photo http://instagram.com/p/TLOKgImwWL/
Grails Keynote - Graeme Rocher
Photo from http://www.flickr.com/photos/y___u/8303330738/
Video:http://skillsmatter.com/podcast/groovy-grails/grails-keynote
Grails.org 新しくなったよ!Grails 2.0/2.1 の新機能の紹介- インタラクティブモード、自動リロードの強化、 dbconsole- UI とエラーリポートの向上、 HTML5
Scaffolding 、 jQuery- バインド変数による controller アクション- 新しい API PageRenderer, LinkGeneration- Resouces プラグイン統合を始めとした静的リソース関連- GORM/Hibernate 関連、テスト関連- Maven プラグイン 2.1 、 Cache プラグインの統合 . . .
Grails Keynote
Grails のロードマップ
Grails Keynote
Photo from http://www.flickr.com/photos/y___u/8390137070/
Grails 2.2 の新機能 :- Groovy2.0 対応
- TypeChecked, CombileStatic, invoke dynamic ...- 名前空間サポート
- Service や Domain Class の名前空間がプラグイン名を使って衝突しないようになるよ
- UrlMappings や g:link でプラグイン名を指定できる- Criteria における sqlProjection の機能追加
Grails Keynote
Grails 2.2 の新機能 :- Forked Mode(Forked Tomcat Execution)
- grails.project.fork.run=true で使えるようになる- JVM のパラメータをカスタマイズできる- あとは普通に run-app- 停止のための grails stop-app コマンド追加
Grails Keynote
Grails 2.3:- Data Binding
- platform-core events の統合http://github.com/grails/grails-core/wiki/Data-Binding
- REST Improvements-PUT/POST/DELETE/GET/PATCH/HEAD . . . etc
-REST scaffolding- REST client / GORM for REST-Rest-Client-Builder プラグインの統合
http://grails.org/plugin/rest-client-builder
Grails Keynote
Grails 2.3:- 非同期処理
- より高いレベルのプログラミングモデルを用意したい- ダイナミックファインダーのコールバック?- 将来的には DetachedCriteria ?
- Hibernate 4 化 / Hibernate 設定の充実- Encoding / Escaping の向上
Grails Keynote
Grails 3.0:- Gradle 対応- Grails プラグインプラットフォーム- Grails アプリケーションプロファイル- バイナリプラグインのランタイムリロード
Grails Keynote
Photo from http://www.flickr.com/photos/y___u/8302275931/
Slide: http://www.slideshare.net/energizedwork/debugging-grails-database-performance
Video:http://skillsmatter.com/podcast/groovy-grails/debugging-grails-database-performance
Debugging GrailsDatabase Performance
- Tom Dunstan
Miniprofiler プラグインの紹介http://grails.org/plugin/miniprofiler
https://github.com/tomdcc/grails-miniprofiler
Debugging GrailsDatabase Performance
元スライドから引用
Profiler プラグインはログを書き出してくれるが、 Grails(GORM) でデータにアクセス可能な箇所が多すぎる- Controller- Service- View- TagLib
. . . etc最終的にフェッチにどれだけかかったのか分かりづらい場合も
Debugging GrailsDatabase Performance
View で 10 SQL を発行し 754 ms かかる例でのデモクエリとかかる時間が一覧され見やすいクエリを Service にまとめたら 24 ms に短縮された
<miniprofiler:javascript /> タグを挿入すれば使える表示するプロファイル結果は Ajax で受け取っている
IntelliJ では、コマンドキー押しながらスワイプで文字のサイズ変えられるよ
Debugging GrailsDatabase Performance
Contributing Back To Grails
- Bobby WarnerPhoto from http://www.flickr.com/photos/y___u/8270792817/
Slide:https://github.com/bobbywarner/ggx2012/blob/master/ggx-contributing-back-to-grails.pdf?raw=true
Video:http://skillsmatter.com/podcast/groovy-grails/contributing-back-to-grails
Grails に貢献しよう!Mail, JIRA, Github, Hudson(Jenkins) が使われてるよ
grails-core は cherry-pick は使わない方針全ての branch は定期的に master に merge される
5件の簡単な修正を Live Pull-Requesting で実践!
Contributing Back To Grails
Photo from http://www.flickr.com/photos/y___u/8303328584/
Slide:http://www.slideshare.net/StphaneMaldini/eventsggx
Video:http://skillsmatter.com/podcast/groovy-grails/reactive-grails-event-oriented-architecture-made-easy
Reactive GrailsEvent Oriented Architecture
- Stephane Maldini
Grails でイベントバスを使う場合の選択肢- Spring-Events プラグイン- Routing プラグイン (Apache camel)- Falcone-Util プラグイン ( メンテされてない )
そこで Platform-Core プラグインですよ!
Reactive Grails
event('mailRegistration',user)
とか書けばノンブロッキングなイベントをトリガできる
.waitFor()
を付ければブロッキングな呼び出しにすることもできる
@grails.events.Listener
を使ってイベントを受けるメソッドを定義
Reactive Grails
Events-SI プラグイン- Spring Integration をベースに DSL で記述- RabbitMQ を通してイベント送るのも楽ちん!
Reactive Grails
元スライドから引用 元スライドから引用
Events-Push プラグイン- JavaScript でイベントを Listen したい- Atmosphere ベース
Grails-Vertx プラグインも計画中!
Reactive Grails
Securing Grails Applications
- Burt BeckwithPhoto from http://www.flickr.com/photos/y___u/8270792917/
Slide:http://www.slideshare.net/burtbeckwith/securing-grails-applications
Video:http://skillsmatter.com/podcast/groovy-grails/securing-grails-applications
Grails でのセキュリティ対策 A to Z 、必読!セキュリティリスクと対策を網羅してある
OWASP: Open Web Application Security Project
でもチートシート公開したよ! ( まだ中身ないけど )https://www.owasp.org/index.php/Grails_Secure_Code_Review_Cheat_Sheet
Don't trust the users!
Securing Grails Applications
SQL インジェクション対策- わかってると思いますがプレースホルダ使いましょう
XSS 対策- grails.views.default.codec="html" 使いましょ
う- <% %> 使うときは気をつけて- <%=person.value%> みたいな使い方はしないよ
うに
Securing Grails Applications
session fixation 対策- grails.plugins.springsecurity.useSessionFixationPrevention=true
insecure direct object reference 対策- .get(id) は id を知られても問題ないオブジェクト
に限ること- ACL の @PreAuthorize を使っても良い- hdiv プラグインもあるよ
Securing Grails Applications
hdiv: http data integrity validatorhttp://hdiv.org/
hdiv プラグインで Grails 2.3 からサポート予定!https://github.com/burtbeckwith/grails-hdiv/
http://repo.grails.org/grails/plugins-releases/org/hdiv/
Securing Grails Applications
CSRF 対策- XSS 対策をした上で、更新処理には POST メソッドを
使う- リンクとフォームに生成トークンを使う- hdiv を使う
security misconfiguration- 不要なものは消すこと- デフォルトパスワードは危険 . . . etc
Securing Grails Applications
failure to restrict url access- grails.plugins.springsecurity.rejectIfNoRule=tru
e を忘れると大変!
insufficient transport layer protection- grails.plugins.springsecurity.
auth.forceHttps=true
unvalidated redirecs and forwards- ?nextPage=/hoge みたいな GET パラメータがあると
き =http://othersite.com/ みたいなことをやりやすい
Securing Grails Applications
Photo from http://www.flickr.com/photos/y___u/8302273751/
Video:http://skillsmatter.com/podcast/groovy-grails/building-an-ecommerce-business-with-gr8-technologies-in-latin-america
Building An Ecommerce Business With GR8
- Domingo Suarez Torres
メキシコの E コマースサービス clickOnero についてのお話規模 :- 20万~ 30万 visits/day- 1500万 PV/day- 8万 concurrent user
参考 : とらのあなが 1200万 PV/day(2011 年の記事 )http://www.itmedia.co.jp/news/articles/1109/07/news070.html
Building An Ecommerce Business With GR8
ver 1.0:
Grails, MySQL, Tomcat, ehcache/terracotta, RabbitMQ
4 人でつくったJava → Grails への転向、 Grails の簡潔さに感動!
テストのカバレッジ低かった、 CI も無しコントローラにたくさんのコードがあったりGORM のクエリがイケてなかったり
Building An Ecommerce Business With GR8
使った Grails プラグイン- Rabbitmq- Spring-Security- Rendering- Quartz- Feeds- Export . . . Etc
JavaMelody のダッシュボードでいろいろ見れて嬉しかったJDBC に入ってきたクエリとかLogstalgia でログを可視化した
Building An Ecommerce Business With GR8
ver 2.0:
single page にしたchaplin/backbone.js を使って 3 コンポーネントに分割- API :Grails, Tomcat(JSON だけしゃべる、 GSP無し )- Admin :Grails, Tomcat - Hipstore: 静的 HTML, chaplin, Apache httpd, CoffeeScript, pushstate, require.js, handlebars, jQuery, underscore, bootstrap, jake, . . .etc
Building An Ecommerce Business With GR8
Spock と Jasmine を使ってテストケースを作成Jenkins も使うようにした
Pushstate で URL 書き換えブックマークとかソーシャルメディアにも対応可能ですげー便利Google のクローラが変なパラメータ付きでやってくる!Zombie.js でサイトを巡回し、生成されたページを静的コンテンツとして利用Web サーバも DB サーバも負荷は減ったしリンクのシェアはできるようになったしいいことずくめ
Building An Ecommerce Business With GR8
Thanks.Copyright(C) 2013 NTT Software Corporation All Rights Reserved.
記載されているロゴ、システム名、製品名は各社および商標権者の登録商標あるいは商標です。