com.sapportals.wcm.crt

Class CrtClassLoaderRegistry

java.lang.Object
  extended byjava.lang.ClassLoader
      extended bycom.sapportals.wcm.crt.CrtClassLoaderRegistry

public final class CrtClassLoaderRegistry
extends ClassLoader

Provides a registry for class loaders.

getClassLoader provides a class loader that aggregates all registered class loaders to find and load classes and resources.

Registered class loaders are chained creating one virtual class loader. From the perspective of the JDK, it's all one classloader. Internally, the class loader chain searches like a classpath.

The following code shows an example how to use this registry:

 
     // add your personal class loader (this should be done only once)
     CrtClassLoaderRegistry.addClassLoader( MyPrettyCoolClass.class.getClassLoader() );
     ...
     // load another class with this class loader
     MyOtherClass myOtherInstance = null;
     try {
       Class myOtherClass = CrtClassLoaderRegistry.forName( "com.company.prg.MyOtherClass" );
       myOtherInstance = (MyOtherClass)myOtherClass.newInstance();
     }
     catch( .... x ) {
       ....
     }
  
  
 

Copyright (c) SAP AG 2001-2002


Method Summary
static void addClassLoader(ClassLoader newLoader)
          Register a class loader to the component runtime.
static void addClassLoader(String id, ClassLoader newLoader)
          Register a class loader with an optional id to the component runtime.
static void addClassLoader(String id, ClassLoader newLoader, Set hints)
          Register a class loader with an optional id to the component runtime.
static void addClassLoaderRegistryListener(IClassLoaderRegistryListener l)
           
protected  Class findClass(String name)
           
protected  URL findResource(String name)
           
protected  Enumeration findResources(String name)
           
static Class forName(String className)
          Returns the Class object associated with the class or interface with the given string name, using this registry.
static ClassLoader getClassLoader()
          Returns the component runtime default class loader.
static void removeClassLoaderRegistryListener(IClassLoaderRegistryListener l)
           
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLibrary, 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
 

Method Detail

findClass

protected Class findClass(String name)
                   throws ClassNotFoundException
Throws:
ClassNotFoundException

findResources

protected Enumeration findResources(String name)
                             throws IOException
Throws:
IOException

findResource

protected URL findResource(String name)

addClassLoader

public static void addClassLoader(ClassLoader newLoader)
Register a class loader to the component runtime.

Parameters:
newLoader - The new class loader instance to be added.

addClassLoader

public static void addClassLoader(String id,
                                  ClassLoader newLoader)
Register a class loader with an optional id to the component runtime. If a class loader with the same id was already registered, this method replaces the former loader with the newLoader .

If newLoader is null the class loader with id is removed.

If id is null the class loader is added anonymous and cannot be removed.

Parameters:
id - The optional id of this class loader
newLoader - The new class loader instance to be added.

addClassLoader

public static void addClassLoader(String id,
                                  ClassLoader newLoader,
                                  Set hints)
Register a class loader with an optional id to the component runtime. If a class loader with the same id was already registered, this method replaces the former loader with the newLoader .

This method is meant as a hook for improved class loading speed. Each class loader newLoader registered comes bundled with a set of Java package names that are in this loaders scope.

Parameters:
id - The id of this class loader (if no id is provided, an automatically generated one will be used)
newLoader - The new class loader instance to be added
hints - A set of package names in the loader's scope

getClassLoader

public static ClassLoader getClassLoader()
Returns the component runtime default class loader. This class loader uses all registered class loaders to find and load class files and resources.

Returns:
The chained class loader

forName

public static Class forName(String className)
                     throws ClassNotFoundException
Returns the Class object associated with the class or interface with the given string name, using this registry.

Parameters:
className -
Returns:
Class object
Throws:
ClassNotFoundException

addClassLoaderRegistryListener

public static void addClassLoaderRegistryListener(IClassLoaderRegistryListener l)

removeClassLoaderRegistryListener

public static void removeClassLoaderRegistryListener(IClassLoaderRegistryListener l)


Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.