Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
AspectJ 5 Standard Library
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<table class="wysiwyg-macro" data-macro-name="unmigrated-wiki-markup" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e3VubWlncmF0ZWQtd2lraS1tYXJrdXB9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>Here is a two-file application called HelloWorld - with an Aspect which prints "Tracing" to show that the aspect has been applied. Load into Eclipse with the AJDT and you can see the aspect getting applied. For this example the AjLib jar is extracted into the project also. The src to the example is attached - see the attachments tab. HellowWorld.java: {color:#7f0055}*package*{color} com.AjlibTest; {color:#7f0055}*public*{color} {color:#7f0055}*class*{color} HelloWorld { &nbsp;&nbsp;&nbsp; {color:#7f0055}*public*{color} {color:#7f0055}*static*{color} {color:#7f0055}*void*{color} main(String\[\] args) &nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DummyObject dummyObject = {color:#7f0055}*new*{color} DummyObject(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dummyObject.someMethod(5); &nbsp;&nbsp;&nbsp; } } DummyObject.java: {color:#7f0055}*package*{color} com.AjlibTest; {color:#7f0055}*public*{color} {color:#7f0055}*class*{color} DummyObject { &nbsp;&nbsp;&nbsp; {color:#7f0055}*public*{color} {color:#7f0055}*int*{color} someMethod({color:#7f0055}*int*{color} i) &nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {color:#7f0055}*return*{color} 7; &nbsp;&nbsp;&nbsp; } } TestTraceAspect.aj: {color:#7f0055}*package*{color} com.AjlibTest; {color:#7f0055}*import*{color} org.codehaus.ajlib.util.tracing.ExecutionTracing; {color:#7f0055}*public*{color} {color:#7f0055}*aspect*{color} TestTraceAspect {color:#7f0055}*extends*{color} ExecutionTracing { &nbsp;&nbsp;&nbsp; {color:#7f0055}*public*{color}&nbsp; pointcut scope() :within(DummyObject); &nbsp;&nbsp;&nbsp; before(): scope() &nbsp;&nbsp;&nbsp; { System.out.println("Tracing"); } } With AjLib extracted along with the src into a single eclipse project for the purposes of this example, the resulting directory strructure looks like this: org\codehaus\ajlib\util\tracing\AbstractTracing.aj org\codehaus\ajlib\util\tracing\BasicTraceFormatter.aj org\codehaus\ajlib\util\tracing\CustomTraceable.aj org\codehaus\ajlib\util\tracing\ExecutionTracing.aj org\codehaus\ajlib\util\tracing\ExtensibleTracing.aj org\codehaus\ajlib\util\tracing\GuardTracing.aj org\codehaus\ajlib\util\tracing\Log4jExecutionTracing.aj org\codehaus\ajlib\util\tracing\Log4jTracer.aj org\codehaus\ajlib\util\tracing\NotTraced.aj org\codehaus\ajlib\util\tracing\PerThreadTracer.aj org\codehaus\ajlib\util\tracing\PrintStreamTracer.aj org\codehaus\ajlib\util\tracing\StandardPointcuts.aj org\codehaus\ajlib\util\tracing\TraceFormatter.aj org\codehaus\ajlib\util\tracing\Tracer.aj org\codehaus\ajlib\util\tracing\XMLTraceFormatter.aj com\AjlibTest\TestTraceAspect.aj com\AjlibTest\DummyObject.java com\AjlibTest\HelloWorld.java This is the output produced to the console from running this example: Tracing Tracing Tracing Tracing trace enter: com.AjlibTest.DummyObject() , this: com.AjlibTest.DummyObject@7a84e4 trace exit: com.AjlibTest.DummyObject() Tracing trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this: com.AjlibTest.DummyObject@7a84e4, args: arg 0 = 5 trace exit: int com.AjlibTest.DummyObject.someMethod(int), return = 7</pre></td></tr></table>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced