2. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Agenda
What is Project Zero
Why should I care?
Creating Applications and REST web services - DEMO
Assembling Applications - DEMO
Deploying application
Running an existing PHP application - DEMO
Web IDE prototype DEMO
Rob Nicholson - Project Zero 2
3. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Introduction
Project Zero is an IBM technology incubator project.
Building a radically simplified platform to enable the productive
development and deployment of rich internet applications.
TM
System language is Java .
Zero runs on a Java Virtual Machine.
TM
Supports Linux, Mac and Windows.
Application languages are PHP and Groovy.
Zero contains a PHP 5 interpreter written in Java TM
Rob Nicholson - Project Zero 3
4. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Some Simplifications We Are Aiming For
Creating new agile web applications.
Sharing assets from different languages.
Implementing REST services.
Building a rich user interface.
I want to spend less time sorting out browser incompatibilities!
Accessibility.
Assembling applications and services.
Deploying applications.
Versioning dependencies.
Rob Nicholson - Project Zero 4
5. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Top Level Architecture
App components
Applications built from loosely
Runtime
coupled components. Dojo Events
PHP
HTTP server
app
Browser
REST
Enabled by:
Global
Event driven architecture. Context
Runtime
app
Groovy
Global Context.
Virtual Directories. Local repository
Package
Java app
Remote repository Manager
Convention based configuration.
Remote repository Zero Application
RESTful web services and AJAX.
Java Virtual Machine
IDE based around Eclipse and PDT
Prototype web IDE.
Command line for deployment.
The application is the web server.
Rob Nicholson - Project Zero 5
6. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
PHP Runtime Architecture • Runtime for PHP 5 scripts
CLI PZ Http
PHP Scripts
• Implemented in Java, runs on any Java 5.0+ VM
SAPI-J
• PHP language elements represented as Java objects
PHP Engine • Parse script to Intermediate Representation.(IR)
Variables
Cache • Cache and Interpret IR
Parser
Debug (DBGp)
Stack IR
P8 Runtime • Compile ->bytecode prototype
Resources
Interpreter •Extensibility via XAPI
Classes
• XAPI-C for C extensions from php.net
Objects Runtime
• XAPI-J for new Java extensions, native libraries
invoked over JNI and Project Zero interface
XAPI-J
XAPI-C
• Extension language choice opaque to PHP script
Java
C Extensions Native
Extensions code •Java Bridge
PZ Extensions •Debug using via DBGp using Eclipse with PDT
Rob Nicholson - Project Zero 6
7. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Virtualized Directories
Resources searched across application and dependencies.
Apps behave as if directories merged.
Applies to all script directories.
/public /app/resources, /app/scripts, /app/views etc.
First-one-wins precedence.
Order based on dependency order in ivy files.
Default files searched within each directory first:
{my application}/index.php
{my application}/index.html
{dependency1}/index.php
{dependency1}/index.html
Rob Nicholson - Project Zero 7
8. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Demo – Your first Zero Application.
See http://www.projectzero.org/wiki/bin/view/Documentation/Videos
Rob Nicholson - Project Zero 8
9. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Implementing REST Services
Zero provides a really simple way to create REST services.
REST services fit well with test-driven development.
Convention for create/retrieve/update/delete operations (CRUD).
You can also list the members in the collection.
HTTP Method URI Description
GET /people List members
POST /people Create member
GET /people/1 Retrieve member
PUT /people/1 Update member
DELETE /people/1 Delete member
Rob Nicholson - Project Zero 9
10. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
REST Services in Project Zero
Each REST service is implemented by a script (called a handler).
Scripts live in the directory: <apphome>/app/resources
Services are accessed using a standard URL convention:
/resources/<collection name>[/member[/<path info>]]
HTTP requests mapped to handler methods as follows:
Resource GET PUT POST DELETE
Collection list putCollection create deleteCollection
/people
Member retrieve update postMember delete
/people/1
Rob Nicholson - Project Zero 10
11. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
RESTful Resources
Values of <memberID> and <pathInfo> are available for member
operations:
Http URI Invokes method in With event data (in global context)
Method <apphome>/app/resour
ces/people.php
GET /resources/people list
POST /resources/people create
GET /resources/people/1/a retrieve /request/params/peopleId = 1
ccounts /event/pathInfo = /accounts
PUT /resources/people/1 update /request/params/peopleId' = 1
DELETE /resources/people/1 delete /request/params/peopleId' = 1
Rob Nicholson - Project Zero 11
12. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Demo – REST in Project Zero,
See http://www.projectzero.org/wiki/bin/view/Documentation/Videos
Rob Nicholson - Project Zero 12
13. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Sharing Assets - Events
All behaviour in the system is modelled as a set of events.
Events are programming language agnostic.
Fired by an application using fire_event().
fire_event('my_event', array(‘data'=>'foobar'));
Event handlers are defined in the Zero configuration file:
/config/handlers += {
quot;eventsquot; : my_event,
quot;handlerquot; : test.php
}
Request Processing events
requestBegin, secure, GET, PUT, POST, DELETE, log, requestEnd
Application specific events
Fired by your application.
Rob Nicholson - Project Zero 13
14. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Sharing Assets - Rendering
Zero provides renderers for generating output.
Renderers are programming language agnostic.
View renderer serves up script output:
zput('/request/view', 'hello.php');
render_view();
XML, JSON and ATOM for well known data types:
zput(quot;/request/viewquot;, quot;JSONquot;);
zput(quot;/request/json/outputquot;, $obj);
render_view();
Error renderer serves up standard error pages.
Rob Nicholson - Project Zero 14
15. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Global Context
Event handlers are stateless
interesting applications contain state
GC provides access/management of application state.
It is NOT persistent. Persistent data goes into the database.
Conceptually a map of data.
Divided into a set of zones with different data lifecycles.
Understands and provides intelligent access to certain data
types.
Externalizes state from the application logic.
Enables clustering and scaling to be added transparently.
Rob Nicholson - Project Zero 15
16. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Global Content Zones
Divided into zones representing different data lifecycles
Zone Scope/Visibility Lifecycle
Config All requests all users. Loaded from config
files.
Application All requests for all users of the Life of the application,
application but not “persistent”
User All request for a particular user For first access until
(HTTP Session equivalent) user times out
Request All handlers along the path of a For the duration of a
single request single request
Event All handlers for a single event The duration of a single
event
Rob Nicholson - Project Zero 16
17. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Accessing the Global Context
Action PHP Example Java Example
Get HTTP Request URI zget (/request/uri) GlobalContext.get(quot;/request
/uriquot;
Get value of user-agent request zget GlobalContext.get(quot;/request
header (/request/headers/in/User- /headers/in/User-Agentquot;)
Agent)
Get list of request parameters list_keys('/request/para GlobalContext.get(quot;/request
ms', false) /paramsquot;)
Get value of request parameter zget ((String [])
parmName (/request/params/ParmName) GlobalContext.get(quot;/request
/params/parmNamequot;))[0]
Set status zput (/request/status,200) request.status = 200
Of course PHP (super)globals are also available.
Rob Nicholson - Project Zero 17
18. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Meerkat Demo
Rob Nicholson - Project Zero 18
19. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Java Bridge
Rob Nicholson - Project Zero 19
20. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Building A Rich User Interface
Dojo is the preferred Ajax/JavaScript toolkit for Zero.
Open source toolkit to simplify rich web applications.
http://www.dojotoolkit.org
v1.0 released on 5th November 2007.
Addresses key problem with browser compatibility.
Dijit library provides rich set of user interface widgets.
Accessibility built in
Internationalised
Theme 100% customisable
DojoX adds experimental and specialised extensions.
Wire, XML, cryptography, network
Rob Nicholson - Project Zero 20
21. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Input controls – buttons, combo box, sliders, text areas.
Layout – accordion, split/stack containers, tabs.
Command – button, menu, toolbar.
User assistance and feedback – progress bar, tooltip, dialog.
Advanced editing and display – editor, tree, colour palette
Rob Nicholson - Project Zero 21
22. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Dojo Core Widget Set (Dijit) Accessibility
ARIA specification implemented in all widgets.
Fully keyboard accessible in Firefox and Internet Explorer.
Screen reader accessible in Firefox.
Works in operating system high-contrast mode (system colours).
Works with images off (regular <img> tags).
Currently only auto-detected in Firefox.
Must be in high contrast mode for image-off support in Internet Explorer.
More information available from: http://www.w3.org/WAI/intro/aria.
Rob Nicholson - Project Zero 22
23. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Deploying Applications
The application is the server
JVM
Web server
Application Code
Language runtimes
Hundreds of applications per box.
Applications started on demand – inetd style
Applications isolation
Quality of service and management built in.
Rob Nicholson - Project Zero 23
24. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Deploying on the command line
Package the app from eclipse:
File->export.
Download Zero command line from projectzero.org, unzip on target machine.
Unzip application.
Zero run :
C:zofficemonitor-all>zero run
Resolving C:zofficemonitor-allconfigivy.xml
zeroinit apphome=C:zofficemonitor-all
zeromake zerohome=C:zerozero-1.0.6169.M2 apphome=C:zofficemonitor-
all appname=officemonitor
2007-10-29 20:58:20 zero.core.cfadapter.ZeroServer::writePid Thread-10
INFO [ PID file written to C:zofficemonitor-alllogszero.pid]
2007-10-29 20:58:20 zero.core.cfadapter.ZeroServer::run Thread-10
INFO [ C:/z/officemonitor-all running on port 8080 ]
See http://www.projectzero.org/wiki/bin/view/Documentation/Videos
Rob Nicholson - Project Zero 24
25. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Versioning Dependencies
Modules are the building blocks of an application.
A module is simply a collection of files packaged together.
Includes a module name, version and author details.
An application declares the modules it depends on.
Versioning ensures applications don’t break!
Specific versions can be set (v1.1.34).
Versions upwards from a particular release (v1.0+).
Ranges of acceptable versions (v1.0 – v1.5).
Remote catalog servers at PZ.net and maven2
Rob Nicholson - Project Zero 25
26. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Visual assembly of feeds and flows - Assemble
http://www.projectzero.org/wiki/bin/view/Documentation/Videos
Rob Nicholson - Project Zero 26
27. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
PHP Application Demo
Rob Nicholson - Project Zero 27
28. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Web tool prototype
Rob Nicholson - Project Zero 28
29. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Installing Project Zero
Get a Java 1.5 JDK.
Get the PHP Development Tools (PDT) Eclipse all-in-one.
Install Zero for PDT using the eclipse update manager.
From the project zero download site.
Links and walkthrough on www.projectzero.org.
Community, blogs, questions, answers, opinions and thoughts:
http://www.projectzero.org/wiki/bin/view/Community/WebHome
Rob Nicholson - Project Zero 29
30. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Features of Zero we have not covered today
File Serving
Error Handling
Logging/Tracing/Debugging
Client Programming with Dojo
Security
Nested resources
Rob Nicholson - Project Zero 30
31. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
PHP Runtime Architecture
CLI PZ Http
PHP Scripts
SAPI-J
PHP Engine
Variables
Cache
Parser
Debug (DBGp)
Stack IR
P8 Runtime
Resources
Interpreter
Classes
Objects Runtime
XAPI-J
XAPI-C
Java
C Extensions Native
Extensions code
PZ Extensions
Rob Nicholson - Project Zero 31
32. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
XAPI-J example
Rob Nicholson - Project Zero 32
33. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
What we learned
PHP is reference implementation based language.
PHP has no spec.
Documentation is good for users.
But not precise enough for language implementers.
Test suite is the real spec.
Many surprises.
Rob Nicholson - Project Zero 33
34. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Quantum mechanics in PHP
In this example we see how observing a value can change how it
behaves.
Counter-intuitive to non physicists.
But similar in some ways to quantum physics.
Rob Nicholson - Project Zero 34
35. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Quantum Mechanics in PHP (simple case)
1. $a=array(“foo”); 4. $b[0]=“bar”;
PHP String
PHP String 0
0 “foo”
$a
“foo”
$a
PHP String
0
2. // do nothing “bar”
$b
3. $b=$a;
PHP String Pictures show PHP programmer’s view. (Not
0
$a “foo”
internals).
Observe that $b and $a are independent.
PHP String
0
$b
“foo”
Rob Nicholson - Project Zero 35
36. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Quantum Mechanics in PHP (observing changes behaviour)
1. $a=array(“foo”); 4. $b[0]=“bar”;
PHP String
PHP String 0
0 “bar”
$a
“foo”
$a
2. $c=&$a[0]; 0
PHP String $b
0
$a
“foo”
$c
3. $b=$a;
0
PHP String All we did was observe the value of $a[0]
$a “foo”
Now $a and $b are not independent.
0
$b
Rob Nicholson - Project Zero 36
37. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
PROJECT ZERO COMMUNITY
WWW.PROJECTZERO.ORG
Rob Nicholson - Project Zero 37
38. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Rob Nicholson - Project Zero 38
39. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Summary
Project Zero is incubating technologies to build web applications
Simply!
Project zero contains a PHP runtime which runs on a JVM.
Project Zero enables same process interoperability between
PHP, Java and Groovy.
Rob Nicholson - Project Zero 39
40. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Questions?
Rob Nicholson - Project Zero 40
41. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Thank You!
Rob Nicholson - Project Zero 41
42. projectzero.org
Zero complexity. Zero overhead. Zero obstacles.
Legal Notices
Java and all Java-based trademarks and logos are trademarks of Sun
Microsystems, Inc. in the United States, other countries, or both.
Microsoft, Windows, Windows NT, and the Windows logo are
trademarks of Microsoft Corporation in the United States, other
countries, or both.
Intel and Pentium are trademarks or registered trademark of Intel
Corporation or its subsidiaries in the United States and other countries.
UNIX is a registered trademark of The Open Group in the United States
and other countries.
Linux is a trademark of Linus Torvalds in the United States, other
countries, or both.
Other company, product, or service names may be trademarks or
service marks of others.
Rob Nicholson - Project Zero 42