Both sides previous revision
Previous revision
Next revision
|
Previous revision
|
examples:example2 [2009/10/26 19:06] aspectscript |
examples:example2 [2009/11/06 20:42] (current) aspectscript |
| |
While the aspect definition in the [[examples/example1|previous example]] appropriately modularizes the new feature, it is a typical example of a //stateful// aspect, implemented with book-keeping code (the ''times'' variable in the pointcut). Recognizing this fact, we now present an alternative implementation that uses a general-purpose ''trace'' | While the aspect definition in the [[examples/example1|previous example]] appropriately modularizes the new feature, it is a typical example of a //stateful// aspect, implemented with book-keeping code (the ''times'' variable in the pointcut). Recognizing this fact, we now present an alternative implementation that uses a general-purpose ''trace'' |
PCD for matching //sequences// of events. | PCD for matching //sequences of events//. |
| \\ |
The implementation follows: | |
| |
<html> | <html> |
<link href="/aspectscript/external/aspectscript/paperExamples/style.css" rel="stylesheet" type="text/css"/> | <link href="/aspectscript/external/aspectscript/paperExamples/style.css" rel="stylesheet" type="text/css"/> |
<script type="text/javascript" language="javascript" src="/aspectscript/external/aspectscript/paperExamples/lib.js"> </script> | <script type="text/javascript" language="javascript" src="/aspectscript/external/aspectscript/paperExamples/lib.js"> </script> |
| |
<iframe id="example1" src="/aspectscript/external/aspectscript/paperExamples/example2-1" width="810" height="470"></iframe> | <iframe id="example1" src="/aspectscript/external/aspectscript/paperExamples/example2-1" width="810" height="470"></iframe> |
<iframe id="code1" style="display:none" src="/aspectscript/external/aspectscript/paperExamples/example2-1/script.js" width="810" height="470"></iframe> | <iframe id="code1" style="display:none" src="/aspectscript/external/aspectscript/paperExamples/example2-1/script.js" width="810" height="470"></iframe> |
<a id="button" class="button" onclick="toggle('code1','example1')"> <span>See the code or example </span></a> | <a id="button" class="button" onclick="toggle('code1','example1')"> <span>Toggle between the code and example </span></a> |
</html> | </html> |
| |
\\ AspectScript permits to expose context information to either the advice or other pointcuts, a pointcut can take as optional parameter an environment, and define new bindings in it. Using this environments, we can match a sequence of //removeTag// invocations happening in a 10 seconds interval. | \\ AspectScript permits to expose context information to either the advice or other pointcuts, a pointcut can take as optional parameter an environment, and define new bindings in it. Using this environment, we can match a sequence of //removeTag// invocations happening in a 10 seconds interval. The following window uses the "trace" PCD with an environment: |
| |
The implementation follows: | <html> |
<html> | |
<link href="/aspectscript/external/aspectscript/paperExamples/style.css" rel="stylesheet" type="text/css"/> | |
<script type="text/javascript" language="javascript" src="/aspectscript/external/aspectscript/paperExamples/lib.js"> </script> | |
<iframe id="example2" src="/aspectscript/external/aspectscript/paperExamples/example2-2" width="810" height="470"></iframe> | <iframe id="example2" src="/aspectscript/external/aspectscript/paperExamples/example2-2" width="810" height="470"></iframe> |
<iframe id="code2" style="display:none" src="/aspectscript/external/aspectscript/paperExamples/example2-2/script.js" width="810" height="470"></iframe> | <iframe id="code2" style="display:none" src="/aspectscript/external/aspectscript/paperExamples/example2-2/script.js" width="810" height="470"></iframe> |
<a id="button" class="button" onclick="toggle('code2','example2')"> <span>See the code or example </span></a> | <a id="button" class="button" onclick="toggle('code2','example2')"> <span>Toggle between the code and example </span></a> |
</html> | </html> |
| |
| |
| |