78
Groovy&Grails eXchange 2012 @London 報報2013/01/18 G*Workshop http:// skillsmatter.com/event/groovy-grails/groovy-grails-exchange-2012

2013.01.18 G*Workshop GGX 2012 Report

  • Upload
    yu-sudo

  • View
    1.753

  • Download
    3

Embed Size (px)

DESCRIPTION

Groovy&Grails eXchange 2012@ロンドン 報告! 2013/01/18開催のG*ワークショップ 2013新春SPでの発表資料です。

Citation preview

Page 1: 2013.01.18 G*Workshop GGX 2012 Report

Groovy&Grails eXchange 2012 @London 報告!

2013/01/18 G*Workshop

http://skillsmatter.com/event/groovy-grails/groovy-grails-exchange-2012

Page 2: 2013.01.18 G*Workshop GGX 2012 Report

Who am I ?

NTT ソフトウェアGrails 推進室Grails Advocate

須藤 悠

Page 3: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 4: 2013.01.18 G*Workshop GGX 2012 Report

ずっと 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

Page 5: 2013.01.18 G*Workshop GGX 2012 Report

本発表の資料はこちらhttp://bit.ly/GGX2012report

各発表のスライド・ビデオへのリンク集のみhttp://bit.ly/GGX2012abst

旅行記と GGX2013 の紹介http://bit.ly/GGX2012tour

Note

Page 8: 2013.01.18 G*Workshop GGX 2012 Report

Groovy エコシステムの新しい仲間GVM: Groovy enVironment Managerhttp://gvmtool.net/

複数バージョンの開発環境を管理する、 RVM の G* 版Groovy, Grails, Griffon, Gradle, Vert.x をサポートLinux, MacOS, Cygwin, Solaris, FreeBSD で使えるよ

Groovy Keynote

Page 9: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 10: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 11: 2013.01.18 G*Workshop GGX 2012 Report

CompileStatic のパフォーマンス

Groovy Keynote

元スライドから引用

Page 12: 2013.01.18 G*Workshop GGX 2012 Report

今後の Groovy のロードマップ

Groovy Keynote

元スライドから引用

Page 13: 2013.01.18 G*Workshop GGX 2012 Report

Groovy 2.1:- invoke dynamic サポートを完全に- @DelegatesTo(DSL の静的型チェック )- Type checker extension( 静的型チェックのカスタ

マイズ )- Alias annotation( アノテーションで interface の

チェック )

Groovy Keynote

Page 14: 2013.01.18 G*Workshop GGX 2012 Report

Groovy 3.0:- MOP2( 新しい Meta-Object Protocol)

Groovy 4.0:- Antlr 4 を使った新しい文法- JDK 8 ラムダ式

Groovy Keynote

Page 15: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 16: 2013.01.18 G*Workshop GGX 2012 Report

Grails + Vert.x なアプリ Hipsteroid のデモhttps://github.com/robfletcher/hipsteroid

複数ウインドウで作業するとそれぞれ同期されるアプリ

Grails For Hipsters

元スライドから引用 元スライドから引用

Page 17: 2013.01.18 G*Workshop GGX 2012 Report

Hipsteroid アプリの構成要素- Grails 2.1.2- Vert.x- MongoDB- ImageMagick- CoffeeScript- LESS- Handlebars

Grails For Hipsters

Page 18: 2013.01.18 G*Workshop GGX 2012 Report

操作のミラーリングには UrlMappings と CoffeeScript(hipsteroid-router.coffee) を利用

LESS+CoffeeScript は CodeKit を使って CSS+JS にhttp://incident57.com/codekit/

Handlebars プラグインいいよ!http://grails.org/plugin/handlebars

Grails For Hipsters

Page 19: 2013.01.18 G*Workshop GGX 2012 Report

Hipster ってなん JARO ?

【名】 〈俗〉進んでいる人、流行に敏感な人◆ 1930 年代か

ら存在した言葉だが、 1950 年代になりジャズファンを指す言葉として使われるようになった。

ヒップスター◆インディーロックなどを聴き、本や芸術などについて語る人たち。独特な服装をしている。

http://eow.alc.co.jp/search?q=Hipster

Grails For Hipsters

Page 21: 2013.01.18 G*Workshop GGX 2012 Report

Grails プラグインすてき!- 多くのユーザを惹きつける- そうしてより良いプラグインができていく

Grails はフレームワークで、プラットフォームではないが…- もっと便利な機能も内包してくれると嬉しい- Low maintenance を目指したい

Grails Platform Core

Page 22: 2013.01.18 G*Workshop GGX 2012 Report

ナイスなプラグインの紹介- email-confirmation

admin UI あるよ- resources

mode UI つくりましょう ( 本体に統合済み )- fresh-security

SpringSecurity のラッパー、 UI と mail confirmation- weceem

イベント処理と UI の統合としてなかなか良い

Grails Platform Core

Page 23: 2013.01.18 G*Workshop GGX 2012 Report

Platform-Core プラグイン作ったよ!http://grails.org/plugin/platform-core

- Configuration API- Security API- UI Extensions- Navigation API- Events API

をまとめたもの

Grails Platform Core

Page 24: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 25: 2013.01.18 G*Workshop GGX 2012 Report

- Configuration APIプラグイン名つきの Config 名前空間、 Config のマージConfig のバリデーションとデフォルト値設定

- Security API基本的なセキュリティ機能の抽象化

- UI Extensionsタグとヘルパプロパティとファンクションのセット

- Navigation APIナビゲーションのための Artefact と DSL 、それにタグリブ

- Events API任意のイベントの実装を接続できる標準的なイベントバスアプリ内でのメッセージングのための軽量デフォルトプロバイダ

Grails Platform Core

Page 26: 2013.01.18 G*Workshop GGX 2012 Report

時間切れになっちゃったけどほんとにすげーんだぜ!> grails update-header コマンドも用意してあるよみなさんのプラグインも migrate してくれると嬉しいなチートシート用意してあるよhttp://bit.ly/platform-core-cheat

SPOKEnPHOTO をローンチしたよ (※iOS アプリ )http://www.spoketechnologies.com/spokenphoto/

Grails Platform Core

Page 28: 2013.01.18 G*Workshop GGX 2012 Report

Test や Resources で Service を利用する際の- 参照・設定する例- Transactional にする例

トランザクション処理に関わるヘルパメソッドSpring SpEL を使った複雑な依存性の設定

Using Spring In Grails

Page 29: 2013.01.18 G*Workshop GGX 2012 Report

Bean のスコープBean の init() や destroy() やafterPropertiesSet()

Bean ポストプロセッサBean エイリアスSpring MVC の機能の使い方

Using Spring In Grails

Page 30: 2013.01.18 G*Workshop GGX 2012 Report

オライリーの Programming Grails を執筆Early Release したよhttp://shop.oreilly.com/product/0636920024750.do

Using Spring In Grails

Page 32: 2013.01.18 G*Workshop GGX 2012 Report

Grails での rapid development のためにout of the box でイケてる画面を用意できる機構が必要

themetrust.com や themeforest.net を見てみてWordpress みたいなテーマ欲しいよね

UI セットとテーマは分かれているべきテーマは複数の UI セットをまとめたものと考える

Grails Platform UI

Page 33: 2013.01.18 G*Workshop GGX 2012 Report

Platform-UI プラグインhttp://grails.org/plugin/platform-ui

Platform-Core 環境において- UI セットの変更- テーマの変更が可能になるようにしたものBootstrap-Theme / Bootstrap-UI プラグインを利用Resources プラグインと連携する

Grails Platform UI

Page 34: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 35: 2013.01.18 G*Workshop GGX 2012 Report

UI セットは GSP テンプレート +Resources で実現テーマは SiteMesh+GSP テンプレート +Resources

2 つのタグリブで階層的に記述する- <theme:layoutZone>- <theme:zone>

テーマ設定は default/config/set at runtime が可能リクエストごとにテーマを変えることもできる

Grails Platform UI

Page 36: 2013.01.18 G*Workshop GGX 2012 Report

Grails.org のサイトを例に、 GSP で zone を組み立てる例

Grails Platform UI

元スライドから引用 元スライドから引用

Page 37: 2013.01.18 G*Workshop GGX 2012 Report

UI セットやテーマをつくるのは Grails コマンドで> grails create-ui-set

> grails fork-ui-set

> grails create-theme

> grails fork-theme

Grails Platform UI

Page 38: 2013.01.18 G*Workshop GGX 2012 Report

チートシート用意してあるよ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

Page 39: 2013.01.18 G*Workshop GGX 2012 Report

テーマチャレンジの作例 :昔Geocities にあったサイト風

Grails Platform UI

Photo from http://www.flickr.com/photos/y___u/8389051645/

Page 40: 2013.01.18 G*Workshop GGX 2012 Report

テーマチャレンジの作例 :昔Geocities にあったサイト風

Grails Platform UI

Photo from http://www.flickr.com/photos/y___u/8389051833/

Page 42: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 43: 2013.01.18 G*Workshop GGX 2012 Report

OAuth の API ラッパーは- 特定の OAuth プロバイダ用ライブラリ- OAuth プロバイダ非依存のフレームワークにわかれる

Grails では oauth プラグイン (Scribe を利用 ) が最もシンプルでよくメンテナンスされてる2 つ以上の OAuthネットワークを使うなら、 spring-social-* プラグインがオススメ

Leveraging Social Media

Page 45: 2013.01.18 G*Workshop GGX 2012 Report

Day 22012/12/14Photo http://instagram.com/p/TLOKgImwWL/

Page 47: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 48: 2013.01.18 G*Workshop GGX 2012 Report

Grails のロードマップ

Grails Keynote

Photo from http://www.flickr.com/photos/y___u/8390137070/

Page 49: 2013.01.18 G*Workshop GGX 2012 Report

Grails 2.2 の新機能 :- Groovy2.0 対応

- TypeChecked, CombileStatic, invoke dynamic ...- 名前空間サポート

- Service や Domain Class の名前空間がプラグイン名を使って衝突しないようになるよ

- UrlMappings や g:link でプラグイン名を指定できる- Criteria における sqlProjection の機能追加

Grails Keynote

Page 50: 2013.01.18 G*Workshop GGX 2012 Report

Grails 2.2 の新機能 :- Forked Mode(Forked Tomcat Execution)

- grails.project.fork.run=true で使えるようになる- JVM のパラメータをカスタマイズできる- あとは普通に run-app- 停止のための grails stop-app コマンド追加

Grails Keynote

Page 51: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 52: 2013.01.18 G*Workshop GGX 2012 Report

Grails 2.3:- 非同期処理

- より高いレベルのプログラミングモデルを用意したい- ダイナミックファインダーのコールバック?- 将来的には DetachedCriteria ?

- Hibernate 4 化 / Hibernate 設定の充実- Encoding / Escaping の向上

Grails Keynote

Page 53: 2013.01.18 G*Workshop GGX 2012 Report

Grails 3.0:- Gradle 対応- Grails プラグインプラットフォーム- Grails アプリケーションプロファイル- バイナリプラグインのランタイムリロード

Grails Keynote

Page 55: 2013.01.18 G*Workshop GGX 2012 Report

Miniprofiler プラグインの紹介http://grails.org/plugin/miniprofiler

https://github.com/tomdcc/grails-miniprofiler

Debugging GrailsDatabase Performance

元スライドから引用

Page 56: 2013.01.18 G*Workshop GGX 2012 Report

Profiler プラグインはログを書き出してくれるが、 Grails(GORM) でデータにアクセス可能な箇所が多すぎる- Controller- Service- View- TagLib

. . . etc最終的にフェッチにどれだけかかったのか分かりづらい場合も

Debugging GrailsDatabase Performance

Page 57: 2013.01.18 G*Workshop GGX 2012 Report

View で 10 SQL を発行し 754 ms かかる例でのデモクエリとかかる時間が一覧され見やすいクエリを Service にまとめたら 24 ms に短縮された

<miniprofiler:javascript /> タグを挿入すれば使える表示するプロファイル結果は Ajax で受け取っている

IntelliJ では、コマンドキー押しながらスワイプで文字のサイズ変えられるよ

Debugging GrailsDatabase Performance

Page 59: 2013.01.18 G*Workshop GGX 2012 Report

Grails に貢献しよう!Mail, JIRA, Github, Hudson(Jenkins) が使われてるよ

grails-core は cherry-pick は使わない方針全ての branch は定期的に master に merge される

5件の簡単な修正を Live Pull-Requesting で実践!

Contributing Back To Grails

Page 61: 2013.01.18 G*Workshop GGX 2012 Report

Grails でイベントバスを使う場合の選択肢- Spring-Events プラグイン- Routing プラグイン (Apache camel)- Falcone-Util プラグイン ( メンテされてない )

そこで Platform-Core プラグインですよ!

Reactive Grails

Page 62: 2013.01.18 G*Workshop GGX 2012 Report

event('mailRegistration',user)

とか書けばノンブロッキングなイベントをトリガできる

.waitFor()

を付ければブロッキングな呼び出しにすることもできる

@grails.events.Listener

を使ってイベントを受けるメソッドを定義

Reactive Grails

Page 63: 2013.01.18 G*Workshop GGX 2012 Report

Events-SI プラグイン- Spring Integration をベースに DSL で記述- RabbitMQ を通してイベント送るのも楽ちん!

Reactive Grails

元スライドから引用 元スライドから引用

Page 64: 2013.01.18 G*Workshop GGX 2012 Report

Events-Push プラグイン- JavaScript でイベントを Listen したい- Atmosphere ベース

Grails-Vertx プラグインも計画中!

Reactive Grails

Page 65: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 66: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 67: 2013.01.18 G*Workshop GGX 2012 Report

SQL インジェクション対策- わかってると思いますがプレースホルダ使いましょう

XSS 対策- grails.views.default.codec="html" 使いましょ

う- <% %> 使うときは気をつけて- <%=person.value%> みたいな使い方はしないよ

うに

Securing Grails Applications

Page 68: 2013.01.18 G*Workshop GGX 2012 Report

session fixation 対策- grails.plugins.springsecurity.useSessionFixationPrevention=true

insecure direct object reference 対策- .get(id) は id を知られても問題ないオブジェクト

に限ること- ACL の @PreAuthorize を使っても良い- hdiv プラグインもあるよ

Securing Grails Applications

Page 69: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 70: 2013.01.18 G*Workshop GGX 2012 Report

CSRF 対策- XSS 対策をした上で、更新処理には POST メソッドを

使う- リンクとフォームに生成トークンを使う- hdiv を使う

security misconfiguration- 不要なものは消すこと- デフォルトパスワードは危険 . . . etc

Securing Grails Applications

Page 71: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 73: 2013.01.18 G*Workshop GGX 2012 Report

メキシコの 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

Page 74: 2013.01.18 G*Workshop GGX 2012 Report

ver 1.0:

Grails, MySQL, Tomcat, ehcache/terracotta, RabbitMQ

4 人でつくったJava → Grails への転向、 Grails の簡潔さに感動!

テストのカバレッジ低かった、 CI も無しコントローラにたくさんのコードがあったりGORM のクエリがイケてなかったり

Building An Ecommerce Business With GR8

Page 75: 2013.01.18 G*Workshop GGX 2012 Report

使った Grails プラグイン- Rabbitmq- Spring-Security- Rendering- Quartz- Feeds- Export . . . Etc

JavaMelody のダッシュボードでいろいろ見れて嬉しかったJDBC に入ってきたクエリとかLogstalgia でログを可視化した

Building An Ecommerce Business With GR8

Page 76: 2013.01.18 G*Workshop GGX 2012 Report

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

Page 77: 2013.01.18 G*Workshop GGX 2012 Report

Spock と Jasmine を使ってテストケースを作成Jenkins も使うようにした

Pushstate で URL 書き換えブックマークとかソーシャルメディアにも対応可能ですげー便利Google のクローラが変なパラメータ付きでやってくる!Zombie.js でサイトを巡回し、生成されたページを静的コンテンツとして利用Web サーバも DB サーバも負荷は減ったしリンクのシェアはできるようになったしいいことずくめ

Building An Ecommerce Business With GR8

Page 78: 2013.01.18 G*Workshop GGX 2012 Report

Thanks.Copyright(C) 2013 NTT Software Corporation All Rights Reserved.

記載されているロゴ、システム名、製品名は各社および商標権者の登録商標あるいは商標です。