Zembly Programming Language

Preview:

Citation preview

zembly Programming Model

1

Srividhya Narayanan, Sr. Engineering Manager

2

Agenda

• Building Blocks• Language Reference• Web APIs• Building a FB application

3

Building Blocks

• Widgets> Are ...

●User interface (rendered in browser)

• Data Services> Are …

●Back-end logic

• API> Are …

●Externally available value-added services

4

Widgets

• Are...> 3 things – HTML, CSS, JavaScript> Flavors

●FB: FBML, FBJS

5

Data Services

• Are...> JavaScript 1.6 including E4X> Called from widgets or from other services

6

API

• Are...> RESTful services > WADL(Web Application Description Language)

described> Called from other widgets and services> Keyset managed in zembly

7

Language Reference

8

Data Services

• Input // Get value of a parameter var a = Parameters.param1;

• Output // Returning a String return "Hello world!";

// Returning an Object

return { foo: "bar" };

9

Data Services

Calling a service from other service

• Calling zembly created Data service – Using Things object

var result = Things.codename.serviceName(parameters);

• Calling external Web API - Using Web object var result = Web.domain.api.serviceName(parameters);

• Passing identity credentials> From keychain using Owner.keychain> Generating on the fly

10

Data Services

Error Occurs when

• Problems with the request or caller, for example, a required parameter wasn't specified

• Syntax errors in the service code

• JavaScript runtime errors in the service code, such as reference to undefined variable

• Uncaught errors from a nested service invocation

• Errors thrown from the service code

• Platform errors

11

Data Services

Error Object

• error.code - Error code returned by the service, or by the platform. Error code is always included.

• error.message - Message may provide a "human readable" information about the error.

• error.details - Details property may carry a structured information about the error.

• error.httpStatusCode - HTTP status code that was used in the service response.

12

Data Services

• Error Handling> Using try-catch block> Throwing errors from services

• Logging in Services> Log.write(message)> Log.log(message)> Log.debug> Log.info

● All these 4 methods currently add a message to the execution log with info level.

> Log.warn - Adds a message to the execution log with warning level

> Log.error - Adds a message to the execution log with error level

13

Widgets

• Parameters> As properties of Parameter object:

Parameters.x> As Markup expressions:

<h1>Hello ${Parameter.name}</h1>> Markup with a scriptlet

<h1>Hi <?=${Parameter.name}</h1>

14

Widgets

• Calling a service from a widget> service invocations from widgets are asynchronous> Things.callService(serviceName, parameters,

options)> Web.callService(serviceName, parameters,

options) - http://zembly.com/things/cb1812d5a786455b82331045884ca7f9

• Service invocation callbacks> options.onSuccess : function(data)> options.onSuccess : function(data, transport,

options)> Service result comes back in data parameter> options.onFailure : function(error)> Error parameter contains the code, message, HTTP status

code and details of the error.

15

Widgets

• Logging> Alert()> Log object

●default logging is turned off when executing published widgets;

• Keychain> Not available

16

Web APIs

17

18

API

• Zembly exposed Web APIs

• Bring Your Own API into zembly. http://wiki.zembly.com/wiki/Bring_Your_Own_API

• NetBeans WADL designer. http://www.netbeans.org/kb/docs/websvc/wadl-zembly.html

19

Facebook Demo

Thank You!

20

srividhya.narayanan@sun.com

Recommended