spring framework 3.2 > 4.0 — themes and trends

112
Spring Framework 3.2 4.0 Themes and Trends

Upload: yongkwon-park

Post on 11-Jul-2015

4.059 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Spring framework 3.2 > 4.0 — themes and trends

Spring����������� ������������������  Framework����������� ������������������  

➟����������� ������������������  3.2����������� ������������������  ➟����������� ������������������  4.0����������� ������������������  Themes����������� ������������������  and����������� ������������������  Trends

Page 2: Spring framework 3.2 > 4.0 — themes and trends

박용권����������� ������������������  /����������� ������������������  SK����������� ������������������  planet����������� ������������������  -����������� ������������������  Platform����������� ������������������  Software����������� ������������������  개발1팀

-����������� ������������������  한국����������� ������������������  스프링����������� ������������������  사용자����������� ������������������  모임(KSUG)

-����������� ������������������  라����������� ������������������  스칼라����������� ������������������  코딩단(La����������� ������������������  Scala����������� ������������������  Coding����������� ������������������  Dan)

-����������� ������������������  봄싹(SpringSprout)

Page 3: Spring framework 3.2 > 4.0 — themes and trends

2009.12.16 2012.12.132011.12.13

3.0 3.1 3.2

Page 4: Spring framework 3.2 > 4.0 — themes and trends

✔����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  3.2����������� ������������������  Update����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  기반����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  테스트����������� ������������������  프레임워크����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  @ControllerAdvice����������� ������������������  애노테이션����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  @MatrixVariable����������� ������������������  애노테이션����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  편리한����������� ������������������  서블릿����������� ������������������  컨텍스트����������� ������������������  초기화����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  Interceptor����������� ������������������  기능����������� ������������������  개선����������� ������������������  사항����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  @RequestBody����������� ������������������  기능����������� ������������������  개선����������� ������������������  사항����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  RestTemplat����������� ������������������  /����������� ������������������  @RequestBody의����������� ������������������  지네릭����������� ������������������  타입을����������� ������������������  지원����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  Content����������� ������������������  negotiation����������� ������������������  기능����������� ������������������  개선����������� ������������������  사항����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  기타����������� ������������������  지원����������� ������������������  및����������� ������������������  개선����������� ������������������  사항����������� ������������������  

!

✔����������� ������������������  Spring����������� ������������������  Core����������� ������������������  3.2����������� ������������������  Update����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  Java����������� ������������������  SE����������� ������������������  7����������� ������������������  /����������� ������������������  OpenJDK����������� ������������������  7에����������� ������������������  대한����������� ������������������  개선����������� ������������������  및����������� ������������������  지원����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  메타����������� ������������������  애노테이션을����������� ������������������  사용한����������� ������������������  빈����������� ������������������  정의����������� ������������������  및����������� ������������������  의존성����������� ������������������  주입����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  기타����������� ������������������  지원����������� ������������������  및����������� ������������������  개선����������� ������������������  사항����������� ������������������  

!

✔����������� ������������������  Next����������� ������������������  stop:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0

Page 5: Spring framework 3.2 > 4.0 — themes and trends

Spring����������� ������������������  MVC����������� ������������������  3.2����������� ������������������  

Update

Page 6: Spring framework 3.2 > 4.0 — themes and trends

서블릿����������� ������������������  3����������� ������������������  기반����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

Spring����������� ������������������  MVC����������� ������������������  Update

See����������� ������������������  Section����������� ������������������  17.3.4,����������� ������������������  "Asynchronous����������� ������������������  Request����������� ������������������  Processing".

✔����������� ������������������  @ReqeustMapping����������� ������������������  핸들러로����������� ������������������  대응����������� ������������������  

✔����������� ������������������  비동기����������� ������������������  처리를����������� ������������������  위한����������� ������������������  3가지����������� ������������������  유형의����������� ������������������  반환����������� ������������������  타입����������� ������������������  제공

Page 7: Spring framework 3.2 > 4.0 — themes and trends

~����������� ������������������  서블릿����������� ������������������  2.5����������� ������������������  :����������� ������������������  Thread����������� ������������������  per����������� ������������������  reqeust

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

브라우저 서블릿����������� ������������������  컨테이너

서블릿

스레드

Page 8: Spring framework 3.2 > 4.0 — themes and trends

~����������� ������������������  서블릿����������� ������������������  2.5����������� ������������������  :����������� ������������������  Thread����������� ������������������  per����������� ������������������  reqeust

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

브라우저 서블릿����������� ������������������  컨테이너

서블릿

블럭

Page 9: Spring framework 3.2 > 4.0 — themes and trends

~����������� ������������������  서블릿����������� ������������������  2.5����������� ������������������  :����������� ������������������  Thread����������� ������������������  per����������� ������������������  reqeust

서블릿

블럭데이터����������� ������������������  조회����������� ������������������  

(1초)

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

브라우저 서블릿����������� ������������������  컨테이너

Page 10: Spring framework 3.2 > 4.0 — themes and trends

서블릿����������� ������������������  3.0����������� ������������������  ~����������� ������������������  :����������� ������������������  비동기����������� ������������������  처리

서블릿

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

브라우저 서블릿����������� ������������������  컨테이너

스레드����������� ������������������  

반환

Page 11: Spring framework 3.2 > 4.0 — themes and trends

서블릿����������� ������������������  3.0����������� ������������������  ~����������� ������������������  :����������� ������������������  비동기����������� ������������������  처리

서블릿

워커����������� ������������������  스레드

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

브라우저 서블릿����������� ������������������  컨테이너

스레드����������� ������������������  

반환

Page 12: Spring framework 3.2 > 4.0 — themes and trends

서블릿����������� ������������������  3.0����������� ������������������  ~����������� ������������������  :����������� ������������������  비동기����������� ������������������  처리를����������� ������������������  위한����������� ������������������  반환����������� ������������������  타입

서블릿

����������� ������������������  ����������� ������������������  ✔����������� ������������������  java.util.concurrent.Callable<?>����������� ������������������  

����������� ������������������  ����������� ������������������  ✔����������� ������������������  org.springframework.web.**.DeferredResult<T>����������� ������������������  

����������� ������������������  ����������� ������������������  ✔����������� ������������������  org.springframework.web.**.AsyncTask

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

브라우저 서블릿����������� ������������������  컨테이너

Page 13: Spring framework 3.2 > 4.0 — themes and trends

Callable<?>을����������� ������������������  사용하는����������� ������������������  예제

@RequestMapping("/async/callable")public Callable<String> callableWithView(final Model model) { return new Callable<String>() { @Override public String call() throws Exception {! /* * 처리시간이 오래걸리는 일: * - 대량의 데이터 임포트 또는 익스포트(xls, cvs, etc) * - 외부 웹 서비스 자원과 연동(RESTful API, etc) * - 통계성 데이터 조회 * - etc */ return "view"; } };}

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

Page 14: Spring framework 3.2 > 4.0 — themes and trends

Callable<?>을����������� ������������������  사용하는����������� ������������������  예제

@RequestMapping("/async/callable")public Callable<String> callableWithView(final Model model) { return new Callable<String>() { @Override public String call() throws Exception {! /* * 처리시간이 오래걸리는 일: * - 대량의 데이터 임포트 또는 익스포트(xls, cvs, etc) * - 외부 웹 서비스 자원과 연동(RESTful API, etc) * - 통계성 데이터 조회 * - etc */ return "view"; } };}

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

Page 15: Spring framework 3.2 > 4.0 — themes and trends

Callable<?>을����������� ������������������  사용하는����������� ������������������  예제

@RequestMapping("/async/callable")public Callable<String> callableWithView(final Model model) { return new Callable<String>() { @Override public String call() throws Exception {! /* * 처리시간이 오래걸리는 일: * - 대량의 데이터 임포트 또는 익스포트(xls, cvs, etc) * - 외부 웹 서비스 자원과 연동(RESTful API, etc) * - 통계성 데이터 조회 * - etc */ return "view"; } };}

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

Page 16: Spring framework 3.2 > 4.0 — themes and trends

DeferredResult<T>를����������� ������������������  사용하는����������� ������������������  예제

final List<DeferredResult<String>> reqeusts = new CopyOnWriteArrayList();!@RequestMapping(method= RequestMethod.GET)public @ResponseBody DeferredResult<String> pullMessage() { final DeferredResult<String> deferredResult = new DeferredResult(null, ""); reqeusts.add(deferredResult);! deferredResult.onCompletion(new Runnable() { public void run() { reqeusts.remove(deferredResult); } });! return deferredResult;}!@RequestMapping(method=RequestMethod.POST)public @ResponseBody void postMessage(@RequestParam String message) { for(DeferredResult<String> deferredResult : reqeusts) { deferredResult.setResult(message); }}

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

Page 17: Spring framework 3.2 > 4.0 — themes and trends

DeferredResult<T>를����������� ������������������  사용하는����������� ������������������  예제

final List<DeferredResult<String>> reqeusts = new CopyOnWriteArrayList();!@RequestMapping(method= RequestMethod.GET)public @ResponseBody DeferredResult<String> pullMessage() { final DeferredResult<String> deferredResult = new DeferredResult(null, ""); reqeusts.add(deferredResult);! deferredResult.onCompletion(new Runnable() { public void run() { reqeusts.remove(deferredResult); } });! return deferredResult;}!@RequestMapping(method=RequestMethod.POST)public @ResponseBody void postMessage(@RequestParam String message) { for(DeferredResult<String> deferredResult : reqeusts) { deferredResult.setResult(message); }}

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

Page 18: Spring framework 3.2 > 4.0 — themes and trends

DeferredResult<T>를����������� ������������������  사용하는����������� ������������������  예제

final List<DeferredResult<String>> reqeusts = new CopyOnWriteArrayList();!@RequestMapping(method= RequestMethod.GET)public @ResponseBody DeferredResult<String> pullMessage() { final DeferredResult<String> deferredResult = new DeferredResult(null, ""); reqeusts.add(deferredResult);! deferredResult.onCompletion(new Runnable() { public void run() { reqeusts.remove(deferredResult); } });! return deferredResult;}!@RequestMapping(method=RequestMethod.POST)public @ResponseBody void postMessage(@RequestParam String message) { for(DeferredResult<String> deferredResult : reqeusts) { deferredResult.setResult(message); }}

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

Page 19: Spring framework 3.2 > 4.0 — themes and trends

DeferredResult<T>를����������� ������������������  사용하는����������� ������������������  예제

final List<DeferredResult<String>> reqeusts = new CopyOnWriteArrayList();!@RequestMapping(method= RequestMethod.GET)public @ResponseBody DeferredResult<String> pullMessage() { final DeferredResult<String> deferredResult = new DeferredResult(null, ""); reqeusts.add(deferredResult);! deferredResult.onCompletion(new Runnable() { public void run() { reqeusts.remove(deferredResult); } });! return deferredResult;}!@RequestMapping(method=RequestMethod.POST)public @ResponseBody void postMessage(@RequestParam String message) { for(DeferredResult<String> deferredResult : reqeusts) { deferredResult.setResult(message); }}

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

Page 20: Spring framework 3.2 > 4.0 — themes and trends

DeferredResult<T>를����������� ������������������  사용하는����������� ������������������  예제

final List<DeferredResult<String>> reqeusts = new CopyOnWriteArrayList();!@RequestMapping(method= RequestMethod.GET)public @ResponseBody DeferredResult<String> pullMessage() { final DeferredResult<String> deferredResult = new DeferredResult(null, ""); reqeusts.add(deferredResult);! deferredResult.onCompletion(new Runnable() { public void run() { reqeusts.remove(deferredResult); } });! return deferredResult;}!@RequestMapping(method=RequestMethod.POST)public @ResponseBody void postMessage(@RequestParam String message) { for(DeferredResult<String> deferredResult : reqeusts) { deferredResult.setResult(message); }}

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

Page 21: Spring framework 3.2 > 4.0 — themes and trends

DeferredResult<T>를����������� ������������������  사용하는����������� ������������������  예제

final List<DeferredResult<String>> reqeusts = new CopyOnWriteArrayList();!@RequestMapping(method= RequestMethod.GET)public @ResponseBody DeferredResult<String> pullMessage() { final DeferredResult<String> deferredResult = new DeferredResult(null, ""); reqeusts.add(deferredResult);! deferredResult.onCompletion(new Runnable() { public void run() { reqeusts.remove(deferredResult); } });! return deferredResult;}!@RequestMapping(method=RequestMethod.POST)public @ResponseBody void postMessage(@RequestParam String message) { for(DeferredResult<String> deferredResult : reqeusts) { deferredResult.setResult(message); }}

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

Page 22: Spring framework 3.2 > 4.0 — themes and trends

서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  처리를����������� ������������������  위한����������� ������������������  설정

<servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.**.DispatcherServlet</servlet-class> <async-supported>true</async-supported></servlet><servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>/</url-pattern></servlet-mapping>!<filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.**.CharacterEncodingFilter</filter-class> <async-supported>true</async-supported></filter><filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST, ASYNC, FORWARD</dispatcher></filter-mapping>

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  서블릿����������� ������������������  3����������� ������������������  비동기����������� ������������������  요청����������� ������������������  처리����������� ������������������  지원

Page 23: Spring framework 3.2 > 4.0 — themes and trends

Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

Spring����������� ������������������  MVC����������� ������������������  Update

✔����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  테스트����������� ������������������  지원����������� ������������������  및����������� ������������������  다양한����������� ������������������  API����������� ������������������  제공����������� ������������������  

✔����������� ������������������  테스트시����������� ������������������  서블릿����������� ������������������  컨테이너가����������� ������������������  필요없음����������� ������������������  

✔����������� ������������������  서버����������� ������������������  사이드����������� ������������������  테스트는����������� ������������������  DispatcherServlet����������� ������������������  포함����������� ������������������  

✔����������� ������������������  클라이언트����������� ������������������  사이드����������� ������������������  테스트는����������� ������������������  RestTemplate����������� ������������������  기반

See����������� ������������������  Section����������� ������������������  11.3.6,����������� ������������������  "Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  Framework".

Page 24: Spring framework 3.2 > 4.0 — themes and trends

MockMvc을����������� ������������������  이용한����������� ������������������  컨트롤러����������� ������������������  테스트

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

MockMvc mockMvc = MockMvcBuilders.standaloneSetup( new HelloController() ).build();!mockMvc.perform( get("/hello").param("name", "arawn") ) .andExpect(status().isOk()) .andExpect(content().string("안녕, arawn!"));

Page 25: Spring framework 3.2 > 4.0 — themes and trends

MockMvc을����������� ������������������  이용한����������� ������������������  컨트롤러����������� ������������������  테스트

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

MockMvc mockMvc = MockMvcBuilders.standaloneSetup( new HelloController() ).build();!mockMvc.perform( get("/hello").param("name", "arawn") ) .andExpect(status().isOk()) .andExpect(content().string("안녕, arawn!"));

Page 26: Spring framework 3.2 > 4.0 — themes and trends

MockMvc을����������� ������������������  이용한����������� ������������������  컨트롤러����������� ������������������  테스트

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

MockMvc mockMvc = MockMvcBuilders.standaloneSetup( new HelloController() ).build();!mockMvc.perform( get("/hello").param("name", "arawn") ) .andExpect(status().isOk()) .andExpect(content().string("안녕, arawn!"));

Page 27: Spring framework 3.2 > 4.0 — themes and trends

MockMvc을����������� ������������������  이용한����������� ������������������  컨트롤러����������� ������������������  테스트

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

MockMvc mockMvc = MockMvcBuilders.standaloneSetup( new HelloController() ).build();!mockMvc.perform( get("/hello").param("name", "arawn") ) .andExpect(status().isOk()) .andExpect(content().string("안녕, arawn!"));

Page 28: Spring framework 3.2 > 4.0 — themes and trends

서버����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제����������� ������������������  :����������� ������������������  standaloneSetup

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

HelloController helloController = new HelloController();!MockMvc mockMvc = MockMvcBuilders .standaloneSetup(helloController) .addFilters(...) .addInterceptors(...) .setMessageConverters(...) .setViewResolvers(...) .build(); // Test CodemockMvc.perform(get("/hello").param("name", "arawn")) .andExpect(status().isOk()) .andExpect(content().string("Hello, arawn!"));

Page 29: Spring framework 3.2 > 4.0 — themes and trends

서버����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제����������� ������������������  :����������� ������������������  standaloneSetup

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

HelloController helloController = new HelloController();!MockMvc mockMvc = MockMvcBuilders .standaloneSetup(helloController) .addFilters(...) .addInterceptors(...) .setMessageConverters(...) .setViewResolvers(...) .build(); // Test CodemockMvc.perform(get("/hello").param("name", "arawn")) .andExpect(status().isOk()) .andExpect(content().string("Hello, arawn!"));

Page 30: Spring framework 3.2 > 4.0 — themes and trends

서버����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제����������� ������������������  :����������� ������������������  standaloneSetup

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

HelloController helloController = new HelloController();!MockMvc mockMvc = MockMvcBuilders .standaloneSetup(helloController) .addFilters(...) .addInterceptors(...) .setMessageConverters(...) .setViewResolvers(...) .build(); // Test CodemockMvc.perform(get("/hello").param("name", "arawn")) .andExpect(status().isOk()) .andExpect(content().string("Hello, arawn!"));

Page 31: Spring framework 3.2 > 4.0 — themes and trends

서버����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제����������� ������������������  :����������� ������������������  standaloneSetup

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

HelloController helloController = new HelloController();!MockMvc mockMvc = MockMvcBuilders .standaloneSetup(helloController) .addFilters(...) .addInterceptors(...) .setMessageConverters(...) .setViewResolvers(...) .build(); // Test CodemockMvc.perform(get("/hello").param("name", "arawn")) .andExpect(status().isOk()) .andExpect(content().string("Hello, arawn!"));

Page 32: Spring framework 3.2 > 4.0 — themes and trends

서버����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제����������� ������������������  :����������� ������������������  standaloneSetup

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

HelloController helloController = new HelloController();!MockMvc mockMvc = MockMvcBuilders .standaloneSetup(helloController) .addFilters(...) .addInterceptors(...) .setMessageConverters(...) .setViewResolvers(...) .build(); // Test CodemockMvc.perform(get("/hello").param("name", "arawn")) .andExpect(status().isOk()) .andExpect(content().string("Hello, arawn!"));

Page 33: Spring framework 3.2 > 4.0 — themes and trends

서버����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제����������� ������������������  :����������� ������������������  webAppContextSetup

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(classes={ KSUGWebAppConfig.class })@WebAppConfigurationpublic class HelloControllerWebAppContextSetupTest {! @Autowired WebApplicationContext wac;! @Test public void testMVC() throws Exception {! MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(wac) .build();! // Test Code }!}

Page 34: Spring framework 3.2 > 4.0 — themes and trends

서버����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제����������� ������������������  :����������� ������������������  webAppContextSetup

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(classes={ KSUGWebAppConfig.class })@WebAppConfigurationpublic class HelloControllerWebAppContextSetupTest {! @Autowired WebApplicationContext wac;! @Test public void testMVC() throws Exception {! MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(wac) .build();! // Test Code }!}

Page 35: Spring framework 3.2 > 4.0 — themes and trends

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(classes={ KSUGWebAppConfig.class })@WebAppConfigurationpublic class HelloControllerWebAppContextSetupTest {! @Autowired WebApplicationContext wac;! @Test public void testMVC() throws Exception {! MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(wac) .build();! // Test Code }!}

서버����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제����������� ������������������  :����������� ������������������  webAppContextSetup

Page 36: Spring framework 3.2 > 4.0 — themes and trends

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(classes={ KSUGWebAppConfig.class })@WebAppConfigurationpublic class HelloControllerWebAppContextSetupTest {! @Autowired WebApplicationContext ! @Test public void testMVC() throws Exception {! MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(wac) .build();! // Test Code }!}

ServletContext가����������� ������������������  필요해요!

서버����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제����������� ������������������  :����������� ������������������  webAppContextSetup

Page 37: Spring framework 3.2 > 4.0 — themes and trends

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(classes={ KSUGWebAppConfig.class })@WebAppConfigurationpublic class HelloControllerWebAppContextSetupTest {! @Autowired WebApplicationContext wac;! MockMvc mockMvc;! @Test public void testMVC() throws Exception {! mockMvc = MockMvcBuilders.webAppContextSetup(wac) .build();! // Test Code }!}

"src/main/webapp"에서����������� ������������������  웹����������� ������������������  자원을����������� ������������������  획득

서버����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제����������� ������������������  :����������� ������������������  webAppContextSetup

Page 38: Spring framework 3.2 > 4.0 — themes and trends

클라이언트����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

RestTemplate restTemplate = new RestTemplate();!MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);!mockServer.expect(requestTo("/hello")) .andRespond(withSuccess("Hello KSUG!", MediaType.TEXT_PLAIN));!String result = restTemplate.getForObject("/hello", String.class);!mockServer.verify();assertThat(result, is("Hello KSUG!"));

Page 39: Spring framework 3.2 > 4.0 — themes and trends

클라이언트����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

RestTemplate restTemplate = new RestTemplate();!MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);!mockServer.expect(requestTo("/hello")) .andRespond(withSuccess("Hello KSUG!", MediaType.TEXT_PLAIN));!String result = restTemplate.getForObject("/hello", String.class);!mockServer.verify();assertThat(result, is("Hello KSUG!"));

Page 40: Spring framework 3.2 > 4.0 — themes and trends

클라이언트����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

RestTemplate restTemplate = new RestTemplate();!MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);!mockServer.expect(requestTo("/hello")) .andRespond(withSuccess("Hello KSUG!", MediaType.TEXT_PLAIN));!String result = restTemplate.getForObject("/hello", String.class);!mockServer.verify();assertThat(result, is("Hello KSUG!"));

Page 41: Spring framework 3.2 > 4.0 — themes and trends

클라이언트����������� ������������������  사이드����������� ������������������  테스트����������� ������������������  예제

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Spring����������� ������������������  MVC����������� ������������������  Test����������� ������������������  framework

RestTemplate restTemplate = new RestTemplate();!MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);!mockServer.expect(requestTo("/hello")) .andRespond(withSuccess("Hello KSUG!", MediaType.TEXT_PLAIN));!String result = restTemplate.getForObject("/hello", String.class);!mockServer.verify();assertThat(result, is("Hello KSUG!"));

Page 42: Spring framework 3.2 > 4.0 — themes and trends

@ControllerAdvice����������� ������������������  애노테이션

Spring����������� ������������������  MVC����������� ������������������  Update

✔����������� ������������������  컨트롤러����������� ������������������  계층내의����������� ������������������  @ReqeustMapping����������� ������������������  핸들러에����������� ������������������  적용����������� ������������������  

✔����������� ������������������  @ExceptionHandler,����������� ������������������  @InitBinder,����������� ������������������  @ModelAttribute����������� ������������������  

✔����������� ������������������  컴포넌트����������� ������������������  스캐닝을����������� ������������������  통해����������� ������������������  자동으로����������� ������������������  등록

See����������� ������������������  Section����������� ������������������  17,����������� ������������������  "Web����������� ������������������  MVC����������� ������������������  framework".

Page 43: Spring framework 3.2 > 4.0 — themes and trends

예제����������� ������������������  :����������� ������������������  @ControllerAdvice가����������� ������������������  없던����������� ������������������  시절에는����������� ������������������  로컬����������� ������������������  동작

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  @ControllerAdvice����������� ������������������  애노테이션

@Controllerpublic class ExampleController {! @InitBinder public void localInitBinder(WebDataBinder webDataBinder) { // webDataBinder.registerCustomEditor(requiredType, propertyEditor); }! @ModelAttribute("embeddedDatabaseTypes") public List<EmbeddedDatabaseType> localModelAttribute() { return Arrays.asList(EmbeddedDatabaseType.values()); }! @ExceptionHandler(IllegalStateException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) public @ResponseBody String exHandler(IllegalStateException exception) { return String.format("Local Error!"); }!}

Page 44: Spring framework 3.2 > 4.0 — themes and trends

예제����������� ������������������  :����������� ������������������  @ControllerAdvice를����������� ������������������  사용한����������� ������������������  전역����������� ������������������  설정

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  @ControllerAdvice����������� ������������������  애노테이션

@ControllerAdvicepublic class GolbalExceptionHandler {! @ExceptionHandler(Exception.class) public String default(Exception exception) { return String.format("Default Error: %s", exception.getMessage()); }! @ExceptionHandler(AjaxRequestExceptoin.class) @ResponseStatus(HttpStatus.BAD_REQUEST) public String ajax(AjaxRequestExceptoin exception) { return String.format("Ajax Error: %s", exception.getMessage()); }! // may also add globally applicable @InitBinder // and @ModelAttribute methods!}

Page 45: Spring framework 3.2 > 4.0 — themes and trends

@MatrixVariable����������� ������������������  애노테이션

Spring����������� ������������������  MVC����������� ������������������  Update

✔����������� ������������������  URI에서����������� ������������������  matrix����������� ������������������  variables����������� ������������������  추출����������� ������������������  후����������� ������������������  데이터����������� ������������������  바인등����������� ������������������  처리

see����������� ������������������  the����������� ������������������  section����������� ������������������  called����������� ������������������  "Matrix����������� ������������������  Variables".

Page 46: Spring framework 3.2 > 4.0 — themes and trends

예제����������� ������������������  :����������� ������������������  @MatrixVariable를����������� ������������������  사용한����������� ������������������  데이터����������� ������������������  바인딩

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  @MatrixVariable����������� ������������������  애노테이션

// GET /map/geo;latitude=37.517079;longitude=127.059631!@RequestMapping(value="/map/geo", method=RequestMethod.GET)public void mapView(@MatrixVariable BigDecimal latitude , @MatrixVariable BigDecimal longitude) {! // latitude == 37.517079 // longitude == 127.059631!}!!!// HandlerMapping.removeSemicolonContent = false

Page 47: Spring framework 3.2 > 4.0 — themes and trends

편리한����������� ������������������  서블릿����������� ������������������  컨텍스트����������� ������������������  초기화����������� ������������������  전략����������� ������������������  제공

Spring����������� ������������������  MVC����������� ������������������  Update

✔����������� ������������������  WebApplicationInitializer에����������� ������������������  대한����������� ������������������  추상����������� ������������������  구현체들...����������� ������������������  

✔����������� ������������������  AbstractDispatcherServletInitializer����������� ������������������  

✔����������� ������������������  AbstractAnnotationConfigDispatcherServletInitializer

See����������� ������������������  Section����������� ������������������  17.14,����������� ������������������  "Code-based����������� ������������������  Servlet����������� ������������������  container����������� ������������������  initialization".

Page 48: Spring framework 3.2 > 4.0 — themes and trends

예제����������� ������������������  :����������� ������������������  WebApplicationInitializer

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Convenient����������� ������������������  WebApplicationInitializer����������� ������������������  Base����������� ������������������  Class

class KSUGWebApplicationInitializer implements WebApplicationInitializer {! @Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext wac = new Annotation...Context(); wac.register(KSUGWebAppConfig.class);! ServletRegistration.Dynamic registration = servletContext .addServlet("dispatcher", new DispatcherServlet(wac)); registration.setLoadOnStartup(1); registration.addMapping("/"); }!}

Page 49: Spring framework 3.2 > 4.0 — themes and trends

예제����������� ������������������  :����������� ������������������  AbstractAnnotationConfigDispatcherServletInitializer

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Convenient����������� ������������������  WebApplicationInitializer����������� ������������������  Base����������� ������������������  Class

public class KSUGWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {! @Override protected Class<?>[] getRootConfigClasses() { return new Class<?>[0]; }! @Override protected Class<?>[] getServletConfigClasses() { return new Class<?>[]{ KSUGWebAppConfig.class }; }! @Override protected String[] getServletMappings() { return new String[]{ "/" }; }!}

Page 50: Spring framework 3.2 > 4.0 — themes and trends

예제����������� ������������������  :����������� ������������������  AbstractAnnotationConfigDispatcherServletInitializer

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  Convenient����������� ������������������  WebApplicationInitializer����������� ������������������  Base����������� ������������������  Class

public class KSUGWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {! @Override protected Class<?>[] getRootConfigClasses() { return new Class<?>[0]; }! @Override protected Class<?>[] getServletConfigClasses() { return new Class<?>[]{ KSUGWebAppConfig.class }; }! @Override protected String[] getServletMappings() { return new String[]{ "/" }; }!}

Page 51: Spring framework 3.2 > 4.0 — themes and trends

Interceptor����������� ������������������  기능����������� ������������������  개선����������� ������������������  사항

Spring����������� ������������������  MVC����������� ������������������  Update

✔����������� ������������������  URL����������� ������������������  제외����������� ������������������  패턴을����������� ������������������  기능����������� ������������������  추가����������� ������������������  

✔����������� ������������������  MVC����������� ������������������  namespace로����������� ������������������  설정����������� ������������������  가능����������� ������������������  

✔����������� ������������������  Java����������� ������������������  Config으로����������� ������������������  설정����������� ������������������  가능

See����������� ������������������  Section����������� ������������������  4,����������� ������������������  "New����������� ������������������  Features����������� ������������������  and����������� ������������������  Enhancements".

Page 52: Spring framework 3.2 > 4.0 — themes and trends

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  인터셉터에����������� ������������������  URL����������� ������������������  제외(Excluded)����������� ������������������  기능

예제����������� ������������������  :����������� ������������������  Java����������� ������������������  Config를����������� ������������������  통한����������� ������������������  URL����������� ������������������  제외@Configuration@EnableWebMvcpublic class InterceptorExampleConfig extends WebMvcConfigurerAdapter {! @Override public void addInterceptors(InterceptorRegistry registry) {! registry.addWebRequestInterceptor(new AllInterceptor());! registry.addWebRequestInterceptor(new IncludeInterceptor()) .addPathPatterns("/include");! registry.addWebRequestInterceptor(new ExcludedInterceptor()) .addPathPatterns("/**") .excludePathPatterns("/include/**");! }!}

Page 53: Spring framework 3.2 > 4.0 — themes and trends

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  인터셉터에����������� ������������������  URL����������� ������������������  제외(Excluded)����������� ������������������  기능

예제����������� ������������������  :����������� ������������������  MVC����������� ������������������  namespace를����������� ������������������  통한����������� ������������������  URL����������� ������������������  제외<mvc:interceptors>! <bean class="org.ksug.seminar.web.interceptor.AllInterceptor"/>! <mvc:interceptor> <mvc:mapping path="/include/**"/> <bean class="org.ksug.seminar.web.interceptor.IncludeInterceptor"/> </mvc:interceptor>! <mvc:interceptor> <mvc:mapping path="/**"/> <mvc:exclude-mapping path="/include/**"/> <bean class="org.ksug.seminar.web.interceptor.ExcludedInterceptor"/> </mvc:interceptor>!</mvc:interceptors>

Page 54: Spring framework 3.2 > 4.0 — themes and trends

@RequestBody����������� ������������������  기능����������� ������������������  개선����������� ������������������  사항

Spring����������� ������������������  MVC����������� ������������������  Update

✔����������� ������������������  유효성����������� ������������������  검사에����������� ������������������  대한����������� ������������������  결과로����������� ������������������  Errors����������� ������������������  받을����������� ������������������  수����������� ������������������  있음����������� ������������������  

✔����������� ������������������  required����������� ������������������  속성����������� ������������������  추가,����������� ������������������  기본값은����������� ������������������  true로����������� ������������������  설정

See����������� ������������������  Section����������� ������������������  4,����������� ������������������  "New����������� ������������������  Features����������� ������������������  and����������� ������������������  Enhancements".

Page 55: Spring framework 3.2 > 4.0 — themes and trends

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  @RequestBody����������� ������������������  기능����������� ������������������  개선����������� ������������������  사항

예제����������� ������������������  :����������� ������������������  @ReqeustBody에����������� ������������������  대한����������� ������������������  유효성����������� ������������������  검사@Controllerpublic class ReqeustBodyTestController {! @RequestMapping(value = "/rbt") @ResponseBody public Domain reqeustBodyTest(@RequestBody @Valid Domain domain , Errors errors) { if(errors.hasErrors()) { // 오류 처리 } // 로직 처리 return domain; }!}

Page 56: Spring framework 3.2 > 4.0 — themes and trends

RestTemplat����������� ������������������  /����������� ������������������  @RequestBody의����������� ������������������  지네릭����������� ������������������  타입을����������� ������������������  지원

Spring����������� ������������������  MVC����������� ������������������  Update

✔����������� ������������������  RestTemplate����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  ParameterizedTypeReference����������� ������������������  추가����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  exchange()����������� ������������������  메소드����������� ������������������  추가����������� ������������������  

✔����������� ������������������  @RequestBody����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  GenericHttpMessageConverter����������� ������������������  추가����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  Jaxb2CollectionHttpMessageConverter����������� ������������������  추가����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  MappingJacksonHttpMessageConverter����������� ������������������  변경

See����������� ������������������  Section����������� ������������������  4,����������� ������������������  "New����������� ������������������  Features����������� ������������������  and����������� ������������������  Enhancements".

Page 57: Spring framework 3.2 > 4.0 — themes and trends

Spring����������� ������������������  MVC����������� ������������������  Update����������� ������������������  :����������� ������������������  RestTemplate이����������� ������������������  지네릭����������� ������������������  타입을����������� ������������������  지원

예제����������� ������������������  :����������� ������������������  RestTemplate으로����������� ������������������  지네릭����������� ������������������  타입����������� ������������������  다루기public List<Player> getPlayers() { ParameterizedTypeReference<List<Player>> playersTypeRef = new ParameterizedTypeReference<List<Player>>(){};! ResponseEntity<List<Player>> responseEntity = restTemplate.exchange(playersJsonDataUrl , HttpMethod.GET , HttpEntity.EMPTY , playersTypeRef);! if(HttpStatus.OK == responseEntity.getStatusCode()) { return responseEntity.getBody(); }! return Collections.emptyList();}

Page 58: Spring framework 3.2 > 4.0 — themes and trends

Content����������� ������������������  negotiation에����������� ������������������  대한����������� ������������������  기능����������� ������������������  개선

Spring����������� ������������������  MVC����������� ������������������  Update

✔����������� ������������������  ContentNegotiationStrategy����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  file����������� ������������������  extension����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  Accept����������� ������������������  header����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  request����������� ������������������  parameter����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  fixed����������� ������������������  content����������� ������������������  type����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  custom����������� ������������������  strategy����������� ������������������  

✔����������� ������������������  ContentNegotiationManager����������� ������������������  

✔����������� ������������������  ContentNegotiationManagerFactoryBean

See����������� ������������������  Section����������� ������������������  17.5.4,����������� ������������������  "Configuring����������� ������������������  Content����������� ������������������  Negotiation".

Page 59: Spring framework 3.2 > 4.0 — themes and trends

기타����������� ������������������  지원����������� ������������������  및����������� ������������������  개선����������� ������������������  사항

Spring����������� ������������������  MVC����������� ������������������  Update

✔ Jackson����������� ������������������  JSON����������� ������������������  2����������� ������������������  라이브러리����������� ������������������  지원����������� ������������������  

✔ ResponseEntityExceptionHandler����������� ������������������  추가����������� ������������������  

✔ HTTP����������� ������������������  PATCH����������� ������������������  method����������� ������������������  지원����������� ������������������  

✔ Tiles����������� ������������������  3����������� ������������������  지원

See����������� ������������������  Section����������� ������������������  4,����������� ������������������  "New����������� ������������������  Features����������� ������������������  and����������� ������������������  Enhancements".

Page 60: Spring framework 3.2 > 4.0 — themes and trends

Spring����������� ������������������  Core����������� ������������������  3.2����������� ������������������  

Update

Page 61: Spring framework 3.2 > 4.0 — themes and trends

Java����������� ������������������  SE����������� ������������������  7����������� ������������������  /����������� ������������������  OpenJDK����������� ������������������  7에����������� ������������������  대한����������� ������������������  개선����������� ������������������  및����������� ������������������  지원

Spring����������� ������������������  Core����������� ������������������  Update

✔����������� ������������������  OpenJDK����������� ������������������  7����������� ������������������  기반으로����������� ������������������  빌드����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  Java����������� ������������������  5����������� ������������������  &����������� ������������������  6에����������� ������������������  대한����������� ������������������  호환성����������� ������������������  유지����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  Java����������� ������������������  7����������� ������������������  기반����������� ������������������  테스트����������� ������������������  및����������� ������������������  관련����������� ������������������  사항����������� ������������������  조정����������� ������������������  !✔����������� ������������������  ASM����������� ������������������  4.0,����������� ������������������  CGLIB����������� ������������������  3.0을����������� ������������������  함께����������� ������������������  제공����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  ASM����������� ������������������  및����������� ������������������  CGLIB����������� ������������������  라이브러리를����������� ������������������  Spring-core����������� ������������������  모듈에����������� ������������������  포함����������� ������������������  

����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  :����������� ������������������  Java����������� ������������������  7����������� ������������������  기반����������� ������������������  바이트����������� ������������������  코드����������� ������������������  포맷을����������� ������������������  지원����������� ������������������  

!

✔����������� ������������������  AspectJ����������� ������������������  1.7����������� ������������������  대응

Page 62: Spring framework 3.2 > 4.0 — themes and trends

의존성����������� ������������������  주입����������� ������������������  및����������� ������������������  @Bean에����������� ������������������  대한����������� ������������������  사용자����������� ������������������  정의����������� ������������������  애노테이션

Spring����������� ������������������  Core����������� ������������������  Update

@Bean @Lazy @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)@Retention(RetentionPolicy.RUNTIME)public @interface PrototypeBean { }!@PrototypeBeanpublic Object prototypeBean() { ... }!!@Value("#{systemProperties}")@Retention(RetentionPolicy.RUNTIME)public @interface SystemProperties { }!@SystemProperties Properties systemProperties;!!@Value("#{environment.getPropertySources().get(\"configProperties\")}")@Retention(RetentionPolicy.RUNTIME)public @interface ConfigPropertySource { }!@ConfigPropertySource PropertySource propertySource;

Page 63: Spring framework 3.2 > 4.0 — themes and trends

의존성����������� ������������������  주입����������� ������������������  및����������� ������������������  @Bean에����������� ������������������  대한����������� ������������������  사용자����������� ������������������  정의����������� ������������������  애노테이션

Spring����������� ������������������  Core����������� ������������������  Update

@Bean @Lazy @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)@Retention(RetentionPolicy.RUNTIME)public @interface PrototypeBean { }!@PrototypeBeanpublic Object prototypeBean() { ... }!!@Value("#{systemProperties}")@Retention(RetentionPolicy.RUNTIME)public @interface SystemProperties { }!@SystemProperties Properties systemProperties;!!@Value("#{environment.getPropertySources().get(\"configProperties\")}")@Retention(RetentionPolicy.RUNTIME)public @interface ConfigPropertySource { }!@ConfigPropertySource PropertySource propertySource;

Page 64: Spring framework 3.2 > 4.0 — themes and trends

의존성����������� ������������������  주입����������� ������������������  및����������� ������������������  @Bean에����������� ������������������  대한����������� ������������������  사용자����������� ������������������  정의����������� ������������������  애노테이션

Spring����������� ������������������  Core����������� ������������������  Update

@Bean @Lazy @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)@Retention(RetentionPolicy.RUNTIME)public @interface PrototypeBean { }!@PrototypeBeanpublic Object prototypeBean() { ... }!!@Value("#{systemProperties}")@Retention(RetentionPolicy.RUNTIME)public @interface SystemProperties { }!@SystemProperties Properties systemProperties;!!@Value("#{environment.getPropertySources().get(\"configProperties\")}")@Retention(RetentionPolicy.RUNTIME)public @interface ConfigPropertySource { }!@ConfigPropertySource PropertySource propertySource;

Page 65: Spring framework 3.2 > 4.0 — themes and trends

의존성����������� ������������������  주입����������� ������������������  및����������� ������������������  @Bean에����������� ������������������  대한����������� ������������������  사용자����������� ������������������  정의����������� ������������������  애노테이션

Spring����������� ������������������  Core����������� ������������������  Update

@Bean @Lazy @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)@Retention(RetentionPolicy.RUNTIME)public @interface PrototypeBean { }!@PrototypeBeanpublic Object prototypeBean() { ... }!!@Value("#{systemProperties}")@Retention(RetentionPolicy.RUNTIME)public @interface SystemProperties { }!@SystemProperties Properties systemProperties;!!@Value("#{environment.getPropertySources().get(\"configProperties\")}")@Retention(RetentionPolicy.RUNTIME)public @interface ConfigPropertySource { }!@ConfigPropertySource PropertySource propertySource;

Page 66: Spring framework 3.2 > 4.0 — themes and trends

의존성����������� ������������������  주입����������� ������������������  및����������� ������������������  @Bean에����������� ������������������  대한����������� ������������������  사용자����������� ������������������  정의����������� ������������������  애노테이션

Spring����������� ������������������  Core����������� ������������������  Update

@Bean @Lazy @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)@Retention(RetentionPolicy.RUNTIME)public @interface PrototypeBean { }!@PrototypeBeanpublic Object prototypeBean() { ... }!!@Value("#{systemProperties}")@Retention(RetentionPolicy.RUNTIME)public @interface SystemProperties { }!@SystemProperties Properties systemProperties;!!@Value("#{environment.getPropertySources().get(\"configProperties\")}")@Retention(RetentionPolicy.RUNTIME)public @interface ConfigPropertySource { }!@ConfigPropertySource PropertySource propertySource;

Page 67: Spring framework 3.2 > 4.0 — themes and trends

기타����������� ������������������  지원����������� ������������������  및����������� ������������������  개선����������� ������������������  사항

Spring����������� ������������������  Core����������� ������������������  Update

✔����������� ������������������  JCache����������� ������������������  0.5에����������� ������������������  대한����������� ������������������  조기����������� ������������������  지원����������� ������������������  ����������� ������������������  

✔����������� ������������������  Joda����������� ������������������  Time����������� ������������������  의존성����������� ������������������  없이����������� ������������������  @DateTimeFormat����������� ������������������  지원����������� ������������������  

✔����������� ������������������  날짜����������� ������������������  및����������� ������������������  시간����������� ������������������  포맷에����������� ������������������  대한����������� ������������������  전역����������� ������������������  설정����������� ������������������  

✔����������� ������������������  동시성����������� ������������������  처리에����������� ������������������  대한����������� ������������������  내부����������� ������������������  구조����������� ������������������  개선

See����������� ������������������  Section����������� ������������������  4,����������� ������������������  "New����������� ������������������  Features����������� ������������������  and����������� ������������������  Enhancements".

Page 68: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  

Spring����������� ������������������  Framework����������� ������������������  

4.0

Page 69: Spring framework 3.2 > 4.0 — themes and trends
Page 70: Spring framework 3.2 > 4.0 — themes and trends
Page 71: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0

Work����������� ������������������  Cloud����������� ������������������  -����������� ������������������  Next����������� ������������������  Stop:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  |����������� ������������������  SpringSource����������� ������������������  Team����������� ������������������  Blog

Page 72: Spring framework 3.2 > 4.0 — themes and trends

Lambda����������� ������������������  

Expressions����������� ������������������  

In����������� ������������������  Java����������� ������������������  8

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0

Page 73: Spring framework 3.2 > 4.0 — themes and trends

Lambda����������� ������������������  Expression����������� ������������������  in����������� ������������������  Java����������� ������������������  8

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Lambda����������� ������������������  Expressions

List<Player> players = playerDatabase.load();!players.stream() .filter( player -> "창원".equals(player.getCity()) && player.getRank() > 5 ) .sorted( (player1, player2) -> player1.getRank().compareTo(player2.getRank()) ) .forEach( player -> { System.out.println(String.format( "Player[name='%s', city='%s', rank=%d]", player.getName(), player.getCity(), player.getRank())); });

/* Console Output: * Player[name='정성용', city='창원', rank=9] * ... */

Page 74: Spring framework 3.2 > 4.0 — themes and trends

(����������� ������������������  ����������� ������������������  )����������� ������������������  ->����������� ������������������  {����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  }

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Lambda����������� ������������������  Expressions

Lambda����������� ������������������  Syntax

Input����������� ������������������  Parameters,����������� ������������������  if����������� ������������������  any

Expressions

Page 75: Spring framework 3.2 > 4.0 — themes and trends

Java����������� ������������������  Collections����������� ������������������  API����������� ������������������  +����������� ������������������  Anonymous����������� ������������������  Class

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Lambda����������� ������������������  Expressions

List<Player> players = Collections.emptyList();!Collections.sort(players, new Comparator<Player>() { public int compare(Player p1, Player p2) { return p1.getRank().compareTo(p2.getRank()); } });

Page 76: Spring framework 3.2 > 4.0 — themes and trends

Java����������� ������������������  Collections����������� ������������������  API����������� ������������������  +����������� ������������������  Anonymous����������� ������������������  Class

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Lambda����������� ������������������  Expressions

List<Player> players = playerDatabase.load();!Collections.sort(players, new Comparator<Player>() { public int compare(Player p1, Player p2) { return p1.getRank().compareTo(p2.getRank()); } });

Page 77: Spring framework 3.2 > 4.0 — themes and trends

Java����������� ������������������  Collections����������� ������������������  API����������� ������������������  +����������� ������������������  Anonymous����������� ������������������  Class

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Lambda����������� ������������������  Expressions

List<Player> players = playerDatabase.load();!Collections.sort(players, new Comparator<Player>() { public int compare(Player p1, Player p2) { return p1.getRank().compareTo(p2.getRank()); } });

(����������� ������������������  ����������� ������������������  )����������� ������������������  ->����������� ������������������  {����������� ������������������  ����������� ������������������  ����������� ������������������  ����������� ������������������  }

Page 78: Spring framework 3.2 > 4.0 — themes and trends

Java����������� ������������������  Collections����������� ������������������  API����������� ������������������  +����������� ������������������  Lambda����������� ������������������  Expression

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Lambda����������� ������������������  Expressions

List<Player> players = playerDatabase.load();!Collections.sort(players, new Comparator<Player>() { public int compare(Player p1, Player p2) { return p1.getRank().compareTo(p2.getRank()); } });!Collections.sort(players, (Player p1, Player p2) -> { return p1.getRank().compareTo(p2.getRank()); });

Page 79: Spring framework 3.2 > 4.0 — themes and trends

Java����������� ������������������  Collections����������� ������������������  API����������� ������������������  +����������� ������������������  Lambda����������� ������������������  Expression

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Lambda����������� ������������������  Expressions

List<Player> players = playerDatabase.load();!Collections.sort(players, new Comparator<Player>() { public int compare(Player p1, Player p2) { return p1.getRank().compareTo(p2.getRank()); } });!Collections.sort(players, (Player p1, Player p2) -> { return p1.getRank().compareTo(p2.getRank()); });

Page 80: Spring framework 3.2 > 4.0 — themes and trends

Java����������� ������������������  Collections����������� ������������������  API����������� ������������������  +����������� ������������������  Lambda����������� ������������������  Expression

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Lambda����������� ������������������  Expressions

List<Player> players = playerDatabase.load();!Collections.sort(players, new Comparator<Player>() { public int compare(Player p1, Player p2) { return p1.getRank().compareTo(p2.getRank()); } });!Collections.sort(players, (p1, p2) -> { p1.getRank().compareTo(p2.getRank()) });

Page 81: Spring framework 3.2 > 4.0 — themes and trends

Spring����������� ������������������  +����������� ������������������  

Lambda����������� ������������������  Expressions

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Lambda����������� ������������������  Expressions

Page 82: Spring framework 3.2 > 4.0 — themes and trends

Groovy-based����������� ������������������  

bean����������� ������������������  definitions

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0

Page 83: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Bean����������� ������������������  definitions(configuration)

<bean id="bean" class="org.ksug.Bean"> <property name="name" value="arawn"/></bean>

XML로����������� ������������������  작성된����������� ������������������  빈����������� ������������������  정의

@Beanpublic Object bean() { // Bean 생성 및 설정 return beanObject;}

Java����������� ������������������  Code로����������� ������������������  작성된����������� ������������������  빈����������� ������������������  정의

Page 84: Spring framework 3.2 > 4.0 — themes and trends

애노테이션으로����������� ������������������  얼룩진����������� ������������������  빈����������� ������������������  정의

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Bean����������� ������������������  definitions(configuration)

@Bean(destroyMethod = "close")@DependsOn({"otherBean1", "otherBean2"})@Lazypublic Object batchScheduler() { // Bean 생성 및 설정 return batchScheduler;}

Page 85: Spring framework 3.2 > 4.0 — themes and trends

Groovy

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Groovy-based����������� ������������������  bean����������� ������������������  definitions

Page 86: Spring framework 3.2 > 4.0 — themes and trends

JVM에서����������� ������������������  실행되는����������� ������������������  Dynamic����������� ������������������  Language

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Groovy

Page 87: Spring framework 3.2 > 4.0 — themes and trends

Scripting����������� ������������������  Language����������� ������������������  소스를����������� ������������������  컴파일하지����������� ������������������  않고����������� ������������������  

바로����������� ������������������  실행시키는...

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Groovy

Page 88: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Groovy

JAVA+����������� ������������������  Python����������� ������������������  

+����������� ������������������  Ruby����������� ������������������  

+����������� ������������������  Smalltalk

Page 89: Spring framework 3.2 > 4.0 — themes and trends

DSL����������� ������������������  지원과����������� ������������������  간결한����������� ������������������  문법����������� ������������������  (Domain-Specific����������� ������������������  Language)

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Groovy

Page 90: Spring framework 3.2 > 4.0 — themes and trends

동일한����������� ������������������  일을����������� ������������������  하는����������� ������������������  자바와����������� ������������������  그루비����������� ������������������  코드

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Groovy

public class HelloJava {! private String name;! public String getName() { return name; } public void setName(String name) { this.name = name; }! public String greet() { return "Hello " + name; }! public static void main(String[] args) { HelloJava helloJava = new HelloJava(); helloJava.setName("KSUG"); System.out.println(helloJava.greet()); }!}

class HelloGrovvy {! String name String greet() { "Hello $name" }! static main(args) { def helloWorld = new HelloGrovvy() helloWorld.name = "KSUG" println helloWorld.greet() }!}

자바 그루비

Page 91: Spring framework 3.2 > 4.0 — themes and trends

DSL����������� ������������������  ->����������� ������������������  Gradle����������� ������������������  build����������� ������������������  language

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Groovy

apply plugin: 'java'apply plugin: 'war'!sourceSets { main { java { srcDir 'src/java' } resources { srcDir 'src/resources' } }}!war { from 'src/rootContent' webInf { from 'src/additionalWebInf' } classpath fileTree('additionalLibs') webXml = file('src/someWeb.xml')}

Page 92: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0

JAVA����������� ������������������  EE����������� ������������������  7

Page 93: Spring framework 3.2 > 4.0 — themes and trends

WebSocket����������� ������������������  (JSR-356)

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  JAVA����������� ������������������  EE����������� ������������������  7

Page 94: Spring framework 3.2 > 4.0 — themes and trends

HTML5����������� ������������������  W3C/IETF����������� ������������������  표준����������� ������������������  

웹����������� ������������������  소켓����������� ������������������  프로토콜����������� ������������������  사용����������� ������������������  양방향����������� ������������������  통신

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  WebSocket(JSR-356)

Page 95: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  WebSocket(JSR-356)

웹����������� ������������������  소켓����������� ������������������  요청����������� ������������������  처리

브라우저 서버

연결(HTTP����������� ������������������  Protocol����������� ������������������  Upgrade)

지속적인����������� ������������������  데이터����������� ������������������  통신

WebSocket����������� ������������������  Frame

Page 96: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  WebSocket(JSR-356)

public class ChatEndpoint extends Endpoint {! @Override public void onOpen(Session session, EndpointConfiguration ec) { session.addMessageHandler( new MessageHandler.Async<String>() { @Override public void onMessage(String msg, boolean status) { ... } }); }! @Override public void onClose(Session session, CloseReason cr) { ... }! @Override public void onError(Session session, Throwable thr) { ... }!}

WebSocket����������� ������������������  API����������� ������������������  :����������� ������������������  Basic

Page 97: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  WebSocket(JSR-356)

@WebSocketEndpoint(value = "/chat", ... )public class ChatEndpoint {! @WebSocketOpen public void onOpen(Session session) { ... }! @WebSocketClose public void onClose(Session session) { ... }! @WebSocketMessage public void say(String message) { sessions.forEach( session -> session.getRemote().sendString(message) ); }}

WebSocket����������� ������������������  API����������� ������������������  :����������� ������������������  POJO����������� ������������������  +����������� ������������������  Annotations

Page 98: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  JAVA����������� ������������������  EE����������� ������������������  7

Servlet����������� ������������������  3.1����������� ������������������  (JSR-340)

Page 99: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Servlet����������� ������������������  3.1(JSR-340)

HTTP����������� ������������������  Protocol����������� ������������������  Upgrade����������� ������������������  API

Page 100: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Servlet����������� ������������������  3.1

서블릿����������� ������������������  컨테이너

웹����������� ������������������  소켓����������� ������������������  클라이언트

HTTP����������� ������������������  클라이언트

WebSocket����������� ������������������  HttpUpgradeHandler

서블릿

웹����������� ������������������  소켓����������� ������������������  핸들러

http://...

ws://...

HTTP와����������� ������������������  웹����������� ������������������  소켓을����������� ������������������  모두����������� ������������������  서블릿����������� ������������������  컨테이너가����������� ������������������  처리

Page 101: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Servlet����������� ������������������  3.1(JSR-340)

Non-Blocking����������� ������������������  I/O����������� ������������������  API

Page 102: Spring framework 3.2 > 4.0 — themes and trends

HTTP는����������� ������������������  요청과����������� ������������������  응답을����������� ������������������  반복

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Servlet����������� ������������������  3.1����������� ������������������  :����������� ������������������  Non-Blocking����������� ������������������  I/O

브라우저 서블릿����������� ������������������  컨테이너

요청

응답

요청

응답

요청

응답

Page 103: Spring framework 3.2 > 4.0 — themes and trends

웹����������� ������������������  소켓은����������� ������������������  연결을����������� ������������������  맺은����������� ������������������  후����������� ������������������  데이터����������� ������������������  송•수신

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Servlet����������� ������������������  3.1����������� ������������������  :����������� ������������������  Non-Blocking����������� ������������������  I/O

브라우저 서블릿����������� ������������������  컨테이너

WebSocket����������� ������������������  Frame

연결

Page 104: Spring framework 3.2 > 4.0 — themes and trends

브라우저와����������� ������������������  서블릿����������� ������������������  컨테이너를����������� ������������������  연결하는����������� ������������������  자원

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Servlet����������� ������������������  3.1����������� ������������������  :����������� ������������������  Non-Blocking����������� ������������������  I/O

브라우저 서블릿����������� ������������������  컨테이너

연결

연결����������� ������������������  종료

Page 105: Spring framework 3.2 > 4.0 — themes and trends

브라우저와����������� ������������������  서블릿����������� ������������������  컨테이너를����������� ������������������  연결하는����������� ������������������  자원

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Servlet����������� ������������������  3.1����������� ������������������  :����������� ������������������  Non-Blocking����������� ������������������  I/O

브라우저 서블릿����������� ������������������  컨테이너

연결

연결����������� ������������������  종료

데이터����������� ������������������  송•수신

Page 106: Spring framework 3.2 > 4.0 — themes and trends

브라우저와����������� ������������������  서블릿����������� ������������������  컨테이너를����������� ������������������  연결하는����������� ������������������  자원

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Servlet����������� ������������������  3.1����������� ������������������  :����������� ������������������  Non-Blocking����������� ������������������  I/O

브라우저 서블릿����������� ������������������  컨테이너

연결

연결����������� ������������������  종료

연결을����������� ������������������  유지하는����������� ������������������  자원

Page 107: Spring framework 3.2 > 4.0 — themes and trends

블럭킹����������� ������������������  I/O가����������� ������������������  가지고����������� ������������������  있는����������� ������������������  한계점

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Servlet����������� ������������������  3.1����������� ������������������  :����������� ������������������  Non-Blocking����������� ������������������  I/O

브라우저 서블릿����������� ������������������  컨테이너

연결

연결����������� ������������������  종료

연결부터����������� ������������������  종료까지����������� ������������������  관리

Page 108: Spring framework 3.2 > 4.0 — themes and trends

넌-블럭킹����������� ������������������  I/O로����������� ������������������  한계점을����������� ������������������  돌파

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  :����������� ������������������  Servlet����������� ������������������  3.1����������� ������������������  :����������� ������������������  Non-Blocking����������� ������������������  I/O

브라우저 서블릿����������� ������������������  컨테이너

연결

연결����������� ������������������  종료

자원을����������� ������������������  효율적으로����������� ������������������  사용

Page 109: Spring framework 3.2 > 4.0 — themes and trends

NEXT����������� ������������������  STOP:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0

Work����������� ������������������  Cloud����������� ������������������  -����������� ������������������  Next����������� ������������������  Stop:����������� ������������������  Spring����������� ������������������  Framework����������� ������������������  4.0����������� ������������������  |����������� ������������������  SpringSource����������� ������������������  Team����������� ������������������  Blog

Page 110: Spring framework 3.2 > 4.0 — themes and trends

Q����������� ������������������  &����������� ������������������  A

Page 111: Spring framework 3.2 > 4.0 — themes and trends
Page 112: Spring framework 3.2 > 4.0 — themes and trends

http://www.flickr.com/photos/wwworks/4759535950/

이미지����������� ������������������  출처(CCL)http://www.flickr.com/photos/seandreilinger/2326448445/