Web Services with JWIG and Xact Christian Kirkegaard BRICS, - - PDF document

web services with jwig and xact
SMART_READER_LITE
LIVE PREVIEW

Web Services with JWIG and Xact Christian Kirkegaard BRICS, - - PDF document

Web Services with JWIG and Xact Christian Kirkegaard BRICS, University of Aarhus JWIG and Xact Extensions of Java for building Web Services Key features Session-based execution model High-level operations for XML manipulation


slide-1
SLIDE 1

Web Services with JWIG and Xact

Christian Kirkegaard BRICS, University of Aarhus

slide-2
SLIDE 2

JWIG and Xact

Extensions of Java for building Web Services Key features

Session-based execution model High-level operations for XML manipulation Static type analysis Checkable design contracts

slide-3
SLIDE 3

Session Threads

show receive f1 show receive f2 request submit Session

http://MyService/xYz123

Zzzz

slide-4
SLIDE 4

public class MyService extends Service { public class Main extends Session { DBConnection db = new DBConnection("mydatabase"); public void main() { show [[ <html> ... </html> ]]; /* login page */ String userid = receive userid; String password = receive password; if (db.isUser(userid,password)) show [[ <html> ... </html> ]]; /* menu page */ else exit [[ <html> ... </html> ]]; /* error page */ ... } } }

slide-5
SLIDE 5

XML Templates

Immutable well-formed XML fragments with

named gaps

[[ <html> <head> <title><[TITLE]></title> </head> <body bgcolor=[COLOR]> <[BODY]> </body> </html> ]]

slide-6
SLIDE 6

XML Construction

The “plug” operation binds values to gaps

[[ <html> <head> <title><[TITLE]></title> </head> <body bgcolor=[COLOR]> <[BODY]> </body> </html> ]] <[ COLOR="pink" ] [[ <html> <head> <title><[TITLE]></title> </head> <body bgcolor="pink"> <[BODY]> </body> </html> ]] [[ <html> <head> <title><[TITLE]></title> </head> <body bgcolor="pink"> <h1><[TITLE]></h1> <ul> <[ITEMS]> </ul> </body> </html> ]] [[ <html> <head> <title>My Links</title> </head> <body bgcolor="pink"> <h1>My Links</h1> <ul> <[ITEMS]> </ul> </body> </html> ]] <[ BODY= ] [[ <h1><[TITLE]></h1> <ul> <[ITEMS]> </ul> ]] <[ TITLE=“My Links" ]

slide-7
SLIDE 7

XML Deconstruction

Use XPath to address sub-templates The “select” operation returns an array of all

addressed sub-templates

The “gapify” operation replaces all addressed

sub-templates with new gaps

slide-8
SLIDE 8

Static Analyses

Show-receive analysis

Verify that all expected fields were shown to client

Plug analysis

Verify that all addressed gaps exist

XML validity analysis

Verify that all shown templates are valid XHTML

documents

slide-9
SLIDE 9

Checkable Design Contracts

Separation of concerns

HTML designer and Web service programmer should

cooperate but work independently

Work scenario

Design basic template structure Formalize in a simple design contract HTML designer writes the templates Programmer writes the code

Automatically verify requirements!

slide-10
SLIDE 10

Checkable Design Contracts

package org.jwig.examples.login template Wrapper { gap TITLE: <AnyString>, gap BODY } template Login { form { field user, field password } } template Menu { gap ITEM: MenuItem } template MenuItem { gap ITEM: MenuItem } page Main: Wrapper { gap Wrapper.BODY: Login }

slide-11
SLIDE 11

Take-home points 1

Sessions and session-based execution

Natural abstraction for many Web services Precise analysis and validation of form fields Simple to implement (in Java) using threads Page-like structure sometimes preferable Back-button navigation preferable (when possible)

slide-12
SLIDE 12

Take-home points 2

XML manipulation using templates with gaps

Flexible and natural abstraction Reuse of common XML fragments Precise static type analysis Separation of concerns using contracts Whole-program analysis Set of operations might be extended

slide-13
SLIDE 13

JWIG and Xact

More information online

http://www.jwig.org/ http://www.brics.dk/Xact

People

Michael I. Schwartzbach Anders Møller Aske Simon Christensen Christian Kirkegaard Henning Böttger