- What is OSGi?
더 감이 오게 정의된 표현은 "The Dynamic Module(Bundle) System for Java"
특징을 훑어 보면
- 모듈화 된 시스템을 위해 고안되었고
- visibility rules을 갖고 있다.(자바의 private/public과 유사한)
- a resolution process(의존성 관리를 위한)가 있고
- 버전 인식이 가능하고
- 설치, 삭제, 갱신, 구동 등이 모두 동적으로 실행 가능하며
- 번들 형태로 서비스를 배포(publish)할 수 있고, Service Registry가 있다.
OSGi 컨테이너
- Open-source implementations: Equinox, Felix (Apache), Knopflerfish
- Significant Enterprise usage: Eclipse, IBM (WebSphere, Lotus), JOnAS, interest from BEA and Oracle
- What problems does it help us to solve?
어디어 써먹을 수 있는가?
Visibility
reflection이나 classloading으로도 접근이 불가능하다. 즉, black-box 기반의 CBD가 가능하고, 보안에도 유리
Operational Control
OSGi 콘솔이나 JMX를 통해 모니터링이 가능하다. 현재 WAS류가 제공해주는 hot deploy 기능보다 한발 더 나아갔다고 해야 하나. 최대 강점은 모든 조작에 재시작이 필요없을 것이란 점
- How does it work?
What is an OSGi bundle?
jar 형태이며 META-INF/MANIFEST.MF 파일에 다음의 선언만을 필요로 한다.
Bundle-SymbolicName: org.swf.beans
이클립스는 OSGi 번들을 플로그인로 관리하려 생성/편집할 수 있다.
JSR 277 (Java Module System)과 유사해보이는데, 이 녀석은 동적이지 못하여 발표자 등은 OSGi에 기반한 JSR 291 (Dynamic Component Support for Java SE)에 밀릴 것이라고 예상했다.
- Where does Spring fit in?
- Spring-OSGi
Spring modules (spring-core, spring-beans, spring-aop) will be shipped as OSGi bundles in Spring 2.1.
2.1 버전에서 Spring이 완전히 OSGi를 수용할 모양이다.
OsgiBundleXmlApplicationContext is a Spring application context based on an OSGi bundle.
There is a "bundle:" prefix for specifying an explicit path.
classpath:나 file: 만이 아닌 bundle: 을 지원하는군.
ConfigurableBundleCreatorTests. This automatically creates an OSGi bundle containing the tests on the fly.
태생부터 테스트를 준비하고 등장한다는거~ 역시 Spring 답다. ^^
그림을 보니까 느낌이 온다. 그렇군. 웹 애플리케이션도 OSGi 모듈로 모두 배포한다면...
이전 프로젝트에서 jar로 모듈화 해서 배포한 것이랑 war로 통으로 배포한 것이랑 별 차이가 없었다.
그런데, OSGi 모듈로 인식되는 jar라면!
Equinox is the only OSGi container that currently supports web applications.
It uses a "bridge servlet" that acts as a front controller and dispatches servlet requests to bundles. To package your application as and deploy it to Equinox, you basically have to create a WAR with the bridge servlet as the only entry in web.xml and the only JAR in WEB-INF/lib is servletbridge.jar. Everything else is packaged under /WEB-INF/eclipse.
마무리에 Raible은 다음과 같이 정리한다.
나는 요즘.. 대학원에서 배웠던 원론적인 이야기들이 차츰 실현되는 것을 느낀다.
객체지향 초창기 바이블이 이야기하던 것이 DDD를 통해 구현될 조짐을 보이고 있고
CBD 바이블에서 이야기하던 것을 OSGi는 매우 충실하게 구현해낼 것 같다.
원문: [TSE] Spring-OSGI with Adrian Colyer

이올린에 북마크하기
이올린에 추천하기