Top Banner
1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.
54

1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

1

HyCon Framework OverviewFrank Allan Hansen and Bent Guldbjerg Christensen

! Run this presentation in presentation mode to watch animations.

Page 2: 1 HyCon Framework Overview Frank 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

Page 3: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 4: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 5: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 6: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 7: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

8

SOAP

• Simple Object Access Protocol – W3C recommendation

http://www.w3.org/TR/soap/

• Platform independent (CORBA, RMI, DCOM,…are not)

Page 8: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

9

SOAP

Page 9: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

10

SOAP

• JWSDP– WSDL >> Java stub classes– Java classes handles

• SOAP marshalling/unmarshalling• Remote communication with services

Page 10: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 11: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

12

The HyCon Framework

Page 12: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 13: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 14: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 15: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 16: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 17: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 18: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

20

Components

Page 19: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 20: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 21: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

23

Data model and the servlet chain

Page 22: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 23: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

25

AbstractObject

Page 24: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

26

Object

Page 25: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

27

Link

Page 26: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 27: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

29

XSLT Handler

Page 28: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

30

XSLT Handler

Page 29: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

31

XSLT style map

Page 30: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

32

AnnotationServlet

Page 31: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

33

Register a servlet in the container: WebInf.xml

Page 32: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 33: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

35

Sensors

Page 34: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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)

Page 35: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

37

Sensor interface

Page 36: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 37: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

39

Using a sensor (GPSEmtagBluetooth)

Page 38: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

40

Step-by-step guide to implementing a service

Page 39: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 40: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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.

Page 41: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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.

Page 42: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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.

Page 43: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

45

XLink Service bottom-up: Data model (runtime)

Page 44: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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– ...

Page 45: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

47

XLink Service bottom-up: Component

• Implementation of the Xlink components interface

Page 46: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 47: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

49

XLink Service bottom-up: Web service (WSDL)

• WSDL for the XLink Web service:

Page 48: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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!

Page 49: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

51

XLink Service bottom-up: Trails in HyConExplorer

Page 50: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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.

Page 51: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

53

Snippet from Ant-script, that generates stub code

Page 52: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

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

Page 53: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

55

JNLP-file, HyConExplorer

Page 54: 1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.

56

Recapture

• Questions ?