KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > emn > info > eaop > IO


1 /* ----------------------------------------------------------------------------
2  * EAOP 1.0, 2002-12-19
3  * (c) 2002 Remi Douence, Mario Sudholt; OBASCO group; EMN/INRIA; France
4  * THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY WARRANTY
5   -------------------------------------------------------------------------- */

6
7 package fr.emn.info.eaop;
8
9 import fr.emn.info.eaop.instrumentation.SelectiveInstrumentation;
10
11 import java.io.*;
12 import java.net.*;
13
14 import recoder.java.declaration.*;
15
16 /**
17  * Class performing I/O, eg for instrumentation configuration.
18  *
19  * This class provides the following services:
20  * <ul>
21  * <li> Initialization of selective instrumentation by dynamically charging
22  * the class <tt>TestInstrumentation</tt>.
23  * <li> Auxiliary methods for warning and error messages.
24  * </ul>
25  *
26  * @author MS
27  * @version 1.0
28  */

29 public class IO {
30     private static SelectiveInstrumentation instrumentationContext = null;
31
32     public static void initializeSelectiveInstrumentation() {
33     if (instrumentationContext == null) {
34         try {
35         ClassLoader JavaDoc cl = IO.class.getClassLoader();
36         Class JavaDoc instrClass = cl.loadClass("TestInstrumentation");
37         instrumentationContext =
38             (SelectiveInstrumentation) instrClass.newInstance();
39         } catch (Exception JavaDoc e) {
40         IO.fail(e, "[setup] Class loading failed");
41         }
42     }
43     }
44     
45     public static SelectiveInstrumentation getInstrumentationContext() {
46     return instrumentationContext;
47     }
48
49     public static void warn(String JavaDoc message) {
50     System.err.println(message);
51     }
52
53     public static void fail(String JavaDoc message) {
54     System.err.println(message);
55     System.exit(1);
56     }
57
58     public static void fail(Exception JavaDoc e, String JavaDoc message) {
59     e.printStackTrace();
60     System.err.println(message);
61     System.exit(1);
62     }
63
64 }
65
Popular Tags