Upload
irea-fletcher
View
222
Download
1
Tags:
Embed Size (px)
Citation preview
aQuteBundle Programming
By Peter KriensCEO aQute
OSGi Technology Officer andOSGi Fellow
©1999-2004 aQute, All Rights Reserved slide #2
Contents
©1999-2004 aQute, All Rights Reserved slide #3
Content R1, R2, R3
Framework
OSGi Specifications Content
Execution Environment
Devic
e M
anag
er
Log
Serv
ice
Http
Ser
vice
R1
User
Adm
in
Serv
ice T
rack
er
Conf
igur
atio
n Ad
min
Pref
eren
ces
Serv
ice
Pack
age
Adm
in
Perm
issio
n Ad
min
R2
Conn
ecto
r Ser
vice
Posit
ion
XML
Pars
er S
ervic
e
UPnP
Ser
vice
Jini S
ervic
e
Wire
Adm
in
Mea
sure
men
t
Star
t Lev
el
URL
Hand
ler
R3 Preliminary
©1999-2004 aQute, All Rights Reserved slide #4
org.osgi.service.log v1.1Log Service
• Simple and small Log service for operator
• 4 Levels– INFO, DEBUG, WARNING, ERROR
• Automatically logs framework events in a defined way
• Other bundles can access log history– Management bundle– Length implementation dependent
©1999-2004 aQute, All Rights Reserved slide #5
org.osgi.service.log v1.1Log Service
a log usera log user a log readera log reader
LogServiceLogService LogEntryLogEntry LogListenerLogListener LogReaderService
LogReaderService
a log service impl.
a log service impl.
A log entryimpl.
A log entryimpl.
A log readerimpl.
A log readerimpl.
Log Service Impl. bundle
Log a message
Store a message for retrieval and broadcast
Message log
Send new log entry
Retrieve log
A loguser bundle
A logreaderusing bundle
©1999-2004 aQute, All Rights Reserved slide #6
org.osgi.service.http v1.1Http Service
• Provides web access to bundles
• A powerful servlet runner– Supports Servlets Version 2.1
• Very simple to export static pages and files (like images)
• Automatically unregisters servlets when bundle is stopped
©1999-2004 aQute, All Rights Reserved slide #7
org.osgi.service.http v1.1Http Service
Impl. Of Httpcontext
Impl. Of Httpcontext
Impl. Of servlet
Impl. Of servlet
HttpContextHttpContext NameSpaceException
NameSpaceException HttpServiceHttpService
javax.servlet.Servlet
javax.servlet.Servlet
Default impl.HttpContext
Default impl.HttpContext
Resourceregistration
Resourceregistration
Servletregistration
Servletregistration
Bundles main code
Bundles main code
javax.servlet.Request/Response
javax.servlet.Request/Response
NameSpacealias
NameSpacealias
An Http Serviceimpl.
An Http Serviceimpl.
©1999-2004 aQute, All Rights Reserved slide #8
org.osgi.service.device v1.1Device Access
• Dynamic device driver download model
• Plug & Play– Plugged in devices identify themselves– Device Manager will download appropriate bundle
• Matching process for best driver
• Extendable– Driver Selector, Driver locator
©1999-2004 aQute, All Rights Reserved slide #9
Device Access 1.1
Locatorbundle
Locatorbundle
DeviceManager
DeviceManager
DeviceDevice
A deviceA device
DriverLocator
DriverLocator
selectorbundle
selectorbundle
DriverSelector
DriverSelector
DriverDriver
References to install
selects attach
©1999-2004 aQute, All Rights Reserved slide #10
Device Access
IEEE1394B
Interface Networkbundle
DriverLocator
DriverLocator
TV
7. attach
4. find bundle location
5. Install bundle
2. register
Camera1. Insert camera
9. Select camera
8. Register camera
10. Show camera on TV
3. Select device
DeviceManager
SonyCCD654
Driver 6. register
TVbundle
Camera
Device
©1999-2004 aQute, All Rights Reserved slide #11
org.osgi.service.cm v1.0Configuration Admin Service
• Configures bundles– At startup, or any later moment
• Maintains a repository of configurations– Local– Management system
• Configurations are key/value pairs– Typed with Meta Types
• Can be extended with plugins
©1999-2004 aQute, All Rights Reserved slide #12
Configuration Admin
clientbundle
clientbundle
ConfigurationAdmin impl
ConfigurationAdmin impl
ConfigurationAdmin
ConfigurationAdmin
Configurationbundle
Configurationbundle
ManagedService
ManagedService
clientbundle
clientbundle
ManagedServiceFactory
ManagedServiceFactory
ConfigurationConfiguration
1
11
0..n
ConfigurationPlugin
ConfigurationPlugin
Plugin implPlugin impl
ConfigurationException
ConfigurationException
©1999-2004 aQute, All Rights Reserved slide #13
org.osgi.service.metatype V1.0Meta Typing
• Data Descriptors for generic editors– Configurations, Properties
• Supports– Basic types like String, Integer, Byte, Short …– Arrays and Vectors
• Uses LDAP Objectclass, attribute model
• Can be localized for different languages
• General validation support
©1999-2004 aQute, All Rights Reserved slide #14
Meta Typing Class Diagram
MetaTypeProvider
MetaTypeProvider
ObjectClassDefinition
ObjectClassDefinition
AttributeDefinition
AttributeDefinition
1..n
1
1 1..n
LocalePID
©1999-2004 aQute, All Rights Reserved slide #15
org.osgi.service.prefs v1.0Preferences Service
• Simple hierarchical model like Windows Registry
• Uses simple hierarchical names– /bundle/121/httpport=81
• Different trees– Multiple named trees per bundle– One system tree
• Storage can be local or on management system
©1999-2004 aQute, All Rights Reserved slide #16
org.osgi.service.prefs v1.0Preferences Service
root Named or System
c2 /c2
d1
c1
/c1/d2
foo=8bar=9lex=‘acme’
d2
d1
d1
foo=8bar=9lex=‘acme’
d2
properties /c1/d2
/c1/d2/d1/d2
properties /c1/d2/d1/d2
©1999-2004 aQute, All Rights Reserved slide #17
Preferences Class Diagram
BackingStoreException
BackingStoreException a bundlea bundle
PreferencesService
PreferencesService
Bundlepreferences
Bundlepreferences
Service impl.Service impl.
Preference Node impl.
Preference Node impl.
PreferencesPreferences
nodes0..n
0..n
1
1
0..n
1
1
1
Root user nodes
Root system node
User name
©1999-2004 aQute, All Rights Reserved slide #18
org.osgi.service.useradmin v1.0User Admin Service
• Repository of users
• Maintains data for authentication and other purposes– Private keys, passwords, bio-profile, User Preferences
• Powerful role based authorization model– Users, group of users, and groups of groups
• Administrative functions
©1999-2004 aQute, All Rights Reserved slide #19
User Admin Class Diagram
User admin impl
User admin impl
UserAdminListener
UserAdminListenerUserAdminUserAdminRoleRole
UserUser
GroupGroup
Role implRole impl
User implUser impl
Group implGroup impl
UserAdminPermission
UserAdminPermission
User name
RequestAuthenticator
RequestAuthenticator
User Listenerimpl.
User Listenerimpl.Action implAction impl
AuthorizationAuthorization UserAdminEvent
UserAdminEvent
authenticate
Consult for authorization
Has roles
Perform action
Receiveevents
Send event
Basic member
Requiredmember
©1999-2004 aQute, All Rights Reserved slide #20
Wire Admin Service (R3)
• Connects Producer services to Consumer services via Wire object
• Wire objects have properties for configuration
WireAdminWireAdmin
ProducerProducer ConsumerConsumerWireWire
©1999-2004 aQute, All Rights Reserved slide #21
Position, Measurement, State
• Support classes for Wire Admin
• Position– Supports GPS like position
• Measurement– SI measurement system to prevent calculation errors– Error calculations– Timestamp
• State
©1999-2004 aQute, All Rights Reserved slide #22
Start Levels (R3)
• Allows Management Agent to control startup/shutdown sequence of installed bundles
• Supports many levels
• System service, implemented by Framework
©1999-2004 aQute, All Rights Reserved slide #23
URL Stream & Content
• Manages the URLStreamHandlerFactory and URLContentHandlerFactory of Java– These factories can only be set once so the
Framework must manage them
• Bundles can register a URLStreamHandlerService or ContentHandler
• The Framework will automatically add these to the standard set
©1999-2004 aQute, All Rights Reserved slide #24
Universal Plug ‘n Play (R3)
• Popular UPnP specifications adapted to OSGi Service Platform
• Makes it very easy to write a UPnP control point or device
• Involves registering a simple UPnPDevice service
©1999-2004 aQute, All Rights Reserved slide #25
Jini (R3)
• Defined how Jini devices can cooperate with an OSGi service platform
• Service Platform very good environment for Jini services, but
• Security issues
©1999-2004 aQute, All Rights Reserved slide #26
Execution Environment (R3)
• OSGi defined 2 execution environments
• Minimal– Intended for really small devices
• Foundation Profile– Adapted from JCP’s Foundation Profile
• Finally!
©1999-2004 aQute, All Rights Reserved slide #27
IO Connector Service (R3)
• Adopted J2ME javax.microedition.io package
• Process in JCP is intended to make this stand-alone
• Connection type + address selected by a single string
• Connection interfaces allows client code to adapt to different schemes– Datagram, Sockets, Servers
©1999-2004 aQute, All Rights Reserved slide #28
XML Parser Service
• Allows different bundles to register an XML parser
• Supports finding “best” parser for a specific application
• Based on standard Java JAR service
©1999-2004 aQute, All Rights Reserved slide #29
aQute
www.aQute.biz
+46 300 39800, [email protected]
z