IBM Presentations: Blue Onyx DeLuxe template
Download
Report
Transcript IBM Presentations: Blue Onyx DeLuxe template
IBM WebSphere sMash
An Introduction to IBM WebSphere sMash
Robin Fernandes - PHP Runtime for WebSphere sMash
[email protected]
Introduction to IBM WebSphere sMash
/
[email protected]
© 2008 IBM Corporation
IBM WebSphere sMash
Why WebSphere sMash?
Developers want to:
– Build Web apps quickly.
– Re-use and combine existing apps simply.
– Take an agile approach to Web app development.
• Quick reaction to change
• Cost-effective development
• Ease of deployment
Speed, Simplicity, Agility
Developers are adopting:
– Dynamic scripting languages for application logic (PHP, Ruby, Groovy…)
• Low barrier to entry, high productivity
• Enable “Search, copy and paste” style development
– REST, JSON to tie Web Apps together
• Simple, works well with Ajax
2
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
What is WebSphere sMash?
A complete platform for developing, assembling
and executing agile Web 2.0 apps quickly and simply.
Started in 2007 as Project Zero, a community driven incubator project
– http://projectzero.org
Released as WebSphere sMash product in May 2008
Built from the ground up with a focus on Speed, Simplicity & Agility
3
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
WebSphere sMash: Speed (time to value)
Quick to get started
–Download from projectzero.org and unzip
Scripting languages: low barrier to entry
– PHP, Groovy
Convention over configuration
– Common tasks shouldn't require configuration
Application-centric runtime
sMash application:
– Write the app, run it, and it’s ready for use.
– No need for a separate application server.
JVM
Web server
Application Code
Language runtimes
4
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
WebSphere sMash: Simplicity
Small number of new concepts in sMash
– Scripts, Events, Global Context
Focus on RESTful architecture
–Build applications around CRUDL events on Resources
–Tooling to encourage use of REST
Trivial deployment
–To move an app to another machine: zip, copy, run
5
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
WebSphere sMash: Agility
A clean runtime for your applications
– Each app has its own JVM process isolation
– Short-lived processes (“ZSO” manages startup on 1st request, recycle)
– App ready for use in <1s, footprint is ~380KB idle and ~28MB running
Modular architecture
– Features and pre-built services downloaded as required
– Core modules about ~5MB (includes HTTP stack, Groovy support)
Browser-based tooling for client and server-side
development
– Includes visual tools to simplify Web app interoperation
6
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Versions of WebSphere sMash
The runtime environment. Available under a
standard IBM commercial license.
RTE
As above + MQ Microbroker for highreliability messaging.
(Reliable Transport Extension)
DE
(Developer Edition)
“Silverstone”
7
Free download! Includes WebSphere
sMash + development tooling. Restricted
production use.
Free download! Bleeding edge version of
WebSphere sMash DE.
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Demo:
WebSphere sMash on http://projectzero.org
The AppBuilder
Hello World on WebSphere sMash
Modules
8
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Available Modules
There are 65+ modules available currently
Modules provide function in many categories
Data Formats (JSON, ATOM, RSS, XML)
Data Access
Resource Modelling
Security / Content Filtering
Activity Flows
Services
Amazon ECS, Flickr, Weather, etc
Utilities (such as HTML parsing)
Management Tools
Development Tooling
Reliable Transport Engine for Messaging Interactions
9
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Key Concept: Events
WebSphere sMash initiates
well-known system events.
Developers define the
application behaviour by
implementing event handlers.
Conventions define where
sMash will search for event
handlers.
Events are stateless. State
information is stored in the
Global Context.
10
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Key Concept: The Global Context
It’s a map of data!
Language-agnostic
Used for passing data between events, for storing application state
Zones define the life time of the data:
Zone
Scope/Visibility
Event
All handlers for a single event
Request
All handlers along the path of a
single request
Temp
All requests for all users of the
application
Config
All requests all users
User
All request for a particular user
(HTTP Session equivalent)
Application
All requests for all users of the
application
Storage
Non-persistent
Spot the zget()
& zput() calls in
the next demo!
Persistent
All requests for all users of the
application
http://www.projectzero.org/sMash/1.0.x/docs/zero.devguide.doc/zero.core/GlobalContextReference.html
11
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Key Concept: RESTful Architecture
What is REST?
– Application is defined in terms of Resources
– Resources are exposed as URIs
– Behaviour is governed by HTTP requests on these URIs
• Standard HTTP methods specify the action to carry out on the resource
(POST / GET / PUT / DELETE )
• Requests are stateless: HTTP requests contains enough information to
carry out the desired operation in full
Scalable, because the request can be handled by any back-end system
http://myshop.com/customer
• GET: Returns a list of customers
• POST: Creates a customer record
http://myshop.com/customer/homer
• GET: Retrieves customer record ‘homer’
• PUT: Updates record ‘homer’
• DELETE: Deletes record ‘homer’
12
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Demo: a RESTful Pastebin
What’s a Pastebin? see http://pastebin.com
– Website for sharing snippets of text, usually code; get a URL for that snippet.
– Useful for collaborating, heavily used by PHP community (help finding bugs in
code, submitting patches etc…)
We’ll use the “Zero Resource Model”
The RESTful resource we’ll use in this demo:
“snippet” : { “title”: string, “lang” : string, “body” : string }
URI
13
Method
Resource
Format
Description
/snippet
GET
List of
snippets
JSON
Show all snippets in the app.
/snippet
POST
Snippet
JSON
Store a single snippet.
/snippet/<id>
GET
Snippet
JSON
Show a single snippet.
/snippet/<id>
PUT
Snippet
JSON
Modify a single snippet.
/snippet/<id>
DELETE
Snippet
JSON
Remove a single snippet.
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
The PHP Engine
Why PHP in sMash?
JVM
– Gartner predict that within 5 years, 60% of 5.5 million PHP developers will
work in corporate IT (up from 13% of 3M today)
– Vast amounts of PHP code available for “search/copy/paste” development
– Wikipedia, Facebook, Flickr, Yahoo, phpBB, SugarCRM…
http://php.net: the de facto standard PHP engine
– Open Source, written in C
– Vast array of extension functions (String, image manipulation, IMAP…)
Why write a PHP engine in Java for sMash?
– Dynamic Languages + JVM =
♥
– Excellent interop with sMash’s Java APIs – and with any Java code!
14
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
PHP Engine Architecture
• Runtime for PHP 5 scripts
PHP Scripts
CLI
• Implemented in Java, runs on any Java 5+ VM
sMash
• Parse script to intermediate representation
SAPI - J
• Compile to bytecode
PHP Engine
Parser
• JVM executes the bytecode
AST
Compiler
Resources
Classes
Runtime
Stack
Interpreter
.class
Objects
Cache
C
Extensions
15
Java
Extensions
sMash
Extensions
• Extensibility via XAPI
• XAPI-C for C extensions from php.net
• XAPI-J for new Java extensions, native libraries
invoked over JNI and Project Zero interface
XAPI-J
XAPI-C
Debug API (DBGp)
P8 Runtime
opcodes
Variables
• Bytecode calls back into runtime to access PHP
language elements, which are represented as Java
objects
•Extension language choice opaque to PHP script
Native
code
•Debug via DBGp using Eclipse with PDT
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
PHP Language Support
Core PHP extensions supported
Currently supports a subset of PHP extensions
– The goal is maximum re-use of existing PHP scripts and
applications.
phpBB
16
SugarCRM
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Two levels of PHP/Java Integration
Direct use of Java objects in PHP Code:
<?php
$date = new Java("java.util.Date", 70, 9, 4);
var_dump($date->toString());
$map = new Java("java.util.HashMap");
$map->put("title", "Java Bridge!");
$map->put("when", $date);
echo $map->get("when")->toString()."\n";
echo $map->get("title")."\n";
$array = array(1,2,3,4,5);
$map->put("stuff", $array); // PHP array to Java Map
var_dump($map->get("stuff"))."\n";
?>
17
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Two levels of PHP/Java Integration
Use annotations and a thin wrapper around your Java code
– Allows definition of PHP specific attributes that could not be
represented in plain Java code.
@XAPIClass("ArrayObject")
public final class ArrayObjectDescriptor {
@XAPIMethod(name = "setIteratorClass")
@XAPIForbidStaticCalls
@XAPIArguments(
PassSemantics = { XAPIPassSemantics.ByValue },
MandatoryArguments = 1, MaximumArguments = 2,
DefaultValues = { "ArrayIterator" }
)
public static void setIteratorClass(RuntimeContextStack runtime, int argsPassed){
//...
18
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Demo: PHP / Java Integration
Show PHP interacting with a custom Java asset
PHP Code
PHP Runtime
in sMash
Your
AST Generator!
Java code
JVM
19
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Features we didn’t cover
Client Programming with the Dojo Framework
Assemble Tooling
Data APIs
Security
Eclipse-based tooling
REST to SOAP adapter
Reliable Messaging
Error Handling
Logging, Tracing, Debugging
…
20
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Summary
WebSphere sMash:
– Runtime optimized for quickly and easily creating situational
applications
– Low barrier to entry
– Browser-based tooling for client and server side development
– Convention over configuration
– Focus on REST
– Java/PHP/Groovy interoperability
• All, including PHP, run on the JVM
21
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
http://projectzero.org
Community site for users and developers
Content
Documentation and User Guides
Design documents and Roadmaps
Demos and Samples
Forum for interactive discussion
Help and Feedback for questions from users
Developer Alerts to notify users of new features and breaking changes
Development discussion
3554 Posts on 828 Topics to date
Blogs
Development blog with interesting commentary, demos, and opinion
News blog for project announcements
Binary Downloads (500,000 and counting…)
Bug Tracking System (Bugzilla)
Source code (Subversion)
22
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Links
– http://projectzero.org
– Search for WebSphere sMash on http://www.ibm.com/developerworks
Thanks to the following for presentation material:
– Colin Thorne, Stuart Hayton, Don Boulia, Rob Nicholson, Roland
Barcia, Steve Ims
Robin Fernandes
[email protected]
[email protected]
23
7/17/2015
© 2008 IBM Corporation
IBM WebSphere sMash
Legal Notices
24
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.
7/17/2015
© 2008 IBM Corporation