Source code: com/chaoswg/xtc4y/test/classloaders/LogClassLoaderExample.java
1 //$Header: /cvsroot/xtc4y/xtc4y/src/com/chaoswg/xtc4y/test/classloaders/LogClassLoaderExample.java,v 1.4 2003/09/08 21:11:35 toggm Exp $
2 /******************************************************************************
3 * XTC4y - eXtreme Testing Collection 4 you *
4 * -------------------------------------------------------------------------- *
5 * URL: http://www.chaoswg.com/xtc4y *
6 * Author: Mike Toggweiler (2.dog@gmx.ch) *
7 * *
8 * Last Updated: $Date: 2003/09/08 21:11:35 $, by $Author: toggm $ *
9 * Version: $Revision: 1.4 $ *
10 * -------------------------------------------------------------------------- *
11 * COPYRIGHT: (c) 2003 by Mike Toggweiler *
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 *****************************************************************************/
18 package com.chaoswg.xtc4y.test.classloaders;
19
20 import com.chaoswg.xtc4y.classloaders.LogClassLoader;
21
22 import org.apache.log4j.BasicConfigurator;
23 import org.apache.log4j.ConsoleAppender;
24 import org.apache.log4j.PatternLayout;
25 import org.apache.log4j.Priority;
26 import org.apache.log4j.Logger;
27
28 /**
29 * Show that the LogClassLoader works :-)
30 * @author Mike Toggweiler
31 **/
32 public class LogClassLoaderExample {
33 private String test;
34 private static Logger log = Logger.getLogger(LogClassLoaderExample.class);
35
36 public LogClassLoaderExample() throws Exception {
37 test = "test2";
38 //shows on it self
39 String className = "com.chaoswg.xtc4y.test.classloaders.SimpleClass";
40 Class cl = Class.forName(className);
41
42 Object obj = cl.newInstance();
43 SimpleClass aclass = (SimpleClass)obj;
44
45 aclass.getName();
46 aclass.setName("test");
47 }
48
49 public static void main(String[] argv) throws Exception {
50 //replace this call if you'd like to use another appender
51 BasicConfigurator.configure();
52 /*ConsoleAppender appender =
53 new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN));
54 appender.setThreshold(Priority.DEBUG);
55 BasicConfigurator.configure(appender);*/
56
57 log.info("Staring log class loaders");
58
59 LogClassLoader loader = new LogClassLoader();
60 String className =
61 "com.chaoswg.xtc4y.test.classloaders.LogClassLoaderExample";
62 Class cl = Class.forName(className, true, loader);
63 Object obj = cl.newInstance();
64
65 }
66 }