Guice 문서 원본 보기
←
Guice
둘러보기로 가기
검색하러 가기
문서 편집 권한이 없습니다. 다음 이유를 확인해주세요:
요청한 명령은 다음 권한을 가진 사용자에게 제한됩니다:
사용자
.
이 문서는 편집하거나 다른 명령을 할 수 없도록 보호되어 있습니다.
문서의 원본을 보거나 복사할 수 있습니다.
Google Guice를 정리 합니다. *홈페이지 : [https://github.com/google/guice https://github.com/google/guice] **Getting Started : [https://github.com/google/guice/wiki/GettingStarted https://github.com/google/guice/wiki/GettingStarted] **사용자 가이드 : [https://github.com/google/guice/wiki/Motivation https://github.com/google/guice/wiki/Motivation] **Java Doc : [http://google.github.io/guice/api-docs/3.0/javadoc/packages.html http://google.github.io/guice/api-docs/3.0/javadoc/packages.html] *다운로드 : *라이선스 : [[Apache 2.0|Apache 2.0]] *플랫폼 : == Guice 개요 == Google에서 발표한 Java 5 이상에서 지원되는 가벼운 DI container으로 Annotation을 사용하여 DI를 구현 <span style="color:#008000;">'''<span style="font-size:larger;">IoC (Inversion of Control, 제어의 역전)</span>'''</span> 프로그램에 의해서 객체(Bean)가 관리되는 것이 아니라, 위임을 통해서 IoC Container가 객체의 생성과 생명주기를 관리<br/>특정 작업을 위한 객체를 프로그램이 직접 생성하는 것이 아니라, IoC Container를 통해서 공급 받음 <span style="color:#008000;">'''<span style="font-size:larger;">DL (Dependency Lookup, 의존성 검색)</span>'''</span> 개발자가 Container에서 제공하는 API를 사용하여 사용하고자 하는 객체(Bean)을 찾는 것 <span style="color:#008000;"><span style="font-size:larger;">'''DI (Dependency Injection, 의존성 주입)'''</span></span> 의존성 주입 방법 *Constructor Injection *Setter Injection *Method Injection {| border="1" cellspacing="0" cellpadding="2" style="width: 100%;" |- | style="text-align: center; background-color: rgb(241, 241, 241);" | 구분 | style="text-align: center; background-color: rgb(241, 241, 241);" | 상세 |- | style="text-align: center;" | Construction Injection | public class PersonService {<br/> private Person person;<br/> <br/> <span style="color:#0000FF;">'''@Inject'''</span><br/> public PersonService(Person person) {<br/> this.person = person;<br/> }<br/>} public class PersonModule extends <span style="color:#0000FF;">'''AbstractModule'''</span> {<br/><span style="color:#0000FF;">''' protected void configure() {<br/> bind(Person.class).to(PersonImpl.class);<br/> }'''</span><br/>} |- | style="text-align: center;" | Setter Injection | |- | style="text-align: center;" | Method Injection | |- | style="text-align: center;" | DI 테스트 | <span style="line-height: 20.7999992370605px;">public class PersonServiceTest {</span><br/><span style="line-height: 20.7999992370605px;"> private </span><span style="line-height: 20.7999992370605px; color: rgb(0, 0, 255);">'''Inject'''</span><span style="line-height: 20.7999992370605px;"> injector = null;</span><br/><br/><span style="line-height: 20.7999992370605px;"> @Before</span><br/><span style="line-height: 20.7999992370605px;"> public void setup() {</span><br/><span style="line-height: 20.7999992370605px;"> injector = </span><span style="line-height: 20.7999992370605px; color: rgb(0, 0, 255);">'''Guice.createInjector(new PersonModule())'''</span><span style="line-height: 20.7999992370605px;">;</span><br/><span style="line-height: 20.7999992370605px;"> }</span><br/><br/><span style="line-height: 20.7999992370605px;"> @Test</span><br/><span style="line-height: 20.7999992370605px;"> public void getPersonService() {</span><br/><span style="line-height: 20.7999992370605px;"> PersonService personService</span><br/><span style="line-height: 20.7999992370605px;"> </span><br/><span style="line-height: 20.7999992370605px;"> personService = </span><span style="line-height: 20.7999992370605px; color: rgb(0, 0, 255);">'''injector.getInstance(PersonService.class)'''</span><span style="line-height: 20.7999992370605px;">;</span><br/><span style="line-height: 20.7999992370605px;"> }</span><br/><span style="line-height: 20.7999992370605px;">}</span><br/> |} == 참고 문헌 == *[http://netframework.tistory.com/entry/Google-Guice%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-DI-1 Dependency Injection, 2014.08] *[http://www.mimul.com/pebble/default/2009/10/16/1255700940000.html http://www.mimul.com/pebble/default/2009/10/16/1255700940000.html] *[http://www.nextree.co.kr/p11247/ http://www.nextree.co.kr/p11247/] *[http://isstory83.tistory.com/91 http://isstory83.tistory.com/91] [[Category:Java|Category:Java]]
Guice
문서로 돌아갑니다.
둘러보기 메뉴
개인 도구
로그인
이름공간
문서
토론
변수
보기
읽기
원본 보기
역사 보기
더 보기
검색
주요 메뉴
오픈소스 컨설팅
오픈소스
오픈소스 라이선스
오픈소스 커뮤니티
오픈소스 종류
오픈소스 현황
오픈소스 한글화
문자셋과 인코딩
Storage
Network
보안
고가용성
모니터링
오픈 API
오픈 서비스
Cloud
BigData
Android
산사랑 노트
둘러보기
인기 문서
최근 수정 문서
모든 문서
모든 분류
임의 문서
위키 사용법
자매 사이트
CMS
오비컨 홈페이지
오비컨 CMS
블로그
데모 - SuiteCRM
산사랑의 Twitter
산사랑의 Facebook
친구 사이트
공개SW 포털
OLIS
한국공개소프트웨어협회
AppCenter 지원본부
OLC
PSEG
개발자 블로그
블로터
개인 메뉴
메뉴 수정
양식함
도구
여기를 가리키는 문서
가리키는 글의 최근 바뀜
특수 문서 목록
문서 정보