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

## org.apache.tomcat.util.compat
Class SimpleClassLoader

    java.lang.Object
      java.lang.ClassLoader
          org.apache.tomcat.util.compat.SimpleClassLoader

public class SimpleClassLoader
extends java.lang.ClassLoader

This is a JDK1.1 equivalent of URLClassLoader. It have no dependency on tomcat or any other api - just standard java. Based on AdaptiveClassLoader from JServ1, with the dependency check and reloading features removed ( and moved to an external component) This is based on the fact that class loading and dependency checking can be separated and we want to support multiple forms of class loaders. The interface also changed to match URLClassLoader. This class should be used _only_ with JDK1.1, for JDK1.2 you should use a class loader that is aware of Permissions and the new rules ( sealing, etc ) This class loader respects the standard order defined in the ClassLoader documentation - for a different order you can plug in a different class loader ( in the configurations ). Since this class loader will be visible to applications we need to prevent exploits - we'll minimize the public method usage. The class path can be set only when the object is constructed.

Field Summary
`protected java.lang.ClassLoader` | `parent` A parent class loader for delegation of finding a class definition.
`protected java.lang.String[]` | `reserved` Reserved names - this class loader will not allow creation of classes that start with one of those strings.
`protected java.net.URL[]` | `urls` The classpath which this classloader searches for class definitions.

Constructor Summary
`SimpleClassLoader(java.net.URL[] urls)`
`SimpleClassLoader(java.net.URL[] urls, java.lang.ClassLoader parent)`
`SimpleClassLoader(java.net.URL[] urls, java.lang.ClassLoader parent, java.lang.String[] reserved)` This is the prefered constructor to be used with this class loader

Method Summary
`java.lang.ClassLoader` | `getParentLoader()` We can't declare a method "getParent" since it'll not compile in JDK1.2 - the method is final.
`java.net.URL` | `getResource(java.lang.String name)` Find a resource with a given name.
`java.io.InputStream` | `getResourceAsStream(java.lang.String name)` Get an InputStream on a given resource.
`java.net.URL[]` | `getURLs()`
`protected java.lang.Class` | `loadClass(java.lang.String name, boolean resolve)` Resolves the specified name to a Class.

Methods inherited from class java.lang.ClassLoader
`clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, 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

### urls

    protected java.net.URL[] urls

  The classpath which this classloader searches for class definitions. Each element of the vector should be either a directory, a .zip file, or a .jar file.

  It may be empty when only system classes are controlled.

### parent

    protected java.lang.ClassLoader parent

  A parent class loader for delegation of finding a class definition. JDK 1.2 contains parent class loaders as part of java.lang.ClassLoader, the parent being passed to a constructor, and retreived with getParent() method. For JDK 1.1 compatibility, we'll duplicate the 1.2 private member var.

### reserved

    protected java.lang.String[] reserved

  Reserved names - this class loader will not allow creation of classes that start with one of those strings.

Constructor Detail

### SimpleClassLoader

    public SimpleClassLoader(java.net.URL[] urls)

### SimpleClassLoader

    public SimpleClassLoader(java.net.URL[] urls,
                             java.lang.ClassLoader parent)

### SimpleClassLoader

    public SimpleClassLoader(java.net.URL[] urls,
                             java.lang.ClassLoader parent,
                             java.lang.String[] reserved)

  This is the prefered constructor to be used with this class loader

Method Detail

### getParentLoader

    public java.lang.ClassLoader getParentLoader()

  We can't declare a method "getParent" since it'll not compile in JDK1.2 - the method is final. But we don't have to - this will be used via JdkCompat

### loadClass

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

  Resolves the specified name to a Class. The method loadClass() is called by the virtual machine. As an abstract method, loadClass() must be defined in a subclass of ClassLoader.

  Parameters:
    `name` - the name of the desired Class.
    `resolve` - true if the Class needs to be resolved; false if the virtual machine just wants to determine whether the class exists or not
  Returns:
    the resulting Class.
  Throws:
    `java.lang.ClassNotFoundException` - if the class loader cannot find a the requested class.

### getResource

    public java.net.URL getResource(java.lang.String name)

  Find a resource with a given name. The return is a URL to the resource. Doing a getContent() on the URL may return an Image, an AudioClip,or an InputStream.

  Parameters:
    `name` - the name of the resource, to be used as is.
  Returns:
    an URL on the resource, or null if not found.

### getResourceAsStream

    public java.io.InputStream getResourceAsStream(java.lang.String name)

  Get an InputStream on a given resource. Will return null if no resource with this name is found.

  The JServClassLoader translate the resource's name to a file or a zip entry. It looks for the resource in all its repository entry.

  Parameters:
    `name` - the name of the resource, to be used as is.
  Returns:
    an InputStream on the resource, or null if not found.
  See Also:
    `Class.getResourceAsStream(String)`

### getURLs

    public java.net.URL[] getURLs()

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

Copyright © 2001 Apache Software Foundation. All Rights Reserved.