SlideShare uma empresa Scribd logo
1 de 56
Baixar para ler offline
Overview
of
Spring 4.0
박용권
: 한국 스프링 사용자 모임(KSUG)
: 봄싹(SpringSprout)
: 라 스칼라 코딩단
http://about.me/arawn
KSUG 일꾼단
: twitter / @arawnkr
: XML Namespace
: AspectJ
: @Component
1.0 배포, 그 후 10년
: Java 5+
: Java Configuration
: RESTful Support
2013/12/13 - 4.0

2009/12 - 3.0
2004/03 - 1.0
 2006/10 - 2.0

?
새로운
애플리케이션 아키텍처
✔ 마이크로 서비스 아키텍처(MSA)
✔ 비동기 기반 REST 서비스
✔ 경량 메시지 아키텍처
“스프링 4.0”
볼거리
✔ 자바 8 지원
✔ 자바 EE 6 및 7 지원
✔ 그루비 빈 정의 DSL
✔ 자바 웹소켓 API 지원
✔ 경량 메시지 아키텍처 지원
✔ REST Client 개발시 비동기 처리
✔ 그외 개선사항
✔ @Deprecated클래스및메소드삭제
Java 8
✔ lambda expressions
✔ method references
✔ JSR-310 Date and Time
✔ repeatable annotations
✔ parameter name discovery
: based on the -parameters compiler flag
지원 기능
동작 환경
✔ Java SE 6+ (JDK 6 update 10, ~2008)
✔ JDK 8 기반 애플리케이션은 4.0 이상 권장
lambda expressions & method references
✔ JdbcTemplate
: PreparedStatementSetter
void setValues(PreparedStatement ps) throws SQLException
: RowMapper
Object mapRow(ResultSet rs, int rowNum) throws SQLException
!
✔ JmsTemplate
: MessageCreator
Message createMessage(Session session) throws JMSException
!
✔ TransactionTemplate, TaskExecutor, etc
콜백 인터페이스(callback interfaces)에 적용 가능
lambda expressions syntax
(
 
 )
 -
 {
 
 
 
 }
Input
 Parameters,
 if
 any
Expressions
Lambdas with JdbcTemplate
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);	
!
ListPerson persons = jdbcTemplate.query(	
SELECT name, age FROM person where age = ?,	
new PreparedStatementSetter() {	
@Override	
public void setValues(PreparedStatement ps) throws SQLException {	
ps.setInt(1, 35);	
}	
},	
new RowMapperPerson() {	
@Override	
public Person mapRow(ResultSet rs, int rowNum) throws SQLException {	
return new Person(rs.getString(1), rs.getInt(2));	
}	
});
Lambdas with JdbcTemplate
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);	
!
ListPerson persons = jdbcTemplate.query(	
SELECT name, age FROM person where age = ?,	
new PreparedStatementSetter() {	
@Override	
public void setValues(PreparedStatement ps) throws SQLException {	
ps.setInt(1, 35);	
}	
},	
new RowMapperPerson() {	
@Override	
public Person mapRow(ResultSet rs, int rowNum) throws SQLException {	
return new Person(rs.getString(1), rs.getInt(2));	
}	
});
(
 
 )
 -
 {
 
 
 
 }
Lambdas with JdbcTemplate
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);	
!
ListPerson persons = jdbcTemplate.query(	
SELECT name, age FROM person where age = ?,	
(PreparedStatement ps) - { 	
ps.setInt(1, 35); 	
},	
(ResultSet rs, int rowNum) - { 	
return new Person(rs.getString(1), rs.getInt(2)); 	
}	
);
Lambdas with JdbcTemplate
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);	
!
ListPerson persons = jdbcTemplate.query(	
SELECT name, age FROM person where age = ?,	
(PreparedStatement ps) - { 	
ps.setInt(1, 35); 	
},	
(ResultSet rs, int rowNum) - { 	
return new Person(rs.getString(1), rs.getInt(2)); 	
}	
);	
!
ListPerson persons = jdbcTemplate.query(	
SELECT name, age FROM person where age = ?,	
ps - ps.setInt(1, 35),	
(rs, rowNum) - new Person(rs.getString(1), rs.getInt(2))	
);
Method References with JdbcTemplate
public ListPerson findAll() {	
return jdbcTemplate.query(SELECT name, age FROM person,	
new RowMapperPerson() {	
@Override	
public Person mapRow(ResultSet rs, int rowNum) throws SQLException {	
return new Person(rs.getString(1), rs.getInt(2));	
}	
});	
}
Method References with JdbcTemplate
public ListPerson findAll() {	
return jdbcTemplate.query(SELECT name, age FROM person,	
new RowMapperPerson() {	
@Override	
public Person mapRow(ResultSet rs, int rowNum) throws SQLException {	
return new Person(rs.getString(1), rs.getInt(2));	
}	
});	
}	
!
public Person mapRow(ResultSet rs, int rowNum) throws SQLException {	
return new Person(rs.getString(1), rs.getInt(2));	
}
Method References with JdbcTemplate
public ListPerson findAll() {	
return jdbcTemplate.query(SELECT name, age FROM person, this::mapRow);	
}	
!
 	
public Person mapRow(ResultSet rs, int rowNum) throws SQLException {	
return new Person(rs.getString(1), rs.getInt(2));	
}
JSR-310: Java의 새로운 날짜와 시간 API
✔ 'java.util.Date' 와 ' java.util.Calendar ' 대체
✔ 직관적이고 사용하기 쉬운 API
✔ 오픈소스 참고: Joda-Time, Time and Money, ICU 등
✔ hello world(NHN 개발자 블로그): Java의 날짜와 시간 API
JSR-310: 날짜와 시간 API 지원
✔ 날짜와 시간 타입에 대한 다양한 컨버터 / 포맷터 제공
: DateTimeConverters
: DateTimeFormatterRegistrar
: Jsr310DateTimeFormatAnnotationFormatterFactory
!
✔ @DateTimeFormat: 포맷팅을 손쉽게 설정
: java.util.Date
: java.util.Calendar
: java.long.Long
: Joda-Time
: JSR-310: java.time.*
JSR-310: 날짜와 시간 API 지원
import org.springframework.format.annotation.DateTimeFormat; 	
import java.time.*;	
	
@Controller	
public class JSR310Controller {	
	
@RequestMapping(value = /jsr310, params = localDate)	
@ResponseBody	
public LocalDate test(LocalDate localDate) {	
return localDate;	
}	
	
@RequestMapping(value = /jsr310, params = localDateTime)	
@ResponseBody	
public LocalDateTime test(@DateTimeFormat(pattern = yyyy-MM-dd HH:mm:ss) 	
LocalDateTime localDateTime) {	
return localDateTime;	
}	
	
}
반복적 애노테이션(@Repeatable)
@PropertySources({	
@PropertySource(classpath:META-INF/properties/environment.xml),	
@PropertySource(classpath:META-INF/properties/environment.properties)	
})	
class PropertySourceConfig {	
// ...	
}	
 	
@PropertySource(classpath:META-INF/properties/environment.xml)	
@PropertySource(classpath:META-INF/properties/environment.properties)	
class PropertySourceConfig {	
// ...	
} @Target(ElementType.TYPE)	
@Retention(RetentionPolicy.RUNTIME)	
@Documented	
@Repeatable(PropertySources.class)	
public @interface PropertySource {	
...	
}
Java EE
6 and 7
✔ JPA 2.1
✔ JTA 1.2
✔ JMS 2.0
✔ Bean Validation 1.1
✔ JSR-236 Concurrency Utilities
지원 명세
동작 환경
✔ Java EE 6+ 이상
✔ Servlet 2.5 도 호환되나, 3.0 이상 권장
그루비
빈 정의 DSL
✔ JVM에서 동작하는 동적 언어
✔ 컴파일 하지 않고 실행하는 스크립트 언어
✔ Java + Python, Ruby, Smalltalk
✔ 간결한 문법, 강력한 기능 그리고 DSL 지원
Groovy
빈 정의 DSL
✔ 간결한 문법으로 빈 정의
✔ XML NameSpace 기능 지원
Groovy DSL 로 빈 정의하기
import org.springframework.web.servlet.view.InternalResourceViewResolver	
import org.springframework.web.servlet.view.JstlView	
	
beans { 	
jstlViewResolver(InternalResourceViewResolver) {	
viewClass = JstlView	
prefix = /WEB-INF/views	
suffix = .jsp	
}	
}
bean id=jstlViewResolver 	
class=org.springframework.web.servlet.view.InternalResourceViewResolver	
property name=viewClass value=org.springframework.web.servlet.view.JstlView/	
property name=prefix value=/WEB-INF/views/	
property name=suffix value=.jsp/	
/bean
XML
Groovy DSL
Groovy DSL 로 XML NameSpace 사용하기
beans xmlns=http://www.springframework.org/schema/beans	
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance	
xmlns:context=http://www.springframework.org/schema/context	
xsi:schemaLocation=...	
!
context:component-scan base-package=jco.conference.oxquiz/ 	
	
/beans
XML
Groovy DSL
beans {	
xmlns context: 'http://www.springframework.org/schema/context'	
	
context.'component-scan'('base-package': 'jco.conference.oxquiz')	
}
Groovy DSL 로 Spring MVC 기본 설정
import org.springframework.web.servlet.view.InternalResourceViewResolver	
import org.springframework.web.servlet.view.JstlView	
	
beans {	
xmlns context: 'http://www.springframework.org/schema/context'	
xmlns mvc: 'http://www.springframework.org/schema/mvc'	
	
context.'component-scan'('base-package': 'jco.conference.oxquiz')	
	
mvc.'annotation-driven'()	
mvc.'default-servlet-handler'()	
	
mvc.'resources'('mapping': '/resources/**', 'location': '/resources/')	
	
jstlViewResolver(InternalResourceViewResolver) {	
viewClass = JstlView	
prefix = '/WEB-INF/views'	
suffix = '.jsp'	
}	
}
WebSocket
and
Messaging
✔ JSR 356: Java 웹소켓 API 지원
✔ SockJS: 웹소켓 미지원 브라우저 대응
spring-websocket module
spring-messaging module
✔ 메시지, 채널 등 추상화 모델 제공
✔ 고수준 메시지 프로토콜 STOMP 지원
✔ HTML5 표준
✔ API: W3C / 프로토콜: IETF
✔ 웹 소켓 프로토콜 사용
✔ 양방향 통신
JSR 356: Java WebSocket API
✔ Tomcat 7.0.47+ and 8.0
✔ Jetty 9.0 and 9.1
✔ WildFly 8.0 (JBoss Application Server)
✔ GlassFish 4.0
JSR 356: Java WebSocket API
WebSocketHandler 인터페이스
import org.springframework.web.socket.WebSocketHandler;	
import org.springframework.web.socket.WebSocketSession;	
import org.springframework.web.socket.WebSocketMessage;	
	
public class EchoHandler implements WebSocketHandler {	
	
@Override	
public void handleMessage(WebSocketSession session	
, WebSocketMessage? message) throws Exception {	
	
sessions.forEach(session - {	
try { session.sendMessage(message); }	
catch (IOException ignore) { }	
});	
	
}	
	
// 생략	
}
예제 코드 : http://goo.gl/SNzGQ2
WebSocket 활성화 및 WebSocketHandler 등록
import org.springframework.web.socket.config.annotation.EnableWebSocket;	
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;	
!
@Configuration	
@EnableWebSocket	
public class ExampleWebSocketConfig implements WebSocketConfigurer {	
 	
@Override	
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {	
registry.addHandler(echoHandler(), /websocket/echo);	
}	
 	
@Bean	
public EchoHandler echoHandler() {	
return new EchoHandler();	
}	
 	
}
예제 코드 : http://goo.gl/SNzGQ2
JavaScript: WebSocket Client
var echoUri = ws://ksug.org/websocket/echo;	
var websocket = new WebSocket(echoUri);	
!
// 접속, 접속종료, 메시지 수신, 오류 이벤트 처리 	
websocket.onopen = function(event) {	
};	
websocket.onclose = function(event) {	
};	
websocket.onmessage = function(event) {	
};	
websocket.onerror = function(event) {	
};	
!
// 메세지 전송	
websocket.send(message!);
예제 코드 : http://goo.gl/iAcbX6
Can I use WebSockets?
✔ Chrome 14.0+ (Current 32.0)
✔ Safari 6.0+ (Current 7.0)
✔ Firefox 11.0+ (Current 27.0)
✔ Internet Explorer 10.0+ (Current 11.0)
✔ iOS Safari 6.0+ (Current 7.0)
✔ Android Browser 4.4
!
!
!
!
!
!
JavaScript로
브라우저 종류에 상관없이
실시간 웹 구현 기술
SockJS 는...
✔ SockJS-client JavaScript client library
✔ SockJS-node Node.js server
✔ SockJS-erlang Erlang server
✔ SockJS-tornado Python server
✔ SockJS-twisted Python server
✔ vert.x Java/vert.x server
✔ SockJS-cyclone Python server
SockJS family
✔ WebSocket
✔ AJAX long polling
✔ AJAX multipart streaming
✔ Forever Iframe
✔ JSONP Polling
지원 기술
SockJS WebSocketHandler 등록하기
@Configuration	
@EnableWebSocket	
public class ExampleWebSocketConfig implements WebSocketConfigurer {	
 	
@Override	
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {	
registry.addHandler(echoHandler(), /websocket/echo).withSockJS();	
}	
 	
@Bean	
public EchoHandler echoHandler() {	
return new EchoHandler();	
}	
 	
}
예제 코드 : http://goo.gl/SNzGQ2
JavaScript: SockJS Client
var echoUri = /websocket/echo/sockjs;	
var sock = new SockJS(echoUri);	
!
// 접속, 접속종료, 메시지 수신, 오류 이벤트 처리 	
sock.onopen = function(event) {	
};	
sock.onclose = function(event) {	
};	
sock.onmessage = function(event) {	
};	
sock.onerror = function(event) {	
};	
!
// 메시지 전송	
sock.send(message!);
예제 코드 : http://goo.gl/iAcbX6
!
!
!
!
!
!
Streaming
Text Oriented
Message Protocol
STOMP 는...
✔ Apache ActiveMQ
✔ RabbitMQ
✔ HornetQ
✔ stomp.erl (Erlang)
✔ Stomp.py (Python)
✔ etc
Server-side
✔ stomp.js
✔ msgs.js
Client-side
STOMP Message 처리
import org.springframework.stereotype.Controller;	
import org.springframework.messaging.handler.annotation.MessageMapping;	
import org.springframework.messaging.Message;	
 	
@Controller	
public class EchoController {	
 	
@Autowired	
private SimpMessageSendingOperations messagingTemplate;	
 	
@MessageMapping(/echo)	
public void echo(MessageString message) {	
messagingTemplate.send(/topic/echo, message);	
}	
 	
}
예제 코드 : http://goo.gl/SNzGQ2
STOMP 활성화 및 설정
@Configuration	
@EnableWebSocketMessageBroker	
public class ExampleWebSocketConfig implements WebSocketMessageBrokerConfigurer {	
 	
@Override	
public void registerStompEndpoints(StompEndpointRegistry registry) {	
registry.addEndpoint(/websocket/endpoint/stomp);	
}	
 	
@Override	
public void configureMessageBroker(MessageBrokerRegistry registry) {	
registry.setApplicationDestinationPrefixes(/stomp);	
registry.enableSimpleBroker(/topic/);	
}	
 	
@Bean	
public EchoController echoController() {	
return new EchoController();	
} 	
}
예제 코드 : http://goo.gl/SNzGQ2

Mais conteúdo relacionado

Mais procurados

Spring mvc
Spring mvcSpring mvc
Spring mvcksain
 
실전! 스프링과 함께하는 환경변수 관리 변천사 발표자료
실전! 스프링과 함께하는 환경변수 관리 변천사 발표자료실전! 스프링과 함께하는 환경변수 관리 변천사 발표자료
실전! 스프링과 함께하는 환경변수 관리 변천사 발표자료수홍 이
 
Spring MVC
Spring MVCSpring MVC
Spring MVCymtech
 
Spring 4.x Web Application 살펴보기
Spring 4.x Web Application  살펴보기Spring 4.x Web Application  살펴보기
Spring 4.x Web Application 살펴보기Ji Heon Kim
 
[오픈소스컨설팅]Spring MVC
[오픈소스컨설팅]Spring MVC [오픈소스컨설팅]Spring MVC
[오픈소스컨설팅]Spring MVC Ji-Woong Choi
 
이벤트 기반 분산 시스템을 향한 여정
이벤트 기반 분산 시스템을 향한 여정이벤트 기반 분산 시스템을 향한 여정
이벤트 기반 분산 시스템을 향한 여정Arawn Park
 
Resource Handling in Spring MVC
Resource Handling in Spring MVCResource Handling in Spring MVC
Resource Handling in Spring MVCArawn Park
 
스프링 어플리케이션의 문제해결사례와 안티패턴
스프링 어플리케이션의 문제해결사례와 안티패턴스프링 어플리케이션의 문제해결사례와 안티패턴
스프링 어플리케이션의 문제해결사례와 안티패턴Sanghyuk Jung
 
Spring-Boot (springcamp2014)
Spring-Boot (springcamp2014)Spring-Boot (springcamp2014)
Spring-Boot (springcamp2014)sung yong jung
 
Spring 웹 프로젝트 시작하기
Spring 웹 프로젝트 시작하기Spring 웹 프로젝트 시작하기
Spring 웹 프로젝트 시작하기jiseob kim
 
Spring boot 5장 cli
Spring boot 5장 cliSpring boot 5장 cli
Spring boot 5장 cliChoonghyun Yang
 
[115] clean fe development_윤지수
[115] clean fe development_윤지수[115] clean fe development_윤지수
[115] clean fe development_윤지수NAVER D2
 
스프링캠프 2016 발표 - Deep dive into spring boot autoconfiguration
스프링캠프 2016 발표 - Deep dive into spring boot autoconfiguration스프링캠프 2016 발표 - Deep dive into spring boot autoconfiguration
스프링캠프 2016 발표 - Deep dive into spring boot autoconfiguration수홍 이
 
Spring one참석기 ksug
Spring one참석기 ksugSpring one참석기 ksug
Spring one참석기 ksugSanghyuk Jung
 
React 튜토리얼 2차시
React 튜토리얼 2차시React 튜토리얼 2차시
React 튜토리얼 2차시태현 김
 
Spring camp 발표자료
Spring camp 발표자료Spring camp 발표자료
Spring camp 발표자료수홍 이
 
XECon2015 :: [2-2] 박상현 - React로 개발하는 SPA 실무 이야기
XECon2015 :: [2-2] 박상현 - React로 개발하는 SPA 실무 이야기XECon2015 :: [2-2] 박상현 - React로 개발하는 SPA 실무 이야기
XECon2015 :: [2-2] 박상현 - React로 개발하는 SPA 실무 이야기XpressEngine
 
Nodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjsNodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjs기동 이
 
자바 웹 개발 시작하기 (5주차 : 스프링 프래임워크)
자바 웹 개발 시작하기 (5주차 : 스프링 프래임워크)자바 웹 개발 시작하기 (5주차 : 스프링 프래임워크)
자바 웹 개발 시작하기 (5주차 : 스프링 프래임워크)DK Lee
 

Mais procurados (20)

Spring mvc
Spring mvcSpring mvc
Spring mvc
 
실전! 스프링과 함께하는 환경변수 관리 변천사 발표자료
실전! 스프링과 함께하는 환경변수 관리 변천사 발표자료실전! 스프링과 함께하는 환경변수 관리 변천사 발표자료
실전! 스프링과 함께하는 환경변수 관리 변천사 발표자료
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Spring Boot 1
Spring Boot 1Spring Boot 1
Spring Boot 1
 
Spring 4.x Web Application 살펴보기
Spring 4.x Web Application  살펴보기Spring 4.x Web Application  살펴보기
Spring 4.x Web Application 살펴보기
 
[오픈소스컨설팅]Spring MVC
[오픈소스컨설팅]Spring MVC [오픈소스컨설팅]Spring MVC
[오픈소스컨설팅]Spring MVC
 
이벤트 기반 분산 시스템을 향한 여정
이벤트 기반 분산 시스템을 향한 여정이벤트 기반 분산 시스템을 향한 여정
이벤트 기반 분산 시스템을 향한 여정
 
Resource Handling in Spring MVC
Resource Handling in Spring MVCResource Handling in Spring MVC
Resource Handling in Spring MVC
 
스프링 어플리케이션의 문제해결사례와 안티패턴
스프링 어플리케이션의 문제해결사례와 안티패턴스프링 어플리케이션의 문제해결사례와 안티패턴
스프링 어플리케이션의 문제해결사례와 안티패턴
 
Spring-Boot (springcamp2014)
Spring-Boot (springcamp2014)Spring-Boot (springcamp2014)
Spring-Boot (springcamp2014)
 
Spring 웹 프로젝트 시작하기
Spring 웹 프로젝트 시작하기Spring 웹 프로젝트 시작하기
Spring 웹 프로젝트 시작하기
 
Spring boot 5장 cli
Spring boot 5장 cliSpring boot 5장 cli
Spring boot 5장 cli
 
[115] clean fe development_윤지수
[115] clean fe development_윤지수[115] clean fe development_윤지수
[115] clean fe development_윤지수
 
스프링캠프 2016 발표 - Deep dive into spring boot autoconfiguration
스프링캠프 2016 발표 - Deep dive into spring boot autoconfiguration스프링캠프 2016 발표 - Deep dive into spring boot autoconfiguration
스프링캠프 2016 발표 - Deep dive into spring boot autoconfiguration
 
Spring one참석기 ksug
Spring one참석기 ksugSpring one참석기 ksug
Spring one참석기 ksug
 
React 튜토리얼 2차시
React 튜토리얼 2차시React 튜토리얼 2차시
React 튜토리얼 2차시
 
Spring camp 발표자료
Spring camp 발표자료Spring camp 발표자료
Spring camp 발표자료
 
XECon2015 :: [2-2] 박상현 - React로 개발하는 SPA 실무 이야기
XECon2015 :: [2-2] 박상현 - React로 개발하는 SPA 실무 이야기XECon2015 :: [2-2] 박상현 - React로 개발하는 SPA 실무 이야기
XECon2015 :: [2-2] 박상현 - React로 개발하는 SPA 실무 이야기
 
Nodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjsNodejs, PhantomJS, casperJs, YSlow, expressjs
Nodejs, PhantomJS, casperJs, YSlow, expressjs
 
자바 웹 개발 시작하기 (5주차 : 스프링 프래임워크)
자바 웹 개발 시작하기 (5주차 : 스프링 프래임워크)자바 웹 개발 시작하기 (5주차 : 스프링 프래임워크)
자바 웹 개발 시작하기 (5주차 : 스프링 프래임워크)
 

Destaque

조금 더 좋은 개발자가 된다는 것( 부제: 컨퍼런스의 발표자가 된다는 것 )
조금 더 좋은 개발자가 된다는 것( 부제: 컨퍼런스의 발표자가 된다는 것 )조금 더 좋은 개발자가 된다는 것( 부제: 컨퍼런스의 발표자가 된다는 것 )
조금 더 좋은 개발자가 된다는 것( 부제: 컨퍼런스의 발표자가 된다는 것 )Arawn Park
 
씹고 뜯고 맛보고 즐기는 스트림 API
씹고 뜯고 맛보고 즐기는 스트림 API씹고 뜯고 맛보고 즐기는 스트림 API
씹고 뜯고 맛보고 즐기는 스트림 APIArawn Park
 
Spring framework 4.x
Spring framework 4.xSpring framework 4.x
Spring framework 4.xArawn Park
 
[Spring Camp 2013] Java Configuration 없인 못살아!
[Spring Camp 2013] Java Configuration 없인 못살아![Spring Camp 2013] Java Configuration 없인 못살아!
[Spring Camp 2013] Java Configuration 없인 못살아!Arawn Park
 
[0119 박민근] 기술 면접시 자주 나오는 문제들(ver 2013)
[0119 박민근] 기술 면접시 자주 나오는 문제들(ver 2013)[0119 박민근] 기술 면접시 자주 나오는 문제들(ver 2013)
[0119 박민근] 기술 면접시 자주 나오는 문제들(ver 2013)MinGeun Park
 
Vagrant와 chef로 개발서버 구축 자동화하기
Vagrant와 chef로 개발서버 구축 자동화하기Vagrant와 chef로 개발서버 구축 자동화하기
Vagrant와 chef로 개발서버 구축 자동화하기Arawn Park
 
소프트웨어 아키텍처
소프트웨어 아키텍처소프트웨어 아키텍처
소프트웨어 아키텍처영기 김
 
개발자 이승우 이력서 (2016)
개발자 이승우 이력서 (2016)개발자 이승우 이력서 (2016)
개발자 이승우 이력서 (2016)SeungWoo Lee
 
포트폴리오 오경원
포트폴리오 오경원포트폴리오 오경원
포트폴리오 오경원Sio Oh
 

Destaque (10)

조금 더 좋은 개발자가 된다는 것( 부제: 컨퍼런스의 발표자가 된다는 것 )
조금 더 좋은 개발자가 된다는 것( 부제: 컨퍼런스의 발표자가 된다는 것 )조금 더 좋은 개발자가 된다는 것( 부제: 컨퍼런스의 발표자가 된다는 것 )
조금 더 좋은 개발자가 된다는 것( 부제: 컨퍼런스의 발표자가 된다는 것 )
 
씹고 뜯고 맛보고 즐기는 스트림 API
씹고 뜯고 맛보고 즐기는 스트림 API씹고 뜯고 맛보고 즐기는 스트림 API
씹고 뜯고 맛보고 즐기는 스트림 API
 
Spring framework 4.x
Spring framework 4.xSpring framework 4.x
Spring framework 4.x
 
[Spring Camp 2013] Java Configuration 없인 못살아!
[Spring Camp 2013] Java Configuration 없인 못살아![Spring Camp 2013] Java Configuration 없인 못살아!
[Spring Camp 2013] Java Configuration 없인 못살아!
 
[0119 박민근] 기술 면접시 자주 나오는 문제들(ver 2013)
[0119 박민근] 기술 면접시 자주 나오는 문제들(ver 2013)[0119 박민근] 기술 면접시 자주 나오는 문제들(ver 2013)
[0119 박민근] 기술 면접시 자주 나오는 문제들(ver 2013)
 
스프링컨트롤러예외처리,@ExceptionHandler, @ControllerAdvice
스프링컨트롤러예외처리,@ExceptionHandler, @ControllerAdvice스프링컨트롤러예외처리,@ExceptionHandler, @ControllerAdvice
스프링컨트롤러예외처리,@ExceptionHandler, @ControllerAdvice
 
Vagrant와 chef로 개발서버 구축 자동화하기
Vagrant와 chef로 개발서버 구축 자동화하기Vagrant와 chef로 개발서버 구축 자동화하기
Vagrant와 chef로 개발서버 구축 자동화하기
 
소프트웨어 아키텍처
소프트웨어 아키텍처소프트웨어 아키텍처
소프트웨어 아키텍처
 
개발자 이승우 이력서 (2016)
개발자 이승우 이력서 (2016)개발자 이승우 이력서 (2016)
개발자 이승우 이력서 (2016)
 
포트폴리오 오경원
포트폴리오 오경원포트폴리오 오경원
포트폴리오 오경원
 

Semelhante a overview of spring4

Jstl_GETCHA_HANJUNG
Jstl_GETCHA_HANJUNGJstl_GETCHA_HANJUNG
Jstl_GETCHA_HANJUNGJung Han
 
Node.js and react
Node.js and reactNode.js and react
Node.js and reactHyungKuIm
 
Mean 스택을 사용한 IoT 개발
Mean 스택을 사용한 IoT 개발Mean 스택을 사용한 IoT 개발
Mean 스택을 사용한 IoT 개발Jay Park
 
Java 8 & Beyond
Java 8 & BeyondJava 8 & Beyond
Java 8 & BeyondJay Lee
 
Clean Front-End Development
Clean Front-End DevelopmentClean Front-End Development
Clean Front-End Development지수 윤
 
Ksug2015 jpa5 스프링과jpa
Ksug2015 jpa5 스프링과jpaKsug2015 jpa5 스프링과jpa
Ksug2015 jpa5 스프링과jpaYounghan Kim
 
Json view 예제 설명
Json view 예제 설명Json view 예제 설명
Json view 예제 설명Hyung Eun Jin
 
GKAC 2015 Apr. - Battery, 안드로이드를 위한 쉬운 웹 API 호출
GKAC 2015 Apr. - Battery, 안드로이드를 위한 쉬운 웹 API 호출GKAC 2015 Apr. - Battery, 안드로이드를 위한 쉬운 웹 API 호출
GKAC 2015 Apr. - Battery, 안드로이드를 위한 쉬운 웹 API 호출GDG Korea
 
Ksug 세미나 (윤성준) (20121208)
Ksug 세미나 (윤성준) (20121208)Ksug 세미나 (윤성준) (20121208)
Ksug 세미나 (윤성준) (20121208)Sungjoon Yoon
 
(IT실무교육/국비지원교육/자바/스프링교육추천)#15.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)
(IT실무교육/국비지원교육/자바/스프링교육추천)#15.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)(IT실무교육/국비지원교육/자바/스프링교육추천)#15.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)
(IT실무교육/국비지원교육/자바/스프링교육추천)#15.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)탑크리에듀(구로디지털단지역3번출구 2분거리)
 
5-4. html5 offline and storage
5-4. html5 offline and storage5-4. html5 offline and storage
5-4. html5 offline and storageJinKyoungHeo
 
Angular2 router&http
Angular2 router&httpAngular2 router&http
Angular2 router&httpDong Jun Kwon
 
#17.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#17.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#17.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#17.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
#22.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#22.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#22.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#22.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
GraphQL overview #2
GraphQL overview #2GraphQL overview #2
GraphQL overview #2기동 이
 

Semelhante a overview of spring4 (20)

Jstl_GETCHA_HANJUNG
Jstl_GETCHA_HANJUNGJstl_GETCHA_HANJUNG
Jstl_GETCHA_HANJUNG
 
Node.js and react
Node.js and reactNode.js and react
Node.js and react
 
Mean 스택을 사용한 IoT 개발
Mean 스택을 사용한 IoT 개발Mean 스택을 사용한 IoT 개발
Mean 스택을 사용한 IoT 개발
 
One-day-codelab
One-day-codelabOne-day-codelab
One-day-codelab
 
Nodejs express
Nodejs expressNodejs express
Nodejs express
 
Java 8 & Beyond
Java 8 & BeyondJava 8 & Beyond
Java 8 & Beyond
 
4-3. jquery
4-3. jquery4-3. jquery
4-3. jquery
 
Clean Front-End Development
Clean Front-End DevelopmentClean Front-End Development
Clean Front-End Development
 
Ksug2015 jpa5 스프링과jpa
Ksug2015 jpa5 스프링과jpaKsug2015 jpa5 스프링과jpa
Ksug2015 jpa5 스프링과jpa
 
Mongo db 최범균
Mongo db 최범균Mongo db 최범균
Mongo db 최범균
 
Json view 예제 설명
Json view 예제 설명Json view 예제 설명
Json view 예제 설명
 
GKAC 2015 Apr. - Battery, 안드로이드를 위한 쉬운 웹 API 호출
GKAC 2015 Apr. - Battery, 안드로이드를 위한 쉬운 웹 API 호출GKAC 2015 Apr. - Battery, 안드로이드를 위한 쉬운 웹 API 호출
GKAC 2015 Apr. - Battery, 안드로이드를 위한 쉬운 웹 API 호출
 
Ksug 세미나 (윤성준) (20121208)
Ksug 세미나 (윤성준) (20121208)Ksug 세미나 (윤성준) (20121208)
Ksug 세미나 (윤성준) (20121208)
 
(IT실무교육/국비지원교육/자바/스프링교육추천)#15.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)
(IT실무교육/국비지원교육/자바/스프링교육추천)#15.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)(IT실무교육/국비지원교육/자바/스프링교육추천)#15.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)
(IT실무교육/국비지원교육/자바/스프링교육추천)#15.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)
 
5-4. html5 offline and storage
5-4. html5 offline and storage5-4. html5 offline and storage
5-4. html5 offline and storage
 
Spring boot actuator
Spring boot   actuatorSpring boot   actuator
Spring boot actuator
 
Angular2 router&http
Angular2 router&httpAngular2 router&http
Angular2 router&http
 
#17.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#17.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#17.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#17.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
 
#22.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#22.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#22.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#22.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
 
GraphQL overview #2
GraphQL overview #2GraphQL overview #2
GraphQL overview #2
 

Mais de Arawn Park

우린 같은 곳을 바라 보고 있나요?
우린 같은 곳을 바라 보고 있나요?우린 같은 곳을 바라 보고 있나요?
우린 같은 곳을 바라 보고 있나요?Arawn Park
 
코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우Arawn Park
 
kotlinx.serialization
kotlinx.serializationkotlinx.serialization
kotlinx.serializationArawn Park
 
#살아있다 #자프링외길12년차 #코프링2개월생존기
#살아있다 #자프링외길12년차 #코프링2개월생존기#살아있다 #자프링외길12년차 #코프링2개월생존기
#살아있다 #자프링외길12년차 #코프링2개월생존기Arawn Park
 
우아한 모노리스
우아한 모노리스우아한 모노리스
우아한 모노리스Arawn Park
 
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다Arawn Park
 
점진적인 레거시 웹 애플리케이션 개선 과정
점진적인 레거시 웹 애플리케이션 개선 과정점진적인 레거시 웹 애플리케이션 개선 과정
점진적인 레거시 웹 애플리케이션 개선 과정Arawn Park
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to KotlinArawn Park
 
Reactive Web - Servlet & Async, Non-blocking I/O
Reactive Web - Servlet & Async, Non-blocking I/OReactive Web - Servlet & Async, Non-blocking I/O
Reactive Web - Servlet & Async, Non-blocking I/OArawn Park
 
Spring framework 3.2 > 4.0 — themes and trends
Spring framework 3.2 > 4.0 — themes and trendsSpring framework 3.2 > 4.0 — themes and trends
Spring framework 3.2 > 4.0 — themes and trendsArawn Park
 

Mais de Arawn Park (10)

우린 같은 곳을 바라 보고 있나요?
우린 같은 곳을 바라 보고 있나요?우린 같은 곳을 바라 보고 있나요?
우린 같은 곳을 바라 보고 있나요?
 
코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우
 
kotlinx.serialization
kotlinx.serializationkotlinx.serialization
kotlinx.serialization
 
#살아있다 #자프링외길12년차 #코프링2개월생존기
#살아있다 #자프링외길12년차 #코프링2개월생존기#살아있다 #자프링외길12년차 #코프링2개월생존기
#살아있다 #자프링외길12년차 #코프링2개월생존기
 
우아한 모노리스
우아한 모노리스우아한 모노리스
우아한 모노리스
 
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
 
점진적인 레거시 웹 애플리케이션 개선 과정
점진적인 레거시 웹 애플리케이션 개선 과정점진적인 레거시 웹 애플리케이션 개선 과정
점진적인 레거시 웹 애플리케이션 개선 과정
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
 
Reactive Web - Servlet & Async, Non-blocking I/O
Reactive Web - Servlet & Async, Non-blocking I/OReactive Web - Servlet & Async, Non-blocking I/O
Reactive Web - Servlet & Async, Non-blocking I/O
 
Spring framework 3.2 > 4.0 — themes and trends
Spring framework 3.2 > 4.0 — themes and trendsSpring framework 3.2 > 4.0 — themes and trends
Spring framework 3.2 > 4.0 — themes and trends
 

overview of spring4

  • 2. 박용권 : 한국 스프링 사용자 모임(KSUG) : 봄싹(SpringSprout) : 라 스칼라 코딩단 http://about.me/arawn KSUG 일꾼단 : twitter / @arawnkr
  • 3. : XML Namespace : AspectJ : @Component 1.0 배포, 그 후 10년 : Java 5+ : Java Configuration : RESTful Support 2013/12/13 - 4.0
 2009/12 - 3.0
2004/03 - 1.0
 2006/10 - 2.0
 ?
  • 4. 새로운 애플리케이션 아키텍처 ✔ 마이크로 서비스 아키텍처(MSA) ✔ 비동기 기반 REST 서비스 ✔ 경량 메시지 아키텍처
  • 5. “스프링 4.0” 볼거리 ✔ 자바 8 지원 ✔ 자바 EE 6 및 7 지원 ✔ 그루비 빈 정의 DSL ✔ 자바 웹소켓 API 지원 ✔ 경량 메시지 아키텍처 지원 ✔ REST Client 개발시 비동기 처리 ✔ 그외 개선사항 ✔ @Deprecated클래스및메소드삭제
  • 6. Java 8 ✔ lambda expressions ✔ method references ✔ JSR-310 Date and Time ✔ repeatable annotations ✔ parameter name discovery : based on the -parameters compiler flag 지원 기능 동작 환경 ✔ Java SE 6+ (JDK 6 update 10, ~2008) ✔ JDK 8 기반 애플리케이션은 4.0 이상 권장
  • 7. lambda expressions & method references ✔ JdbcTemplate : PreparedStatementSetter void setValues(PreparedStatement ps) throws SQLException : RowMapper Object mapRow(ResultSet rs, int rowNum) throws SQLException ! ✔ JmsTemplate : MessageCreator Message createMessage(Session session) throws JMSException ! ✔ TransactionTemplate, TaskExecutor, etc 콜백 인터페이스(callback interfaces)에 적용 가능
  • 9.  
  • 10.  )
  • 11.  -
  • 12.  {
  • 13.  
  • 14.  
  • 15.  
  • 18.  if
  • 20. Lambdas with JdbcTemplate JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); ! ListPerson persons = jdbcTemplate.query( SELECT name, age FROM person where age = ?, new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setInt(1, 35); } }, new RowMapperPerson() { @Override public Person mapRow(ResultSet rs, int rowNum) throws SQLException { return new Person(rs.getString(1), rs.getInt(2)); } });
  • 21. Lambdas with JdbcTemplate JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); ! ListPerson persons = jdbcTemplate.query( SELECT name, age FROM person where age = ?, new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setInt(1, 35); } }, new RowMapperPerson() { @Override public Person mapRow(ResultSet rs, int rowNum) throws SQLException { return new Person(rs.getString(1), rs.getInt(2)); } }); (
  • 22.  
  • 23.  )
  • 24.  -
  • 25.  {
  • 26.  
  • 27.  
  • 28.  
  • 29.  }
  • 30. Lambdas with JdbcTemplate JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); ! ListPerson persons = jdbcTemplate.query( SELECT name, age FROM person where age = ?, (PreparedStatement ps) - { ps.setInt(1, 35); }, (ResultSet rs, int rowNum) - { return new Person(rs.getString(1), rs.getInt(2)); } );
  • 31. Lambdas with JdbcTemplate JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); ! ListPerson persons = jdbcTemplate.query( SELECT name, age FROM person where age = ?, (PreparedStatement ps) - { ps.setInt(1, 35); }, (ResultSet rs, int rowNum) - { return new Person(rs.getString(1), rs.getInt(2)); } ); ! ListPerson persons = jdbcTemplate.query( SELECT name, age FROM person where age = ?, ps - ps.setInt(1, 35), (rs, rowNum) - new Person(rs.getString(1), rs.getInt(2)) );
  • 32. Method References with JdbcTemplate public ListPerson findAll() { return jdbcTemplate.query(SELECT name, age FROM person, new RowMapperPerson() { @Override public Person mapRow(ResultSet rs, int rowNum) throws SQLException { return new Person(rs.getString(1), rs.getInt(2)); } }); }
  • 33. Method References with JdbcTemplate public ListPerson findAll() { return jdbcTemplate.query(SELECT name, age FROM person, new RowMapperPerson() { @Override public Person mapRow(ResultSet rs, int rowNum) throws SQLException { return new Person(rs.getString(1), rs.getInt(2)); } }); } ! public Person mapRow(ResultSet rs, int rowNum) throws SQLException { return new Person(rs.getString(1), rs.getInt(2)); }
  • 34. Method References with JdbcTemplate public ListPerson findAll() { return jdbcTemplate.query(SELECT name, age FROM person, this::mapRow); } !   public Person mapRow(ResultSet rs, int rowNum) throws SQLException { return new Person(rs.getString(1), rs.getInt(2)); }
  • 35. JSR-310: Java의 새로운 날짜와 시간 API ✔ 'java.util.Date' 와 ' java.util.Calendar ' 대체 ✔ 직관적이고 사용하기 쉬운 API ✔ 오픈소스 참고: Joda-Time, Time and Money, ICU 등 ✔ hello world(NHN 개발자 블로그): Java의 날짜와 시간 API
  • 36. JSR-310: 날짜와 시간 API 지원 ✔ 날짜와 시간 타입에 대한 다양한 컨버터 / 포맷터 제공 : DateTimeConverters : DateTimeFormatterRegistrar : Jsr310DateTimeFormatAnnotationFormatterFactory ! ✔ @DateTimeFormat: 포맷팅을 손쉽게 설정 : java.util.Date : java.util.Calendar : java.long.Long : Joda-Time : JSR-310: java.time.*
  • 37. JSR-310: 날짜와 시간 API 지원 import org.springframework.format.annotation.DateTimeFormat;  import java.time.*; @Controller public class JSR310Controller { @RequestMapping(value = /jsr310, params = localDate) @ResponseBody public LocalDate test(LocalDate localDate) { return localDate; } @RequestMapping(value = /jsr310, params = localDateTime) @ResponseBody public LocalDateTime test(@DateTimeFormat(pattern = yyyy-MM-dd HH:mm:ss) LocalDateTime localDateTime) { return localDateTime; } }
  • 38. 반복적 애노테이션(@Repeatable) @PropertySources({ @PropertySource(classpath:META-INF/properties/environment.xml), @PropertySource(classpath:META-INF/properties/environment.properties) }) class PropertySourceConfig { // ... }   @PropertySource(classpath:META-INF/properties/environment.xml) @PropertySource(classpath:META-INF/properties/environment.properties) class PropertySourceConfig { // ... } @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Repeatable(PropertySources.class) public @interface PropertySource { ... }
  • 39. Java EE 6 and 7 ✔ JPA 2.1 ✔ JTA 1.2 ✔ JMS 2.0 ✔ Bean Validation 1.1 ✔ JSR-236 Concurrency Utilities 지원 명세 동작 환경 ✔ Java EE 6+ 이상 ✔ Servlet 2.5 도 호환되나, 3.0 이상 권장
  • 40. 그루비 빈 정의 DSL ✔ JVM에서 동작하는 동적 언어 ✔ 컴파일 하지 않고 실행하는 스크립트 언어 ✔ Java + Python, Ruby, Smalltalk ✔ 간결한 문법, 강력한 기능 그리고 DSL 지원 Groovy 빈 정의 DSL ✔ 간결한 문법으로 빈 정의 ✔ XML NameSpace 기능 지원
  • 41. Groovy DSL 로 빈 정의하기 import org.springframework.web.servlet.view.InternalResourceViewResolver import org.springframework.web.servlet.view.JstlView beans { jstlViewResolver(InternalResourceViewResolver) { viewClass = JstlView prefix = /WEB-INF/views suffix = .jsp } } bean id=jstlViewResolver class=org.springframework.web.servlet.view.InternalResourceViewResolver property name=viewClass value=org.springframework.web.servlet.view.JstlView/ property name=prefix value=/WEB-INF/views/ property name=suffix value=.jsp/ /bean XML Groovy DSL
  • 42. Groovy DSL 로 XML NameSpace 사용하기 beans xmlns=http://www.springframework.org/schema/beans xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:context=http://www.springframework.org/schema/context xsi:schemaLocation=... ! context:component-scan base-package=jco.conference.oxquiz/ /beans XML Groovy DSL beans { xmlns context: 'http://www.springframework.org/schema/context' context.'component-scan'('base-package': 'jco.conference.oxquiz') }
  • 43. Groovy DSL 로 Spring MVC 기본 설정 import org.springframework.web.servlet.view.InternalResourceViewResolver import org.springframework.web.servlet.view.JstlView beans { xmlns context: 'http://www.springframework.org/schema/context' xmlns mvc: 'http://www.springframework.org/schema/mvc' context.'component-scan'('base-package': 'jco.conference.oxquiz') mvc.'annotation-driven'() mvc.'default-servlet-handler'() mvc.'resources'('mapping': '/resources/**', 'location': '/resources/') jstlViewResolver(InternalResourceViewResolver) { viewClass = JstlView prefix = '/WEB-INF/views' suffix = '.jsp' } }
  • 44. WebSocket and Messaging ✔ JSR 356: Java 웹소켓 API 지원 ✔ SockJS: 웹소켓 미지원 브라우저 대응 spring-websocket module spring-messaging module ✔ 메시지, 채널 등 추상화 모델 제공 ✔ 고수준 메시지 프로토콜 STOMP 지원
  • 45. ✔ HTML5 표준 ✔ API: W3C / 프로토콜: IETF ✔ 웹 소켓 프로토콜 사용 ✔ 양방향 통신 JSR 356: Java WebSocket API
  • 46. ✔ Tomcat 7.0.47+ and 8.0 ✔ Jetty 9.0 and 9.1 ✔ WildFly 8.0 (JBoss Application Server) ✔ GlassFish 4.0 JSR 356: Java WebSocket API
  • 47. WebSocketHandler 인터페이스 import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.WebSocketMessage; public class EchoHandler implements WebSocketHandler { @Override public void handleMessage(WebSocketSession session , WebSocketMessage? message) throws Exception { sessions.forEach(session - { try { session.sendMessage(message); } catch (IOException ignore) { } }); } // 생략 } 예제 코드 : http://goo.gl/SNzGQ2
  • 48. WebSocket 활성화 및 WebSocketHandler 등록 import org.springframework.web.socket.config.annotation.EnableWebSocket; import org.springframework.web.socket.config.annotation.WebSocketConfigurer; ! @Configuration @EnableWebSocket public class ExampleWebSocketConfig implements WebSocketConfigurer {   @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { registry.addHandler(echoHandler(), /websocket/echo); }   @Bean public EchoHandler echoHandler() { return new EchoHandler(); }   } 예제 코드 : http://goo.gl/SNzGQ2
  • 49. JavaScript: WebSocket Client var echoUri = ws://ksug.org/websocket/echo; var websocket = new WebSocket(echoUri); ! // 접속, 접속종료, 메시지 수신, 오류 이벤트 처리 websocket.onopen = function(event) { }; websocket.onclose = function(event) { }; websocket.onmessage = function(event) { }; websocket.onerror = function(event) { }; ! // 메세지 전송 websocket.send(message!); 예제 코드 : http://goo.gl/iAcbX6
  • 50. Can I use WebSockets? ✔ Chrome 14.0+ (Current 32.0) ✔ Safari 6.0+ (Current 7.0) ✔ Firefox 11.0+ (Current 27.0) ✔ Internet Explorer 10.0+ (Current 11.0) ✔ iOS Safari 6.0+ (Current 7.0) ✔ Android Browser 4.4
  • 51. ! ! ! ! ! ! JavaScript로 브라우저 종류에 상관없이 실시간 웹 구현 기술 SockJS 는... ✔ SockJS-client JavaScript client library ✔ SockJS-node Node.js server ✔ SockJS-erlang Erlang server ✔ SockJS-tornado Python server ✔ SockJS-twisted Python server ✔ vert.x Java/vert.x server ✔ SockJS-cyclone Python server SockJS family ✔ WebSocket ✔ AJAX long polling ✔ AJAX multipart streaming ✔ Forever Iframe ✔ JSONP Polling 지원 기술
  • 52. SockJS WebSocketHandler 등록하기 @Configuration @EnableWebSocket public class ExampleWebSocketConfig implements WebSocketConfigurer {   @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { registry.addHandler(echoHandler(), /websocket/echo).withSockJS(); }   @Bean public EchoHandler echoHandler() { return new EchoHandler(); }   } 예제 코드 : http://goo.gl/SNzGQ2
  • 53. JavaScript: SockJS Client var echoUri = /websocket/echo/sockjs; var sock = new SockJS(echoUri); ! // 접속, 접속종료, 메시지 수신, 오류 이벤트 처리 sock.onopen = function(event) { }; sock.onclose = function(event) { }; sock.onmessage = function(event) { }; sock.onerror = function(event) { }; ! // 메시지 전송 sock.send(message!); 예제 코드 : http://goo.gl/iAcbX6
  • 54. ! ! ! ! ! ! Streaming Text Oriented Message Protocol STOMP 는... ✔ Apache ActiveMQ ✔ RabbitMQ ✔ HornetQ ✔ stomp.erl (Erlang) ✔ Stomp.py (Python) ✔ etc Server-side ✔ stomp.js ✔ msgs.js Client-side
  • 55. STOMP Message 처리 import org.springframework.stereotype.Controller; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.Message;   @Controller public class EchoController {   @Autowired private SimpMessageSendingOperations messagingTemplate;   @MessageMapping(/echo) public void echo(MessageString message) { messagingTemplate.send(/topic/echo, message); }   } 예제 코드 : http://goo.gl/SNzGQ2
  • 56. STOMP 활성화 및 설정 @Configuration @EnableWebSocketMessageBroker public class ExampleWebSocketConfig implements WebSocketMessageBrokerConfigurer {   @Override public void registerStompEndpoints(StompEndpointRegistry registry) { registry.addEndpoint(/websocket/endpoint/stomp); }   @Override public void configureMessageBroker(MessageBrokerRegistry registry) { registry.setApplicationDestinationPrefixes(/stomp); registry.enableSimpleBroker(/topic/); }   @Bean public EchoController echoController() { return new EchoController(); }  } 예제 코드 : http://goo.gl/SNzGQ2
  • 57. JavaScript: STOMP Client var echoUri = ws://ksug.org/websocket/endpoint/stomp; var websocket = new WebSocket(echoUri); ! var stompClient = Stomp.over(websocket); stompClient.connect(' ', ' ', function(frame) { // 접속성공 ! stompClient.subscribe(/topic/echo, function(message) { // echo 채널 메시지 수신 }); }, function (error) { // 접속실패 }); ! // 메시지 전송 stompClient.send('/stomp/message', {}, message!); 예제 코드 : http://goo.gl/iAcbX6
  • 59. Google PlusREST FacebookREST TwitterREST 순차적으로 API 호출시 응답시간이 길다 SNS에서 URL 공유 횟수를 알고싶다! Server
  • 60. 병렬적으로 API 호출시 응답시간이 짧다 SNS에서 URL 공유 횟수를 알고싶다! Server Google PlusREST FacebookREST TwitterREST
  • 61. REST 클라이언트 개발시 비동기 지원 AsyncRestTemplate final String FACEBOOK_COUNT_API = http://graph.facebook.com/?id={url}; ! ListenableFutureResponseEntityRepository[] reposForEntity = asyncRestTemplate.getForEntity(GITHUB_API_USERS_REPOS, Repository[].class, uriVariables); ! reposForEntity.addCallback(new ListenableFutureCallbackResponseEntityRepository[]() { @Override public void onSuccess(ResponseEntityRepository[] entity) { // 응답 데이터 처리 } @Override public void onFailure(Throwable throwable) { // 예외 처리 } }); 예제 코드 : http://goo.gl/YspZGN
  • 62. 그외 개선사항 ✔ Generics 기반 의존성 주입 ✔ 메타 애노테이션 속성 재정의 ✔ 조건부 빈 정의 ✔ 기타 Core Container ✔ @RestController 추가 ✔ Spring MVC: TimeZone 사용 지원 Web ✔ 테스트용 메타 애노테이션 정의 ✔ mock.web.* 이하 Servlet 3.0 필요 Testing
  • 63. Generics 기반 의존성 주입 public interface RepositoryT { ... }   public interface PlayerRepository extends RepositoryPlayer { ... }   ! @Controller public class PlayerController {   @Autowired private RepositoryPlayer playerRepository; }
  • 64. 메타 애노테이션 속성 재정의 @Transactional(indexDataSource) @Retention(RetentionPolicy.RUNTIME) public @interface IndexDataSourceTransactional { boolean readOnly() default false; }   @Transactional(metaDataSource) @Retention(RetentionPolicy.RUNTIME) public @interface MetaDataSourceTransactional { boolean readOnly() default false; }   @Service public class ExampleServiceImpl implements ExampleService {   @IndexDataSourceTransactional(readOnly = true) public IndexEntity findIndex() { ... }   @MetaDataSourceTransactional(readOnly = true) public MetaEntity findMeta() { ... } }
  • 65. 조건에 따른 빈 정의 ✔ 조건에 따라 빈을 필터링하는 일반적인 방법 추가 : Spring 3.1 @Profile 보다 더욱 유연하고 동적으로 지원 : Spring Boot 프로젝트에서 적극적으로 사용 ! ✔ @Conditional 과 Condition 인터페이스로 조건부 필터링 구현 : 다양한 조건에 따라 대응 가능(시스템 OS, 자바 버전, 빈 등록여부 등...) : @Profile도 ProfileCondition을 통해 동작되도록 구현 : 사용자 정의 조건부 빈 정의 지원
  • 66. 조건에 따른 빈 정의: Spring Boot @Configuration @ConditionalOnWebApplication public class EmbeddedServletContainerAutoConfiguration { ! @Configuration @ConditionalOnClass({ Servlet.class, Tomcat.class }) @ConditionalOnMissingBean(value = EmbeddedServletContainerFactory.class) public static class EmbeddedTomcat { // Tomcat 구동 } ! @Configuration @ConditionalOnClass({ Servlet.class, Server.class, Loader.class }) @ConditionalOnMissingBean(value = EmbeddedServletContainerFactory.class) public static class EmbeddedJetty { // Jetty 구동 } }
  • 67. Core Container 개선사항: 기타 ✔ 기본 생성자 없이 CGLIB 프록시 생성 : 오픈소스 objenesis를 사용한 프록시 대상 객체 생성 ! ✔ 순서를 보장하는 의존성 주입 : Ordered 인터페이스 또는 @Ordered 에 따른 정렬 후 의존성 주입 ! ✔ 의존성 주입시 @Lazy 지원 ! ✔ @Description: 빈 정의시 주석 작성
  • 68. 테스트용 메타 애노테이션 정의 @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({/app-config.xml, /test-data-access-config.xml}) @ActiveProfiles(dev) @Transactional public class OrderServiceTests { ... }   @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({/app-config.xml, /test-data-access-config.xml}) @ActiveProfiles(dev) @Transactional public class UserServiceTests { ... }
  • 69. 테스트용 메타 애노테이션 정의 @RunWith(SpringJUnit4ClassRunner.class) @TransactionalDevTest public class OrderServiceTests { ... }   @RunWith(SpringJUnit4ClassRunner.class) @TransactionalDevTest public class UserServiceTests { ... } @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @ContextConfiguration({/app-config.xml, /test-data-access-config.xml}) @ActiveProfiles(dev) @Transactional public @interface TransactionalDevTest { }
  • 70. @Deprecated 클래스 및 메소드 삭제 ✔ @Deprecated 클래스 및 메소드 모두 삭제 : API Differences Report에서 확인 가능 ! ✔ Third-Party 라이브러리 호환 : 버전 4.0 기준 2010/2011년도 이후 버전을 사용 : Hibernate 3.6+, EhCache 2.1+, Quartz 1.8+, Groovy 1.8+, Joda-Time 2.0+ : 예외적으로 Hibernate Validator는 4.3+ 버전이 필요 : Jackson 1.8/1.9는 @Deprecated 선언, 2.0+ 이상을 지원하는데 집중
  • 73. Special Thanks to ✔ Designed for Sails.js, an MVC framework for Node by Balderdash @mikermcneil / @KallunaLovegood ✔ OXQuiz Fornt-end by @outsideris
  • 74. 한국 스프링 사용자 그룹 (KSUG) https://www.facebook.com/groups/springkorea/ http://groups.google.com/group/ksug http://www.ksug.org/