• No results found

Equinox Framework: A Happier OSGi R6 Implementation

N/A
N/A
Protected

Academic year: 2021

Share "Equinox Framework: A Happier OSGi R6 Implementation"

Copied!
61
0
0

Loading.... (view fulltext now)

Full text

(1)

Equinox Framework:

A Happier OSGi R6 Implementation

Tom Watson

IBM

(2)

Agenda

New to OSGi R6 Core

Redesign Core Equinox and Why

What Breaks?

(3)

OSGi R6 Core

Finalizing specification in March 2014

Equinox Luna release will be the RI (June 2014)

R6 Noteworthy Additions

Service Scopes

Data Transfer Objects

Native Namespace

Extension Bundle Activators

WeavingHook Enhancements

(4)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

(5)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

S

registers

si

ng

le

to

n

Singleton object that

implements the

service contract

(6)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

S

gets

Each Bundle can get

access to the singleton

object via the registry

si

ng

le

to

(7)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

S

gets

Each Bundle can get

access to the singleton

object via the registry

si

ng

le

to

(8)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

registers

(9)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

SF

registers

bu

nd

le

ServiceFactory

that

creates one service

instance for each bundle

(10)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

SF

gets

Each Bundle can get

access to a bundle

specific service

object via the registry

bu

nd

(11)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

SF

gets

B S

1

bu

nd

le

(12)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

SF

gets

B S

1

bu

nd

le

(13)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

SF

gets

B S

1

C S

2

bu

nd

le

(14)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

Prototype (new for R6) – Prototype

Service Factory used to create a

service object for each request for the

service

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

registers

(15)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

Prototype (new for R6) – Prototype

Service Factory used to create a

service object for each request for the

service

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

PSF

pr

ot

ot

yp

e

registers

PrototypeServiceFactory

That creates multiple service

instances for each bundle

(16)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

Prototype (new for R6) – Prototype

Service Factory used to create a

service object for each request for the

service

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

PSF

gets

ServiceObjects.getService()

Each Bundle can

request a new instance

of the service

object via the registry

pr

ot

ot

yp

(17)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

Prototype (new for R6) – Prototype

Service Factory used to create a

service object for each request for the

service

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

PSF

gets

B S

1

pr

ot

ot

yp

e

(18)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

Prototype (new for R6) – Prototype

Service Factory used to create a

service object for each request for the

service

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

PSF

B S

1

pr

ot

ot

yp

e

(19)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

Prototype (new for R6) – Prototype

Service Factory used to create a

service object for each request for the

service

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

PSF

gets

B S

1

ServiceObjects.getService()

pr

ot

ot

yp

e

(20)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

Prototype (new for R6) – Prototype

Service Factory used to create a

service object for each request for the

service

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

PSF

gets

B S

1

S

2

...

pr

ot

ot

yp

e

(21)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

Prototype (new for R6) – Prototype

Service Factory used to create a

service object for each request for the

service

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

PSF

gets

B S

1

S

2

...

ServiceObjects.getService()

pr

ot

ot

yp

e

(22)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

Prototype (new for R6) – Prototype

Service Factory used to create a

service object for each request for the

service

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

PSF

B S

1

S

2

...

C S

3

gets

pr

ot

ot

yp

e

(23)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

Prototype (new for R6) – Prototype

Service Factory used to create a

service object for each request for the

service

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

PSF

B S

1

S

2

...

C S

3

pr

ot

ot

yp

e

(24)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

Prototype (new for R6) – Prototype

Service Factory used to create a

service object for each request for the

service

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

PSF

gets

B S

1

S

2

...

C S

3

ServiceObjects.getService()

pr

ot

ot

yp

e

(25)

OSGi R6 Core – Service Scopes

Identify the scope of a service

object

Singleton – single instance used by all

bundles

Bundle – Service Factory used to create

a service object for each bundle

Prototype (new for R6) – Prototype

Service Factory used to create a

service object for each request for the

service

A

B

C

B

un

dl

es

S

e

rv

ic

e

R

eg

is

tr

y

PSF

B S

1

S

2

...

C S

3

S

4

...

pr

ot

ot

yp

e

(26)

Data Transfer Objects

An object that carries data between processes

The motivation for its use has to do with the fact that

communication between processes is usually done resorting to

remote interfaces (e.g. web services), where each call is an

expensive operation.

Does not have any behavior except for storage and retrieval of its

(27)

OSGi R6 Core – Data Transfer Objects

DTOs represent the state of runtime objects

Core Framework supplies a number of DTOs

Easily serializable

Only has public fields with limited types

Must form a tree to simplify serialization

Data contained is a snapshot of the state

DTOs do not track state changes

DTOs are not thread safe

(28)

OSGi R6 Core – Obtaining Core DTOs

Core Framework DTOs obtained via bundle adapt

(29)

OSGi R6 Core – Obtaining Core DTOs

Core Framework DTOs obtained via bundle adapt

BundleDTO

– for a bundle: state, id, name, version.

(30)

OSGi R6 Core – Obtaining Core DTOs

Core Framework DTOs obtained via bundle adapt

BundleDTO

– for a bundle: state, id, name, version.

BundleRevisionDTO

– for a bundle revision: requirements, capabilities

BundleRevisionDTO dto

(31)

OSGi R6 Core – Obtaining Core DTOs

Core Framework DTOs obtained via bundle adapt

BundleDTO

– for a bundle: state, id, name, version.

BundleRevisionDTO

– for a bundle revision: requirements, capabilities

BundleWiringDTO

– for a bundle wiring: required and provided wires

BundleWiringDTO dto

(32)

OSGi R6 Core – Obtaining Core DTOs

Core Framework DTOs obtained via bundle adapt

BundleDTO

– for a bundle: state, id, name, version.

BundleRevisionDTO

– for a bundle revision: requirements, capabilities

BundleWiringDTO

– for a bundle wiring: required and provided wires

ServiceReferenceDTO

– for a registered service: properties, using bundles

ServiceReferenceDTO[] dtos

(33)

OSGi R6 Core – Obtaining Core DTOs

Core Framework DTOs obtained via bundle adapt

BundleDTO

– for a bundle: state, id, name, version.

BundleRevisionDTO

– for a bundle revision: requirements, capabilities

BundleWiringDTO

– for a bundle wiring: required and provided wires

ServiceReferenceDTO

– for a registered service: properties, using bundles

FrameworkDTO

– for the framework: list installed bundles, services, launch props

FrameworkDTO dto

(34)

OSGi R6 Core – Obtaining Core DTOs

Core Framework DTOs obtained via bundle adapt

BundleDTO

– for a bundle: state, id, name, version.

BundleRevisionDTO

– for a bundle revision: requirements, capabilities

BundleWiringDTO

– for a bundle wiring: required and provided wires

ServiceReferenceDTO

– for a registered service: properties, using bundles

FrameworkDTO

– for the framework: list installed bundles, services, launch props

BundleStartLevelDTO

– for a bundle start-level and start options

BundleStartLevelDTO dto

(35)

OSGi R6 Core – Obtaining Core DTOs

Core Framework DTOs obtained via bundle adapt

BundleDTO

– for a bundle: state, id, name, version.

BundleRevisionDTO

– for a bundle revision: requirements, capabilities

BundleWiringDTO

– for a bundle wiring: required and provided wires

ServiceReferenceDTO

– for a registered service: properties, using bundles

FrameworkDTO

– for the framework: list installed bundles, services, launch props

BundleStartLevelDTO

– for a bundle start-level and start options

FrameworkStartLevelDTO

– for the framework start-level and initial bundle

start-level

FrameworkStartLevelDTO dto

(36)

OSGi R6 Core – Native Namespace

Describes the native environment the framework is

running

Framework provides a capability in the

osgi.native

namespace

Bundle-NativeCode

headers are converted in to

requirements in the

osgi.native

namespace

Last requirement type in OSGi to be transformed into

(37)

OSGi R6 Core – Extension Bundle Activators

Allows

system.bundle

fragments to hook into the

initialization and shutdown process of the framework

Usecase involves scenarios that require hooks to be in

place before any other bundles are resolved

Equinox regions uses this to ensure the regions are

established before any bundle resolution operations

occur

(38)

OSGi R6 Core – Weaving Hook Enhancements

New

WovenClassListener

Listen to class weaving process to detect new dynamic imports

Needed by isolation engines, such as subsystems, to provide access to imports

added by

WeavingHook

implementations

Package import permissions are auto-granted to Woven

bundles for package imports added by a

WeavingHook

With security enabled a woven bundle may be prevented from wiring to a

(39)

Equinox Framework in need of a redesign

One unhappy implementation

Dependencies are modelled differently from the

generic dependency model of the OSGi

specification

Requires adapting Equinox resolver types to OSGi wiring

types

Needed to call out to resolver and weaving hooks

Hard to reason about locking strategy

OSGi Resolver and Weaving Hooks introduced more

callouts to user code

Too many abstraction layers!

Hard to prototype core OSGi changes for the

reference implementation

Dependency Resolution (e.g. Native Namespace)

Hook impls

adaptor hooks

OSGI wiring

resolver

Equinox

base

adaptor

Equinox – Moving Forward

(40)

Equinox – Redesign the Core

Implement a core module container

(41)

Equinox – Redesign the Core

Implement a core module container

Responsible for managing resources

(42)

Equinox – Redesign the Core

Implement a core module container

Responsible for managing resources

Lifecycle

(43)

Equinox – Redesign the Core

Implement a core module container

Responsible for managing resources

Lifecycle

Metadata – Capabilities and Requirements

(44)

Equinox – Redesign the Core

Implement a core module container

Responsible for managing resources

Lifecycle

Metadata – Capabilities and Requirements

Resolution

(45)

Equinox – Redesign the Core

Implement a core module container

Responsible for managing resources

Lifecycle

Metadata – Capabilities and Requirements

Resolution

Persistent settings

(46)

Equinox – Redesign the Core

Implement a core module container

Responsible for managing resources

Lifecycle

Metadata – Capabilities and Requirements

Resolution

Persistent settings

Uses an OSGi R5 Resolver service

Currently Apache Felix

(47)

Equinox – Redesign the Core

Implement a core module container

Responsible for managing resources

Lifecycle

Metadata – Capabilities and Requirements

Resolution

Persistent settings

Uses an OSGi R5 Resolver service

Currently Apache Felix

Concurrency in mind from the start

Properly handle call outs (hooks) while holding no locks

Tools may use it for modelling OSGi wiring (PDE)

(48)

Equinox – Redesign the Core

Implement a core module container

Responsible for managing resources

Lifecycle

Metadata – Capabilities and Requirements

Resolution

Persistent settings

Uses an OSGi R5 Resolver service

Currently Apache Felix

Concurrency in mind from the start

Properly handle call outs (hooks) while holding no locks

Tools may use it for modeling OSGi wiring (PDE)

Does not deal with bundle content, class loading,

service registry, event listeners, security

Happy

Container

class loading

service registry

event listeners

security

bundle content

(49)

Equinox – Redesign the Framework

Happy

Container

class loading

service registry

event listeners

security

bundle content

I care

about that

big X

(50)

Equinox – Redesign the Framework

Uses the container as the core

Keeps complicated concurrency concerns in

one place

Uses reentrant read/write lock for the module 'database'

For long running operations optimistic locking is used. For

example, resolution.

(51)

Equinox – Redesign the Framework

Uses the container as the core

Keeps complicated concurrency concerns in

one place

Uses reentrant read/write lock for the module 'database'

For long running operations optimistic locking is used. For

example, resolution.

Implements Framework bits outside of the

container

Bundle content

Class loading

Service registry

Event listeners

Security

Container

Happy Equinox

class loading

service registry

event listeners

security

bundle content

(52)

Equinox – Configuration

Don't access config statically

Get rid of static class

FrameworkProperties

Instead make available an instance of

EquinoxConfiguration

Greatly simplifies and optimizes

embedding and starting multiple

Framework instances

A special class loader was needed to isolate static

config data for each framework instance

Container

class loading

service registry

event listeners

security

bundle content

Happy Equinox

configuration

config.ini

(53)

Equinox – Hooks

Hook impls

Container

class loading

service registry

event listeners

security

bundle content

Happy Equinox

configuration

config.ini

Equinox Hooks are still supported

Much of the internal details changed requiring an overhaul

of the Equinox Hooks SPI

ALL existing Equinox Hook implementers are broken and

will need migration

Unhappy Equinox had too many Hooks

Three class loading hooks – now one, but no ability to

override bundle class loader implementation

Bundle File hook – removed, use wrapper hook instead

Adaptor hook – removed, no more adaptor

Bundle Watcher – removed, was a glorified bundle listener

Added ability to specify a bundle activator that is called

during framework start/stop

Improved Storage Hook to handle hooks being

added/removed better

(54)

Equinox – Old State/Resolver

Container

Happy Equinox

• Equinox Container has no implementation

of old Equinox resolver API

Still exports the Equinox resolver API

(55)

Equinox – Old State/Resolver

Container

Happy Equinox

• Equinox Container has no implementation

of old Equinox resolver API

Still exports the Equinox resolver API

No longer registers the

PlatformAdmin

service

• Equinox Compatibility fragment

Hooks into Equinox to register a

PlatformAdmin

implementation

Attempts to mirror the Equinox wiring state in the

PlatformAdmin implementation

Has some limitations modeling the running state

Useful for offline modeling, for example: PDE

Disgruntled

Fragment

(56)

Equinox – Plugin Converter

Container

Happy Equinox

• Equinox Container has no implementation

of the Plugin Converter

Support for Eclipse 2.0 style plugins

Still exports the plugin converter API

(57)

Equinox – Old State/Resolver

Container

Happy Equinox

• Equinox Container has no implementation

of the Plugin Converter

Support for Eclipse 2.0 style plugins

Still exports the plugin converter API

No longer registers the

PluginConverter

service

• Equinox Compatibility fragment

Hooks into Equinox to register a

PluginConverter

implementation

Converts Eclipse 2.0 style plugins into proper bundles

Disgruntled

Fragment

(58)

Equinox – What Breaks?

Container

Happy Equinox

• All Equinox Framework Hook

implementations must be migrated

• Some limitations for the compatibility

resolver

Disconnected from the running wiring state

Cannot be used to diagnose resolution errors

Cannot be used to disable bundles at runtime

Disgruntled

Fragment

(59)

Equinox – Current Status

• Work is being done in the git master branch

http://git.eclipse.org/c/equinox/rt.equinox.framework.git/log/?h=master

http://git.eclipse.org/c/equinox/rt.equinox.bundles.git/log/?h=master

• Implementation has been in Luna since M1

• Fully compliant with the current suite of compliance tests for

OSGi R6

Will be the reference implementation of the Core Framework for R6

• Successful if nobody notices

(60)

Evaluate This Session

Sign-in:

www.eclipsecon.org

Select session from schedule

Evaluate:

1

2

3

(61)

IBM and WebSphere are trademarks or registered trademarks of

International Business Machines Corp., registered in many

jurisdictions worldwide.

Java and all Java-based trademarks and logos are trademarks or

registered trademarks of Oracle and/or its affiliates.

Other product and service names might be trademarks of IBM or other

companies. A current list of IBM trademarks is available on the Web at

“Copyright and trademark information” at

www.ibm.com/legal/copytrade.shtml.

References

Related documents

For example, if there are more than 20 UEs in a cell and the proportion of HSUPA UEs is greater than 50%, this feature can effectively reduce the RTWP that exceeds the

Empirical Colebrook equation implicit in unknown flow friction factor (λ) is an accepted standard for calculation of hydraulic resistance in hydraulically smooth and rough pipes..

The performance for Equinox Frontier Diversified Fund, Equinox Frontier Masters Fund, and Equinox Long/Short Commodity Fund is net of fees and charges, including management

Equinox Gold Corp., 2021, Equinox Gold completes acquisition of Premier Gold Mines, i-80 Gold created: Vancouver, British Columbia, Canada, Equinox Gold Corp.. (Accessed May 13,

The fees promulgated by the Board of Examiners for Speech-Language Pathology and Audiology shall be exclusive and no municipality shall have the right to require any person

The Stentor model seems to have been dropped, the Harmonic trumpets go up to 13700, the “JR” model is dropped, and the Keefer – Williams model goes up to 10098. In my dating, I

We assume that a transient fault during the calculation of the next state at time step t causes an erroneous value at exactly one of the state variables in the next state vector ξ [ t

36 The project focuses on three types of protest spaces: (1) issue-specific spaces, such as the German Easter March Movement focus on military bases; (2) collective memory