|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.ClassLoader | +--java.security.SecureClassLoader | +--java.net.URLClassLoader | +--org.openejb.util.proxy.ProxyClassLoader
ClassLoader for dynamically generating byte-code and loading classes.
Inner Class Summary | |
(package private) static class |
ProxyClassLoader.ClassByteCode
Wrapper for class to byte-code mappings. |
class |
ProxyClassLoader.ProxyByteCodeStreamHandler
|
class |
ProxyClassLoader.ProxyByteCodeURLConnection
|
Inner classes inherited from class java.lang.ClassLoader |
java.lang.ClassLoader.NativeLibrary |
Fields inherited from class java.lang.ClassLoader |
nocerts |
Constructor Summary | |
ProxyClassLoader()
|
Method Summary | |
void |
addURL(java.io.File directory)
|
protected static void |
cacheByteCode(java.lang.Class clazz,
byte[] byteCode)
|
java.lang.Class |
defineClass(java.lang.String name,
byte[] byteCode)
Converts an array of bytes into an instance of class Class . |
java.net.URL |
findResource(java.lang.String name)
Finds the resource with the given name. |
protected static byte[] |
getCachedByteCode(java.lang.Class clazz)
|
protected static byte[] |
getCachedByteCode(java.lang.String className)
Find the byte-code for the specified class. |
protected java.lang.Class |
loadClass(java.lang.String name,
boolean resolve)
This method should not need to be overridden by subclasses. |
Methods inherited from class java.net.URLClassLoader |
addURL, definePackage, findClass, findResources, getPermissions, getURLs, newInstance, newInstance |
Methods inherited from class java.security.SecureClassLoader |
|
Methods inherited from class java.lang.ClassLoader |
addClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findNative, findSystemClass, getBootstrapClassPath, getCallerClassLoader, getGetClassLoaderPerm, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, isAncestor, loadClass, loadLibrary, resolveClass, setSigners |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ProxyClassLoader()
Method Detail |
public java.lang.Class defineClass(java.lang.String name, byte[] byteCode) throws java.lang.ClassFormatError
Class
.
Before the Class can be used it must be resolved.
This method assigns a default ProtectionDomain
to
the newly defined class. The ProtectionDomain
contains the set of permissions granted when
a call to Policy.getPolicy().getPermissions()
is made with
a Codesource of null,null
. The default domain is
created on the first invocation of defineClass
, and
re-used on subsequent calls.
To assign a specific ProtectionDomain
to the class,
use the defineClass
method that takes a
ProtectionDomain
as one of its arguments.
name
- the expected name of the class, or null
if not known, using '.' and not '/' as the separator
and without a trailing ".class" suffix.b
- the bytes that make up the class data. The bytes in
positions off
through off+len-1
should have the format of a valid class file as defined
by the
Java
Virtual Machine Specification.Class
object that was created from the
specified class datajava.lang.ClassFormatError
- if the data did not contain a valid classjava.lang.SecurityException
- if an attempt is made to add this class
to a package that contains classes that were signed by
a different set of certificates then this class, which
is unsigned.ClassLoader.loadClass(java.lang.String, boolean)
,
ClassLoader.resolveClass(java.lang.Class)
,
ProtectionDomain
,
java.security.Policy
,
CodeSource
,
SecureClassLoader
public java.net.URL findResource(java.lang.String name)
ClassLoader.defineClass(...)
. Calling
Class.getResourceAsStream(proxyClassName) will return null because
there is no .class definition in the file system. In this situation,
it is the responsibility of the class loader (ProxyClassLoader) that
loaded the class definition to implement ClassLoader.findResource(...)
and return a URL that can be used to retreive the proxy class byte-code.findResource
in class java.net.URLClassLoader
name
- the resource namenull
if the resource could not be foundjava.lang.ClassLoader.defineClass
,
java.lang.ClassLoader.getSystemResourceAsStream()
,
ProxyClassLoader
,
org.openejb.util.proxy.ProxyClassLoader.findResource
public void addURL(java.io.File directory) throws java.net.MalformedURLException
protected java.lang.Class loadClass(java.lang.String name, boolean resolve) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
name
- resolve
- java.lang.ClassNotFoundException
- protected static byte[] getCachedByteCode(java.lang.String className)
ClassLoader.defineClass(...)
. Calling
Class.getResourceAsStream(proxyClassName) will return null because
there is no .class definition in the file system. In this situation,
it is the responsibility of the class loader (ProxyClassLoader) that
loaded the class definition to implement ClassLoader.findResource(...)
and return a URL that can be used to retreive the proxy class byte-code.className
- java.lang.ClassLoader.defineClass
,
java.lang.ClassLoader.getSystemResourceAsStream()
,
ProxyClassLoader
,
org.openejb.util.proxy.ProxyClassLoader.findResource
protected static byte[] getCachedByteCode(java.lang.Class clazz)
protected static void cacheByteCode(java.lang.Class clazz, byte[] byteCode)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |