KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > logging > ArgLoggingTarget


1 /**************************************************************************************
2  * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
3  * http://aspectwerkz.codehaus.org *
4  * ---------------------------------------------------------------------------------- *
5  * The software in this package is published under the terms of the LGPL license *
6  * a copy of which has been included with this distribution in the license.txt file. *
7  **************************************************************************************/

8 package examples.logging;
9
10 /**
11  * @author <a HREF="mailto:alex@gnilux.com">Alexandre Vasseur </a>
12  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
13  */

14 public class ArgLoggingTarget {
15
16     private int m_counter1;
17
18     private int m_counter2;
19
20     public int getCounter() {
21         System.out.println("getCounter before");
22         return m_counter1;
23     }
24
25     public void increment() {
26         System.out.println("increment before = " + m_counter2);
27         m_counter2 = m_counter2 + 1;
28         System.out.println("increment after = " + m_counter2);
29     }
30
31     /**
32      * @Annotation
33      */

34     public int toLog_1(int typeMatch, String JavaDoc s, int i) {
35         System.out.println("toLog_1");
36         toLog_2(0, "b", 2);
37         return 0;
38     }
39
40     public java.lang.String JavaDoc[] toLog_2(int typeMatch, String JavaDoc s, int i) {
41         System.out.println("toLog_2");
42         int result = toLog_3(0, new String JavaDoc[]{"c"});
43         return null;
44     }
45
46     private static int toLog_3(int typeMatch, String JavaDoc[] sarr) {
47         System.out.println("toLog_2");
48         return -1;
49     }
50
51     public static void main(String JavaDoc args[]) throws Throwable JavaDoc {
52         new Runner().run();
53     }
54 }
55
56 class Runner {
57
58     public void run() {
59         ArgLoggingTarget target = new ArgLoggingTarget();
60         doRun(target);
61     }
62
63     public void doRun(ArgLoggingTarget target) {
64         target.toLog_1(0, "a", 1);
65         int counter1 = target.getCounter();
66         System.out.println("getCounter after = " + counter1);
67         target.increment();
68     }
69 }
Popular Tags