Post on 20-Dec-2015
1
HyCon Framework OverviewFrank Allan Hansen and Bent Guldbjerg Christensen
! Run this presentation in presentation mode to watch animations.
2
Agenda
• Introduction to Web services
• HyCon platform and architecture
• Implementing services with the framework
3
Old School Web Services
• Web services, in the general meaning of the term, are services offered on the Web.
http://www.google.com/search?q=Webservice&start=0&start=0&...
Google Web server http
Html document
5
Web Services
• Programmatic interfaces• Access and execute remote objects
– Well-defined service interface• Request• Response
• XML– WSDL
Web Services Description Language
– SOAPSimple Object Access Protocol
– UDDIUniversal Description, Discovery, and Integration
• Platform independent
6
WSDL
• Web Services Description Language– Ariba, IBM and Microsoft– WSDL is a 1.2 W3C working draft
• A WSDL document describes a network services: – Operations– Arguments and types (xsd)– Service binding
7
Creating WSDL Documents
• WSDL documents can be hand-written
• Generated by tools– JWSDP:
• Remote java interface• Information about the service container
– JWSDP includes ant tasks for generating WSDL documents and deploying the services
• Ex.:http://fahbentor.daimi.au.dk:15342/contextit-jaxrpc/xlink?WSDL
8
SOAP
• Simple Object Access Protocol – W3C recommendation
http://www.w3.org/TR/soap/
• Platform independent (CORBA, RMI, DCOM,…are not)
10
SOAP
• JWSDP– WSDL >> Java stub classes– Java classes handles
• SOAP marshalling/unmarshalling• Remote communication with services
11
Web Services recapture
• Service are described with WSDL documents– Generated from the service interface
• Client applications communicate with service through SOAP messages– Classes generating and parsing objects to
and from SOAP are generated from WSDL documents
13
Overview
• HyCon – Platform– Components and services– XSLT servlet Chain– Sensors
• A practical guide to the HyCon framework– Step by Step building of a Web service
14
HyCon Requirements
• Context-aware hypermedia framework– Extensible data model capable of
representing object or entities and their context
– Hypermedia model integrated in the data model
– Services for accessing the data:• Object, context, and hypermedia structures
– Services should be useable from many different (mobile) devices
– Devices should support capturing of sensor data used to measure the context
15
HyCon Data model
AbstractObject Property ValueId
AttributesObject
Context Location Annotation
Body Link
Arc Locator
Href Geotag
1
N
M
1 NM1
N
M
1 1
2
16
The HyCon Architecture
Trail ServiceAnnotation Service...
eBag/MediaTrayHyconExplorer...
Data Data Data
Storage Layer
Server Layer
Components
Components
Terminal Layer
Sensor Layer
Data layer
Search
Server communication
Bluetooth communication
Weather
GPS abstraction ...
Profile Location Annotation Link
Service Interfaces
Sensor Interfaces
Infra structure
MySQL
HyperContextServer Components
Servlets,Web services
Symbian applications,Tablet applications,Web browsers
Sensor abstraction
Data layer
Sensor equipment
Bluetooth ID
Weather
RFID
Sound recorder
CameraGPS unit IR
...
Service Interfaces
Local Sensors Remote Sensors
17
The HyCon Server Architecture
Sensors
Phone
Tablet PC
Server
XSLTServlet
AnnotationServlet
LocationServlet
...
Servlets container
SOAP
LocationService
...
AnnotationService
SOAP
SOAP
Web services container
AnnotationComponent
LocationComponent
...
...
...
DataLayerComponent Data
19
XSLT servlet chain
• The servlet interfacet is build around a servlet filter chain, with aXSLT-engine in one end and Service servlets in the other
• This requires all services to produceXML output
...
LocationServlet
Stylesheetmap.xml Stylesheet.xslStylesheet.xslStylesheet.xsl
XSLT Handler
SAX Parser
XsltStyleDescriptorCompiled StyleSheets
Select Stylesheet
Request
Response
Request
Wrapped Response
AnnotationServlet
Wrapped ResponseXML
21
Components (Annotation Component)
dl: DataLayer
AnnotationServiceComponent()
create()
create()
delete()
getAllAnnotations()
getAllAnnotationsSystem()
getAnnotation()
getAnnotationSystem()
getAnnotationsByAnnotatesId()
getAnnotationsByAnnotatesIdSystem()
getAnnotationsByAnnotatesIdsVectorSystem()
getAnnotationsByCreator()
getAnnotationsByCreatorSystem()
getAnnotationsInContext()
getAnnotationsInContextSystem()
update()
update()
AnnotationServiceComponent
create()
create()
delete()
getAnnotation()
getAnnotationSystem()
getAnnotationsByAnnotatesId()
getAnnotationsByAnnotatesIdSystem()
getAnnotationsByCreator()
getAnnotationsByCreatorSystem()
update()
update()
«interface»AnnotationServiceIF
config: ServletConfig
destroy()
doGet()
doPost()
getServletConfig()
init()
run()
setServletConfig()
xmlError()
xmlStatus()
xmlToString()
dk::contextit::service::AbstractServiceServlet
AbstractWebservice()
getAllContexts()
getAnnotation()
getArcDummy()
getContext()
getGeoTag()
getLinkDummy()
getLocation()
getNewId()
getObject()
getProperty()
getSlideDummy()
getSlideShowDummy()
getValue()
setArcDummy()
setLinkDummy()
setSlideDummy()
setSlideShowDummy()
dk::contextit::service::AbstractWebservice
create()
delete()
getAllAnnotations()
getAnnotation()
getAnnotationsByAnnotatesId()
getAnnotationsByCreator()
getAnnotationsInContext()
init()
run()
update()
dk::contextit::service::AnnotationServlet
AnnotationWebservice()
create()
create()
delete()
getAllAnnotations()
getAnnotation()
getAnnotationsByAnnotatesId()
getAnnotationsByAnnotatesIdSystem()
getAnnotationsByAnnotatesIdsVectorSystem()
getAnnotationsByCreator()
update()
update()
dk::contextit::service::AnnotationWebservice create()
create()
delete()
getAllAnnotations()
getAnnotation()
getAnnotationsByAnnotatesId()
getAnnotationsByAnnotatesIdSystem()
getAnnotationsByAnnotatesIdsVectorSystem()
getAnnotationsByCreator()
getGeoTag()
getLocation()
getNewId()
getProperty()
getValue()
update()
update()
«interface»dk::contextit::service::AnnotationWebserviceIF
22
Using Components: Check List
1. Create local interface
2. Implement component
3. Implements services (that use the component(s))
4. Create remote service interfaces
5. …and implement client applications
24
HyCon Data model
AbstractObject Property ValueId
AttributesObject
Context Location Annotation
Body Link
Arc Locator
Href Geotag
1
N
M
1 NM1
N
M
1 1
2
28
The XSLT servlet chain
...
LocationServlet
Stylesheetmap.xml Stylesheet.xslStylesheet.xslStylesheet.xsl
XSLT Handler
SAX Parser
XsltStyleDescriptorCompiled StyleSheets
Select Stylesheet
Request
Response
Request
Wrapped Response
AnnotationServlet
Wrapped ResponseXML
34
Using Servlets and the XSLT Chain: Check List
1. Create servlet (a service based on components)
2. Register the servlet in WebInf.xml
3. Implement the stylesheet– Or use an exsisting one eg. ”raw”
4. Register the stylesheet
5. Map the stylesheet to a key/user-agent in the Style map
6. …and implement client applications
36
Sensors
• Sensors in HyCon is defined by an interface• Sensors must implement a
– Pull based interface– Event based interface
• Sensors’ implementation is undefined in the framework– Local sensors (Bluetooth GPS)– Network based sensors (Bluetooth position)
38
Sensor interface (2)
GPSparser2()
GPSparser2
SensorEvent()
SensorEvent
addListener()
computeSensorData()
getDescription()
getName()
getSensorData()
getSensorHistory()
removeListener()
«interface»SensorInterface
GPGGA: String
GPGSA: String
GPRMC: String
inputStream: InputStream
lastlocation: Location
listeners: Vector
readThread: Thread
sensorhistory: Vector
serialPort: SerialPort
GPSEmtagBluetoothSensor()
addListener()
close()
computeSensorData()
getDescription()
getGPGGAString()
getGPGSAString()
getGPRMCString()
getName()
getSensorData()
getSensorHistory()
removeListener()
run()
serialEvent()
setGPSString()
GPSEmtagBluetoothSensor
SensorHasData()
SensorListenerAdapter
SensorHasData()
«interface»SensorListenerInterface
gpslistener: SensorListenerInterface
gpssensor: GPSEmtagBluetoothSensor
iconPath: String
iconPathweather: String
SVGMap()
SVGMap()
createGeoGoogleDoc()
createLocation()
getCanvas()
getMyX()
getMyY()
insertLocation()
markLocation()
removeAllGeoGoogleDocs()
removeGeoGoogleDoc()
removeLocation()
removeWeatherInfo()
setMyX()
setMyY()
showMapScale()
showOverviewMap()
stateChanged()
unMarkGeoTags()
unMarkLocations()
upDateWeatherInfo()
updateDoc()
updateDocLayers()
updateMap()
dk::contextit::browser::SVGMap
annoService: AnnotationWebserviceIF
cp: ContextPresenter
gpssensor: GPSEmtagBluetoothSensor
locService: LocationWebserviceIF
mainSplitPane: JSplitPane
ob: ObjectBrowser
sm: SVGMap
HyConExplorer()
actionPerformed()
annotate()
annotate()
createLocation()
createLocation()
getGpssensor()
setActiveStatus()
setGpsStatus()
setGpssensor()
setStatusText()
stopTimer()
dk::contextit::browser::HyConExplorer
Client Application
Sensor implementation
Sensor interfaces
41A practical guide to the HyCon framework
• Development environment• XLink Service bottom-up
– XLink data structure– XLink data model– XLink component– XLink Web service
• WSDL interface
– XLink service in HyconExplorer– Trails as an example of an XLink structure
• Scripts with Ant• Distribution with Webstart
42Development environment
• HyCon is implemented in Java.• Eclipse is used as the development environment
(better than Emacs...).• The source code is shared through a
cvs-repository.
43
XLink Service bottom-up
• The framework includes a number of services which provide methods for retrieving and storing certain data structures on the server – Location– Annotation– eBag– Map– Slide– XLink
• As an example of a service implementation we will look at the XLink service.
44
AbstractObject Property ValueId
AttributesObject
Context Location Annotation
Body Link
Arc Locator
Href Geotag
1
N
M
1 NM1
N
M
1 1
2
Object
Link
Arc
1
N
M1 1
2
AbstractObject Property ValueId
Attributes
Context Location Annotation
Body
Locator
Href Geotag
1 NM1
N
M
XLink Service bottom-up: Data structure
• Data structure: XLink– Et Link contains references to resources (objects) in
the data model.– Et Link may contain Arc-objects, that specify
associations among resources in the Link.
46
XLink Service bottom-up: Component (interface)
• The component which encapsulates the functionality of the Xlink service is first described by an interface:– create new Link in the Storage layer– Retrieve Link from the Storage layer– Delete Link from the Storage layer– ...
48
XLink Service bottom-up: Web service (server)
• To provide the functionality of the Xlink component over the internet we use the Tomcat container and the Web service (WSDL). We could also have use a Servlet interface (CGI).– The Servlet interface (CGI) is simple and well-known from Web
programming - parameters is sent as pairs of strings.– The Web service interface (WSDL) is built on top of CGI, and support more
abstractions - parameters and results are sent as via SOAP (Simple Object Access Protocol).
• A WSDL (Web Service Definition Language) file, contains a description of a Web service – that is, data types of parameters and results of calling its methods.
• By creating a Remote Java interface in a service for the component (~10 lines, which is quite similar to the original component interface), JWSDP (Java Web Services Developer Pack ) can generate the WSDL-file (~250 lines).
• WSDL for the XLink Web service: – http://fahbentor.daimi.au.dk:15342/contextit-jaxrpc/xlink?WSDL
50
XLink Service bottom-up: Webservice (client)
• To use a Web service from a (client) application, one should call the methods defined in the WSDL-file. Ie. Parameters have to be translated from Java objects to SOAP elements and send to a specific socket, and the result is returned as SOAP elements, which has to be translated to Java objects.
• Luckily JWSDP can generate the client stub code, which handles marshalling.– The stub code is generated from the WSDL-file!
52
Scripts with Apache Ant
• To ease the process of generating eg. the WSDL-files and stub code, we use Ant. – Ant is useful for:
• starting a program, copy files, delete files, sign jars etc., which are all inherent to development (next generation make).
– Ant-files (Ant-scripts) include tasks, and are described in XML.
– Ant is integrated in Eclipse, so changes in ”the bottom” of eg. the XLink Web servicen, which requires recompilation and regeneration of multiple files can be done with a single click on the Ant-script.
54
Distribution with Java Webstart
• To run, eg., HyConExplorer outside Eclipse, the Java classes and packages which comprise the application or is used by the application must be available...
• An elegant way to distribute a Java program is by using Java Webstart. The program and packages are made available on a Web server, and a JNLP-file (Java Network Launching Protocol), how to get the program and the programs access rights (disk access, network access etc.)
– Webstart automatically checks for new versions of the program before start => Easy update of applications
– Webstart is installed with Java.
• Url to JNLP-file for HyConExplorer:– http://fahbentor.daimi.au.dk:15342/contextit/ce.jnlp