Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Aeromockが渋谷Javaにやってキタ━(゚∀゚)━!(Aeromockを支える技術)
Search
stormcat24
December 12, 2014
Programming
1
1k
Aeromockが渋谷Javaにやってキタ━(゚∀゚)━!(Aeromockを支える技術)
Shibuya Java #9
stormcat24
December 12, 2014
Tweet
Share
More Decks by stormcat24
See All by stormcat24
素早く賢く失敗するDeveloper Productivityの実現を目指して
stormcat24
4
4.4k
KubernetesのマニフェストをそれなりにCIしたい
stormcat24
4
1.2k
令和時代のSaaS開発
stormcat24
1
240
History in 5 years of CircleCI and CyberAgent
stormcat24
3
800
Kubernetes Handson Osaka
stormcat24
5
540
Kubernetes Handson
stormcat24
5
4.2k
DockerとKubernetesでアプリケーション開発にコンテナをフル活用!
stormcat24
0
290
Base Image Journey 2018
stormcat24
29
130k
kotlin-fest
stormcat24
13
17k
Other Decks in Programming
See All in Programming
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
1.2k
Kotlin Multiplatform at Stable and Beyond (Kotlin Vienna, October 2024)
zsmb
2
340
WEBアプリケーションにおけるAWS Lambdaを用いた大規模な非同期処理の実践
delhi09
PRO
7
4k
標準ライブラリの動向とイテレータのパフォーマンス
makki_d
3
190
上手に付き合うコンポーネントテスト
quramy
3
1.2k
Progressive Web Apps for Rails developers
siaw23
2
540
Modern Functional Fluent CFML REST by Luis Majano
ortus24
0
130
Quarto Clean Theme
nicetak
0
220
Micro Frontends for Java Microservices - dev2next 2024
mraible
PRO
0
200
Unlocking Python's Core Magic
leew
0
120
モジュラモノリス、その前に / Modular monolith, before that
euglena1215
6
660
[KR] Server Driven Compose With Firebase
skydoves
2
170
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
What the flash - Photography Introduction
edds
67
11k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Rails Girls Zürich Keynote
gr2m
93
13k
Building an army of robots
kneath
302
42k
Adopting Sorbet at Scale
ufuk
73
9k
Pencils Down: Stop Designing & Start Developing
hursman
119
11k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.5k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.8k
Designing on Purpose - Digital PM Summit 2013
jponch
114
6.9k
Unsuck your backbone
ammeep
667
57k
Into the Great Unknown - MozCon
thekraken
30
1.4k
Transcript
Aeromock͕ौ୩Javaʹ ͬͯŝŦᴸᴸ ƅ㱼ƅ)ᴸᴸ!! (AeromockΛࢧ͑Δٕज़ʣ Akinori Yamada (@stormcat24) 2014/12/13 Shibuya Java
#9
who? ‣ @stormcat24 ‣ CyberAgent, Inc. ‣ ࡶ༻ܥΖ͙Β·ʔ ‣ Scalaͱ͔ͦͷΜ
‣ ࠷ۙJavaΛݟͭͭ͋͠Δ
Agenda ‣ Aeromock is Կ ‣ AeromockΛࢧ͑Δٕज़ ‣ ࠓޙͷలʹ͍ͭͯ ‣
·ͱΊ
Aeromock is Կ
https://github.com/CyberAgent/aeromock
Aeromock is ‣ ScalaϞοΫαʔό ‣ JVMܥςϯϓϨʔτΤϯδϯͷελϒ ‣ Freemarker/Velocity/Groovy Templates etc
‣ JSON API ‣ Protocol Buffers
動作イメージ Aeromock Client 3FRVFTU )5.- σʔλϑΝΠϧ (JSON / YAML) ςϯϓϨʔτ
ϑΝΠϧ (FTLʣ
目指すところ ‣ ϑϩϯτ͕αʔόαΠυʹґଘͤͣʹ։ൃ ‣ ຊͷҙຯͰͷɺϑϩϯτΤϯυɾαʔόαΠυ ۀͷཱ֬ ‣ ઐྖҬͷ࡞ۀʹྗ ‣ লϦιʔε
‣ ࠶ىಈෆཁͰαΫαΫ։ൃ
Aeromockを支える技術
使ってる技術 ‣ Netty ‣ Javassist ‣ Groovy ‣ Gradle ‣
snakeyaml ‣ javax.el ‣ Scaldi
Netty ‣ http://netty.io/ ‣ Netty4ܥΛར༻ ‣ ͱʹ͔͘ബ͚Εബ͍΄Ͳ͍͍ͱ͍͏ߟ͑ ‣ ϨΠϠʔͷίϯτϩʔϧ͕͍͢͠
Javassist ‣ όΠτίʔυΤϯϋϯα ‣ ςϯϓϨ্Ͱϝιουίʔϧ͕͋ΔʢΫιʣ࣮ͱ͔ ੈؒʹͬͺΓ͋Δ ‣ σʔλϑΝΠϧͰඞཁͳϝιουఆٛΛͯ͠ɺಈత ʹΠϯελϯεʹ࣮ͤ͞Δ
<p>${target.execute()}</p> メソッド呼び出し(遺憾) target: __methods: - name: execute: value: shibuya_java <p>shibuya_java</p>
動的に追加されるメソッド public Object execute(Object[] args) { return “shibuya_java”; }
Groovy ‣ ϧʔςΟϯά੍ޚεΫϦϓτʢrouting.groovyʣͷDSLΛGroovy Ͱ࣮ ‣ ΧελϜλάϑΝϯΫγϣϯͷϞοΫ࣮ʹར༻ ‣ ࠶ىಈͳ͠ͰɺτϥΠΞϯυΤϥʔ͍ͨ͠εΫϦϓςΟϯάʹ ͔ͳΓ༗༻ ‣
ύϑΥʔϚϯεʹҙʢมߋ͕͋ͬͨͱ͖͚ͩύʔε͢Δ࣮ ʹͯ͠Δʣ ‣ groovy.util.GroovyScriptEngineͰ༰қʹΈࠐΊΔ
Gradle ‣ aeromock-brewʢύοέʔδϚωʔδϟʣͰར༻ ‣ https://github.com/CyberAgent/aeromock-brew ‣ gradlewΛ௨ͯ͠ɺMaven Central͔Βҙͷόʔ δϣϯΛΠϯετʔϧͰ͖Δ ‣
GradleͰॻ͚ΫϩεϓϥοτϑΥʔϜΛ͋Μ·Γ ҙࣝ͠ͳͯ͘ࡁΉ
snakeyaml ‣ https://code.google.com/p/snakeyaml/ ‣ JavaͷYAML࣮ ‣ σʔλϑΝΠϧͱͯ͠JSONʹՃ͑ɺYAMLΛ࠾༻ ͍ͯ͠ΔʢίϝϯτΛ༷ͱ͍ͯͨ͢͠͠Ίʣ
javax.el ‣ σʔλϑΝΠϧͷதͰɺมΛՃ͍ͨ͠Α͏ͳͱ ͖ɺELࣜͷൣᙝͰ͖ͳΑ͏ʹͰ͖Δ ‣ EL3.0ʢJSR-341ʣ ‣ org.glassfish:javax.el:3.0.0Λར༻ ‣ javax.el.ELProcessorΛ͑ɺׂͱ؆୯ʹಋೖͰ
͖Δ
form_data: name: ${FORM_DATA[‘name’].trim()} age: ${PARAMETERS[‘age’].trim()} comment: ${PARAMETERS[‘comment’].substring(0, 100)} ELར༻ྫ
protobuf-java ‣ protobufͷJava࣮ ‣ com.google.protobuf:protobuf-java:2.6.1 ‣ protobufͷόΠφϦΛੜ͢ΔͨΊʹར༻
protoparser ‣ https://github.com/square/protoparser ‣ protoϑΝΠϧͷύʔαʔ ‣ protobuf-javaʹύʔαʔແ͔ͬͨʢผ్ protocͰύʔεˠJavaͷίʔυΛੜ͢ΔͨΊʣ ‣ ύʔεͯ͠औಘͨ͠protobufͷߏͱɺσʔλϑΝ
ΠϧΛಥ͖߹ΘͤΔ
Scaldi ‣ http://scaldi.org/ ‣ Scala༻ͷܰྔͳDIϥΠϒϥϦ ‣ ࠷ॳDIແ͠Ͱ࣮͕ͯͨ͠ɺͩΜͩΜਏ͘ͳ͖ͬͯ ͨͷͰಋೖ
今後の展望について
φϏήʔγϣϯπʔϧ ‣ ݱঢ়ɺݟ͍ͨը໘ͷURLΛ͍͍ͪͪϒϥβʹೖྗ ͢Δඞཁ͕͋ΔͷͰλϧ͍ ‣ ԼͷςϯϓϨʔτΛϑΝΠϧπϦʔදࣔͯ͠ɺඈ ΔWeb UIΛ༻ҙ ‣ ࣍ͷϝδϟʔϦϦʔεͰͷೖΛ༧ఆ
Live Loading ‣ ςϯϓϨσʔλϑΝΠϧΛมߋͨ͠߹ɺ͍͍ͪ ͪϦϩʔυ͢Δͷ͕λϧ͍ ‣ grunt-contrib-watchͷAeromock൛Έ͍ͨͳ
テンプレートエンジン ‣ धཁͷߴͦ͏ͳςϯϓϨʔτΤϯδϯʹରԠ͢Δ ‣ ࣍Կ͕͍͍Ͱ͔͢Ͷ|шƅ)ŧŽŕ ‣ ಛఆͷόʔδϣϯʹ͕ͬͭΓґଘͯ͠͠·͍ͬͯΔ ͷͰɺ͏গ͠ϓϥΨϒϧͳߏʹ͍ͨ͠ʢOSGi ͷ࠾༻ͱ͔ʣ
テスト支援 ‣ ςϯϓϨʔτͱσʔλϑΝΠϧͷνΣοΫπʔϧ ‣ Ұಈ͘Α͏ʹ࡞ͬͨσʔλϑΝΠϧ͕ɺ์ஔ͞Ε ͯ؊৺ͳͱ͖ʹಈ͔ͳ͍ͳΜͯ͜ͱ͋Δ ‣ ܧଓతʹ࣭ΛอͯΔΈΛͭ͘Δ ‣ ࣮Ӆ͠ػೳͱͯ͠طʹ͋Δʢ·͍ͩʣ
まとめ
Javaで迷惑かけないようにしよう ‣ αʔόαΠυʹҾ͖ͣΒΕΔͱɺϑϩϯτΤϯδχ ΞͷJavaͷҹ͕ѱ͘ͳΔ ‣ Javaѱ͘ͳ͍ɻʢΫιʣϓϩδΣΫτ͕ѱ͍ ‣ ϑϩϯτΤϯδχΞʹจ۟ݴΘΕͳ͍ͨΊͷࢪࡦ͕ ඞཁ
ステッカー置いてきますね