itemscript, a specification for restful json integration

41
Itemscript A declarative language based on JSON

Upload: itemfoo

Post on 21-Jan-2015

892 views

Category:

Technology


1 download

DESCRIPTION

a briefing on the Itemscript project and a demonstration of the Item Lens proof of concept.

TRANSCRIPT

Page 1: Itemscript, a specification for RESTful JSON integration

Itemscript

A declarative languagebased on JSON

Page 2: Itemscript, a specification for RESTful JSON integration

Vision

Simple schema 

data storeapplication markup

Applications from componentsDe-couple technical details

Lean developmentBusiness agility

Page 3: Itemscript, a specification for RESTful JSON integration

Itemscript is Declarative

• Separates design (what) from construction  (how)o Simple APIo Lends itself to iterative developmento Technical details are hiddeno Controls are exposedo Swap components without breaking the API

Page 4: Itemscript, a specification for RESTful JSON integration
Page 5: Itemscript, a specification for RESTful JSON integration
Page 6: Itemscript, a specification for RESTful JSON integration

Itemscript Philosophy

Applications are multi-layered• Core is compiled code• Wrapped around that are configuration files• Wrapped around that are user settings    • Compiled settings are the hardest to change• Configuration files help,

but only offer limited access• User settings are usually very limited

Applications should expose all useful settings

Core

Configuration

User settings

Page 7: Itemscript, a specification for RESTful JSON integration

Itemscript is JSON

• JSON is simple• JSON has widespread support• JSON is an ideal data-interchange language

Page 8: Itemscript, a specification for RESTful JSON integration

JSON easily maps to native objects

JSON Objects• Native objects & packages• Nested object graphs• Maps/hashes/dictionaries• Databases• Key-value stores• Cloud databases

      JSON Arrays• Lists/arrays/sets• Query results

Page 9: Itemscript, a specification for RESTful JSON integration

Extending JSON

• Deal with more data than fits in memoryo Databaseso Queries

• Handle references• Manage local and remote data• Handle identifiers• Support schemas• Manage persistence• Handle events

Page 10: Itemscript, a specification for RESTful JSON integration

Semantics

• Itemscript Schema    JSON Schema language 

      • Itemscript JAM 

JSON Application Markup

Page 11: Itemscript, a specification for RESTful JSON integration

Itemscript schemaDog Type"com.example.petstore.SCHEMA" :{"Dog" : {"ID name" : "","weight" : 0,"REQUIRED owner" : "","breed" : "","isFixed" : true,}}item of type Dog:"com.example.petstore.dogs.Bella" : {"TYPE" : "com.example.petstore.SCHEMA.Dog","name" : "Bella","weight" : 9.2,"owner" : "Vera","breed" : "Cavalier King Charles","isFixed" : true}

http://itemscript.org/ItemscriptSchema.html

Page 12: Itemscript, a specification for RESTful JSON integration

Itemscript JAM

{          "widget" : "GWT.Image",          "title" : "Itemscript Logo",          "width" : "100px",          "height" : "100px",          "url" : "./itemscript-logo.jpg"        }

Page 13: Itemscript, a specification for RESTful JSON integration
Page 14: Itemscript, a specification for RESTful JSON integration

Business agility

• Lean development using declarationso Developer & user iterate togethero Discover needs as you develop solutions

• Iterate applications as requirements developo Add elements & event handlers as you need themo Trade up as better options arrive

Page 15: Itemscript, a specification for RESTful JSON integration

Proof of Concept

• Item Lens (JAM animator)o rich web UI based on Google GWT

• Item Store (Column store)o persistence based on Apache Derby 

         • Item Hash (Model application)

o item tracker built using Itemscript JAM

Page 16: Itemscript, a specification for RESTful JSON integration
Page 17: Itemscript, a specification for RESTful JSON integration

Itemscript execution

Itemscript

Item Lens Item Store

SchemaJAM

Item StoreProtocol

SQL

MQ

Cache

XML

Page 18: Itemscript, a specification for RESTful JSON integration

Itemscript Applications

“Small pieces loosely joined” a collection of Lego bricks

Compiled objects are managed in libraries, by type

All "wiring-up" is done using JSON declarations

No sharp distinction between application-building, configuration, or user settings

http://www.smallpieces.com

Page 19: Itemscript, a specification for RESTful JSON integration

How we built it

• Build objects that can be configured using JSON.• Use semantics that describe the domain 

           widget, handler, page ticket, priority, status

white  • For each object type,

build a factory that trades JSON for an object instance.• For each class of object (e.g. widget),

combine the factories into a foundry.• Factor out common code.

Page 20: Itemscript, a specification for RESTful JSON integration

Itemscript System

• Each system has one "root" JSON objecto Acts as shared in-memory database for your application.o Application configurationo Application state

• You can load additional Items - hold as long as needed, natively-garbage-collected.o Load system and initial configurationo Load Item from remote datastoreo Copy part of Item to current application stateo Discard Item

Page 21: Itemscript, a specification for RESTful JSON integration

The Item

The smallest unit of transferrable data.• Guaranteed to be transmitted as a whole.• Guaranteed to be fully navigable locally/synchronously.      

Consists of a JSON Object, including nested other objects.

Metadata and data live together in the JSON Object. _ prefix denotes metadata.

_CONNECTION key tells you where this Item came from._ID key gives you the GUID key for an Item.

_PARENT_ID key gives you the GUID key for a parent

Page 22: Itemscript, a specification for RESTful JSON integration

Item Lens applications

• Application o a set of nested Widgets.o usually includes a PagePanel.

• PagePanel shows the Pages that have been defined.• Each Page is a set of nested Widgets.

• Popups are also a set of nested Widgets.• Dialog boxes• Error boxes 

Page 23: Itemscript, a specification for RESTful JSON integration

Item Lens bootstrap

• Item Lens starts an application: o loads modules (using GWT module system), o modules register Foundries containing Factories, or register

additional Factories in existing Foundries. e.g. WidgetFoundry 

• Item Lens loads and stores the script file.o Reads script file for more definitions - widgets, pages, popupso stores them in the corresponding Foundry.

 • Item Lens reads script file to build the application.  

Page 24: Itemscript, a specification for RESTful JSON integration

Item Store

The Item Store is a key-value store of Items.   Any Item can be the root of another key-value store.

o May map to: database-table-row.o Or to: database-table-row-subTable-rowset.

  Easily replaced with SQL tables, key/value stores   Maps Item Store namespace locations to connect to

remote locations and services.

Page 25: Itemscript, a specification for RESTful JSON integration

Item Store

• Item Store RPCo Simple data store

Get Put Remove

o Simple proxy for the service provider Connect services when your application is ready Swap out services without changing applications

Page 26: Itemscript, a specification for RESTful JSON integration

Developing Itemscript applications

• Client sideo Wrap widgets and components in Itemscripto Wire up components to build interfaces

• Server sideo Declare Itemscript data types o Assign types to locationso Connect locations to services

Page 27: Itemscript, a specification for RESTful JSON integration

Item Hash

• Building the model application  o item hash use caseo item hash design processo pulldown list exampleo date picker exampleo event exampleo adding a new fieldo adding a new event handler

Page 28: Itemscript, a specification for RESTful JSON integration

Item Hash Page Nesting

Page 29: Itemscript, a specification for RESTful JSON integration

New Case Page Nesting

Page 30: Itemscript, a specification for RESTful JSON integration

Editing the Form

                  {                                "widget" : "GWT.VerticalPanel",                                    "contents" : [                        {                          "widget" : "GWT.Html",                          "html" : "<small>Priority</small>"                          "id" : "Priority"                        },                        {                         "widget" : "GWT.ListBox",                         "width" : "200px",                         "height" : "20px"                         "data" : "ItemHash.db/priorities"                        }                     ]                  }

Page 31: Itemscript, a specification for RESTful JSON integration

Item Lens

"Can I set the date picker to tomorrow?"

Page 32: Itemscript, a specification for RESTful JSON integration

Changing the Date Picker

What would the JSON look like?

{    "widget" : "ItemLens.DatePickerTextBox"    "width" : "200px",    "height" : "25px",   "date" : "tomorrow"}

Page 33: Itemscript, a specification for RESTful JSON integration

Changing the Date Picker

When the "date" declaration says "tomorrow", what logic do we need to add?

if (params.hasOptionalString("date")) {    String dateStr = params.getString("date");    if (dateStr.equalsIgnoreCase("tomorrow")) {        Date tomorrow = new Date(new            Date().getTime()+DAY_AS_MILLISECONDS);        box.setValue(tomorrow);    }}

Page 34: Itemscript, a specification for RESTful JSON integration

Event Handling

"Let's make the login box pop up."

Page 35: Itemscript, a specification for RESTful JSON integration

Event Handling

What would the JSON look like?

{    "widget" : "GWT.Html"       "cellHorizontalAlignment" : "right"      "html" : "<small><b>login</b></small>"       "clickHandlers" : {        "clickHandler" : "ItemLens.PopupPanelShowClickHandler",         "popup" : "loginPrompt"  }}

Page 36: Itemscript, a specification for RESTful JSON integration

Event Handling

Implementing a "clickHandler"

Register a factory to create an action.

Animating "popup" : "loginPrompt"

• Read the "loginPrompt" object in "popups" section.• Parse loginPrompt for the parameter needed.• Build a popup widget.

Page 37: Itemscript, a specification for RESTful JSON integration

Event Handling"popups": {    "loginPrompt" : {      "widget" : "GWT.DialogBox",      "id" : "Login",      "title" : "user login",      "showRelativeTo" : "searchbox",      "width" : "100px",      "cellHorizontalAlignment" : "center",      "cellVerticalAlignment" : "bottom",      "html" : "<strong>User Login</strong>",      "autohide" : false,      "contents" : {      "widget" : "GWT.VerticalPanel",      "cellSpacing" : 5      "contents" : [              ...

Page 38: Itemscript, a specification for RESTful JSON integration

Adding Widget Libraries

GChart{  "widget" : "GChart.Chart",  "canvas" : true,  "chartHeight" : 200,  "chartWidth" : 300,  "chartTitle" : "&lt;h3&gt;2008 Sales by Pie  Flavor&lt;br&gt;(Puny Pies, Inc.) &lt;/h3&gt;",  "legendVisible" : false,  "initialPieSliceOrientation" : 0.425,  "curves" : [     {      "symbol" : "pieSliceOptimalShading",      "modelWidth" : 6,      "backgroundColor" : "green",      "borderColor" : "white",      "height" : 0,      "fillSpacing" : 0,      "fillThickness" : 3,      "hoverText" : "Apple, 65%",      "pieSliceSize" : 0.65,      "points" : [        {          "point" : "5,5",          "annotationText" : "Apple",          "annotationLocation" : "outsidePieArc"        }        ...

• Designers learn a few new declarations, not a new API

• Full demo at http://tinyurl.com/gchartdemo

Page 39: Itemscript, a specification for RESTful JSON integration

Downloads

• Item Lens         AJAX using Google GWT        Components from Google Maps, Gchart, GWT Widget library

• Itemscript Core Libraries        Convenient JSON library for Java & GWT applications

Page 40: Itemscript, a specification for RESTful JSON integration

What's Next?

• Item Store

• Itemscript schema validator

• Declarative security model  

• Hosted Service

• Application exchange

Page 41: Itemscript, a specification for RESTful JSON integration

Working with Itemscript

Project pageshttp://itemscript.orghttp://code.google.com/p/itemscript/

Twitter updateshttp://twitter.com/itemscript

FAQhttp://code.google.com/p/itemscript/wiki/itemscriptfaq