com.ibm.di.loader
Class IDILoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by com.ibm.di.loader.IDILoader

public class IDILoader
extends java.lang.ClassLoader

This class is responsible for loading classes from the jar files that are placed in the jars directory


Constructor Summary
IDILoader()
          Constructor for the IDILoader object
 
Method Summary
 void addFiles(java.lang.String path)
          Add all files in the given path to our internal list of jar files
 void addInstalledComponent(java.lang.String path)
          Locate idi.inf in a jar file, and add it to the sysconfig String
 void addInstalledXMLComponent(java.lang.String path)
          Locate tdi.xml in a jar file, and add it to the sysconfigs Vector
 void addPackages(java.io.File path)
          Add all files in the given path to our internal list of packages
 void cacheJarContents(java.lang.String path)
          Locate all classes in a jar file, and add the names to a local cache.
protected  java.lang.Class<?> findClass(java.lang.String name)
          Finds the specified class
protected  java.lang.String findLibrary(java.lang.String name)
          Returns the absolute path name of a native library.
protected  java.net.URL findResource(java.lang.String name)
          Finds the resource with the given name.
protected  java.util.Enumeration<java.net.URL> findResources(java.lang.String name)
          Returns an Enumeration of URLs representing all the resources with the given name.
static java.util.Vector<java.lang.String> getAllSysConfigs()
          Returns a Vector with all the idi.inf files.
static java.util.List<java.lang.String> getInstalledPackages()
           
static IDILoader getInstance()
           
static java.lang.String getModificationDate(java.lang.String className)
          Returns the time a class was modified
 java.lang.String getPathForClass(java.lang.String clsname)
           
static java.lang.String getSysConfig()
          Returns the accumulated sysConfig ( concatenation of all the idi.inf files ).
 java.lang.Class<?> loadClassFromFile(java.lang.String fileName)
          Load a Class from a .class file Try to avoid duplicate defining of classes by keeping a local cache, which maps from fileName to class.
 java.lang.Class<?> loadClassFromFile(java.lang.String path, java.lang.String className)
          Locate all classes in a jar file, and define the classes found.
static void main(java.lang.String[] args)
          The main program for the IDILoader class
 void run(java.lang.String name, java.lang.String[] args)
          Main processing method for the IDILoader object.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IDILoader

public IDILoader()
Constructor for the IDILoader object

Method Detail

getSysConfig

public static java.lang.String getSysConfig()
Returns the accumulated sysConfig ( concatenation of all the idi.inf files ).

Returns:
The sysConfig value

getAllSysConfigs

public static java.util.Vector<java.lang.String> getAllSysConfigs()
Returns a Vector with all the idi.inf files.

Returns:
Vector containing Strings, each String is the URL for an idi.inf file.
Since:
7.0

getModificationDate

public static java.lang.String getModificationDate(java.lang.String className)
Returns the time a class was modified

Parameters:
className - the name of the class
Returns:
The modification time as a String or null if not found

getInstalledPackages

public static java.util.List<java.lang.String> getInstalledPackages()
Returns:
the list of installed packages

getPathForClass

public java.lang.String getPathForClass(java.lang.String clsname)
Parameters:
clsname - the name of the class which path to get
Returns:
the path from which a class is/will be loaded.

main

public static void main(java.lang.String[] args)
The main program for the IDILoader class

Parameters:
args - The command line arguments

addFiles

public void addFiles(java.lang.String path)
Add all files in the given path to our internal list of jar files

Parameters:
path - The path of the file(s) to be added

addPackages

public void addPackages(java.io.File path)
Add all files in the given path to our internal list of packages

Parameters:
path - The path of the file(s) to be added

addInstalledComponent

public void addInstalledComponent(java.lang.String path)
Locate idi.inf in a jar file, and add it to the sysconfig String

Parameters:
path - The absolute path of the jar file

addInstalledXMLComponent

public void addInstalledXMLComponent(java.lang.String path)
Locate tdi.xml in a jar file, and add it to the sysconfigs Vector

Parameters:
path - The absolute path of the jar file

cacheJarContents

public void cacheJarContents(java.lang.String path)
Locate all classes in a jar file, and add the names to a local cache. This cache contains a mapping from class name to path name.

Parameters:
path - The absolute path of the jar file

run

public void run(java.lang.String name,
                java.lang.String[] args)
Main processing method for the IDILoader object. Build internal structures, load the named class, and call the main method of that class, passing the arguments

Parameters:
name - The class to load and call the main method in. If name == null, only build internal structures
args - Parameters to pass to the main method in the named class

findClass

protected java.lang.Class<?> findClass(java.lang.String name)
                                throws java.lang.ClassNotFoundException
Finds the specified class

Overrides:
findClass in class java.lang.ClassLoader
Parameters:
name - The name of the class
Returns:
The resulting Class object
Throws:
java.lang.ClassNotFoundException - If the class could not be found

findResource

protected java.net.URL findResource(java.lang.String name)
Finds the resource with the given name.

Overrides:
findResource in class java.lang.ClassLoader
Parameters:
name - The resource name
Returns:
A URL object for reading the resource, or null if the resource could not be found

findResources

protected java.util.Enumeration<java.net.URL> findResources(java.lang.String name)
                                                     throws java.io.IOException
Returns an Enumeration of URLs representing all the resources with the given name. Class loader implementations should override this method to specify where to load resources from.

Overrides:
findResources in class java.lang.ClassLoader
Parameters:
name - the resource name
Returns:
an Enumeration of URLs for the resources
Throws:
java.io.IOException - if I/O errors occur

findLibrary

protected java.lang.String findLibrary(java.lang.String name)
Returns the absolute path name of a native library.

Overrides:
findLibrary in class java.lang.ClassLoader
Parameters:
name - The library name
Returns:
The absolute path of the native library

loadClassFromFile

public java.lang.Class<?> loadClassFromFile(java.lang.String fileName)
                                     throws java.lang.Exception
Load a Class from a .class file Try to avoid duplicate defining of classes by keeping a local cache, which maps from fileName to class.

Parameters:
fileName - - The name of the .class file
Returns:
- The loaded class
Throws:
java.lang.Exception - if an internal error occurs.

getInstance

public static IDILoader getInstance()
Returns:
the first instance of IDILoader that was created.
Since:
7.0

loadClassFromFile

public java.lang.Class<?> loadClassFromFile(java.lang.String path,
                                            java.lang.String className)
Locate all classes in a jar file, and define the classes found.

Parameters:
path - The absolute path of the jar file