basics:intro
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| basics:intro [2007/02/23 10:24] – bdefrain | basics:intro [2021/02/05 13:49] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | [[basics: | ||
| + | [[basics: | ||
| + | [[basics: | ||
| + | [[basics: | ||
| + | [[basics: | ||
| + | [[basics: | ||
| + | [[basics: | ||
| + | [[basics: | ||
| ====== The Basics: Intro ====== | ====== The Basics: Intro ====== | ||
| - | In this exercise, you will use aspects to instrument a dummy class in order to get acquainted with the basic techniques of AspectJ. | + | In this exercise, you will use aspects to instrument a dummy class in order to get acquainted with the basic techniques of AspectJ: pointcuts, advices and inter-type declarations. |
| ===== Set-up ===== | ===== Set-up ===== | ||
| - | - Create a **new AspectJ Project** in Eclipse | + | |
| - | - Create the following | + | - Create |
| + | - **Run** the code. Right-click | ||
| <code aspectj> | <code aspectj> | ||
| public class Application { | public class Application { | ||
| - | public int go = 10; | + | |
| - | + | ||
| - | public void start() { | + | public void start() { |
| - | | + | System.out.println(" |
| - | | + | stop(go); |
| - | } | + | } |
| - | public void stop(int i) { | + | |
| - | | + | System.out.println(" |
| - | } | + | } |
| - | public void exec() throws Exception { | + | |
| - | | + | throw new Exception(" |
| - | } | + | } |
| - | public static void main(String[] | + | public String toString() { |
| - | | + | return " |
| - | | + | } |
| - | | + | |
| - | | + | |
| - | | + | Application t = new Application(); |
| - | } | + | |
| + | | ||
| + | t.stop(25); | ||
| + | try { t.exec(); } | ||
| + | catch(Exception e) { System.out.println(e); | ||
| + | } | ||
| } | } | ||
| </ | </ | ||
| - | - Create | + | |
| + | You should see the following output on the **Console** view (which you can open through **Window** | ||
| + | |||
| + | < | ||
| + | Application go: 10 | ||
| + | Starting | ||
| + | Stopping | ||
| + | Stopping | ||
| + | java.lang.Exception: | ||
| + | </ | ||
| + | |||
| + | <note tip> | ||
| + | In the following | ||
| + | </ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | Start the Basics track at [[basics: | ||
basics/intro.1172222643.txt.gz · Last modified: by bdefrain
