Top Banner
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten Ziegeler | Adobe
37

OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

Sep 13, 2018

Download

Documents

dinhminh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

OSGi R7 upcoming specificationsDavid Bosschaert & Carsten Ziegeler | Adobe

Page 2: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Carsten Ziegeler

RnD Adobe Research Switzerland

Team Lead / Founder of Adobe Granite

Member of the Apache Software Foundation

VP of Apache Felix and Sling

OSGi Expert Groups and Board member

2

Page 3: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

David Bosschaert

Adobe R&D Ireland

OSGi EEG co-chair

Apache member and committer

ISO JTC1 SC38 (Cloud Computing) Ireland committee member

3

Page 4: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

OSGi Specification Process

Requirements, Use Cases -> RFP

Technical Specification -> RFC

https://github.com/osgi/design

Reference Implementation

Compatibility Testsuite

Spec Chapter

4

Page 5: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Converterand Serialization Service

Page 6: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Object Conversion

Wouldn’t you like to convert anything to everything?

Peter Kriens’ work in Bnd started it

Convert

Scalars, Collections, Arrays

Interfaces, maps, DTOs, JavaBeans, Annotations

Need predictable behaviour – as little implementation freedom as possible

Can be customized

RFC 215 – Implementation in Apache Felix (/converter)

6

Page 7: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Sample conversions

Examples:

Converter c = new StandardConverter();

// Convert scalars

int i = c.convert("123").to(int.class);

UUID id = c.convert("067e6162-3b6f-4ae2-a171-2470b63dff00").to(UUID.class);

List<String> ls = Arrays.asList("978", "142", "-99");

short[] la = c.convert(ls).to(short[].class);

7

Page 8: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Convert configuration data into typed information with defaults

Map<String, String> myMap = new HashMap<>();

myMap.put("refresh", "750");

myMap.put("other", "hello");

// Convert map structures

@interface MyAnnotation {

int refresh() default 500;

String temp() default "/tmp";

}

MyAnnotation myAnn = converter.convert(someMap).to(MyAnnotation.class)

int refresh = myAnn.refresh(); // 750

Strine temp = myAnn.temp(); // "/tmp"

8

Page 9: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Customize your converter

The converter service itself always behaves the same

Need customizations? Create a new converter: ConverterBuilder

Change default behaviour of array to scalar conversion

Convert char[] to String via adapter

// Default behaviour

String s = converter.convert(new char[] {‘h’, ‘i’}).to(String.class); // s = “h”

Converter c = converter.newConverterBuilder()

.rule(char[].class, String.class, MyCnv::caToString, MyCnv::stringToCA)

.build();

String s2 = c.convert(new char[] {‘h’, ‘i’}).to(String.class); // ss=“hi”

9

Page 10: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Serialization service

Take an object, turn it into a file/stream, and back

with the help of the converter

YAML, JSON, or your own format

Serializations can be customized with the converter

10

Page 11: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Example JSON Serializer

@Reference(target="(mimetype=application/json)")

Serializer jsonSerializer;

public void someMethod() {

Map m = … some map …;

String s = jsonSerializer.serialize(m).toString();

MyBean someBean = … some Java Bean …;

String s2 = jsonSerializer.serializer(someBean).toString();

// and deserialize back

MyBean recreated = jsonSerializer.deserialize(MyBean.class).from(s2);

11

{"prop1": "val1","prop2": 42,"nested": {"really": true}

}

Page 12: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Config Admin and Configurator

Page 13: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

OSGi Configurations

Configuration Admin Improvements

Alias for factory configurations

Optimized change handling

Revived ConfigurationPlugin

13

Page 14: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Configuration Admin Plugins

14

Configuration

AdminComponent

PluginPlugin

PluginPlugin

Cfg Cfg‘

Page 15: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Reusable Configuration Format I

configurations:

- my.special.component:

some_prop: 42

and_another: "some string"

- and.a.factory.cmp#foo

...

- and.a.factory.cmp#bar

...

15

Page 16: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Reusable Configuration Format II

configurations:

- my.special.component:

some_prop: 42

and_another: "some string"

:configurator:environments:

- dev

- test

16

Page 17: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

OSGi Configurator

Configurations as bundle resources

Environment support

Binaries

State handling and ranking

17

Page 18: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Push Streams

Page 19: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Push Streams

Like Java 8 streams, but data is pushed

For event-based data, which may or may not be infinite

Async processing and buffering

Supports back pressure

Mapping, filtering, flat-mapping

Coalescing and windowing

Merging and splitting

Example:

Humidity reader/processor stream

sends an alarm when over 90%

RFC 216 – Implementation will be in Apache Aries

19

Page 20: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Asynchronous Push Streams example

PushStreamProvider psp = new PushStreamProvider();

try (SimplePushEventSource<Long> ses = psp.createSimpleEventSource(Long.class)) {

ses.connectPromise().then(p -> {

long counter = 0;

while (counter < Long.MAX_VALUE && ses.isConnected()) {

ses.publish(++counter);

Thread.sleep(100);

System.out.println("Published: " + counter);

}

return null;

});

psp.createStream(ses).

filter(l -> l % 2L == 0).

forEach(f -> System.out.println("Consumed even: " + f));

20

Page 21: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Declarative Service updates

Page 22: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Declarative Service Updates

Field Injection of activation objects

Constructor injection

22

Page 23: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Activation Objects

23

@Component

public class MyComponent {

public @interface Config {

int easy_max() default 10;

int medium_max() default 50;

int hard_max() default 100;

}

@Activate

private BundleContext bundleContext;

@Activate

private Config config;

Page 24: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Constructor Injection

24

@Component

public class MyComponent {

@Activate

public MyComponent(

BundleContext bundleContext,

@Reference EventAdmin eventAdmin,

Config config,

@Reference List<Receivers> receivers) {

Page 25: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Cluster Informationpreviously known as Cloud Ecosystems

Page 26: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Cluster Information

OSGi frameworks running in a distributed environment

Cloud

IoT

<buzzword xyz in the future>

Many frameworks

New ones appearing

… and disappearing

Other entities too, like databases

26

Page 27: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Cluster Information

Discovery of OSGi frameworks in a distributed environment

Find out what is available

get notifications of changes

Provision your application within the given resources

Also: non-OSGi frameworks (e.g. Database)

Monitor your application

Make changes if needed

RFC 183 – Implementation in Eclipse Concierge

27

Page 28: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Cluster Information

FrameworkNodeStatus service provides metadata

Java version

OSGi version

OS version

IP address

Physical location (country, ISO 3166)

Metrics

tags / other / custom

Provisioning API (install/start/stop/uninstall bundles etc…)

28

Page 29: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

JAX-RS support

Page 30: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

JAX-RS Services

JAX-RS inOSGi

Service / Whiteboard Model

(Http Service)

30

Page 31: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Simple Resource

31

@Component(service = TestService.class,

property = {

"osgi.jaxrs.resource.base=/myapp"

})

@Path("service")

public class TestService {

@GET

public String getHelloWorld() {

return "Hello World";

}

}

Page 32: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

OSGi Enabled

32

@Component(service = TestService.class,

property = {

"osgi.jaxrs.resource.base=/myapp"

})

@Path("service")

public class TestService {

@Reference

private GameController game;

@Activate

protected void activate(final Config config) {}

@GET

public String getHelloWorld() {

return "Hello World";

}

}

Page 33: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Parameters

33

@Component(service = TestService.class,

property = {

"osgi.jaxrs.resource.base=/myapp"

})

@Path("service/{name}")

public class TestService {

@GET

public String getHelloWorld(@PathParam("name") String name) {

return "Hello " + name;

}

}

Page 34: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

JAX-RS Support

Get, Post, Delete with Parameters

Application support

Filters and Interceptors

Request Scope vs Singleton

34

Page 35: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Additional OSGi R7 work

Page 36: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

And much more...

Service Decorations

Http Whiteboard Update

Transaction Control

JPA Updates

Remote Service Intents

36

Page 37: OSGi R7 upcoming specifications - adapt.to · © 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. OSGi R7 upcoming specifications David Bosschaert & Carsten