Spring Spring MVC Spring DI Spring AOP Spring
- Slides: 106
둘째 날 셋째 날 개발 환경 세팅 Spring 기본 Spring MVC 사용자 관리 시스템 개발 (실습) Spring DI Spring AOP 첫째 날 Spring JDBC & Transaction Spring Test
Spring은 Lightweight Application Framework 5 / 한빛 교육센터 Spring 교육
둘째 날 셋째 날 개발 환경 세팅 Spring 기본 Spring MVC 사용자 관리 시스템 개발 (실습) Spring DI Spring AOP 첫째 날 Spring JDBC & Transaction Spring Test 11 / 한빛 교육센터 Spring 교육
Spring DI
Inversion of Control? Dependency Injection? 13 / 한빛 교육센터 Spring 교육
Factory Pattern 19 / 한빛 교육센터 Spring 교육
Factory Pattern 20 / 한빛 교육센터 Spring 교육
클래스 의존관계에 대한 Metadata (XML 또는 Property) Spring Framework (Application. Context) 24 / 한빛 교육센터 Spring 교육
Inversion of Control (Io. C) 25 / 한빛 교육센터 Spring 교육
• EJB • Spring Io. C : Inversion of Control DI : Dependency Injection DP : Dependency Pull DP Io. C Setter Inj DI Constructor Inj • Spring • Pico. Container Method Inj 26 / 한빛 교육센터 Spring 교육
Servlet Container Service Init Create Servlet A Destory Servlet B Servlet Container 27 / 한빛 교육센터 Spring 교육 Servlet D
EJB Container Service Init Create EJB A EJB B Destory EJB Container 28 / 한빛 교육센터 Spring 교육 EJB D
Io. C(DI) Container Service Init Create POJO A Destory POJO B POJO C Io. C(또는 DI) Container 29 / 한빛 교육센터 Spring 교육 POJO D
Spring Bean Scope
Singleton? , Non Singleton? 31 / 한빛 교육센터 Spring 교육
Singleton Pattern을 활용한 Singleton 32 / 한빛 교육센터 Spring 교육
지금까지의 Singleton 구현 방법 public class Message. Service { private static Message. Service instance; private Message. Service() {} public static Message. Service get. Instance() { if(instance == null ) { instance = new Message. Service(); } return instance; } } 33 / 한빛 교육센터 Spring 교육
Spring 기반하의 Singleton 34 / 한빛 교육센터 Spring 교육
Spring 프레임워크의 Singleton 구현 방법 <bean id="annyoung. World. Message. Provider" class="net. javajigi. ioc. Annyoung. World. Message. Provider" scope=“singleton” /> <bean id="hello. World. Message. Provider" class="net. javajigi. ioc. Helloworld. Message. Provider"/> 35 / 한빛 교육센터 Spring 교육
<bean id="renderer" class="net. javajigi. ioc. Default. Message. Renderer"> <property name="message. Provider"> <ref local=“hi. World. Message. Provider" /> </property> </bean> <bean id="hi. World. Message. Provider" class="net. javajigi. ioc. Hiworld. Message. Provider" /> Application. Context 36 / 한빛 교육센터 Spring 교육 키(key) 값(value) “renderer " Default. Message. Renderer 인스턴스 " hi. World. Message. Provider” Hi. World. Message. Provider 인스턴스
웹 애플리케이션 Servlet. Context(sigle instance) 키(key) 값(value) “org. springframework. web. context. Web. Application. Context. ROOT" Web. Application. Context 인스턴스 JVM 37 / 한빛 교육센터 Spring 교육
Spring 프레임워크의 Non Singleton 구현 방법 <bean id="annyoung. World. Message. Provider" class="net. javajigi. ioc. Annyoung. World. Message. Provider" scope=“prototype” /> <bean id="hello. World. Message. Provider" class="net. javajigi. ioc. Helloworld. Message. Provider“ scope=“prototype” /> 38 / 한빛 교육센터 Spring 교육
Singleton Instance name = null new Person(); Thread A public class Person { private String name; public void set. Name(String name) { this. name = name; } new Person(); public String get. Name() { return name; } Thread B } 40 / 한빛 교육센터 Spring 교육
Singleton Instance name = “예은” person. set. Name(“예은”); public class Person { private String name; public void set. Name(String name) { this. name = name; } Thread A public String get. Name() { return name; } } 41 / 한빛 교육센터 Spring 교육
Singleton Instance name = “주한” person. set. Name(“주한”); public class Person { private String name; public void set. Name(String name) { this. name = name; } Thread B public String get. Name() { return name; } } 42 / 한빛 교육센터 Spring 교육
Singleton Instance name = “주한” person. get. Name(); => 주한 public class Person { private String name; public void set. Name(String name) { this. name = name; } Thread A public String get. Name() { return name; } } 43 / 한빛 교육센터 Spring 교육
Spring Bean Instance 생성
new <bean id="message. Provider" class="net. javajigi. di. New. Message. Provider"/> 46 / 한빛 교육센터 Spring 교육
Factory method <bean id="message. Provider" class="net. javajigi. di. Singleton. Message. Provider" factory-method="get. Instance" /> 47 / 한빛 교육센터 Spring 교육
Factory. Bean Interface <bean id="message. Provider" class="net. javajigi. di. Message. Provider. Factory. Bean"> <property name="type"> <util: constant static-field="net. javajigi. di. Message. Provider. Factory. Bean. ANNYOUNG_WORLD_PROVIDER"/> </property> </bean> 48 / 한빛 교육센터 Spring 교육
<bean id="user. Service" class="net. javajigi. user. service. User. Service. Impl"> <property name="user. DAO"> <ref local="user. DAO" /> </property> </bean> Application. Context context = new Class. Path. Xml. Application. Context(paths); User. Service user. Service = context. get. Bean(“user. Service”); 49 / 한빛 교육센터 Spring 교육
<bean id="user. Service" class="org. springframework. aop. framework. Proxy. Factory. Bean"> <property name="target"> <ref local="user. Service. Target" /> </property> <property name="interceptor. Names"> <list> <value>logging. Advice</value> <value>email. Notification. Throws. Advice</value> </list> </property> </bean> Application. Context context = new Class. Path. Xml. Application. Context(paths); Proxy. Factory. Bean factory. Bean = context. get. Bean(“user. Service”); 50 / 한빛 교육센터 Spring 교육
<bean id="user. Service" class="org. springframework. aop. framework. Proxy. Factory. Bean"> <property name="target"> <ref local="user. Service. Target" /> </property> <property name="interceptor. Names"> <list> <value>logging. Advice</value> <value>email. Notification. Throws. Advice</value> </list> </property> </bean> Application. Context context = new Class. Path. Xml. Application. Context(paths); User. Service user. Service = context. get. Bean(“user. Service”); 51 / 한빛 교육센터 Spring 교육
둘째 날 셋째 날 개발 환경 세팅 Spring 기본 Spring MVC 사용자 관리 시스템 개발 (실습) Spring DI Spring AOP 첫째 날 Spring JDBC & Transaction Spring Test 52 / 한빛 교육센터 Spring 교육
Spring JDBC
Template Method Pattern 55 / 한빛 교육센터 Spring 교육
public abstract class Abstract. Class { public void template. Method() { //. . 비지니스 로직 구현 operation 1(); //. . 비지니스 로직 구현 operation 2(); } protected abstract void operation 1(); protected abstract void operation 2(); } 57 / 한빛 교육센터 Spring 교육
public class Concrete. Class. A extends Abstract. Class { protected void operation 1() { // TODO Auto-generated method stub } protected void operation 2() { // TODO Auto-generated method stub } } 58 / 한빛 교육센터 Spring 교육
Template Method = Io. C 59 / 한빛 교육센터 Spring 교육
Callback Class Callback Method 60 / 한빛 교육센터 Spring 교육
public interface Row. Callback. Handler { void process. Row(Result. Set rs) throws SQLException; } 61 / 한빛 교육센터 Spring 교육
public void query(String sql, Row. Callback. Handler callback. Handler) throws Jdbc. Sql. Exception { Connection con = null; Prepared. Statement ps = null; Result. Set rs = null; try { con = <code to get connection> ps = con. prepare. Statement (sql); rs = ps. execute. Query(); while (rs. next()) { callback. Handler. process. Row(rs); } rs. close(); ps. close(); } catch (SQLException ex) { throw new Jdbc. Sql. Exception("Couldn't run query [" + sql + "]", ex); } finally { Data. Source. Utils. close. Connection. If. Necessary(this. data. Source, con); } } 62 / 한빛 교육센터 Spring 교육
class String. Handler implements Jdbc. Template. Row. Callback. Handler { private List 1 = new Linked. List(); public void process. Row(Result. Set rs)throws SQLException { 1. add(rs. get. String(1)); } public String[] get. Strings() { return (String[]) 1. to. Array(new String[1. size()]); } } String. Handler sh = new String. Handler(); jdbc. Template. query("SELECT FORENAME FROM CUSTMR", sh); String[] forenames = sh. get. Strings(); 63 / 한빛 교육센터 Spring 교육
Spring Transaction
Persistence Layer Where? Business Layer 65 / 한빛 교육센터 Spring 교육
TXa TXa TXb 68 / 한빛 교육센터 Spring 교육 TXb
TXa SELECT CATEGORYNAME FROM ORDER WHERE ORDERID = 1 Result “BOOK” TXb UPDATE ORDER SET CATEGORYNAME=“MUSIC” WHERE ORDERID = 1 TXa SELECT CATEGORYNAME FROM ORDER WHERE ORDERID = 1 Result ? 72 / 한빛 교육센터 Spring 교육
Dirty Read TXa SELECT CATEGORYNAME FROM ORDER WHERE ORDERID = 1 Result “BOOK” TXb UPDATE ORDER SET CATEGORYNAME=“MUSIC” WHERE ORDERID = 1 TXa SELECT CATEGORYNAME FROM ORDER WHERE ORDERID = 1 Result “MUSIC” 73 / 한빛 교육센터 Spring 교육
Non. Repeatable Read(Fuzzy Read) – Update, Delete TXa SELECT CATEGORYNAME FROM ORDER WHERE ORDERID = 1 Result “BOOK” TXb UPDATE ORDER SET CATEGORYNAME=“MUSIC” WHERE ORDERID = 1 TXa SELECT CATEGORYNAME FROM ORDER WHERE ORDERID = 1 Result “BOOK” 74 / 한빛 교육센터 Spring 교육
Non. Repeatable Read(Fuzzy Read) – Update, Delete Commit TXb TXa SELECT CATEGORYNAME FROM ORDER WHERE ORDERID = 1 Result “MUSIC” 75 / 한빛 교육센터 Spring 교육
Phantom Read - Insert TXa SELECT COUNT(*) FROM ORDER Result 10 TXb INSERT INTO ORDER (ORDERID, CATEGORYNAME) VALUES ( 11, “GAME” TXa SELECT COUNT(*) FROM ORDER Result 10 76 / 한빛 교육센터 Spring 교육
Phantom Read - Insert Commit TXb TXa SELECT COUNT(*) FROM ORDER Result 11 77 / 한빛 교육센터 Spring 교육
Isolation Level Dirty Read Non. Repetable Read Phantom Read uncommitted (ISOLATION_READ_U NCOMMITTED) Possible Read committed (ISOLATION_READ_C OMMITTED) Not Possible Repetable read (ISOLATION_REPEAT ABLE_READ) Not Possible Serializable (ISOLATION_SERIALI ZABLE) Not Possible 78 / 한빛 교육센터 Spring 교육
PROPAGATION_REQUIRED TXa TXa PROPAGATION_REQUIRED 80 / 한빛 교육센터 Spring 교육
PROPAGATION_REQUIRED TXa TXb PROPAGATION_REQUIRES_NEW 81 / 한빛 교육센터 Spring 교육
PROPAGATION_REQUIRED TXa TXa PROPAGATION_SUPPORTS 82 / 한빛 교육센터 Spring 교육
PROPAGATION_SUPPORTS 83 / 한빛 교육센터 Spring 교육
PROPAGATION_REQUIRED TXa PROPAGATION_NOT_SUPPORTED 84 / 한빛 교육센터 Spring 교육 TXa
PROPAGATION_REQUIRED TXa TXa PROPAGATION_MADATORY 85 / 한빛 교육센터 Spring 교육
Throw Exception PROPAGATION_MADATORY 86 / 한빛 교육센터 Spring 교육
PROPAGATION_REQUIRED TXa Throw Exception PROPAGATION_NEVER 87 / 한빛 교육센터 Spring 교육
PROPAGATION_REQUIRED, read. Only, timeout_0180, -Application. Exception 89 / 한빛 교육센터 Spring 교육
둘째 날 셋째 날 개발 환경 세팅 Spring 기본 Spring MVC 사용자 관리 시스템 개발 (실습) Spring DI Spring AOP 첫째 날 Spring JDBC & Transaction Spring Test 90 / 한빛 교육센터 Spring 교육
컨테이너 기반 테스트 Cycle Test Development Server 재시작 Build Deploy 92 / 한빛 교육센터 Spring 교육
Junit 기반 테스트 Cycle Test 94 / 한빛 교육센터 Spring 교육 Development
org. springframework. test 95 / 한빛 교육센터 Spring 교육
기존의 테스트 방식 public class Standard. Out. Message. Renderer. Test { private Message. Renderer renderer; @Before public void set. Up() throws Exception { Application. Context application. Context = new Class. Path. Xml. Application. Context( "net/javajigi/helloworld/Hello. World. xml"); renderer = (Message. Renderer) application. Context. get. Bean("renderer"); } @Test public void test. Render() { renderer. render(); } } 96 / 한빛 교육센터 Spring 교육
Abstract. Dependency. Injection. Spring. Context. Tests public class Standard. Out. Message. Renderer. With. DITest extends Abstract. Dependency. Injection. Spring. Context. Tests { private Message. Renderer renderer; public void set. Renderer(Message. Renderer renderer) { this. renderer = renderer; } @Override protected String[] get. Config. Locations() { return new String[] { "classpath: net/javajigi/helloworld/Hello. World. xml" }; } public void test. Render() { renderer. render(); } } 97 / 한빛 교육센터 Spring 교육
Abstract. Transactional. Spring. Context. Tests 테스트시 변경된 데이터를 자동 Rollback 100 / 한빛 교육센터 Spring 교육
Tx begin. Tx Business Logic Success 아니오 Rollback 101 / 한빛 교육센터 Spring 교육 예 Commit
Tx begin. Tx Unit Test Default 자동 Rollback 102 / 한빛 교육센터 Spring 교육
Abstract. Transactional. Data. Source. Spring. Context. Tests 테스트를 위한 Query 구현이 가능 103 / 한빛 교육센터 Spring 교육
Spring Mock Object ? 104 / 한빛 교육센터 Spring 교육
Mock. Http. Servlet. Request Mock. Http. Servlet. Response 105 / 한빛 교육센터 Spring 교육
Thank you.
- Spring boot aspect example
- Spring oop
- Eclipse plugin
- Java spring board
- Request flow in spring mvc
- Eclipse.ini jdk 설정
- Spring 아이디 찾기 소스
- Aop network
- Isaop
- Jboss aop
- What is aop
- Handlerinterceptoradapter
- Aop
- Amplificateur
- Mvc routing
- Swing mvc example
- Blackboard mvc
- Struts 2 mvc
- Mvc life cycle in c#
- Mvc mis
- Difference between view and partial view in mvc
- Tvc avc and mvc
- Modelo vista controlador
- Nj road test requirements
- Mvt vs mvc
- Jee
- Mvc m
- Asp.net mvc 5 identity authentication and authorization
- Mvc vs webforms
- Mvc muster
- Misterios gozosos meditados mvc
- Action selectors in mvc
- Getting a driver's license illegally may result in
- Wzorzec projektowy mvc
- Delphi mvc
- What mvc stands for
- Mvc spencer
- Model layer in mvc
- Mvc architecture in jsp
- Boundary control entity
- Asp net core roadmap
- Mvc java swing
- Mvc paradigm
- Asp net tutorialspoint
- Mvc design pattern in java
- Mvc intro
- Trygve reenskaug mvc
- Model view controller
- Swing mvc example
- Trygve reenskaug mvc
- Kim ki duk spring summer fall winter
- Fall months
- Big spring school district
- Potential energy spring
- Silver spring hotel cork
- Forms of energy?
- Prague spring
- Spring loaded inverted pendulum
- Stretching spring
- Helical spring formula
- Yuki spring bed
- Diameter if you know circumference
- Cos217 spring 2021
- In spring it's warm
- Tidal bulge
- Spring
- Dpg spring meeting
- Kinetic energy of a spring
- Spring nature
- Cos217 spring 2021
- Spring equations
- Ftp server spring 2017
- Math enrichment spring 2020
- Mass spring system in real life
- Spring udp
- Grepor
- Rj spring rubber and metal parts
- A wind up toy is fully wound and at rest
- Spring valley ela
- Tension in elastic string
- Spring framework overview
- How to paint spring flowers in watercolor
- Malay mancatcher trap diagram
- Vulnerabilitäts-stress-modell nach zubin und spring
- World history spring final exam review answers
- Spring security denyall
- Kunming golf package
- Elmvale spring water
- Spring earth tilt
- Tunisia arab spring timeline
- Assonance in dulce et decorum est
- Silent spring apush
- What images spring to mind
- Fall winter summer spring
- Start.spring,io
- Spring batch validation
- Spring bean dependency graph
- Unlocking of knee joint
- Subtalární kloub
- 2200n
- What images spring to mind
- Net productivity
- Jpa pageable
- Energy stored in a spring
- аоп java
- Shift lateral fisioterapia
- Spring framework architecture