Sweet Home 3D 4.1

com.eteks.sweethome3d.tools
Class ExtensionsClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by com.eteks.sweethome3d.tools.ExtensionsClassLoader

public class ExtensionsClassLoader
extends ClassLoader

Class loader able to load classes and DLLs with a higher priority from a given set of JARs. Its bytecode is Java 1.1 compatible to be loadable by old JVMs.

Author:
Emmanuel Puybaret

Constructor Summary
ExtensionsClassLoader(ClassLoader parent, ProtectionDomain protectionDomain, String[] extensionJarsAndDlls, String[] applicationPackages)
          Creates a class loader.
ExtensionsClassLoader(ClassLoader parent, ProtectionDomain protectionDomain, String[] extensionJarAndDllResources, URL[] extensionJarAndDllUrls, String[] applicationPackages, File cacheFolder, String cachedFilesPrefix)
          Creates a class loader.
ExtensionsClassLoader(ClassLoader parent, ProtectionDomain protectionDomain, String[] extensionJarAndDllResources, URL[] extensionJarAndDllUrls, String[] applicationPackages, File cacheFolder, String cachedFilesPrefix, boolean cacheOnlyJars)
          Creates a class loader.
 
Method Summary
 void copyInputStreamToFile(InputStream input, File file)
          Copies the input content to the given file.
protected  Class findClass(String name)
          Finds and defines the given class among the extension JARs given in constructor, then among resources.
protected  String findLibrary(String libname)
          Returns the library path of an extension DLL.
protected  URL findResource(String name)
          Returns the URL of the given resource searching first if it exists among the extension JARs given in constructor.
protected  Class loadClass(String name, boolean resolve)
          Loads a class with this class loader if its package belongs to applicationPackages given in constructor.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, 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
 

Constructor Detail

ExtensionsClassLoader

public ExtensionsClassLoader(ClassLoader parent,
                             ProtectionDomain protectionDomain,
                             String[] extensionJarsAndDlls,
                             String[] applicationPackages)
Creates a class loader. It will consider JARs and DLLs of extensionJarsAndDlls accessed as resources as classpath and libclasspath elements with a higher priority than the ones of default classpath, and will load itself all the classes belonging to packages of applicationPackages. No cache will be used.


ExtensionsClassLoader

public ExtensionsClassLoader(ClassLoader parent,
                             ProtectionDomain protectionDomain,
                             String[] extensionJarAndDllResources,
                             URL[] extensionJarAndDllUrls,
                             String[] applicationPackages,
                             File cacheFolder,
                             String cachedFilesPrefix)
Creates a class loader. It will consider JARs and DLLs of extensionJarAndDllResources and extensionJarAndDllUrls as classpath and libclasspath elements with a higher priority than the ones of default classpath, and will load itself all the classes belonging to packages of applicationPackages.
Copies of extensionJarAndDllResources and extensionJarAndDllUrls will be stored in the given cache folder if possible, each file being prefixed by cachedFilesPrefix.


ExtensionsClassLoader

public ExtensionsClassLoader(ClassLoader parent,
                             ProtectionDomain protectionDomain,
                             String[] extensionJarAndDllResources,
                             URL[] extensionJarAndDllUrls,
                             String[] applicationPackages,
                             File cacheFolder,
                             String cachedFilesPrefix,
                             boolean cacheOnlyJars)
Creates a class loader. It will consider JARs and DLLs of extensionJarAndDllResources and extensionJarAndDllUrls as classpath and libclasspath elements with a higher priority than the ones of default classpath, and will load itself all the classes belonging to packages of applicationPackages.
Copies of extensionJarAndDllResources and extensionJarAndDllUrls will be stored in the given cache folder if possible, each file being prefixed by cachedFilesPrefix.

Method Detail

copyInputStreamToFile

public void copyInputStreamToFile(InputStream input,
                                  File file)
                           throws FileNotFoundException,
                                  IOException
Copies the input content to the given file.

Throws:
FileNotFoundException
IOException

findClass

protected Class findClass(String name)
                   throws ClassNotFoundException
Finds and defines the given class among the extension JARs given in constructor, then among resources.

Overrides:
findClass in class ClassLoader
Throws:
ClassNotFoundException

findLibrary

protected String findLibrary(String libname)
Returns the library path of an extension DLL.

Overrides:
findLibrary in class ClassLoader

findResource

protected URL findResource(String name)
Returns the URL of the given resource searching first if it exists among the extension JARs given in constructor.

Overrides:
findResource in class ClassLoader

loadClass

protected Class loadClass(String name,
                          boolean resolve)
                   throws ClassNotFoundException
Loads a class with this class loader if its package belongs to applicationPackages given in constructor.

Overrides:
loadClass in class ClassLoader
Throws:
ClassNotFoundException

Sweet Home 3D 4.1

© Copyrights 2006-2013 eTeks - All rights reserved
Distributed under GNU General Public License