Project Zero JavaOne 2008

5,783 views

Published on

Project Zero PHP talk at JavaOne 2008.
This talk describes IBM WebSphere sMash and the PHP support within it. For more information visit http://www.projectzero.org

Published in: Business, Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,783
On SlideShare
0
From Embeds
0
Number of Embeds
45
Actions
Shares
0
Downloads
139
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Project Zero JavaOne 2008

  1. The Duke and the Elephant: PHP meets JavaTM Technology. The best of both worlds. Rob Nicholson . IBM Senior Technical Staff Member
  2. Agenda Whys and Whats of PHP on the Java Virtual Machine (JVM™) software How we mix PHP, Java platform and Groovy Demonstration of PHP and Java Platform Interaction ProjectZero Community © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 2
  3. Agenda Whys and Whats of PHP on the Java Virtual Machine (JVM™) software How we mix PHP, Java platform and Groovy Demonstration of PHP and Java Platform Interaction ProjectZero Community © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 3
  4. Why PHP? PHP present on 20M+ web domains (34% of internet) • Validated by significant web properties PHP snippets and extensions exist to do almost anything Language has evolved in open source • Survival of the simplest and fastest Simple syntax and dynamic typing encourage situational applications Gartner (Dec 2007) TIOBE Programming Community Index (March 2008) • PHP Developers to grow from 3 to 5.5 million by 2013 • PHP Developers in Commercial or Corporate IT to grow from 13% to 60% by 2013 • “Pay special attention to opportunities to leverage PHP in combination with Java development efforts” © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 4
  5. Introducing WebSphere sMash WebSphere sMash is an Agile Web Application Platform • Architected around Dynamic Scripting, REST, Rich Web Interfaces, AJAX, and Feeds • Optimized for • Speed • Simplicity • Agility Key Scenarios • Enables developers to build web 2.0-style applications by easily pulling in, composing, and “cobbling together” pre-existing assets (PHP assets, services, feeds, code snippets) using dynamic scripting languages and simple consumption principles based on REST • Leverages existing SOA investments by enabling rapid development of dynamic web applications that are assembled from enterprise assets and publicly available APIs System language is Java platform Application languages are and • Contains a PHP 5 interpreter written in Java programming language © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 5
  6. Project Zero Incubating the Technology Project Zero is the development and incubation community for WebSphere sMash • Live on the Internet since June 2007 Project Zero represents • The people that build and use WebSphere sMash • The incubation of new technology that will deliver in future versions of WebSphere sMash • The community of 3rd party assets that leverage the WebSphere sMash platform All released versions are called WebSphere sMash © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 6
  7. The Duke and the Elephpant © Hideyuki Shimooka © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 7
  8. Top Level Architecture App components Runtime Dojo Events PHP HTTP server app Browser REST Global Context Runtime app Groovy Local repository Package JavaTM app Remote repository Manager Remote repository Zero Application Loose coupling: Java Virtual Machine • Event driven architecture • Global Context • Virtual Directories © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 8
  9. PHP Runtime Architecture CLI PZ Http PHP Scripts • Runtime for PHP 5 scripts SAPI-J • Implemented in Java code, runs on any Java platform 5.0+ VM PHP Engine • PHP language elements represented as Java code Variables Parser Cache objects Debug (DBGp) Stack IR P8 Runtime • Parse script to Intermediate Representation (IR) Resources • Cache and Interpret IR Interpreter Classes • Compile ->bytecode prototype Objects Runtime • Extensibility via XAPI • XAPI-C for C extensions from php.net XAPI-C XAPI-J • XAPI-J for new Java platform extensions, Java native libraries invoked over JNI™ API and C Extensions Native Project Zero interface Extensions code • Extension language choice opaque to PHP script PZ Extensions • Java Platform Bridge • Debug using via DBGp using Eclipse with PDT © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 9
  10. XAPI-J example Extend PHP using Java Platform @XAPIExtension(quot;BigDecimalquot;) public class BigDecimalExt extends ExtensionBaseImpl { @XAPIFunction(quot;add_bigdecimalquot;) public void add(RuntimeContext ctxt) { RuntimeServices rts = getRuntimeServices(); InvocationService inv = rts.getInvocationService(); Object[] args = inv.parseArguments(ctxt, quot;ssquot;, false); BigDecimal arg1 = new BigDecimal(( ( XAPIString) args[0]).getString()); BigDecimal arg2 = new BigDecimal(( ( XAPIString) args[1]).getString()); BigDecimal result = arg1.add(arg2); ctxt.setReturnValue(result.toString()); } © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 10
  11. Java Platform Bridge Easy access to Java Classes from PHP <?php $date = new Java(quot;java.util.Datequot;, 70, 9, 4); var_dump($date->toString()); $map = new Java(quot;java.util.HashMapquot;); $map->put(quot;titlequot;, quot;Java Bridge!quot;); $map->put(quot;whenquot;, $date); echo $map->get(quot;whenquot;)->toString().quot;nquot;; echo $map->get(quot;titlequot;).quot;nquot;; $array = array(1,2,3,4,5); $map->put(quot;stuffquot;, $array); // PHP array converted to Java Map var_dump($map->get(quot;stuffquot;)).quot;nquot;; ?> © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 11
  12. Agenda Whys and Whats of PHP on the Java Virtual Machine software How we mix PHP, Java platform and Groovy Demonstration of PHP and Java Platform Interaction ProjectZero Community © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 12
  13. Virtualized Directories Facilitate Application Composition 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 © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 13
  14. REST Services Made easy Zero provides a really simple way to create REST services 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 © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 14
  15. REST Services in WebSphere sMash 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 deleteCollecti on /people Member retrieve update postMember delete /people/1 © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 15
  16. Demo – REST in WebSphere sMash 2008 JavaOneSM Conference | java.sun.com/javaone | 16
  17. Events Promote Loose Coupling 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 © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 17
  18. 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 © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 18
  19. 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 © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 19
  20. 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 © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 20
  21. Deploying Applications The Application is the server Java VM 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 © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 21
  22. Built in development tooling Browser-Based Development IDE Built as a sMash application Provides full development lifecycle for Zero applications • Create, Edit, Test Provides Visual Editors for Activities and Web Page construction • Including a DOJO-enabled page editor Basic Eclipse-based tooling also available if required © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 22
  23. Activities Let Developers Visually “Mash-up” Services and Feeds Compose applications by “wiring” together REST services Visually or programmatically combine existing feeds and services that enrich, sort, and filter data in a pipeline Configure templates to alter pipeline routes, log events along the pipeline Numerous built-in activities, including • Get Feed, Call Service, Aggregate, Sort, Transform, Filter, Send Mail, XSLT, Conditionals, Loops © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 23
  24. Installing WebSphere sMash Eclipse CLI / Browser IDE Get JavaTM 1.5(+) JDK Get PHP Development Tools (PDT) Download installer (<800K) All-in-one eclipse package Install Zero using the Eclipse update manager Libraries fetched as needed. Links and walkthrough on www.projectzero.org © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 24
  25. Agenda Whys and Whats of PHP on the Java Virtual Machine software How we mix PHP, Java platform and Groovy Demonstration of PHP and Java Platform Interaction. ProjectZero Community © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 25
  26. Demo: Integration with SugarCRM Scenario: Scheduling meetings requires co-ordination across the business Solution: WebSphere sMash workflow triggered from SugarCRM PHP-Java Platform Interoperability • The best of both worlds © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 26
  27. Demo – Integration with SugarCRM 2008 JavaOneSM Conference | java.sun.com/javaone | 27
  28. Agenda Whys and Whats of PHP on the Java Virtual Machine software How we mix PHP, Java platform and Groovy Demonstration of PHP and Java Platform Interaction ProjectZero Community © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 28
  29. Community Driven Commercial Development Evolve the core platform based on developer feedback Commercial development using a transparent development process Enabled via an external web site providing: http://www.projectzero.org A focal point for all sMash development activities Expose the IBM® development process to the external developer community All design decisions are discussed and communicated via external forums Registered users can post comments and feedback to the forums Frictionless download of latest code and documentation Registration not required for binary downloads Latest builds immediately available to developers Source code can be viewed by registered users © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 29
  30. Site Contents Content • Documentation • Project information • Roadmaps • Design documents • Demos and Samples • iCal calendar • Future plans Forum for interactive discussion • Help and Feedback for questions from users • Developer Alerts to notify users of new features and breaking changes • Zero Development for publicly accessible discussion amongst the Zero development team • 3554 Posts on 828 Topics to date Blogs • Development blog with interesting commentary, demos, and opinion • News blog for project announcements Binary Downloads (257,738 and counting…) Bug Tracking System (Bugzilla) Source code (Subversion) © 2008 IBM Corporation 3 2008 JavaOneSM Conference | java.sun.com/javaone | 30
  31. Features of sMash we have not covered today File Serving Error Handling View Rendering Logging, Tracing, Debugging Client Programming with the Dojo Ajax Framework Security Nested resources © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 31
  32. Summary Project Zero is incubating technologies to build web applications in WebSphere sMash • Simply! WebSphere sMash contains a PHP runtime which runs on a JVM software WebSphere sMash enables same process interoperability between PHP, Java platform and Groovy © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 32
  33. Questions? © 2008 IBM Corporation 2008 JavaOneSM Conference | java.sun.com/javaone | 33
  34. Rob Nicholson 2008 JavaOneSM Conference | java.sun.com/javaone | 34

×