본문 바로가기

JAVA

[ OSGi ] 1 - OSGi 기초

728x90




OSGi란 ( Open Service Gateway initiative )

OSGi는 Java VM에서  구동 될수 있는 플렛폼의 규약(Dynamic Module for Java)으로 Bundle( 혹은 Component / Plug-in / Moudule )의 Life Cycle ( install, start, stop, update, uninstall )을 Application의 재시작 없이 관리하는 프레임워크이다.

OSGi의 적용된 대표적인 Application으로는 java 개발자라면 누구나 사용하는 Eclipse가 있다. (Eclipse의 Plugin인은 OSGi 기반이다. )


OSGi는 Specification만 존재하므로 여러 구현체 들이 따로 있는데 다음과 같다.

  • Eclipse Equinox
  • Apache Felix
  • Knopflerfish
  • Concierge
  • Posyst mBedded Server


OSGi 시작

OSGi를 시작하기 위해서는 위에서 나열한 구현체들중 하나가 필요한데 여기서는 Eclipse의 Equinox를 사용하기로 한다. 

Eclipse 설치 된 곳의  plugin folder에 들어가면 "org.eclipse.osgi_3.8.1.v20120830-144521.jar"와 같은 ( 버전별로 파일 명은 다를 수 있음 ) jar파일이 있는데 이 파일을 이용한다. 아니면 http://download.eclipse.org/equinox/ 에서 Eclipse 버전별 equinox를 받을 수 있다.


나는 실행의 편의성을 위해 equinox.jar라고 이름을 변경하여 사용한다.


OSGi의 실행을 위해 command 창에서 "java -Dosgi.console.enable.builtin=true -jar equinox.jar -console" 명령어를 입력한다. 

java -Dosgi.console.enable.builtin=true -jar equinox.jar -console


osgi> 



*** 추가내용 *********************************************************************************************

equinox osgi 3.8 버전 이후 부터 console이 바뀌었다고한다. 


3.8 버전 이하는 위에서 처럼 하면되고

3.8 버전 이상에서는 다음과 같이 해야한다. 


1. 폴더구조

sample 

   |-- plugins

            |-- org.apache.felix.gogo.command_xxx.jar

            |-- org.apache.felix.gogo.runtime_xxx.jar

            |-- org.apache.felix.gogo.shell_xxx.jar

            |-- org.eclipse.equinox.common_xxx.jar

            |-- org.eclipse.equinox.console_xxx.jar

            |-- org.eclipse.osgi_xxx.jar

   |-- configuration

            |-- config.ini


2. config.ini 파일 ( osgi 구동시 같이 start 될 bundle 목록 )

#Eclipse Runtime Configuration File

osgi.bundles=org.eclipse.equinox.common_3.6.200.v20130402-1505.jar@2:start,\

org.eclipse.equinox.console_xxx.jar@start,\

org.apache.felix.gogo.shell_xxx.jar@start,\

org.apache.felix.gogo.command_xxx.jar@start,\

org.apache.felix.gogo.runtime_xxx.jar@start

osgi.bundles.defaultStartLevel=4


3. 실행

plugins 폴더 밑에서 

 java -Dosgi.console.enable.builtin=true -jar org.eclipse.osgi_xxx.jar -console

와 같이 입력하면 된다.


**********************************************************************************************************


osgi command가 실행 되면 "ss"를 입력해보자


osgi> ss


Framework is launched.


id State       Bundle

0 ACTIVE      org.eclipse.osgi_3.9.1.v20140110-1610


osgi> 


osgi의 command line 명령어는 "help"를 입력하거나 다음 URL을 참고.

http://eclipse.org/equinox/documents/quickstart-framework.php

http://isurues.wordpress.com/2009/01/01/useful-equinox-osgi-commands/



첨부 : OSGi Framework

plugins_osgi_1.zip




참고 자료


[1] Guru's Blog

OSGi 시작하기 

http://xguru.net/443 




참고로 OSGi의 자료는 대부분 2007-8 년도의 문서들이 많다. 한국이건 외국이건...

저 시기때 한창 많은 글들이 올라오던 기술을 이제서야 접해 봤다는 것이....


'JAVA' 카테고리의 다른 글

[ OSGi ] 6 - Spring DM 3  (0) 2014.08.28
[ OSGi ] 5 - Spring DM 2  (0) 2014.08.26
[ OSGi ] 4 - Spring DM 1  (0) 2014.08.25
[ OSGi ] 3 - OSGi plugin 의존 관계  (0) 2014.08.20
[ OSGi ] 2 - OSGi plugin project  (2) 2014.08.19

태그