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/07 11:31]
aspectscript
otm:ordering_of_messages:fifo [2011/01/24 18:59]
aspectscript
Line 1: Line 1:
-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 wrong page due to unexpected order of executions of responses. For instance, consider a website that creates a web page from two 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 correctly.+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 wrong page due to an unexpected order of executions of responses. For instance, consider a website that creates a 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 correctly. The use of the **Fifo** strategy can ensure, which executes the response in the same order that are sent the requests, the web page is always created correctly. 
  
-When the **activate order** is clicked, the web page always is created correctly. When the **deactive order** is clicked +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. 
  
-<code javascript> 
-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