What’s cool in the new and updated OSGi specs (DS, Cloud and more) - David Bosschaert, Carsten...

Post on 10-May-2015

769 views 0 download

Tags:

description

OSGi Community Event 2013 (http://www.osgi.org/CommunityEvent2013/Schedule) ABSTRACT Carsten and David will look at new and updated OSGi specs that are in the works. Developing components has never been easier. Learn more about the new Prototype Service Factory, OSGi/CDI integration and the improved annotation support for Declarative Services. Many people are realizing that OSGi is a great foundation technology for fluid cloud-computing architectures where the deployments change dynamically and applications don't simply scale by duplicating the entire VMs but by providing extra capacity exactly to those components that need it. Work is being done to create standards that facilitate such a portable OSGi cloud in ‘Cloud Ecosystems’ and the REST API specs. Learn more about these and other upcoming specs during this talk. SPEAKER BIOS David Bosschaert David Bosschaert, Principal Software Engineer at Red Hat, spends the majority of his time on the JBoss OSGi framework, JBoss AS7, Apache Aries and other open source projects. He is also co-chair of the OSGi Enterprise Expert Group and an active participant in the OSGi Cloud efforts. Before joining JBoss/Red Hat in 2010, David worked for IONA Technologies and Progress Software in Dublin, Ireland. Carsten Ziegeler Carsten Ziegeler is senior developer at Adobe Research Switzerland and spends most of his time on architectural and infrastructure topics. Working for over 25 years in open source projects, Carsten is a member of the Apache Software Foundation and heavily participates in several Apache communities including Sling, Felix and ACE. He is a frequent speaker on technology and open source conferences and participates in the OSGi Core Platform and Enterprise expert groups.

Transcript of What’s cool in the new and updated OSGi specs (DS, Cloud and more) - David Bosschaert, Carsten...

Carsten Ziegeler

David Bosschaert

What's cool in the new and updated

OSGi Specs

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

1 of 50 28/10/2013 07:56

Speakers

David Bosschaert (david@redhat.com)

⦿ JBoss/Fuse at Red Hat

⦿ Co-chair OSGi EEG

⦿ Open-source and cloud enthusiast

Carsten Ziegeler (cziegeler@apache.org)

⦿ RnD Adobe Research Switzerland

⦿ OSGi CPEG and EEG Member

⦿ ASF member

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

2 of 50 28/10/2013 07:56

Agenda⦿ Framework updates

⦿ OSGi/CDI integration

⦿ Repository update

⦿ Declarative Services

⦿ Http Service

⦿ Cloud

⦿ Portable Java Contracts

⦿ Semantic Versioning Annotations

⦿ Other spec updates

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

3 of 50 28/10/2013 07:56

Framework Updates

Service Scopes (RFC 195)⦿ Service Scopes: singleton, bundle, prototype

⦿ Driver: Support for EEG specs (EJB, CDI)

⦿ Usage in other spec updates

⦿ New PrototypeServiceFactory

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

4 of 50 28/10/2013 07:56

PrototypeServiceFactory

ppuubblliicc iinntteerrffaaccee PPrroottoottyyppeeSSeerrvviicceeFFaaccttoorryy<S>

eexxtteennddss SSeerrvviicceeFFaaccttoorryy<S> {

S getService(BBuunnddllee bundle,

SSeerrvviicceeRReeggiissttrraattiioonn<S> registration);

vvooiidd ungetService(BBuunnddllee bundle,

SSeerrvviicceeRReeggiissttrraattiioonn<S> registration,

S service);

}

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

5 of 50 28/10/2013 07:56

New method in BundleContext:ppuubblliicc iinntteerrffaaccee BBuunnddlleeCCoonntteexxtt {

<S> SSeerrvviicceeOObbjjeeccttss<S> getServiceObjects(SSeerrvviicceeRReeffeerreennccee<S> rreeff);

}

New Interface ServiceObjects:ppuubblliicc iinntteerrffaaccee SSeerrvviicceeOObbjjeeccttss<S> {

S getService();

vvooiidd ungetService(S service);

}

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

6 of 50 28/10/2013 07:56

DataTransferObjects

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

7 of 50 28/10/2013 07:56

RFC 185 – Data Transfer Objects⦿ Defines a DTO model for OSGi⦿ Serializable/Deserializable objects

⦿ Use cases: REST, JMX, Web Console...

⦿ To be adopted by other specs

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

8 of 50 28/10/2013 07:56

RFC 185 – Data Transfer ObjectsGetting DTOs: adapter patternppuubblliicc ccllaassss BBuunnddlleeDDTTOO eexxtteennddss org.osgi.dto.DTO {

ppuubblliicc lloonngg id;

ppuubblliicc lloonngg lastModified;

ppuubblliicc iinntt state;

ppuubblliicc SSttrriinngg symbolicName;

ppuubblliicc SSttrriinngg version;

}

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

9 of 50 28/10/2013 07:56

RFC 185 – Data Transfer ObjectsDTOs for the OSGi framework

⦿ FrameworkDTO

⦿ BundleDTO

⦿ ServiceReferenceDTO

⦿ BundleStartLevelDTO, FrameworkStartLevelDTO

⦿ CapabilityDTO, RequirementDTO, ResourceDTO

⦿ BundleWiringsDTO, etc

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

10 of 50 28/10/2013 07:56

OSGi/CDIintegration

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

11 of 50 28/10/2013 07:56

RFC 193 - CDI SupportBridging OSGi and standard JavaEE

dependency model

● Publishing CDI beans as OSGi services

● Injecting OSGi services in CDI beansCDI = Contexts and dependency injection

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

12 of 50 28/10/2013 07:56

RFC 193 - Examples● Publishing CDI bean as OSGi service@Component

ppuubblliicc ccllaassss MMyyCCoommppoonneenntt iimmpplleemmeennttss MMyyIInntteerrffaaccee { ... }

● Dependency Injection@Inject

@Service

pprriivvaattee MMyyIInntteerrffaaccee serviceA;

@Inject

@Service(optional = ttrruuee)

pprriivvaattee MMyyIInntteerrffaaccee serviceB;

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

13 of 50 28/10/2013 07:56

Repository1.1

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

14 of 50 28/10/2013 07:56

OSGi Repository today

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

15 of 50 28/10/2013 07:56

Example Repository namespaces

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

16 of 50 28/10/2013 07:56

RFC 187 - Repository 1.1Existing repository powerful

but: limited to queries in a single namespace

New in RFC 187:Combine requirements spanning multiple namespaces:

RReeppoossiittoorryy repo = ... // Obtain from Service Registry

CCoolllleeccttiioonn<RReessoouurrccee> res = repo.findProviders(

repo.getExpressionCombiner().aanndd(

repo.newRequirementBuilder("osgi.wiring.package").

addDirective("filter","(osgi.wiring.package=foo.pkg1)").

buildExpression(),

repo.newRequirementBuilder("osgi.identity").

addDirective("filter",

"(license=http://opensource.org/licenses/Apache-2.0)").

buildExpression()));

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

17 of 50 28/10/2013 07:56

DeclarativeServices

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

18 of 50 28/10/2013 07:56

RFC 190 - Declarative Services

Enhancements⦿ Support of service scopes

⦿ Diagnostic API

⦿ DTOs

⦿ But most importantly...

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

19 of 50 28/10/2013 07:56

Use annotations for

configuration...@interface MMyyCCoonnffiigg {

bboooolleeaann enabled() ddeeffaauulltt ttrruuee;

SSttrriinngg[] topic() ddeeffaauulltt {"topicA", "topicB"};

SSttrriinngg userName();

iinntt service_ranking() ddeeffaauulltt 15;

}

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

20 of 50 28/10/2013 07:56

...and reference them in

lifecycle methods@Component

ppuubblliicc ccllaassss MMyyCCoommppoonneenntt {

SSttrriinngg userName;

SSttrriinngg[] topics;

@Activate

pprrootteecctteedd vvooiidd activate(ffiinnaall MMyyCCoonnffiigg config) {

iiff ( config.enabled() ) {

tthhiiss.userName = config.userName();

tthhiiss.topics = config.topic();

}

}

}

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

21 of 50 28/10/2013 07:56

...or even simpler...@Component

ppuubblliicc ccllaassss MMyyCCoommppoonneenntt {

pprriivvaattee MMyyCCoonnffiigg configuration;

@Activate

pprrootteecctteedd vvooiidd activate(ffiinnaall MMyyCCoonnffiigg config) {

iiff ( config.enabled() ) {

tthhiiss.configuration = config;

}

}

}

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

22 of 50 28/10/2013 07:56

Annotation Mapping⦿ Fields registered as component

properties

⦿ Name mapping (_ -> .)

⦿ Type mapping for configurations

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

23 of 50 28/10/2013 07:56

Mapping@interface MMyyCCoonnffiigg {

bboooolleeaann enabled() ddeeffaauulltt ttrruuee;

SSttrriinngg[] topic() ddeeffaauulltt {"topicA", "topicB"};

SSttrriinngg userName();

iinntt service_ranking() ddeeffaauulltt 15;

}

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

24 of 50 28/10/2013 07:56

RFC 190 - Declarative Services

Enhancements⦿ Annotation configuration support

⦿ Support of service scopes

⦿ Diagnostic API

⦿ DTOs

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

25 of 50 28/10/2013 07:56

HTTPService

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

26 of 50 28/10/2013 07:56

RFC 189 - Http Service

Update⦿ Update to Servlet API 3+

⦿ Whiteboard support for

Servlets, Servlet Filters

Listeners, Resources and HttpContexts

⦿ and DTOs

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

27 of 50 28/10/2013 07:56

Whiteboard Servlet Registration@Component(service = javax.servlet.SSeerrvvlleett.ccllaassss,

scope="PROTOTYPE",

pprrooppeerrttyy={

"osgi.http.whiteboard.servlet.pattern=/products/*",

})

ppuubblliicc ccllaassss MMyySSeerrvvlleett eexxtteennddss HHttttppSSeerrvvlleett {

...

}

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

28 of 50 28/10/2013 07:56

Whiteboard Servlet Filter

Registration@Component(service = javax.servlet.FFiilltteerr.ccllaassss,

scope="PROTOTYPE",

pprrooppeerrttyy={

"osgi.http.whiteboard.filter.pattern=/products/*",

})

ppuubblliicc ccllaassss MMyyFFiilltteerr iimmpplleemmeennttss FFiilltteerr {

...

}

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

29 of 50 28/10/2013 07:56

Additional Support⦿ Most listener types are supported

Register with their interface

⦿ Error Pages and Resources

⦿ Shared HttpContexts

⦿ Target Http Service

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

30 of 50 28/10/2013 07:56

CloudWhat's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

31 of 50 28/10/2013 07:56

Current PaaS offerings...

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

32 of 50 28/10/2013 07:56

OSGi Cloud Ecosystems PaaS

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

33 of 50 28/10/2013 07:56

An OSGi cloud ecosystem...⦿ Many frameworks

○ hosting a variety of deployments

⦿ Together providing The Application

⦿ Not a bunch of replicas ○ rather a collection of different nodes

○ with different roles working together

○ some may be replicas

⦿ Load varies over time

⦿ ... and so does your cloud system ○ topology

○ configuration

○ number of nodes

○ depending on the demand

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

34 of 50 28/10/2013 07:56

To realize this you need...⦿ Information!

○ need to know what nodes are available

○ ability to react to changes

⦿ Provisioning capability

⦿ Remote invocation ○ inside your cloud system

○ to get nodes to communicate

○ either directly...

○ ... or as a means to set up communication channels

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

35 of 50 28/10/2013 07:56

RFC 183 - Cloud EcosystemsFFrraammeewwoorrkkNNooddeeSSttaattuuss service:

information about each Cloud node

accessible as a Remote Service

throughout the ecosystem

Information such as:Hostname/IP address

Location (country etc)

OSGi and Java version running

A REST management URL

Runtime metadataAvailable memory / disk space

Load measurement

... you can add custom metadata too ...

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

36 of 50 28/10/2013 07:56

FrameworkNodeStatus service properties

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

37 of 50 28/10/2013 07:56

RFC 182 - REST APIA cloud-friendly remote management API

works great with FrameworkNodeStatus

Example:addingService(SSeerrvviicceeRReeffeerreennccee<FFrraammeewwoorrkkNNooddeeSSttaattuuss> rreeff) {

// A new Node became available

SSttrriinngg url = rreeff.getProperty("org.osgi.node.rest.url");

RReessttCClliieenntt rc = nneeww RReessttCClliieenntt(nneeww URI(url));

// Provision the new node

rc.installBundle(...);

rc.startBundle(...);

}

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

38 of 50 28/10/2013 07:56

Additional ideas in RFC 183⦿ Special Remote Services config type・ osgi.configtype.ecosystem

・ defines supported Remote Service data types

・ not visible outside of cloud system

⦿ Ability to intercept remote service calls・ can provide different service for each client

・ can do invocation counting (quotas, billing)

⦿ Providing remote services meta-data・ quota exceeded

・ payment needed

・ maintenance scheduled

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

39 of 50 28/10/2013 07:56

Current OSGi cloud workProvides a base line

○ to build fluid cloud systems

○ portability across clouds

Where everything is dynamic

○ nodes can be repurposed

... and you deal with your cloud nodes

through OSGi services

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

40 of 50 28/10/2013 07:56

PortableJavaContracts

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

41 of 50 28/10/2013 07:56

Semantic Versioning...... is a versioning policy for exported packages.

OSGi versions: <major>.<minor>.<micro>.<qualifier>

Updating package versions:

● fix/patch (no change to API):

update micro

● extend API (affects implementers, not clients):

update minor

● API breakage:

update major

Note: not always used for bundle versions

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

42 of 50 28/10/2013 07:56

Semantic Versioning is great, but...

- not all projects use it, e.g. APIs from JSRs

- e.g. Servlet 3 is backward compatible with 2.5

- what's its javax.servlet package version?2.6 ?

or 3.0 ?

- different projects made different choices

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

43 of 50 28/10/2013 07:56

RFC 180: Portable Java Contracts

osgi.contract capability to the rescue

● client bundle requires capability with 'marketing' or 'spec' version

● and also imports the package without version osgi.contract provider binds the contract version to package versions

IImmppoorrtt-PPaacckkaaggee: javax.servlet, javax.servlet.http

RReeqquuiirree-CCaappaabbiilliittyy: osgi.contract;

filter:="(&(osgi.contract=JavaServlet)(version=3.0))"

Allows writing portable bundles that import non-semantically

versioned packages.

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

44 of 50 28/10/2013 07:56

Type andPackageAnnotations

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

45 of 50 28/10/2013 07:56

RFC 197 – OSGi Type and

Package Annotations⦿ Annotations for documenting semantic

versioning information⦿ Class retention annotations

⦿ @Version

⦿ @ProviderType

⦿ @ConsumerType

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

46 of 50 28/10/2013 07:56

OtherEnterpriseSpecupdates

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

47 of 50 28/10/2013 07:56

▻ Blueprint 1.1・ Non-damped service references

・ Grace period enhancements

・ Many small fixes

▻ Remote Service Admin 1.1・ Remote Service registration modification

▻ Subsystems 1.1・ Provide Deployment Manifest separately

・ Many small enhancements

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

48 of 50 28/10/2013 07:56

When can I get it?RFCs available to everyone today:

https://github.com/osgi/design

(https://github.com/osgi/design)

◎ Most work aimed at Core/Enterprise R6 (2014)

◎ Some specs in Enterprise R7 (2015)

What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

49 of 50 28/10/2013 07:56

Questions?What's cool in the new and updated OSGi specs file:///Users/david/clones/ece2013/eclipsecon.html?print

50 of 50 28/10/2013 07:56