com.altair.hwm.beans.utils
Class HWMClassLoader

java.lang.Object
  extended by com.altair.hwm.beans.utils.HWMClassLoader

public class HWMClassLoader
extends java.lang.Object

Title: HWMClassLoader

Description: This class will be the util class to load the beans. This is required because the bean class may not be in the classpath. It will use the URL Class loader to load it from a jar file.

Company: Altair Engineering, Inc.


Constructor Summary
HWMClassLoader()
          This default constructor will add all the jars to the CP from the system CP and from the lib dir
HWMClassLoader(HWMClassLoader hwmClassLoader)
          This constructor will take a previously created class loader and set it as the parent class loader
 
Method Summary
 void AddJarsFromCP(java.lang.String strClassPath)
          Extracts the jars from the classpath and adds it to the URL class loader
 java.net.URLClassLoader AddToClassPath(java.lang.String strClassPath)
          Adds the given path to the class loader
 java.net.URLClassLoader AddToClassPath(java.lang.String[] arrstrClassPath)
          Adds the given path to the class loader
 java.lang.String GetClasspath()
          Returns the claspath to use while compiling the adapter classes
 com.altair.hwm.beans.utils.HWMURLClassLoader GetURLClassLoader()
          Returns the URL class loader
 java.lang.Class LoadClass(java.lang.String strBeanClassName)
          Loads the given class name by using a url class loader and searching in the jar files set until now
 java.lang.Class LoadClass(java.lang.String strBeanClassName, java.lang.String strFileName)
          Loads the given class name by using a url class loader and searching in the jar file given
 java.lang.Class LoadClassFromFile(java.lang.String strBeanClassName, java.lang.String strFileName)
          Loads the class using the HWMURLClassLoader.
 void PrintURLSHandled()
          Prints out the URLs handled by this URL class loader
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HWMClassLoader

public HWMClassLoader(HWMClassLoader hwmClassLoader)
This constructor will take a previously created class loader and set it as the parent class loader

Parameters:
hwmClassLoader - The parent class loader

HWMClassLoader

public HWMClassLoader()
This default constructor will add all the jars to the CP from the system CP and from the lib dir

Method Detail

AddJarsFromCP

public void AddJarsFromCP(java.lang.String strClassPath)
Extracts the jars from the classpath and adds it to the URL class loader

Parameters:
strClassPath - The system class path

AddToClassPath

public java.net.URLClassLoader AddToClassPath(java.lang.String strClassPath)
                                       throws java.net.MalformedURLException,
                                              java.lang.SecurityException
Adds the given path to the class loader

Parameters:
strClassPath - The jar file name or a class path to a java class
Returns:
URLClassLoader The URL class loader with updated classpath
Throws:
MalformedURLException, - SecurityException
java.net.MalformedURLException
java.lang.SecurityException

AddToClassPath

public java.net.URLClassLoader AddToClassPath(java.lang.String[] arrstrClassPath)
                                       throws java.net.MalformedURLException,
                                              java.lang.SecurityException
Adds the given path to the class loader

Parameters:
arrStrClassPath - The array of jar file names or class paths to a java class
Returns:
URLClassLoader The URL class loader with updated classpath
Throws:
MalformedURLException, - SecurityException
java.net.MalformedURLException
java.lang.SecurityException

LoadClassFromFile

public java.lang.Class LoadClassFromFile(java.lang.String strBeanClassName,
                                         java.lang.String strFileName)
                                  throws java.lang.ClassNotFoundException,
                                         java.net.MalformedURLException,
                                         java.lang.SecurityException
Loads the class using the HWMURLClassLoader. This is needed because we need to read the byte code and define the class.

Parameters:
strBeanClassName - The class name to be loaded
strFileName - The absolute file name of the java class
Returns:
Class The required "Class" object
Throws:
java.lang.ClassNotFoundException - MalformedURLException, SecurityException
java.net.MalformedURLException
java.lang.SecurityException

GetClasspath

public java.lang.String GetClasspath()
Returns the claspath to use while compiling the adapter classes

Returns:
String Classpath

LoadClass

public java.lang.Class LoadClass(java.lang.String strBeanClassName,
                                 java.lang.String strFileName)
                          throws java.lang.ClassNotFoundException,
                                 java.net.MalformedURLException,
                                 java.lang.SecurityException
Loads the given class name by using a url class loader and searching in the jar file given

Parameters:
strBeanClassName - The class name of the bean
strFileName - The jar file name or path where the given class may be found
Returns:
Class The required "Class" object
Throws:
java.lang.ClassNotFoundException - MalformedURLException, SecurityException
java.net.MalformedURLException
java.lang.SecurityException

LoadClass

public java.lang.Class LoadClass(java.lang.String strBeanClassName)
                          throws java.lang.ClassNotFoundException,
                                 java.net.MalformedURLException,
                                 java.lang.SecurityException
Loads the given class name by using a url class loader and searching in the jar files set until now

Parameters:
strBeanClassName - The class name of the bean
Returns:
Class The required "Class" object
Throws:
java.lang.ClassNotFoundException - MalformedURLException, SecurityException
java.net.MalformedURLException
java.lang.SecurityException

PrintURLSHandled

public void PrintURLSHandled()
Prints out the URLs handled by this URL class loader


GetURLClassLoader

public com.altair.hwm.beans.utils.HWMURLClassLoader GetURLClassLoader()
Returns the URL class loader

Returns:
HWMURLClassLoader The URL class loader