org.jibx.binding.classes
Class ClassCache

java.lang.Object
  extended by org.jibx.binding.classes.ClassCache

public class ClassCache
extends java.lang.Object

Cache for class files being modified. Handles loading and saving of class files. Classes are loaded directly from the file system paths supplied on initialization in preference to the system class path.

Version:
1.0
Author:
Dennis M. Sosnoski

Field Summary
private  java.util.HashMap m_classMap
          Map from class names to actual class information.
private  java.lang.String[] m_paths
          Paths to be searched for class files.
private  java.io.File[] m_roots
          Root directories corresponding to paths.
private static ClassCache s_instance
          Singleton instance of class (created when paths set)
 
Constructor Summary
private ClassCache(java.lang.String[] paths)
          Constructor.
 
Method Summary
(package private) static void addClassFile(ClassFile cf)
          Add created class information to cache.
static ClassFile getClassFile(java.lang.String name)
          Get class information.
private  ClassFile getClassFileImpl(java.lang.String name)
          Get class information.
static void setPaths(java.lang.String[] paths)
          Set class paths to be searched.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_instance

private static ClassCache s_instance
Singleton instance of class (created when paths set)


m_paths

private java.lang.String[] m_paths
Paths to be searched for class files.


m_roots

private java.io.File[] m_roots
Root directories corresponding to paths.


m_classMap

private java.util.HashMap m_classMap
Map from class names to actual class information.

Constructor Detail

ClassCache

private ClassCache(java.lang.String[] paths)
Constructor. Discards jar file paths and normalizes all other paths (except the empty path) to end with the system path separator character.

Parameters:
paths - ordered set of paths to be searched for class files
Method Detail

getClassFileImpl

private ClassFile getClassFileImpl(java.lang.String name)
                            throws JiBXException
Get class information. Looks up the class in cache, and if not already present tries to find it based on the class file search path list. If the class file is found it is loaded and this method calls itself recursively to load the whole hierarchy of superclasses.

Parameters:
name - fully-qualified name of class to be found
Returns:
class information, or null if class not found
Throws:
JiBXException - on any error accessing class file

getClassFile

public static ClassFile getClassFile(java.lang.String name)
                              throws JiBXException
Get class information. Looks up the class in cache, and if not already present tries to find it based on the class file search path list. If the class file is found it is loaded along with all superclasses.

Parameters:
name - fully-qualified name of class to be found
Returns:
class information, or null if class not found
Throws:
JiBXException - on any error accessing class file

addClassFile

static void addClassFile(ClassFile cf)
Add created class information to cache.

Parameters:
cf - information for class to be added

setPaths

public static void setPaths(java.lang.String[] paths)
Set class paths to be searched. Discards jar file paths and normalizes all other paths (except the empty path) to end with the system path separator character.

Parameters:
paths - ordered set of paths to be searched for class files


Project Web Site