ks.common.interfaces
Interface ILoader


public interface ILoader

Enables dynamic loading of classes.


Method Summary
 boolean addJar(java.lang.String key, java.lang.String path, java.lang.String jarName)
          add a new jar file keyed with the String key.
 java.util.jar.Manifest getManifest(java.lang.String key)
          Gets the Manifest for the Jar file associated with the given key.
 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.
 

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. Future 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.
Throws:
java.io.FileNotFoundException

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.
Throws:
java.lang.ClassNotFoundException

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.

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"