what is os gi and what does osgi

27
OSGi What is OSGi and What does OSGi? Witted by YunChang.Lee

Upload: yunchang-lee

Post on 16-Apr-2017

528 views

Category:

Software


0 download

TRANSCRIPT

OSGi

What is OSGi and What does OSGi?

Witted by YunChang.Lee

What is OSGi?OSGi 프레임워크는 독립적인 자바 / 가상 머신 환경에서 제공하고 있지 않는 세련되고 , 완전하며 동적인 SOA(Service Oriented Architec-ture) 기반의 컴포넌트 모델을 구현한다 . 응용 프로그램 또는 구성 요소( 번들 , Bundle) 는 재시동 과정 없이 원격지를 통해 설치 (installed), 시작 (started), 정지 (stopped), 업데이트 (updated) 그리고 제거(uninstalled) 할 수 있다 .The OSGi (Open Service Gateway initiative) specification describes a modular system and a service platform for the Java programming language that implements a complete and dynamic component model, something that does not exist in standalone Java/VM environments. Applications or components, coming in the form of bundles for deployment, can be remotely installed, started, stopped, updated, and uninstalled without requiring a reboot; management of Java packages/classes is specified in great detail. Application life cycle management is implemented via APIs that allow for remote downloading of management policies. The service registry allows bundles to detect the addition of new ser-vices, or the removal of services, and adapt accordingly.

The OSGi specifications have evolved beyond the original focus of service gateways, and are now used in applications ranging from mobile phones to the open-source Eclipse IDE. Other application areas include automobiles, industrial au-tomation, building automation, PDAs, grid computing, en-tertainment, fleet management and application servers.

What does OSGi?Each plugin is a versioned artifact that has its own class-loader.Each plugin depends on both specific jars that it contains and also other specific versioned plug-ins.Because of the versioning and isolated classloaders, differ-ent versions of the same artifact can be loaded at the same time. If one component of your application relies on one version of a plug-in and another depends on another ver-sion, they both can be loaded at the same time.

With this, you can structure your application as a set of ver-sioned plugin artifacts that are loaded on demand. Each plugin is a standalone component. Just as Maven helps you structure your build so it is repeatable and defined by a set of specific versions of artifacts it is created by, OSGi helps you do this at runtime.

OSGi Alliance

OSGi Alliance 는 OSGi 관련 표준 선정 기구

OSGi Specifications

OSGi Release 6OSGi Release 6 was first released in June 2014. Core was released in June 2014.

OSGi Framework implementations

Dead Project

OSGi Framework Architecture

Bundles - Bundles are the OSGi components made by the developers. Services - The services layer connects bundles in a dynamic way by offering a pub-

lish-find-bind model for plain old Java objects. Life-Cycle - The API to install, start, stop, update, and uninstall bundles. Modules - The layer that defines how a bundle can import and export code. Security - The layer that handles the security aspects. Execution Environment - Defines what methods and classes are available in a spe-

cific platform.

OSGi System Layering

Services are dynamic. This means that a bundle can decide to with-draw its service from the registry while other bundles are still using this service. Bundles using such a service must then ensure that they no longer use the service object and drop any references. We know, this sounds like a significant complexity but it turns out that helper classes like the Service Tracker and frameworks like iPOJO, Spring, and Declarative Services can make the pain minimal while the advantages are quite large.

OSGi 프레임워크는 크게 번들 실행주기 ( 설치 / 시작 / 제거 / 업데이트 ), OSGi 기본 실행단위인 번들과 서비스에 대한 운영 관리 및 리소스와 서비스 레지스트리를 담당 한다 . 복수 개의 클래스 로더에 의해 각각 서로 다른 OSGi 어플리케이션이 독립성을 가지고 실행되지만 ,OSGi Framework Service Registry 에 등록된 Sharing Code 와 주소에 의해 서로 다른 번들간의 리소스 공유와 연동 / 통합으로무수한 서비스들을 생성하고 실행한다 .

Bundle Life Cycle

Bundle State DescriptionINSTALLED The bundle has been successfully installed.

RESOLVED All Java classes that the bundle needs are available. This state indicates that the bundle is either ready to be started or has stopped.

STARTINGThe bundle is being started, the BundleActivator.start method will be called, and this method has not yet returned. When the bundle has an activation policy, the bundle will remain in the STARTING state until the bundle is activated according to its activation pol-icy.

ACTIVE The bundle has been successfully activated and is running; its Bundle Activator start method has been called and returned.

STOPPING The bundle is being stopped. The BundleActivator.stop method has been called but the stop method has not yet returned.

UNINSTALLED The bundle has been uninstalled. It cannot move into another state.

Karaf Console

Service

The OSGi service registry enables a bundle to publish objects to a shared registry, advertised via a given set of Java interfaces. Published services also have service properties associated with them in the registry. The registry is a crucial feature of OSGi, facilitating decoupling between bun-dles by promoting a dynamic collaborative model based on a service-ori-ented paradigm (publish/find/bind).Blueprint integrates tightly with the service registry, allowing clients to pub-lish, find and bind services in a POJO-friendly manner, without coupling themselves to the OSGi API.

Benefits of Using OSGi

BenefitsReduced Complexity FastReuse LazyReal World SecureEasy Deployment HumbleDynamic Updates Non IntrusiveTransparency Runs EverywhereVersioning Widely UsedSimple Supported by Key Com-

paniesSmall

Standard Services : OSGi System Services

System Services Description

LoggingThe logging of information, warnings, debug information or errors is handled through the Log Service. It receives log entries and then dispatches these entries to other bundles that subscribed to this information.

Configuration Admin

This service allows an operator to set and get the configuration information of deployed bundles

Device Access Facilitates the coordination of automatic detection and attachment of existing devices. This is used for Plug and Play scenarios.

User Admin This service uses a database with user information (private and public) for authentication and authorization purposes.

IO Connector The IO Connector Service implements the CDC/CLDC javax.microedition.io package as a service. This service allows bundles to provide new and alternative protocol schemes.

Preferences Offers an alternative, more OSGi-friendly mechanism to using Java’s default Properties for storing preferences.

Component Run-time

The dynamic nature of services—they can come and go at any time—makes writing soft-ware harder. The Component Runtime specification can simplify handling these dynamic aspects by providing an XML based declaration of the dependencies.

Deployment Ad-min Standardizes access to some of the responsibilities of the management agent.

Event Admin Provides an inter-bundle communication mechanism based on a publish-and-subscribe model.

Application Ad-min

Simplifies the management of an environment with many different types of applications that are simultaneously available.

Standard Services : OSGi Protocol Services

Protocol Services Description

HTTP Service Allows information to be sent and received from OSGi using HTTP.

UPnP Device Service Specifies how OSGi bundles can be developed to interoper-ate with Universal Plug and Play (UPnP) devices.

DMT AdminDefines an API for managing a device using concepts from the Open Mobile Alliance (OMA) device management speci-fications.

Standard Services : OSGi Miscella-neousMiscellaneous Services Description

Wire Admin Allows the connection between a Producer service and a Con-sumer service.

XML Parser The XML Parser service allows a bundle to locate a parser with desired properties and compatibility with JAXP.

Measurement and State

The Measurement and State service allows and simplifies the correct handling of measurements in an OSGi service plat-form.

iPOJO

iPOJO is a service component runtime aiming to simplify OSGi application development. It natively supports ALL the dynamism of OSGi. iPOJO is made to run modern applications exhibiting modularity and requiring runtime adaption and autonomic behavior. Main features  Components are developed as POJOs - no dependencies or complex

API  Use annotations, XML or a fluent API to declare your components and

instances  Require and provide services without requiring code, while being

amazingly powerful  iPOJO applications are natively resilient to dynamism  Extensible and customizable, develop your own component model  iPOJO applications are supporting dynamic adaptation, and exhibit

autonomic behavior

Apache Felix iPOJO

Blueprint Service

Enterprise Modules Project (Gemini) 

The Blueprint Service specification defines a dependency injection framework, specifically for OSGi bundles, that understands the unique dynamic nature of services. It provides an OSGi bundle programming model with minimal implementation dependencies and virtually no accidental complexity in the Java code. Bun-dles in this programming model contain a number of XML definition resources which are used to wire the application together and start it when the bundle is active.This Blueprint Service specification is derived from the Spring Dynamic Modules project.There are currently two open source imple-mentations of the Blueprint:

Dependency injection framework

Dependency injection

Declarative Services Blueprint iPOJO

Callback injec-tion

Yes Yes (public method only)

Yes

Constructor in-jection

No Yes Yes

Field injection No No YesSetter injec-tion

Yes Yes Yes

Proxy injection No Yes YesList injection No Yes YesNullable injec-tion

No No Yes

Dependency injection framework

Lifecycle Declarative Services Blueprint iPOJO

Callbacks (ac-tivate/deacti-vate)

Yes Yes Yes

Factory pat-tern

Yes Yes Yes

Lazy initializa-tion

Yes Yes Yes

Damping No Yes YesField synchro-nization

No No Yes

Component lifecycle con-trol

Yes Partial Yes

Service lifecy-cle control

No No Yes

Dependency injection framework

Configuration Declarative Services Blueprint iPOJO

Property con-figuration

No Yes Yes

Field configu-ration

No No Yes

Configuration Admin

Yes No Yes

Dependency injection framework

Services Declarative Services Blueprint iPOJO

Custom at-tribute type

No Yes Yes

Lazy initializa-tion

Yes Yes Yes

Composite services

No No Yes

Dependency injection framework

Component description

Declarative Services Blueprint iPOJO

XML Yes Yes YesJava annota-tions

No No Yes

API No No Yes

Dependency injection framework

Nonfunctional Declarative Services Blueprint iPOJO

Multiple providers

Yes Yes No

How to use Blueprint Service

Bundle Start 필요

How to use Blueprint Service

Apache Karaf

Apache Karaf is a small OSGi based runtime which provides a lightweight container onto which various components and applications can be deployed.Here is a short list of features supported by the Karaf:•Hot deployment: Karaf supports hot deployment of OSGi bundles by monitoring jar files inside the [home]/deploydirectory. Each time a jar is copied in this folder, it will be installed inside the runtime. You can then update or delete it and changes will be handled automatically. In addition, the Karaf also supports exploded bundles and custom deployers (blueprint and spring ones are included by default).•Dynamic configuration: Services are usually configured through the ConfigurationAdmin OSGi service. Such configuration can be defined in Karaf using property files inside the [home]/etc directory. These configurations are monitored and changes on the properties files will be propagated to the services.•Logging System: using a centralized logging back end supported by Log4J, Karaf supports a number of different APIs (JDK 1.4, JCL, SLF4J, Avalon, Tomcat, OSGi)•Provisioning: Provisioning of libraries or applications can be done through a number of different ways, by which they will be downloaded locally, installed and started.•Native OS integration: Karaf can be integrated into your own Operating System as a service so that the lifecycle will be bound to your Operating System.•Extensible Shell console: Karaf features a nice text console where you can manage the services, install new applications or libraries and manage their state. This shell is easily extensible by deploying new commands dynamically along with new features or applications.•Remote access: use any SSH client to connect to Karaf and issue commands in the console•Security framework based on JAAS•Managing instances: Karaf provides simple commands for managing multiple instances. You can easily create, delete, start and stop instances of Karaf through the console.

ServiceMix

Apache ServiceMix is a flexible, open-source integration container that uni-fies the features and functionality of Apache ActiveMQ, Camel, CXF, andKaraf into a powerful runtime plat-form you can use to build your own integrations solutions. It provides a complete, enterprise ready ESB ex-clusively powered by OSGi.

JBoss FUSE

JBoss Fuse is an open source Enterprise Service Bus (ESB) with an elastic foot-print that supports integration beyond the data center. The ability to deploy JBoss Fuse in several different configura-tions enables intelligent integration to all facets of your business – on premise or in the Cloud.