01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Core License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: ClassManager.java,v 1.3 2002/06/08 00:49:38 mediumnet Exp $
08:
09: package org.ozoneDB.core;
10:
11: import java.io.*;
12: import org.ozoneDB.*;
13: import org.ozoneDB.DxLib.*;
14: import org.ozoneDB.util.*;
15:
16: /**
17: * @author <a href="http://www.softwarebuero.de/">SMB</a>
18: * @version $Revision: 1.3 $Date: 2002/06/08 00:49:38 $
19: */
20: public final class ClassManager extends ServerComponent {
21:
22: protected ClassLoader classLoader;
23:
24: public ClassManager(Env _env) {
25: super (_env);
26: }
27:
28: public void startup() throws Exception {
29: env.logWriter.newEntry(this , "startup...", LogWriter.INFO);
30: dropClasses();
31: }
32:
33: public void shutdown() throws Exception {
34: env.logWriter.newEntry(this , "shutdown...", LogWriter.INFO);
35: }
36:
37: public void save() throws Exception {
38: }
39:
40: public Class classForName(String name) throws ClassNotFoundExc {
41: if (false && env.logWriter.hasTarget(LogWriter.DEBUG3)) {
42: env.logWriter.newEntry(this , "classForName(): " + name,
43: LogWriter.DEBUG3);
44: }
45: try {
46: // as long as the OzoneClassLoader does not work as expected and does
47: // not allow to drop classes we can directly use the context loader
48: // of the thread to avoid problems in managed environments like
49: // servlets
50: Class cl;
51:
52: // If we do not use OzoneClassLoader, we have to care for primitive types ourselves
53: cl = OzoneClassLoader.primitiveType(name);
54:
55: if (cl == null) {
56: cl = Thread.currentThread().getContextClassLoader()
57: .loadClass(name);
58: }
59:
60: // Class cl = classLoader.loadClass( name );
61:
62: if (false && env.logWriter.hasTarget(LogWriter.DEBUG3)) {
63: env.logWriter.newEntry(this , " class: "
64: + cl.getName() + ", " + cl.hashCode(),
65: LogWriter.DEBUG3);
66: }
67: return cl;
68: } catch (ClassNotFoundException e) {
69: throw new ClassNotFoundExc(e.getMessage());
70: }
71: }
72:
73: public void dropClasses() throws Exception {
74: env.logWriter.newEntry(this , "dropClasses()", LogWriter.DEBUG3);
75: classLoader = new OzoneClassLoader();
76: }
77: }
|