Upload
david-bosschaert
View
1.251
Download
1
Tags:
Embed Size (px)
DESCRIPTION
Presentation given at EclipseCon Europe 2013 in Ludwigsburg (Germany) about ongoing specification work in OSGi, covering the Core Platform Expert Group (CPEG) and the Enterprise Expert Group (EEG)
Citation preview
Carsten Ziegeler
David Bosschaert
What's cool in the new and updated
OSGi Specs
What's cool in the new and updated OSGi specs
1 of 50
Speakers
David Bosschaert ([email protected])
⦿ JBoss/Fuse at Red Hat
⦿ Co-chair OSGi EEG
⦿ Open-source and cloud enthusiast
Carsten Ziegeler ([email protected])
⦿ RnD Adobe Research Switzerland
⦿ OSGi CPEG and EEG Member
⦿ ASF member
What's cool in the new and updated OSGi specs
2 of 50
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
3 of 50
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
4 of 50
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
5 of 50
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
6 of 50
DataTransferObjects
What's cool in the new and updated OSGi specs
7 of 50
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
8 of 50
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
9 of 50
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
10 of 50
OSGi/CDIintegration
What's cool in the new and updated OSGi specs
11 of 50
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
12 of 50
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
13 of 50
Repository1.1
What's cool in the new and updated OSGi specs
14 of 50
OSGi Repository today
What's cool in the new and updated OSGi specs
15 of 50
Example Repository namespaces
What's cool in the new and updated OSGi specs
16 of 50
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
17 of 50
DeclarativeServices
What's cool in the new and updated OSGi specs
18 of 50
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
19 of 50
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
20 of 50
...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
21 of 50
...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
22 of 50
Annotation Mapping⦿ Fields registered as component
properties
⦿ Name mapping (_ -> .)
⦿ Type mapping for configurations
What's cool in the new and updated OSGi specs
23 of 50
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
24 of 50
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
25 of 50
HTTPService
What's cool in the new and updated OSGi specs
26 of 50
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
27 of 50
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
28 of 50
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
29 of 50
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
30 of 50
CloudWhat's cool in the new and updated OSGi specs
31 of 50
Current PaaS offerings...
What's cool in the new and updated OSGi specs
32 of 50
OSGi Cloud Ecosystems PaaS
What's cool in the new and updated OSGi specs
33 of 50
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
34 of 50
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
35 of 50
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
36 of 50
FrameworkNodeStatus service properties
What's cool in the new and updated OSGi specs
37 of 50
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
38 of 50
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
39 of 50
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
40 of 50
PortableJavaContracts
What's cool in the new and updated OSGi specs
41 of 50
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
42 of 50
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
43 of 50
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
44 of 50
Type andPackageAnnotations
What's cool in the new and updated OSGi specs
45 of 50
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
46 of 50
OtherEnterpriseSpecupdates
What's cool in the new and updated OSGi specs
47 of 50
▻ 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
48 of 50
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
49 of 50
Questions?What's cool in the new and updated OSGi specs
50 of 50