org.apache.derby.impl.services.reflect
Class JarLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by org.apache.derby.impl.services.reflect.JarLoader

final class JarLoader
extends java.security.SecureClassLoader


Field Summary
private  StorageFile installedJar
          Handle to the installed jar file.
private  boolean isStream
          True if the jar can only be accessed using a stream, because the jar is itself in a database jar.
private  java.util.jar.JarFile jar
          When the jar file can be manipulated as a java.util.JarFile this holds the reference to the open jar.
private  java.lang.String[] name
          Two part name for the jar file.
private  UpdateLoader updateLoader
           
private  HeaderPrintWriter vs
           
 
Constructor Summary
JarLoader(UpdateLoader updateLoader, java.lang.String[] name, HeaderPrintWriter vs)
           
 
Method Summary
(package private)  java.lang.Class checkLoaded(java.lang.String className, boolean resolve)
           
(package private)  java.lang.String getJarName()
          Return the SQL name for the installed jar.
private  java.io.InputStream getRawStream(java.io.InputStream in, java.lang.String name)
          Get a stream from a zip file that is itself a stream.
private  java.io.InputStream getRawStream(java.lang.String name)
          Get a stream for a resource directly from a JarFile.
 java.io.InputStream getResourceAsStream(java.lang.String name)
           
private  java.security.cert.Certificate[] getSigners(java.lang.String className, java.util.jar.JarEntry je)
          Validate the security certificates (signers) for the class data.
(package private)  java.io.InputStream getStream(java.lang.String name)
          Get an InputStream for the given resource.
private  java.lang.SecurityException handleException(java.lang.Exception e, java.lang.String className)
          Provide a SecurityManager with information about the class name and the jar file.
(package private)  void initialize()
          Initialize the class loader so it knows if it is loading from a ZipFile or an InputStream
protected  java.lang.Class loadClass(java.lang.String className, boolean resolve)
          Handle all requests to the top-level loader.
private  java.lang.Class loadClassData(java.io.InputStream in, java.lang.String className, java.lang.String jvmClassName, boolean resolve)
          Load the class data when the installed jar is accessible only as an input stream (the jar is itself in a database jar).
private  java.lang.Class loadClassData(java.util.jar.JarEntry e, java.io.InputStream in, java.lang.String className, boolean resolve)
          Load and optionally resolve the class given its JarEntry and an InputStream to the class fiel format.
(package private)  java.lang.Class loadClassData(java.lang.String className, java.lang.String jvmClassName, boolean resolve)
           
private  java.lang.Class loadClassDataFromJar(java.lang.String className, java.lang.String jvmClassName, boolean resolve)
          Load the class data when the installed jar is accessible as a java.util.jarFile.
(package private)  byte[] readData(java.util.jar.JarEntry ze, java.io.InputStream in, java.lang.String className)
          Read the raw data for the class file format into a byte array that can be used for loading the class.
(package private)  void setInvalid()
          Set this loader to be invaid so that it will not resolve any classes or resources.
 java.lang.String toString()
          Return the jar name if toString() is called on this class loader.
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass, getPermissions
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, 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, wait, wait, wait
 

Field Detail

name

private final java.lang.String[] name
Two part name for the jar file.


installedJar

private StorageFile installedJar
Handle to the installed jar file.


jar

private java.util.jar.JarFile jar
When the jar file can be manipulated as a java.util.JarFile this holds the reference to the open jar. When the jar can only be manipulated as an InputStream (because the jar is itself in a database jar) then this will be null.


isStream

private boolean isStream
True if the jar can only be accessed using a stream, because the jar is itself in a database jar. When fals the jar is accessed using the jar field.


updateLoader

private UpdateLoader updateLoader

vs

private HeaderPrintWriter vs
Constructor Detail

JarLoader

JarLoader(UpdateLoader updateLoader,
          java.lang.String[] name,
          HeaderPrintWriter vs)
Method Detail

initialize

void initialize()
Initialize the class loader so it knows if it is loading from a ZipFile or an InputStream


loadClass

protected java.lang.Class loadClass(java.lang.String className,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
Handle all requests to the top-level loader.

Overrides:
loadClass in class java.lang.ClassLoader
Throws:
java.lang.ClassNotFoundException - Class can not be found

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Overrides:
getResourceAsStream in class java.lang.ClassLoader

getJarName

final java.lang.String getJarName()
Return the SQL name for the installed jar. Used for error and informational messages.


loadClassData

java.lang.Class loadClassData(java.lang.String className,
                              java.lang.String jvmClassName,
                              boolean resolve)

getStream

java.io.InputStream getStream(java.lang.String name)
Get an InputStream for the given resource.


loadClassDataFromJar

private java.lang.Class loadClassDataFromJar(java.lang.String className,
                                             java.lang.String jvmClassName,
                                             boolean resolve)
                                      throws java.io.IOException
Load the class data when the installed jar is accessible as a java.util.jarFile.

Throws:
java.io.IOException

loadClassData

private java.lang.Class loadClassData(java.io.InputStream in,
                                      java.lang.String className,
                                      java.lang.String jvmClassName,
                                      boolean resolve)
                               throws java.io.IOException
Load the class data when the installed jar is accessible only as an input stream (the jar is itself in a database jar).

Throws:
java.io.IOException

loadClassData

private java.lang.Class loadClassData(java.util.jar.JarEntry e,
                                      java.io.InputStream in,
                                      java.lang.String className,
                                      boolean resolve)
                               throws java.io.IOException
Load and optionally resolve the class given its JarEntry and an InputStream to the class fiel format. This is common code for when the jar is accessed directly using JarFile or through InputStream.

Throws:
java.io.IOException

checkLoaded

java.lang.Class checkLoaded(java.lang.String className,
                            boolean resolve)

setInvalid

void setInvalid()
Set this loader to be invaid so that it will not resolve any classes or resources.


getRawStream

private java.io.InputStream getRawStream(java.lang.String name)
Get a stream for a resource directly from a JarFile. In this case we can safely return the stream directly. It's a new stream set up by the zip code to read just the contents of this entry.


getRawStream

private java.io.InputStream getRawStream(java.io.InputStream in,
                                         java.lang.String name)
Get a stream from a zip file that is itself a stream. We copy to the contents to a byte array and return a stream around that to the caller. Though a copy is involved it has the benefit of:


readData

byte[] readData(java.util.jar.JarEntry ze,
                java.io.InputStream in,
                java.lang.String className)
          throws java.io.IOException
Read the raw data for the class file format into a byte array that can be used for loading the class. If this is a signed class and it has been compromised then a SecurityException will be thrown.

Throws:
java.io.IOException

getSigners

private java.security.cert.Certificate[] getSigners(java.lang.String className,
                                                    java.util.jar.JarEntry je)
                                             throws java.io.IOException
Validate the security certificates (signers) for the class data.

Throws:
java.io.IOException

handleException

private java.lang.SecurityException handleException(java.lang.Exception e,
                                                    java.lang.String className)
Provide a SecurityManager with information about the class name and the jar file.


toString

public java.lang.String toString()
Return the jar name if toString() is called on this class loader.

Overrides:
toString in class java.lang.Object

Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.