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
Spring Scala : 스프링이 스칼라를 만났을 때
Search
Outsider
October 14, 2013
Technology
0
72
Spring Scala : 스프링이 스칼라를 만났을 때
Springcamp 2013 with Scala에서 발표한 발표자료
Outsider
October 14, 2013
Tweet
Share
More Decks by Outsider
See All by Outsider
당근 개발자 플랫폼은 어떤 문제를 해결하고 있는가?
outsider
1
3k
오픈소스에 기여할 때 알면 좋을 개발 프로세스
outsider
0
1.6k
DevOps를 가속화하는 플랫폼 엔지니어링
outsider
0
3.5k
클라우드 시대에 맞는 사이트 신뢰성 엔지니어
outsider
0
1.4k
디자인에 이어 코딩까지 AI가 프로그램 개발을 척척? : GitHub Copilot, 어디까지 알아보셨나요
outsider
0
1.4k
Citizen 개발기
outsider
0
910
오픈소스 뒤에 메인테이너 있어요
outsider
0
89
오픈소스에 기여할 때 해도 되는 일과 하면 안되는 일
outsider
0
63
Lessons from maintaining Mocha, an open source project
outsider
0
3k
Other Decks in Technology
See All in Technology
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
910
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
260
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
130
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
140
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.5k
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
160
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
710
Terraform Stacks入門 #HashiTalks
msato
0
360
複雑なState管理からの脱却
sansantech
PRO
1
160
Featured
See All Featured
A Philosophy of Restraint
colly
203
16k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
Typedesign – Prime Four
hannesfritz
40
2.4k
The Language of Interfaces
destraynor
154
24k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Designing for humans not robots
tammielis
250
25k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Transcript
4QSJOH4DBMB ݅լਸٸ झ݂ झணۄܳ 0VUTJEFS BU4QSJOH$BNQXJUI4DBMB
0VUTJEFS !0VUTJEFS PVUTJEFSJT!HNBJMDPN ٬ਸજইೞח۽Ӓېݠ ࠆल ۄझணۄ٬ױ '3&/%4١ীࢲഝز নೠӝࣿীҙब݆ IUUQCMPHPVUTJEFSOFLS࠶۽Ӓ
झணۄ۽ झ݂ۨਕܳ ࢎਊೡࣻחо ߊীࢲח
झ݂झணۄоযڃӝמਸਗೞחо पઁ۽झணۄীࢲझ݂ਸࢎਊೡٸח যڃगоחо ߊীࢲח
None
IUUQXXXGMJDLSDPNQIPUPTGBNJMZNXS ఆ۞ ਢۨਕחহ
झ݂ਸࢎਊೡࣻহਸө
4QSJOH
झ݂झணۄ IUUQTHJUIVCDPNTQSJOHQSPKFDUTTQSJOHTDBMB झணۄ۽झ݂ۨਕܳऔѱࢎਊೞب۾ W.
झணۄېझܳझ݂࠼ਵ۽োѾ झ݂మ݁ਸೣࣻഋधਵ۽ࢎਊ झணۄஸ۩࣌ਸઓࢿੑ +BWB$POGJHܳ4DBMB$POGJH झ݂झணۄ
झ݂࠼োزޙઁ
1 public class Person { 2 private String name; 3
4 public String getName() { 5 return this.name; 6 } 7 8 public void setName(String name) { 9 this.name = name; 10 } 11 }
झணۄח ߄࠼ӏডਸ ٮܰঋח
1 class Person { 2 var name:String = _ 3
}
1 class Person { 2 var name:String = _ 3
4 def name():String = name 5 def name_=(n:String) = name = n 6 }
1 public class Person { 2 private String name; 3
4 public String name() { 5 return this.name; 6 } 7 8 public void name_$eq(String name) { 9 this.name = name; 10 } 11 }
!#FBO1SPQFSUZ ೧Ѿ଼
1 import scala.beans.BeanProperty 2 3 class Person { 4 5
@BeanProperty 6 var name:String = _ 7 }
4QSJOH4DBMB ೧Ѿ଼
झ݂ #FBO*OGP'BDUPSZۚੋఠಕझࢎਊ
1 <repositories> 2 <repository> 3 <id>repository.springsource.milestone</id> 4 <name>SpringSource Milestone Repository</name>
5 <url>http://repo.springsource.org/milestone</url> 6 </repository> 7 </repositories> 8 9 <dependencies> 10 <dependency> 11 <groupId>org.springframework.scala</groupId> 12 <artifactId>spring-scala</artifactId> 13 <version>1.0.0.M2</version> 14 </dependency> 15 </dependencies>
झ݂మ݁
झ݂झணۄమ݁ ߔੋఠಕझ OVMM߈ജ ېझۄఠ ೣࣻ 0QUJPO߈ജ ېझݒפಁझ
4JNQMF+ECD5FNQMBUF +NT5FNQMBUF 3FTU5FNQMBUF 5SBOTBDUJPO5FNQMBUF
1 template.send("queue", 2 new MessageCreator() { 3 public Message createMessage(Session
session) 4 throws JMSException { 5 return session 6 .createTextMessage("Hello World"); 7 } 8 });
1 template.send("queue") { 2 session: Session => 3 session.createTextMessage("Hello World")
4 }
1 RestTemplate restTemplate = new RestTemplate(); 2 3 String result
= restTemplate 4 .getForObject( 5 "http://example.com", 6 String.class);
1 val restTemplate = new RestTemplate() 2 3 val result
= restTemplate 4 .getForAny[String] 5 ("http://example.com")
4DBMB$POGJH
9.- +BWB$POGJH
9.- +BWB$POGJH 4DBMB$POGJH
'VODUJPOBM$POGJHVSBUJPO
1 import org.springframework.scala. 2 context.function.FunctionalConfiguration 3 4 class ScalaExampleConfiguration 5
extends FunctionalConfiguration { 6 7 bean("foo") { 8 "Foo" 9 } 10 }
1 class ScalaExampleConfiguration 2 extends FunctionalConfiguration { 3 4 bean(
5 "foo", 6 aliases = Seq("bar") 7 scope = BeanDefinition.SCOPE_PROTOTYPE) { 8 "Foo" 9 } 10 }
1 class ScalaExampleConfiguration 2 extends FunctionalConfiguration { 3 4 prototype("foo")
{ 5 "Foo" 6 } 7 8 singleton("bar") { 9 "Bar" 10 } 11 }
1 class ScalaExampleConfiguration 2 extends FunctionalConfiguration { 3 4 val
conference = bean() { 5 val c = new Conference("SpringCamp") 6 c.when = "2013-10-13" 7 c.where = "ুझ" 8 c 9 } 10 11 bean("helloService") { 12 new HelloService(conference()) 13 } 14 }
'VODUJPOBM$POGJH"QQMJDBUJPO$POUFYU
1 import org.springframework.scala.context. 2! function.FunctionalConfigApplicationContext 3 4 object HelloApp extends
App { 5 val context = 6 FunctionalConfigApplicationContext[ScalaExampleConfiguration] 7 val helloService = context.getBean(classOf[HelloService]) 8 }
झ݂झணۄо ਵݶ झணۄ۽झ݂ਸ ॶࣻחо IUUQXXXGMJDLSDPNQIPUPTDIJDBHPBSUEFQBSUNFOU
झணۄ۽ झ݂۽ંܳ োزೞ۰ݶ ݆সਃೞ IUUQXXXGMJDLSDPNQIPUPTKPFTIMBCPUOJL
झ݂झணۄо೧חੌӓੌࠗ IUUQXXXGMJDLSDPNQIPUPTMFOPSFN
IUUQXXXGMJDLSDPNQIPUPTEVHTQS 4QSJOH 1FU$MJOJD http://docs.spring.io/docs/petclinic.html https://github.com/spring-projects/spring-petclinic/
.BWFO
1 <dependencies> 2 <dependency> 3 <groupId>org.scala-lang</groupId> 4 <artifactId>scala-library</artifactId> 5 <version>2.10.1</version>
6 </dependency> 7 </dependencies> झணۄۄ࠳۞ܻ୶о
TDBMBNBWFOQMVHJO ݫ࠵ীࢲझணۄஹੌ߂పझ WXJUITDBMBW
1 <plugin> 2 <groupId>net.alchim31.maven</groupId> 3 <artifactId>scala-maven-plugin</artifactId> 4 <version>3.1.6</version> 5 <executions>
6 <execution> 7 <id>scala-compile-first</id> 8 <phase>process-resources</phase> 9 <goals> 10 <goal>add-source</goal> 11 <goal>compile</goal> 12 </goals> 13 </execution> 14 <execution> 15 <id>scala-test-compile</id> 16 <phase>process-test-resources</phase> 17 <goals> 18 <goal>testCompile</goal> 19 </goals> 20 </execution> 21 <execution> 22 <phase>process-resources</phase> 23 <goals> 24 <goal>compile</goal> 25 </goals> 26 </execution> 27 </executions> 28 </plugin>
۽ંҳઑ TSD NBJO KBWB UFTU KBWB TSD NBJO KBWB UFTU
KBWB TDBMB TDBMB
झணۄېझ
1 class Pet { 2 private var name:String = _
3 4 def name():String = name 5 def name_=(n:String) = name = n 6 }
1 Pet pet = new Pet(); 2 pet.name_$eq(“Dog”); 3 String
n = pet.name();
য֢ప࣌
1 @Controller 2 @SessionAttributes("visit") 3 public class OwnerController { 4
@RequestMapping("/owners/{ownerId}") 5 public ModelAndView showOwner( 6 @PathVariable("ownerId") int ownerId) { 7 // .. 8 } 9 10 @RequestMapping( 11 value = "visits/new", 12 method = RequestMethod.GET) 13 public String initNewVisitForm() { 14 // .. 15 } 16 }
1 @Controller 2 @SessionAttributes(Array("visit")) 3 class OwnerController { 4 @RequestMapping(Array("/owners/{ownerId}"))
5 def showOwner( 6 @PathVariable("ownerId") ownerId:Int) = { 7 //.. 8 } 9 10 @RequestMapping( 11 value = Array("/visits/new"), 12 method = Array(RequestMethod.GET)) 13 def initNewVisitForm = { 14 // ... 15 } 16 }
1 @Controller 2 public class VisitController { 3 4 private
final ClinicService cs; 5 6 @Autowired 7 public VisitController(ClinicService cs) { 8 this.cs = cs; 9 } 10 }
1 @Controller 2 class VisitController @Autowired() (cs: ClinicService) { 3
}
য֢ప࣌ઓࢿয়ܨ
ஹੌद য֢ప࣌ীೠ ઓࢿਃೞ 4DBMBীࢲח೧Ѿؽ
<8"3/*/(>XBSOJOH$MBTT PSHKPEBDPOWFSU'SPN4USJOHOPUGPVOE DPOUJOVJOHXJUIBTUVC <8"3/*/(>XBSOJOH$BVHIU KBWBMBOH/VMM1PJOUFS&YDFQUJPO XIJMFQBSTJOHBOOPUBUJPOTJOKPEBUJNFKBS PSHKPEBUJNF%BUF5JNFDMBTT <&3303>FSSPSFSSPSXIJMFMPBEJOH%BUF5JNF DMBTTGJMFKPEBUJNFKBS
PSHKPEBUJNF%BUF5JNFDMBTT JTCSPLFO
1 org.joda.time.DateTime 2 3 @org.joda.convert.FromString 4 public static DateTime parse(String
s) {}
1 <dependency> 2 <groupId>org.joda</groupId> 3 <artifactId>joda-convert</artifactId> 4 <version>1.5</version> 5 </dependency>
KPEBUJNF
1 object Joda { 2 implicit 3 def dateTimeOrdering: Ordering[DateTime]
= 4 Ordering.fromLessThan(_ isBefore _) 5 } 1 import Joda._ 2 dateTimes.sorted
$PMMFDUJPOT
झணۄஸۑ࣌җ ߄ஸۑ࣌ ܰ
java.util. Collection List Map Set scala.collection.immutable. Iterable List Map Set
scala.collection.mutable. Iterable Map Set
1 import scala.collection.JavaConversions._ asJavaCollection asJavaDictionary asJavaEnumeration asJavaIterable asJavaIterator asScalaBuffer ...
ٸ۽ח ߄ېझܳ ࢎਊ
FSSPS PWFSMPBEFENFUIPEWBMVFRVFSZXJUIBMUFSOBUJWFT
য়ߡۄ٘ೞח҃ য়ߡ۽٬ػݫࢲ٘ܳഐೞח҃ ఋੑ࢚ࣘҳઑܳо҃
.PEFM"OE7JFX
1 def initFindForm( 2 model: Map[String, Object] 3 ) =
{} FSSPS PSHTQSJOHGSBNFXPSLCFBOT#FBO*OTUBOUJBUJPO&YDFQUJPO $PVMEOPUJOTUBOUJBUFCFBODMBTT <TDBMBDPMMFDUJPOJNNVUBCMF.BQ> 4QFDJGJFEDMBTTJTBOJOUFSGBDF
࠭
IUUQTHJUIVCDPNPVUTJEFSJTTQSJOHQFUDMJOJD
झணۄ۽झ݂ਸࢎਊೡࣻ झ݂חѨૐػۨਕ۽ ాೞҊաݶॶ݅೧ࠁੋ गח݅ఋੑয়ܨա߄৬ झணۄݽনܲगٜ ۨಌ۠झחѢহਵ۽गח ೧Ѿ೧ঠೠ
2VFTUJPOT IUUQXXXGMJDLSDPNQIPUPTPMJWBOEFS