Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.core
Class OverridingClassLoader

    java.lang.Object
      java.lang.ClassLoader
          org.springframework.core.OverridingClassLoader

Direct Known Subclasses:
  SimpleInstrumentableClassLoader, SimpleThrowawayClassLoader

    public class OverridingClassLoader

extends ClassLoader

`ClassLoader` that does not always delegate to the parent loader, as normal class loaders do. This enables, for example, instrumentation to be forced in the overriding ClassLoader, or a "throwaway" class loading behavior, where selected classes are temporarily loaded in the overriding ClassLoader, in order to load an instrumented version of the class in the parent ClassLoader later on.

Since:
  2.0.1
Author:
  Rod Johnson, Juergen Hoeller

Field Summary
`static String[]` | `DEFAULT_EXCLUDED_PACKAGES` Packages that are excluded by default

Constructor Summary
`OverridingClassLoader(ClassLoader parent)` Create a new OverridingClassLoader for the given class loader.

Method Summary
`void` | `excludeClass(String className)` Add a class name to exclude from overriding.
`void` | `excludePackage(String packageName)` Add a package name to exclude from overriding.
`protected boolean` | `isEligibleForOverriding(String className)` Determine whether the specified class is eligible for overriding by this class loader.
`protected Class` | `loadClass(String name, boolean resolve)`
`protected InputStream` | `openStreamForClass(String name)` Open an InputStream for the specified class.
`protected byte[]` | `transformIfNecessary(String name, byte[] bytes)` Transformation hook to be implemented by subclasses.

Methods inherited from class java.lang.ClassLoader
`clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_EXCLUDED_PACKAGES

    public static final String[] DEFAULT_EXCLUDED_PACKAGES

  Packages that are excluded by default

Constructor Detail

### OverridingClassLoader

    public OverridingClassLoader(ClassLoader parent)

  Create a new OverridingClassLoader for the given class loader.

  Parameters:
    `parent` - the ClassLoader to build an overriding ClassLoader for

Method Detail

### excludePackage

    public void excludePackage(String packageName)

  Add a package name to exclude from overriding.

  Any class whose fully-qualified name starts with the name registered here will be handled by the parent ClassLoader in the usual fashion.

  Parameters:
    `packageName` - the package name to exclude

### excludeClass

    public void excludeClass(String className)

  Add a class name to exclude from overriding.

  Any class name registered here will be handled by the parent ClassLoader in the usual fashion.

  Parameters:
    `className` - the class name to exclude

### loadClass

    protected Class loadClass(String name,
                              boolean resolve)
                       throws ClassNotFoundException

  Overrides:
    `loadClass` in class `ClassLoader`
  Throws:
    `ClassNotFoundException`

### isEligibleForOverriding

    protected boolean isEligibleForOverriding(String className)

  Determine whether the specified class is eligible for overriding by this class loader.

  The default implementation checks against excluded packages and classes.

  Parameters:
    `className` - the class name to check
  Returns:
    whether the specified class is eligible
  See Also:
    `excludePackage(java.lang.String)`, `excludeClass(java.lang.String)`

### openStreamForClass

    protected InputStream openStreamForClass(String name)

  Open an InputStream for the specified class.

  The default implementation loads a standard class file through the parent ClassLoader's `getResourceAsStream` method.

  Parameters:
    `name` - the name of the class
  Returns:
    the InputStream containing the byte code for the specified class

### transformIfNecessary

    protected byte[] transformIfNecessary(String name,
                                          byte[] bytes)

  Transformation hook to be implemented by subclasses.

  The default implementation simply returns the given bytes as-is.

  Parameters:
    `name` - the fully-qualified name of the class being transformed
    `bytes` - the raw bytes of the class
  Returns:
    the transformed bytes (never `null`; same as the input bytes if the transformation produced no changes)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2007 The Spring Framework.