07. 분산프로그래밍 - Sprig Framework 명지대학교 ICT 융합대학김정호 1
분산시스템을개발할수있다. 분산시스템을이해할수있다. 분산시스템을분석 / 설계할수있다. 분산시스템을구현할수있다. 네트워크이론을이해할수있다. Compoet Diagram 을작성할수있다. 수강시스템을이해하고신규기능을추가구현할수있다. RMI 프로그램을구현할수있다. Deploymet Diagram 을작성할수있다. 보험사시스템을스프링기반의분산시스템을구현할수있다. 2
강의커리큘럼 Week 강의내용 비고 1 소프트웨어시스템및분산시스템소개 2 분산시스템개요 3 분산시스템을위한네트워크개요 4 분산프로그래밍실습 - RMI를이용한구현 분산프로그래밍실습 5 분산프로그래밍실습 수강신청프로그램이해 멀티프로세스코드작성 6 분산프로그래밍실습 신규기능추가구현 멀티프로세스코드작성 7 분산프로그래밍실습 구현계속 실습코드작성 8 분산프로그래밍실습 구현레포트제출 중간평가 9 스프링프레임워크이해및구현환경구축 10 스프링기반의구현실습 -1 11 스프링기반의구현실습 -2 12 스프링기반의웹구현실습 -1 시스템구축 1 13 스프링기반의웹구현실습 -2 시스템구축 2 14 스프링기반의웹구현실습 -3 시스템구축 3 15 스프링기반의웹구현실습 -4 시스템구축 4 16 기말발표 기말고사 3
Itroductio u Software Platform v a major piece of software, as a operatig system, a operatig eviromet, or a database, uder which various smaller applica tio programs ca be desiged to ru. [Dictioary.com] v Applicatio 이작동하는기반소프트웨어 v Examples Widows, Liux JVM,.Net Web Browser Etherium 4
Itroductio u Software Framework v a abstractio i which software providig geeric fuctioality ca be selectively chaged by additioal user-writte code, thus providig applicatio-specific software. [Wikipedia] v Applicatio 을지원하는모듈들 v Examples Eclipse, Ajax Sprig Tesorflow 5
Itroductio u Sprig is a geeral applicatio framework v addresses overall applicatio architecture iteral structure of a applicatio v focus o cosistet programmig model decouplig from cocrete rutime eviromet v supports ay kid of Java applicatio special support for J2EE eviromets u Ope source project o SourceForge v fouded by Rod Johso & Jürge Höller v Apache licese 6
Itroductio u Foudatio: core cotaier v Iversio of Cotrol geeral lifecycle maagemet for ay kid of applicatio compoets v Depedecy Ijectio wirig betwee applicatio compoets istead service lookups u Further foudatio: AOP framework v proxy-based AOP for POJOs v flexible combiatio of iterceptors 7
What is a bea? u Typical java bea with a uique id u I sprig there are basically two types v Sigleto Oe istace of the bea created ad refereced each time it is requested v Prototype (o-sigleto) New bea created each time Same as ew ClassName() u Beas are ormally created by Sprig as late as possible 8
What is a bea defiitio? u Defies a bea for Sprig to maage v Key attributes class (required): fully qualified java class ame id: the uique idetifier for this bea cofiguratio: (sigleto, iit-method, etc.) costructor-arg: argumets to pass to the costructor at creatio time property: argumets to pass to the bea setters at creatio time Collaborators: other beas eeded i this bea (a.k.a depedecies), specified i property or costructorarg u Typically defied i a XML file 9
What is a bea factory? u Ofte see as a ApplicatioCotext v BeaFactory is ot used directly ofte v ApplicatioCotext is a complete superset of bea factory methods Same iterface implemeted Offers a richer set of features u Sprig uses a BeaFactory to create, maage ad locate beas which are basically istaces of a class v Typical usage is a XML bea factory which allows cofiguratio via XML files 10
Sample bea defiitio <bea id="examplebea" class= org.example.examplebea"> <property ame="beaoe"><ref bea="aotherexamplebea"/></property> <property ame="beatwo"><ref bea="yetaotherbea"/></property> <property ame="itegerproperty"><value>1</value></property> </bea> public class ExampleBea { private AotherBea beaoe; private YetAotherBea beatwo; private it i; public void setbeaoe(aotherbea beaoe) { this.beaoe = beaoe; } public void setbeatwo(yetaotherbea beatwo) { this.beatwo = beatwo; } public void setitegerproperty(it i) { this.i = i; } } 11
Bea properties? u The primary method of depedecy ijectio u Ca be aother bea, value, collectio, etc. <bea id="examplebea" class="org.example.examplebea"> <property ame="aotherbea"> <ref bea="someotherbea" /> </property> </bea> u This ca be writte i shorthad as follows <bea id="examplebea" class="org.example.examplebea"> <property ame="aotherbea" ref="someotherbea" /> </bea> 12
Aoymous vs ID u Beas that do ot eed to be refereced elsewhere ca be defied aoymously u This bea is idetified (has a id) ad ca be accessed to iject it ito aother bea <bea id="examplebea" class="org.example.examplebea"> <property ame="aotherbea" ref="someotherbea" /> </bea> u This bea is aoymous (o id) <bea class="org.example.examplebea"> <property ame="aotherbea" ref="someotherbea" /> </bea> 13
What is a ier bea? u It is a way to defie a bea eeded by aother bea i a shorthad way v Always aoymous (id is igored) v Always prototype (o-sigleto) <bea id="outer" class="org.example.somebea"> <property ame="perso"> <bea class="org.example.persoimpl"> <property ame="ame"><value>aaro</value></property> <property ame="age"><value>31</value></property> </bea> </property> </bea> 14
Bea iit-method u The iit method rus AFTER all bea depedecies are loaded v Costructor loads whe the bea is first istatiated v Allows the programmer to execute code oce all depedecies are preset <bea id="examplebea" class= org.example.examplebea" iit-method= iit /> public class ExampleBea { public void iit() { // do somethig } } 15
Bea values u Sprig ca iject more tha just other beas u Values o beas ca be of a few types v Direct value (strig, it, etc.) v Collectio (list, set, map, props) v Bea v Compoud property <bea class="org.example.examplebea"> <property ame="email"> <value>azeckoski@gmail.com</value> </property> </bea> 16
Abstract (paret) beas u Allows defiitio of part of a bea which ca be reused may times i other bea defiitios <bea id="abstractbea" abstract="true" class="org.example.paretbea"> <property ame="ame" value="paret-az"/> <property ame="age" value="31"/> </bea> <bea id="childbea" class="org.example.childbea" paret="abstractbea" iit-method="iit"> <property ame="ame" value="child-az"/> </bea> The paret bea defies 2 values (ame, age) The child bea uses the paret age value (31) The child bea overrides the paret ame value (from paret-az to child- AZ) Paret bea could ot be ijected, child could 17
Sprig Stack 18
Questio? 19