ks.jarloader
Class JarLoaderFacade

java.lang.Object
  |
  +--ks.jarloader.JarLoaderFacade

public class JarLoaderFacade
extends java.lang.Object

The JarLoaderFacade handles the loading of Classes from mulitple jar files. The jar files are treated as separate protection domains. Each protection domain is defined by the String key passed in when the jar is added. These keys must be unique. Files loaded through the delegation mechanism(to the SystemClassLoader) will not be from separate domains.

See Also:
jarLoader.JarLoader

Field Summary
protected  java.util.Hashtable jarLoaders
           
 
Constructor Summary
JarLoaderFacade()
           
 
Method Summary
 boolean activate()
          Nothing to do.
 boolean addJar(java.lang.String key, java.lang.String path, java.lang.String jarName)
          add a new jar file keyed with the String key.
 boolean connect(IBlock block, java.lang.String interfaceName)
          Has no required help.
 void deactivate()
          Nothing to do.
 java.util.jar.Manifest getManifest(java.lang.String key)
          Gets the Manifest for the Jar file associated with the given key.
 java.util.Enumeration getProvided()
          Provides ILoader interface.
 java.util.Enumeration getRequired()
          Nothing required.
 java.lang.Class loadClass(java.lang.String key, java.lang.String className)
          loads the named class from the JarLoader associated with the specified key.
 void removeJar(java.lang.String key, java.lang.String jarName)
          remove the JarLoader keyed with the String key if it indeed loads files for the named jar file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jarLoaders

protected java.util.Hashtable jarLoaders
Constructor Detail

JarLoaderFacade

public JarLoaderFacade()
Method Detail

addJar

public boolean addJar(java.lang.String key,
                      java.lang.String path,
                      java.lang.String jarName)
               throws java.io.FileNotFoundException
add a new jar file keyed with the String key. calls to loadClass( String key, String className ) will load jars from this jar file.

Parameters:
key - used to reference this jar file.
jarName - the name of the jar file to be loaded e.g. "classes.jar"
path - the path to the jar file. e.g. "jar/storage/"*
Returns:
true if the jar is succesfully loaded and no previous jar was keyed by the same name. If a jar already has been keyed with key false is returned and the new jar is not loaded.
java.io.FileNotFoundException

getManifest

public java.util.jar.Manifest getManifest(java.lang.String key)
Gets the Manifest for the Jar file associated with the given key.

Parameters:
key - the identifier of the JarLoader to use for loading.
Returns:
the Manifest for the named JarFile or null if not found.

loadClass

public java.lang.Class loadClass(java.lang.String key,
                                 java.lang.String className)
                          throws java.lang.ClassNotFoundException
loads the named class from the JarLoader associated with the specified key.

Parameters:
key - the identifier of the JarLoader to use for loading.
className - the name of the Class to load.
Returns:
the Class named or null if no JarLoader is associated with the key.
java.lang.ClassNotFoundException

removeJar

public void removeJar(java.lang.String key,
                      java.lang.String jarName)
remove the JarLoader keyed with the String key if it indeed loads files for the named jar file.

After successfully removing the JarLoader, files from the named jarFile will no longer be loadable through this class. However, if Classes exist which were created by the removed jarLoader they can still load classes from it.

Parameters:
key - used to reference this jar file.
jarName - the name of the jar file to be removed e.g. "classes.jar"

activate

public boolean activate()
                 throws java.lang.Exception
Nothing to do.

java.lang.Exception
See Also:
edu.wpi.cs.cs509.cmi.interfaces.IBlock#activate()

connect

public boolean connect(IBlock block,
                       java.lang.String interfaceName)
                throws java.lang.Exception
Has no required help.

java.lang.Exception
See Also:
edu.wpi.cs.cs509.cmi.interfaces.IBlock#connect(edu.wpi.cs.cs509.cmi.interfaces.IBlock, java.lang.String)

deactivate

public void deactivate()
                throws java.lang.Exception
Nothing to do.

java.lang.Exception
See Also:
edu.wpi.cs.cs509.cmi.interfaces.IBlock#deactivate()

getProvided

public java.util.Enumeration getProvided()
Provides ILoader interface.

See Also:
edu.wpi.cs.cs509.cmi.interfaces.IBlock#getProvided()

getRequired

public java.util.Enumeration getRequired()
Nothing required.

See Also:
edu.wpi.cs.cs509.cmi.interfaces.IBlock#getRequired()