KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > testmodel > Xxx


1 /*****************************************************************************
2  * Copyright (C) NanoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  *****************************************************************************/

9 package org.nanocontainer.testmodel;
10
11 import junit.framework.Assert;
12 import org.picocontainer.Disposable;
13 import org.picocontainer.Startable;
14
15 /**
16  * An abstract component and three dependancies used for testing.
17  */

18 public abstract class Xxx implements Startable, Disposable {
19
20     public static String JavaDoc componentRecorder = "";
21
22     public static void reset() {
23         componentRecorder = "";
24     }
25
26     public void start() {
27         componentRecorder += "<" + code();
28     }
29
30     public void stop() {
31         componentRecorder += code() + ">";
32     }
33
34     public void dispose() {
35         componentRecorder += "!" + code();
36     }
37
38     private String JavaDoc code() {
39         String JavaDoc name = getClass().getName();
40         return name.substring(name.indexOf('$') + 1, name.length());
41     }
42
43     public static class A extends Xxx {
44     }
45
46     public static class B extends Xxx {
47         A a;
48
49         public B(A a) {
50             Assert.assertNotNull(a);
51             this.a = a;
52         }
53
54         public A getA() {
55             return a;
56         }
57     }
58
59     public static class C extends Xxx {
60     }
61 }
62
Popular Tags