|
WebObjects 5.2 | |||||||||
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 | +--com.webobjects.eoapplication.EOURLClassLoader
EOURLClassLoader is an URLClassLoader that can be used to add classes to your program at runtime. Provided a url or set of urls to search through, and a class to load, the class loader will look for the class in the set of classes available at the URLs it knows of. Once a matching class is found the class is registered with the WebObjects frameworks so that other classes in the WebObjects runtime will know about it.
This is useful specifically for Java Client applications so that classes needed by the client application can be downloaded on demand. EOApplication uses the shared class loader if the bindings of the WOJavaClientApplet that application connects to specifies classes for the client to download. Developers can also use this class to add classes to the running Java Client application.
Example: First, add the NSArray of url(s) for the class loader to search through
using EOURLClassLoader.sharedURLClassLoader().addURLs()
. Then call
EOURLClassLoader.sharedURLClassLoader().loadClass()
to load an individual
class, or EOURLClassLoader.sharedURLClassLoader().loadClasses()
to load an array of classes. The classes are then registered with the WebObjects
frameworks using the static registerClass
method.
To use your custom subclass of EOURLClassLoader in an EOApplication,
make sure that you set your class loader as the default class loader
with setSharedURLClassLoader
before EOApplication's startApplication
method is invoked (write your own main function which prepares the class loader
and then jumps into EOApplication's main function).
URLClassLoader
Constructor Summary | |
EOURLClassLoader(URL[] urls)
Creates a new EOURLClassLoader object initialized to search at the URLs urls for classes. |
|
EOURLClassLoader(URL[] urls,
ClassLoader parentClassLoader)
Creates a new EOURLClassLoader object initialized to search at the URLs urls for classes. |
|
EOURLClassLoader(URL[] urls,
ClassLoader parentClassLoader,
URLStreamHandlerFactory streamHandlerFactory)
Creates a new EOURLClassLoader object initialized to search at the URLs urls for classes. |
Method Summary | |
void |
addURLs(NSArray urls)
Adds the URLs specified by String in the array urls to the list
of urls for the class loader to search when trying to load a class. |
NSArray |
allLoadedClasses()
Returns all of the class objects that have been loaded through the class loader instance. |
protected Class |
loadClass(String className,
boolean resolveClass)
Tries to load the class named className and registers it with the
WebObjects frameworks. |
void |
loadClasses(NSArray classNames)
Tries to load the classes specified by name in the array classNames
and registers them with the WebObjects frameworks. |
static void |
registerClass(Class objectClass)
Registers a class loaded with an EOURLClassLoader with the WebObjects frameworks. |
static void |
setSharedURLClassLoader(EOURLClassLoader classLoader)
Sets the class loader object to use as the shared EOURLClassLoader class loader. |
static EOURLClassLoader |
sharedURLClassLoader()
Returns the shared EOURLClassLoader class loader instance. |
Methods inherited from class java.net.URLClassLoader |
addURL, definePackage, findClass, findResource, findResources, getPermissions, getURLs, newInstance, newInstance |
Methods inherited from class java.security.SecureClassLoader |
defineClass |
Methods inherited from class java.lang.ClassLoader |
defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setSigners |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EOURLClassLoader(URL[] urls)
urls
for classes. The parent class loader will be
the default parent class loader.urls
- array of URL objectspublic EOURLClassLoader(URL[] urls, ClassLoader parentClassLoader)
urls
for classes. The parent class loader will be
parentClassLoader
.urls
- array of URL objectsparentClassLoader
- the parent class loader for the new EOURLClassLoaderpublic EOURLClassLoader(URL[] urls, ClassLoader parentClassLoader, URLStreamHandlerFactory streamHandlerFactory)
urls
for classes. The parent class loader will be
parentClassLoader
and the stream handler factory will
be streamHandlerFactory
.urls
- array of URL objectsparentClassLoader
- the parent class loader for the new EOURLClassLoaderstreamHandlerFactory
- the stream handler factory for the new EOURLClassLoaderMethod Detail |
public void addURLs(NSArray urls) throws MalformedURLException
urls
to the list
of urls for the class loader to search when trying to load a class.urls
- array of String's representing URLspublic NSArray allLoadedClasses()
protected Class loadClass(String className, boolean resolveClass) throws ClassNotFoundException
className
and registers it with the
WebObjects frameworks. If the class loader (or one of its parent class loaders)
cannot find the class, this method throws a ClassNotFoundException
.loadClass
in class ClassLoader
className
- the fully specified name of the class to loadresolveClass
- true
if the class loader will try to resolve the
class immediately; false
otherwisepublic void loadClasses(NSArray classNames) throws ClassNotFoundException
classNames
and registers them with the WebObjects frameworks. If the class loader (or one of
its parent class loaders) cannot find one of the classes, this method throws a
ClassNotFoundException
.classNames
- array of fully specified class names to loadpublic static void registerClass(Class objectClass)
objectClass
- Class object to registerpublic static void setSharedURLClassLoader(EOURLClassLoader classLoader)
classLoader
- the EOURLClassLoader (or subclass) instance to use as the shared class loaderpublic static EOURLClassLoader sharedURLClassLoader()
|
Last updated Fri Feb 21 13:15:00 PST 2003. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |