10. Behavior Only
Do NOT disclose parameters and implementation details.
Do NOT shape a Service after your rst/only implementation.
This is NOT Object Orientation. Or is it... ;-)
11. Scale Invariance
Service Interface should NOT re ect the scale
your ( rst) implementation will support.
13. Think BIG
act small!
Your service interface should be future proof,
your implementation should t your current needs.
Keep many possible implementations
(functionality, scale) in mind when designing interfaces.
15. OSGi Recap
Service
Log Store Prefs
publish publish
publish use
use use
Bundle Bundle Bundle Bundle
install Life Cycle
installed
Service start start starting
Bundle Bundle Bundle Life Cycle resolved active
Module
end uninstall stopping stop
Security
uninstalled
OSGi framework
Java Virtual Machine
Module
Bundle Bundle Bundle Bundle
imports exports imports
exports exports exports
org.apache.util 1.0 org.apache.db 1.4
org.apache.log 2.3 org.apache.util 1.1
16. Container Style
Development
Application consists of
interdependent Services
Public Services are accessed
through UI/SOAP/JMS/...
17. Be a Good Host
Offer facilities to
your components
OSGi Compendium is a
Catalog of generic Facilities
Add your own to the container if needed
18. Deploy Everything
Not just code!
Content
Configurations
Testcases
Work
19. Inversion of Control
Use declarative Lifecycle and
Dependency Management
Develop POJO’s
Delegate injection
20. Add Chemistry
Deployed services react
on each other
Resulting in behavior
and new services
Define these reactions in terms of
life cycle and dependencies
24. Aspect Services
Aspect
Repository Cache Repository
get() get()
getVersions() intercepts getVersions()
get(version) get(version)
store(Document) store(Document)
Transparently inject an interceptor service
"in front of" all services matching a lter
25. Aspect Services
class Activator {
public void init(context, manager) {
manager.add(
createAspectService(
DocumentRepository.class,
DocumentRepositoryCache.class,
10));
}
}
26. Adapter Services
Adapter
Repository Cache Repository Cache
Manageable get()
getCacheHits() getVersions()
adapts
setSize() get(version)
setTTL() store(Document)
flush()
Start an instance of the adapter service for any
"adaptee" service matching a lter
27. Adapter Services
class Activator {
public void init(context, manager) {
manager.add(
createAdapterService(
Manageable.class,
DocumentRepositoryCache.class,
DocumentRepositoryCacheManageable.class));
}
}
28. Resource Adapters
Resource
Audio Track Adapter
play() MP3
adapts
pause() File
stop()
Start an instance of a Resource Driven Service for all
resources matching a lter
Resources: File(system) abstraction, access by InputStream
29. Resource Adapters
class Activator {
public void init(context, manager) {
manager.add(
createResourceAdapterService(
"(extension=mp3)",
AudioTrack.class,
MP3AudioTrack.class));
}
}
30. Dependency
Management & OSGi
Not standard OSGi, a number of extensions available.
Felix Dependency Manager implements these patterns.
31. Lean Development
Service Interfaces
OSGi based Apps
Service Creation Patterns