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/06/27 05:25]
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 a 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 incorrect. Using a customized strategy, named **discardLate**, of ordering that discard the obsolete response, we can avoid aforementioned problem.+====== The FIFO strategy ======
  
-<code javascript> +A mashup application is created from the combination of information retrieved from different servers, //e.g.// Housing MapsProgrammers have to overcome the issue of creating an incorrect Web page due to an arbitrary (and unexpectedorder of server responsesFor instance, consider a Web page that is created with two Ajax requests. If the second server response is processed before the first server response, the Web page is created incorrectly. A **FIFO** strategy, which processes the server responses in the same order as the Ajax requests are sent, ensures that the Web page is always created correctly
-var discardLate = function(jp) { + 
-  if(!this.isLate(jp)){     //is obsolete this join point? +When the "activate order" button is clicked, the web page is created correctly. When 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. 
-    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 piece of advice, which is a JavaScript function, that is executed every time a server response is received: 
 +
 +<code javascript>
 +var FIFO = function(jp){
 +  var request = jp . target ;
 +  if (this.idServerRespExpected != request.idServerResp){
 +    this.jpsQueue.push(jp) ;
 +  }
 +  else{
 +    jp.proceed() ;
 +    this.idServerRespExpected = request.idServerResp + 1;
 +   // executing jp proceeds that can be executed now
 +   this.idServerRespExpected =this.jpsQueue.execRecEarlyJPs( this . idServerRespExpected ) ;
 +  }
 +}
 +</code>
 +
 +Go back the [[otm/ordering_of_messages|the parent Web page]].
  • otm/ordering_of_messages/fifo.txt
  • Last modified: 2012/02/06 17:16
  • by aspectscript