XAJA - Reverse AJAX framework

12
© THE CODING MACHINE - 2007 DAVID NEGRIER Chief Technical Officer THE CODING MACHINE [email protected] http://www.thecodingmachine.com/ projects/xaja

description

 

Transcript of XAJA - Reverse AJAX framework

Page 1: XAJA - Reverse AJAX framework

© THE CODING MACHINE - 2007

DAVID NEGRIER Chief Technical OfficerTHE CODING MACHINE

[email protected]

http://www.thecodingmachine.com/projects/xaja

Page 2: XAJA - Reverse AJAX framework

© THE CODING MACHINE - 2007

THE XAJA MACHINE in four points

Page 3: XAJA - Reverse AJAX framework

© THE CODING MACHINE - 2007

Reverse & refresh

Page 4: XAJA - Reverse AJAX framework

© THE CODING MACHINE - 2007

PA

RT 2

Page 5: XAJA - Reverse AJAX framework

© THE CODING MACHINE - 2007

Reverse Ajax is the ability to push data instantly from a web server to the user's browser, without user interaction.

In order to establish a 2 ways data link, the Reverse Ajax technique (also known as Comet) tricks the browser by making several requests, one of which is answered very slowly.

Reverse Ajax

Page 6: XAJA - Reverse AJAX framework

© THE CODING MACHINE - 2007

How XAJA works ?

In PHP, there is no standard equivalent of the Java Message System. This is why Xaja comes with its own Message Broker.

Xaja's message broker is a process that should be started when the server is started.

The message broker can listen to clients on two kind of sockets: TCP sockets or IPC sockets.

A message broker and a long-lived process are enough to implement efficient Reverse Ajax applications.

However, this is not exactly easy. For each page, the developer must develop several PHP scripts. Xaja makes this process easy by providing the XajaController.

Page 7: XAJA - Reverse AJAX framework

© THE CODING MACHINE - 2007

Leveraging the power of the long-lived processes

In Xaja, the XajaController keeps the state of the whole document that is sent to the browser. Xaja does this through an output buffer (using PHP's obstart() function).

Xaja parses the document and stores the document in the XajaController. The DOM is stored on the server side. When the developers modifies the DOM on the server side, changes are automatically pushed to the browser.

Furthermore, Xaja applies some transformations to the XML. For instance, it provides a number of new tags and a number of new attributes on standard HTML tags that makes development really easier.

Page 8: XAJA - Reverse AJAX framework

© THE CODING MACHINE - 2007

PA

RT 3

Page 9: XAJA - Reverse AJAX framework

© THE CODING MACHINE - 2007

Main points

Claim Control Of Your Browser!

Access Widgets $xajaController->getWidgetById() will return an HTML node

Remove Content $widget->removeChildren() will remove children HTML nodes

Use the pencil $xajaController->setPencil() will set the pencil in position

Use Scriptaculous $widget->pulsate() … or any other Scriptaculous effect!

Use the Message Broker to Push Data to Other Processes!

Send a message $xajaController->sendMessageToBroker() sends messages

Listen for messages $xajaController->addListener() will listen for messages

Set the callback $xajaController->setCallBackOnMessage() sets the callback

These are only a subset of the features provided by Xaja.

Use event handlers attributes

Use custom attributes

phponclick, phpvalue or any other Xaja special attribute contains directly PHP code.

Page 10: XAJA - Reverse AJAX framework

© THE CODING MACHINE - 2007

Performance impacts on the server side

A server running Xaja must run a Broker process. Furthermore, for each client, the server runs 2 long-lived processes.

Therefore, an application with 100 concurrent users will start 201 concurrent processes!

Hopefully, the “copy-on-write” mechanism of the Operating Systems prevents the OS from reloading the whole PHP program each time a process is launched.

Memory consumption

Broker 11 Mo

1 user 4,2 Mo

10 user 42 Mo

Tests performed on the memory consumption of the sample Address Book application show that a user consumes on average 4,2 Mo of RAM, for both long-lived processes.

Xaja is still in early development stage and no test has been done yet to see the impact of the increase number of processes on the performances. However, we can already say that Xaja behaves correctly with 10 concurrent users.

Page 11: XAJA - Reverse AJAX framework

© THE CODING MACHINE - 2007

What’s coming next?

Xaja is still in early development and a lot of features need to be added.

In the coming monthes, we plan to add:

Compatibility with Safari and Opera

Several useful tags, including menus, self-validating textboxes, auto-complete controls, trees, drag’n’drop, sliders and all the cool stuff that we got used to!

Reverse Data Sources and Reverse Datagrids!

Just imagine you could write something like this:<?php

$reverse_ds = new ReverseSQLDataSource(“SELECT * FROM users”);

?>

<datagrid datasource=“$reverse_ds” />

Xaja will reach its goal if it brings pervasive reverse ajax: reverse ajax everywhere, with no need to develop additional code.

Page 12: XAJA - Reverse AJAX framework

© THE CODING MACHINE - 2007

Conclusion

By leveraging the power of Reverse Ajax, Xaja does not only provide a push mechanism on the browser.

It also completely reverses the way a developer should think about its application and the way applications are designed. It also enables the developer to be much more efficient by using custom tags and attributes.

We release Xaja as an Open Source library with the hope that many developers will be interested and will come and help us adding features to it.

So if you want to enrich Xaja with a new killer tag, if you want to help us improving it by reporting bugs or patches, or if you want to perform a complete performance test, please contact us and join the team!