Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Future on Servlet #scala_ks

Future on Servlet #scala_ks

A presentation which shows you what the pain points are when working with Scala Future on Servlet environment

Kazuhiro Sera

August 01, 2015
Tweet

More Decks by Kazuhiro Sera

Other Decks in Programming

Transcript

  1. 'VUVSFPO4FSWMFU
    ,B[VIJSP4FSB!TFSBUDI

    View full-size slide

  2. 8IPBN*
    w!TFSBUDI
    w4DBMJLF+%#$ʢʙʣ
    w4LJOOZ'SBNFXPSLʢʙʣ
    w4DBMBUSBɺKTPOTɺ4DBMBUF
    w. *OD4PGUXBSF%FWFMPQFS

    View full-size slide

  3. "HFOEB
    w8IZ'VUVSF
    w5ISFBEMPDBMUIJOHTJOUIFXJME
    w'VUVSFIBTJUTPXOUISFBEQPPM
    w4FSWMFU"1*`TNVUBCJMJUZ
    wSFDZDMJOHSFRVFTUJTTVFJOBTZODNPEF
    w4DBMBUSB%ZOBNJD4DPQFJTTVF
    w4LJOOZ`TTPMVUJPO

    View full-size slide

  4. )PXUPVTF'VUVSF
    w
    $SFBUJOHBOEDPNQPTJOHNVMUJQMF
    'VUVSFTBOEUIFO"XBJUSFTVMU 'VUVSF

    SFUVSOJOH4FSWMFUSFTQPOTFTZODISPOPVTMZ
    w
    3VOOJOH4FSWMFUTJOBTZODNPEF
    TVQQPSUFETJODF4FSWMFU

    View full-size slide

  5. 8IZ'VUVSF
    w6TJOH'VUVSFPO4FSWMFUJTOPUBMXBZT
    SFDPNNFOEFE
    w050) 'VUVSFJTUIFTUBOEBSEJO4DBMB
    OPX TPNFUJNFTOFFEFEUPTNPPUIMZ
    JOUFHSBUF'VUVSFCBTFEMJCSBSJFT
    w.ZOFBSB⒎BJSVTJOHOVMBCTDBMBPBVUI
    QSPWJEFSJOB4FSWMFUBQQMJDBUJPO

    View full-size slide

  6. 5ISFBEMPDBMUIJOHT
    JOUIFXJME

    View full-size slide

  7. 5ISFBEFENPEFM
    wPOFUISFBEGPSPOFSFRVFTU
    w"UISFBESFUVSOTBSFTQPOTFGPSBSFRVFTU
    w0OUIFTBNFUISFBEGPSXIPMFQSPDFTT
    w5ISFBEQPPMNBOBHFECZDPOUBJOFST
    w+BWB&&IBT+43UPTIPXIPXUPVTF
    DPODVSSFODZ

    View full-size slide

  8. 5ISFBE-PDBM
    w%ZOBNJD7BSJBCMFJO4DBMB
    w4PNFUJNFTIBWFBOFBTZUJNFPGJUCZ
    VTJOH5ISFBE-PDBMJGOPNVMUJUISFBEJOH
    w/POFFEUPUBLFTUBUFBSPVOEUPNFUIPET
    w"01GSJFOEMZ
    w*NQMJDJUTUBUFNBLFTDPEFTJNQMF

    View full-size slide

  9. 'VUVSFIBT
    JUTPXOUISFBEQPPM

    View full-size slide

  10. 'VUVSF
    w'VUVSFTDBMBEPD
    w'VUVSFBQQMZ\EJ⒎FSFOUUISFBEIFSF^
    w'VUVSFTVDDFTTGVM\TBNFUISFBEIFSF^
    w$BOFBTJMZDSFBUFBTZODPQFSBUJPOTUIBU
    SVOPOEJ⒎FSFOUUISFBETNBOBHFECZ
    UISFBEQPPM &YFDVUJPO$POUFYU

    w5PPFBTZUPBDDFTTpFMETPOUIF4FSWMFU
    UISFBEGSPN'VUVSFUISFBET

    View full-size slide

  11. 4FSWMFU"1*`TNVUBCJMJUZ

    View full-size slide

  12. 4FSWMFU"1*JTNVUBCMF
    w3FRVFTUTFU"UUSJCVUF 4USJOH "OZ3FG

    w*NQMFNFOUBUJPOQBUUFSOTUIBUEFQFOEPO
    SFRVFTUBUUSJCVUFT
    w0CKFDUTNBOBHFECZDPOUBJOFST
    w8SJUJOHSFTVMUWBMVFPOSFTQPOTFBOZUJNF
    w4JNQMZBDDFTTJOHUIFNBNPOHNVMUJQMF
    UISFBETJTTPGSBHJMF

    View full-size slide

  13. SFDZDMJOHSFRVFTUJTTVF
    JOBTZODNPEF

    View full-size slide

  14. +43+BWB4FSWMFU4QFDJpDBUJPO
    IUUQTKDQPSHFOKTSEFUBJM JE

    View full-size slide

  15. #VHSFRVFTUHFU$POUFYU1BUI
    JTOVMMXIFOXPSLJOHJOBTZODNPEF
    IUUQTCVHTFDMJQTFPSHCVHTTIPX@CVHDHJ JE
    +FUUZ

    View full-size slide

  16. #VH/VMM1PJOUFS&YDFQUJPOJOPSHBQBDIFDBUBMJOBDPOOFDUPS
    IUUQTC[BQBDIFPSHCVH[JMMBTIPX@CVHDHJ JED
    5PNDBU

    View full-size slide

  17. +43+BWB4FSWMFU4QFDJpDBUJPO
    IUUQTKDQPSHFOKTSEFUBJM JE

    View full-size slide

  18. SFDZDMJOHSFRVFTUT
    w*OGBDU SFRVFTUDBOCFSFDZDMFECFGPSF
    "TZOD$POUFYUDPNQMFUF

    w$POUBJOFSTDPNNPOMZEPUIFlSFDZDMFzJO
    PSEFSUPBWPJEQFSGPSNBODFPWFSIFBE
    w*G*VOEFSTUBOESJHIU FWFOUIPVHI4FSWMFU
    TQFDTBZTTBNFBCPVUSFTQPOTF

    SFTQPOTFXPO`UCFSFDZDMFEVOUJMJUT
    DMPTVSFBUMFBTUJODBTFTPGTUBUFMFTT)551

    View full-size slide

  19. 4DBMBUSB
    %ZOBNJD4DPQFJTTVF

    View full-size slide

  20. Too easy to access this value
    everywhere including Future
    threads created on this Servlet

    View full-size slide

  21. SFRVFTUSFTQPOTF
    w4DBMBUSB#BTF`TSFRVFTUSFTQPOTFBSF
    UISFBEMPDBM UPPEBOHFSPVTUPBDDFTT
    UIFNGSPN'VUVSFUISFBET
    w"MMUIF%4-BOEFYUFOTJPOTEPO`UBDDFQU
    SFRVFTUBTJNQMJDJUQBSBNFUFS
    w*OUIFJOJUJBMTUBUF UIJTEFTJHOJT
    SFBTPOBCMF 'VUVSFEJEO`UFYJTUBUUIFUJNF
    4JOBUSBDPODFQU

    View full-size slide

  22. 4LJOOZ`TTPMVUJPO

    View full-size slide

  23. TLJOOZFOHJOF

    View full-size slide

  24. TLJOOZFOHJOF
    w4UBSUFEBTB4DBMBUSBGPSL NVDIJNQSPWFE
    JOUFSOBMDPEFXIJMF%4-TPVSDF
    DPNQBUJCJMJUZJTLFQU
    w.BOZSFOBNJOHSFQBDLBHJOHBOEBGFX
    SFNPWBMPOUSBJUT
    w1BTTFEBMMUIF4DBMBUSB`TFYJTUJOHUFTUT
    w*`EMPWFUPDPOUSJCVUFTLJOOZFOHJOF`T
    JNQSPWFNFOUTUP4DBMBUSBUPP

    View full-size slide

  25. TUBCMFSFRVFTU

    View full-size slide

  26. TUBCMFSFRVFTU
    w4UBCMFBDDFTTUPSFBEPOMZEBUB SFRVFTU
    BUUSJCVUFTFWFOXIFOSFRVFTUIBTCFFO
    SFDZDMFEXIJMF'VUVSFPQTBSFTUJMMSVOOJOH
    w7BMJEBUFTVOTUBCMFBDDFTTUPPCKFDUT
    NBOBHFECZDPOUBJOFST .

    w4IPVMEXPSLBUMFBTUPO+FUUZBOE5PNDBU

    View full-size slide

  27. /PNPSF%ZOBNJD4DPQF

    View full-size slide

  28. /PNPSF%ZOBNJD4DPQF
    w1BTTTLJOOZFOHJOF$POUFYUBTJNQMJDJU
    QBSBNFUFSUPBMMUIF%4-"1*T
    w"TZOD4LJOOZ&OHJOF4FSWMFU'JMUFSBDDFQU
    $POUFYU
    "OZBTBDUJPOJOTUFBE
    w0O4DBMBUSBDPNQBUJCMFUSBJUT EFUFDU
    GSBHJMFDPEFCZDIFDLJOHDPNQJMBUJPO
    FSSPSTbFSSPSBNCJHVPVTJNQMJDJUWBMVFT`

    View full-size slide

  29. /FXBTZODUSBJU

    View full-size slide

  30. 4DBMBUSBDPNQBUJCMFUSBJU

    View full-size slide

  31. 0ILJOJ

    b5IBOLT`JO0TBLB

    View full-size slide