springdmfor osgi™toby.epril.com/upload/jco9-springdm_for_osgi.pdfosgi™...

28
SpringDM for OSGi™ 이일민 KSUG/Epril

Upload: others

Post on 22-Mar-2020

13 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

SpringDMfor OSGi™

이일민

KSUG/Epril

Page 2: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

OSGi™

•자바를 위한 다이나믹 모듈 시스템

§Java

§Dynamic

§Module System

•OSGi

§Eclipse

§IBM WebSphere 6.1, Lotus

§BEA WebLogic Event Server 2.0

§BMW, Nokia, Canon

Page 3: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Module System

•Bundle이라고 불리는 모듈의 조합으로 구성된 시스템

•강력한 visibility 규칙

§블랙박스

§의도하지 않은 모듈간의 커플링 차단

•안전한 의존관계 처리 프로세스

•유연한 버전관리 기능

§버전을 통한 export/import

Page 4: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Dynamic

•Bundle은 시스템 실행중에 동적으로

§설치(install)

§시작(start)

§종료(stop)

§제거(uninstall)

§수정(update)

•할 수 있다

•Bundle에 대한 정보와 상태도 조회가능

Page 5: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Service-Oriented

•SOA in JVM

•번들은 서비스로 배포될 수 있다

•서비스 레지스트리를 통해서 다른 번들을 찾고 바인딩 할 수 있다

•모든 작업은 동적으로 실행중에 가능하다

Page 6: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Bundle

export-package x.y.z

privateimplementationpackages

•Export된 인터페이스는 버전정보와 함께 공개된다

•Passive contribution

•공개된 타입은 type space에추가되어져 사용된다

•Import한 번들의 update,refresh시에새로운 버전이 적용된다(resolution process)

•구현부분은 외부로 공개되지 않고차단된다

Page 7: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Service Bundle

•Published Service

•Active Contribution

•서비스는 레지스트리에 공개된다

•서비스를 이용하는 번들은서비스의 변경을 즉시 알 수 있다

service interface

privateimplementationobjects

Page 8: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Versioning

•Import되는 패키지는version정보를 가질 수있다

•같은 패키지/클래스의다른 버전이 동시에 사용될수 있다

Module A

Module C1.0

Module B

Module C2.0

Page 9: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Spring vs OSGi

•Spring

§느슨하게 연결된(Loosely Coupled)

§Dependency Injection

§POJO 프로그래밍 모델

•OSGi

§Coarse-grained 컴포넌트 (>object, <jee)

§Bundle 레벨의 동적인 배치

§서비스 방식 지원

§POJO기반의 개발은 어려움(invasive)

Page 10: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Spring + OSGi

•Spring Dyamic Module for OSGi

•Spring과 OSGi의 장점을 결합

•Loosely coupled컴포넌트 모델

•다이나믹 Dependency Injection

Page 11: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

OSGi Extender Bundle

•Spring의 설정정보를 이용해서 다이나믹하게 스프링 기반의 bundle로 만든다

•Spring Bean(POJO)을 서비스로 이용할수 있다

•Bundle간의 Dependency Injection지원

•기존 스프링 기반의 애플리케이션을 간단하게OSGi Bundle형태로 재구성 할 수 있다

Page 12: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Spring Bundle

•설정파일

§/META-INF/spring/*.xml

•필요한 패키지를 export/import 설정

§/META-INF/MANIFEST.MF

•Spring2.5의 모든 모듈은 OSGi Bundle로패키징 되어있다

Page 13: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

SpringDM OSGi

Infrastructure Bundles

Spring Bean Service

SpringOSGiExtender

OSGi Platform

Applicaion Bundles

Application Context

Page 14: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Dependency Injection

•Bundle사이의 bean depdency injection은 OSGi Service Registry를 이용한다

•공개된 서비스의 reference를 import한다

•Spring을 이용하지 않은 서비스와도 같은 방법에 의해서 DI가 가능하다

Page 15: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Dependency Injection

Service Registry

Bundle A Bundle B

Page 16: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Export Service

•어떤 스프링 bean도 서비스로 export될 수있다

•<osgi:service>

§ref : bean reference

§interface : Service interface

Page 17: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Reference Service

•최적의 서비스를 동적으로binding(injection)한다

•<osgi:reference/>

§Id: Spring context에서 사용될 id

§Interface: Service interface

Page 18: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Demo

•Agent -> Membership

•Context 생성

§필수 service reference가 모두 준비될 때까지기다린다

§순서에 상관없이 번들을 install/start 해주면된다

Page 19: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Reference Listener

•<osgi:listener bind-method=“..”unbind-method=“..”>

•SpringOSGi에 의해서 동적으로 변화되는binding정보를 얻을 수 있다

Page 20: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Integration Testing

•Testing

§스프링!

§POJO/DI를 이용한 Unit Test

§Spring Integration Test

•SpringOSGi Integration Test

§OSGi Platform위에서 테스트

§JUnit을 이용해서 다이나믹하게 테스트용 번들을 생성해주는 기능

Page 21: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

OSGi Server Platform

•OSGi를 이용한 서버 환경

•Enterprise Service를 번들 형태로 제공

•기존의 JEE라이브러리/프레임워크의 활용

Page 22: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

OSGi Server

OSGi Service Platform

Enterprise Service Bundles

WebContainer

TxService …

Web

App Bundles

AppBundle

App Bundle

Page 23: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Embedded OSGi

Web App

Servlet Bridge

OSGi Service Platform

AppBundle

AppBundle

Bundles

Page 24: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

OSGi한계와 Spring

•기존 JEE프레임워크/라이브러리를 OSGi환경에서 사용하는데는 어려움이 있다

§Class/Resource Loading

üClass visibility

üClass.forName

ücontext class loader

•SpringOSGi의 도움으로 많은 부분이 해결

Page 25: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

전망

•IBM,BEA,Oracle,SS등을 중심으로 서버OSGi 기술이 발전

•기존 JEE기술과 프레임워크의 OSGi적용작업

•Spring OSGi

§Web

§Library Issue

•OSGi관련 툴의 발전

Page 26: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

OSGi Platform/Tool

•Eclipse Equinox

§Eclipse의 기반

§PDE환경에서 개발이 편리

•Apache Felix

•Knopflefish

•다양한 상용/오픈소스 OSGi Platform

•PaxRunner/BND/Maven

Page 27: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

Reference

•Eclipse/Equinox

•OSGi Alliance Specfication

•SpringDM OSGi 아티클 &동영상

•Spring&OSGi Google Groups

•http://toby.epril.com

•http://www.springframework.co.kr

•KSUG 세미나 – SpringOSGi

Page 28: SpringDMfor OSGi™toby.epril.com/upload/JCO9-SpringDM_For_OSGi.pdfOSGi™ •자바를위한다이나믹모듈시스템 §Java §Dynamic §Module System •OSGi §Eclipse §IBM WebSphere

이저작물은크리에이티브커먼즈코리아저작자표시-비영리-동일조건변경허락 2.0 대한민국라이센스에따라이용하실수있습니다.

This work is licensed under Creative Commons Korea Attribution 2.0 License.