DAVID NEGRIER Chief Technical Officer THE CODING MACHINE [email_address] http://www.thecodingmachine.com/projects/xaja
THE XAJA MACHINE in four points
Reverse & refresh
PART 2
Reverse Ajax 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.
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 .
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.
PART 3
Main points These are only a subset of the features provided by Xaja. 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 Use event handlers attributes Use custom attributes phponclick, phpvalue  or any other Xaja special attribute contains  directly PHP code.
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.
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 .
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!

XAJA - Reverse AJAX framework

  • 1.
    DAVID NEGRIER ChiefTechnical Officer THE CODING MACHINE [email_address] http://www.thecodingmachine.com/projects/xaja
  • 2.
    THE XAJA MACHINEin four points
  • 3.
  • 4.
  • 5.
    Reverse Ajax ReverseAjax 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.
  • 6.
    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 .
  • 7.
    Leveraging the powerof 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.
  • 8.
  • 9.
    Main points Theseare only a subset of the features provided by Xaja. 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 Use event handlers attributes Use custom attributes phponclick, phpvalue or any other Xaja special attribute contains directly PHP code.
  • 10.
    Performance impacts onthe 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.
  • 11.
    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 .
  • 12.
    Conclusion By leveragingthe 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!