org.openejb.util
Class SafeToolkit

java.lang.Object
  extended byorg.openejb.util.SafeToolkit

public class SafeToolkit
extends Object


Field Summary
protected static HashMap _tempcodebases
           
protected static HashMap codebases
           
protected static Messages messages
           
 
Constructor Summary
protected SafeToolkit(String systemLocation)
          Creates a new SafeToolkit dedicated to the specified system location.
 
Method Summary
protected static File createTempCopy(String codebase)
           
 Class forName(String className)
          Attempts to find and load the specified class.
 Class forName(String className, String codebase)
          Attempts to find and load the specified class, using the specified codebase.
protected static ClassLoader getClassLoader(String codebase)
          Ensures that a class loader for each code base used in the system is created at most one time.
protected static ClassLoader getCodebaseClassLoader(String codebase)
          Ensures that a class loader for each code base used in the system is created at most one time.
protected static ClassLoader getCodebaseTempClassLoader(String codebase)
          Ensures that a class loader for each code base used in the system is created at most one time.
static ClassLoader getContextClassLoader()
           
 SafeProperties getSafeProperties(Properties props)
          Returns a new SafeProperties instance dedicated to this toolkit.
protected static ClassLoader getTempClassLoader(String codebase)
          Ensures that a class loader for each code base used in the system is created at most one time.
static SafeToolkit getToolkit(String systemLocation)
          Returns an instance of a SafeToolkit dedicated to the specified system location.
static Class loadClass(String className, String codebase)
          Loads the class using the class loader for the specific codebase.
static Class loadClass(String className, String codebase, boolean cache)
           
static Class loadTempClass(String className, String codebase)
          Loads the class using the class loader for the specific codebase.
static Class loadTempClass(String className, String codebase, boolean cache)
           
 Object newInstance(Class clazz)
          Attempts to instaniate the specified class.
 Object newInstance(String className)
          Attempts to find and load the specified class then instaniate it.
 Object newInstance(String className, String codebase)
          Attempts to find and load the specified class then instaniate it.
static void unloadTempCodebase(String codebase)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messages

protected static Messages messages

codebases

protected static HashMap codebases

_tempcodebases

protected static HashMap _tempcodebases
Constructor Detail

SafeToolkit

protected SafeToolkit(String systemLocation)
Creates a new SafeToolkit dedicated to the specified system location.

Method Detail

getToolkit

public static SafeToolkit getToolkit(String systemLocation)
Returns an instance of a SafeToolkit dedicated to the specified system location.


forName

public Class forName(String className)
              throws OpenEJBException
Attempts to find and load the specified class.

Parameters:
className - the name of the class to be loaded.
Throws:
OpenEJBExcption - if the class cannot be found.
OpenEJBException

forName

public Class forName(String className,
                     String codebase)
              throws OpenEJBException
Attempts to find and load the specified class, using the specified codebase. If the codebase is null, the bootstrap classloader is used.

Parameters:
className - the name of the class to be loaded.
codebase - the codebase to load the class from.
Throws:
OpenEJBExcption - if the class cannot be found.
OpenEJBException

newInstance

public Object newInstance(String className)
                   throws OpenEJBException
Attempts to find and load the specified class then instaniate it.

Parameters:
className - the name of the class to be instantiated.
Throws:
OpenEJBException - if the class cannot be found or is not accessible .

newInstance

public Object newInstance(String className,
                          String codebase)
                   throws OpenEJBException
Attempts to find and load the specified class then instaniate it.

Parameters:
className - the name of the class to be instantiated.
Throws:
OpenEJBException - if the class cannot be found or is not accessible .

newInstance

public Object newInstance(Class clazz)
                   throws OpenEJBException
Attempts to instaniate the specified class.

Throws:
OpenEJBException - if the class is not accessible .

getSafeProperties

public SafeProperties getSafeProperties(Properties props)
                                 throws OpenEJBException
Returns a new SafeProperties instance dedicated to this toolkit.

Throws:
OpenEJBException - the properties object passed in is null.

loadClass

public static Class loadClass(String className,
                              String codebase)
                       throws OpenEJBException
Loads the class using the class loader for the specific codebase. If the codebase is null, the bootstrap classloader is used.

Parameters:
className -
codebase -
Returns:
Throws:
ClassNotFoundException
OpenEJBException

loadClass

public static Class loadClass(String className,
                              String codebase,
                              boolean cache)
                       throws OpenEJBException
Throws:
OpenEJBException

getCodebaseClassLoader

protected static ClassLoader getCodebaseClassLoader(String codebase)
                                             throws OpenEJBException
Ensures that a class loader for each code base used in the system is created at most one time. The default bootsrap classloader is used if codebase is null.

Parameters:
codebase -
Returns:
Throws:
OpenEJBException

getClassLoader

protected static ClassLoader getClassLoader(String codebase)
                                     throws OpenEJBException
Ensures that a class loader for each code base used in the system is created at most one time. The default bootsrap classloader is used if codebase is null.

Parameters:
codebase -
Returns:
Throws:
OpenEJBException

getContextClassLoader

public static ClassLoader getContextClassLoader()

loadTempClass

public static Class loadTempClass(String className,
                                  String codebase)
                           throws OpenEJBException
Loads the class using the class loader for the specific codebase. If the codebase is null, the bootstrap classloader is used.

Parameters:
className -
codebase -
Returns:
Throws:
ClassNotFoundException
OpenEJBException

loadTempClass

public static Class loadTempClass(String className,
                                  String codebase,
                                  boolean cache)
                           throws OpenEJBException
Throws:
OpenEJBException

unloadTempCodebase

public static void unloadTempCodebase(String codebase)

getCodebaseTempClassLoader

protected static ClassLoader getCodebaseTempClassLoader(String codebase)
                                                 throws OpenEJBException
Ensures that a class loader for each code base used in the system is created at most one time. The default bootsrap classloader is used if codebase is null.

Parameters:
codebase -
Returns:
Throws:
OpenEJBException

getTempClassLoader

protected static ClassLoader getTempClassLoader(String codebase)
                                         throws OpenEJBException
Ensures that a class loader for each code base used in the system is created at most one time. The default bootsrap classloader is used if codebase is null.

Parameters:
codebase -
Returns:
Throws:
OpenEJBException

createTempCopy

protected static File createTempCopy(String codebase)
                              throws OpenEJBException
Throws:
OpenEJBException


Copyright © 1999-2005 OpenEJB. All Rights Reserved.