org.iids.aos.agentserver.java
Class JavaAgentRunner.MyURLClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.iids.aos.agentserver.java.JavaAgentRunner.MyURLClassLoader
Enclosing class:
JavaAgentRunner

Deprecated.

@Deprecated
public static class JavaAgentRunner.MyURLClassLoader
extends java.net.URLClassLoader

Our own version of URLClassLoader with one extra function: public void close(); This will close all underlying JarFiles, which the original URLClassLoader keeps open, so you could run out of file descriptors when running many agents, and Windows will not delete open files. Note: Java JDK7 will extend URLClassLoader with its own close() so this class will not be necessary then. http://blogs.sun.com/CoreJavaTechTips/entry/closing_a_urlclassloader See: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5041014 Where this code originates. Note: Closing the file may cause IllegalStateExceptions: zipfile closed when the URLClassLoader tries to reload classes. It seems that the class may not be in this jarfile, but the fact it throws an exception causes the classloading algorithm to fail. So we need to catch this exception and deal with it. We can either reopen the original jar-file (if it still exists) or open another (empty) jarfile.


Constructor Summary
JavaAgentRunner.MyURLClassLoader(java.net.URL[] urls)
          Deprecated.  
JavaAgentRunner.MyURLClassLoader(java.net.URL[] urls, java.lang.ClassLoader parent)
          Deprecated.  
JavaAgentRunner.MyURLClassLoader(java.net.URL[] urls, java.lang.ClassLoader parent, java.net.URLStreamHandlerFactory factory)
          Deprecated.  
 
Method Summary
 void close()
          Deprecated. Close the underlying zipfile.
 java.net.URL findResource(java.lang.String name)
          Deprecated. Overriding the findResource mechanism.
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaAgentRunner.MyURLClassLoader

public JavaAgentRunner.MyURLClassLoader(java.net.URL[] urls,
                                        java.lang.ClassLoader parent,
                                        java.net.URLStreamHandlerFactory factory)
Deprecated. 

JavaAgentRunner.MyURLClassLoader

public JavaAgentRunner.MyURLClassLoader(java.net.URL[] urls)
Deprecated. 

JavaAgentRunner.MyURLClassLoader

public JavaAgentRunner.MyURLClassLoader(java.net.URL[] urls,
                                        java.lang.ClassLoader parent)
Deprecated. 
Method Detail

findResource

public java.net.URL findResource(java.lang.String name)
Deprecated. 
Overriding the findResource mechanism. This method can deal with `zipfile closed' IllegalStateExceptions. This exception can be thrown because the URLClassLoader could have closed the underlying zipfile via the close() method, which is called at the end of the lifecycle of an agent. However, this classloader can still somehow be called to load other classes. To prevent the zipfile closed exception to stop the normal flow of the classloader class resolve algorithm, we can try to 1) reopen the original zipfile 2) temporarily create a new (empty) zipfile and open that one instead. Note, the zipfile has usually already been deleted (JavaAgentCodeSegment deletes them immediately after use). Maybe this is really a hack... but it works for now, until something better is found.

Overrides:
findResource in class java.net.URLClassLoader
Parameters:
name - class to find
Returns:
URL to class

close

public void close()
Deprecated. 
Close the underlying zipfile.



Copyright © 2003, 2004 IIDS Group. All Rights Reserved.