otm:ordering_of_messages:fifo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
otm:ordering_of_messages:fifo [2011/01/05 20:12]
aspectscript
otm:ordering_of_messages:fifo [2011/01/24 18:59]
aspectscript
Line 1: Line 1:
-Web applications typically update data from servers (//eg.// whether, time) Developers has to overcome the issue of using obsolete data due to a late response of a server. For example, consider a website that shows the current time of certain country using two Ajax requests. If the response second request arrives before than the response the first ajax request arrive, the showed time will be incorrectUsing a customized strategy, named **discardLate**, of ordering that discard the obsolete response, we can avoid aforementioned problem.+Every day, [[http://en.wikipedia.org/wiki/Mashup_%28web_application_hybrid%29|mashup]] applications are more present. These applications are created with requests to several servers. Developers have to overcome the issue of creating a wrong page due to an unexpected order of executions of responses. For instance, consider a website that creates web page from two ajax requests. If the second response is executed before the first response, the web page is created incorrectly. Instead, the if the first response is executed before the second response, the web page is created correctlyThe use of the **Fifo** strategy can ensurewhich executes the response in the same order that are sent the requeststhe web page is always created correctly
  
-<code javascript> +When the "activate order" button is clicked, the web page is created correctlyWhen the "deactivate order" button is clicked, the web page could create incorrectly**NOTE:** Please first watch the application without clicking the "activate order" button to appreciate clearly the aforementioned issue
-var discardLate = function(jp) { +
-  if(!this.isLate(jp)){     //is obsolete this join point? +
-    jp.proceed(); +
-    this.updateCr(jp); //notifies that join point was executed. +
-  } +
-+
-</code>+
  
-The implementation follows:  
 <html> <html>
-   <link href="/aspectscript/external/otm/paperExample-SPE/order/style.css" rel="stylesheet" type="text/css"/> +   <link href="/aspectscript/external/otm/paperExample-SPE/style.css" rel="stylesheet" type="text/css"/> 
-  <script type="text/javascript" language="javascript" src="/aspectscript/external/otm/paperExample-SPE/order/lib.js"> </script>+     <script type="text/javascript" language="javascript" src="/aspectscript/external/otm/paperExample-SPE/lib.js"> </script>
    <iframe id="example" src="/aspectscript/external/otm/paperExample-SPE/order/fifo" width="810" height="470"></iframe>        <iframe id="example" src="/aspectscript/external/otm/paperExample-SPE/order/fifo" width="810" height="470"></iframe>    
     <iframe id="code" style="display:none" src="/aspectscript/external/otm/paperExample-SPE/order/fifo/script.js" width="810" height="470"></iframe>     <iframe id="code" style="display:none" src="/aspectscript/external/otm/paperExample-SPE/order/fifo/script.js" width="810" height="470"></iframe>
    <a id="button" class="button" onclick="toggle('code','example')"> <span>Toggle between the code and example </span></a>    <a id="button" class="button" onclick="toggle('code','example')"> <span>Toggle between the code and example </span></a>
 </html> </html>
 +
 +The Fifo strategy is implemented as a TM advice, which is a JavaScript function, that is executed every time a response is retrieved: 
 +
 +<code javascript>
 +var fifo = function(jp){  //jp represents the execution of a response 
 +    if(this.isEarly(jp)){  
 +        this.queue.push(jp); //if the response is retrieved early, then it is stored and not executed
 +    }
 +    else{
 +        jp.proceed();
 +        this.updateCr(jp);
 +        this.queue.executeEarlyJPs(); //check if now other responses can be executed
 +    }
 +};
 +</code>
 +
 +Go back the [[otm/ordering_of_messages|the parent page]] web page.
  • otm/ordering_of_messages/fifo.txt
  • Last modified: 2012/02/06 17:16
  • by aspectscript