PluginLoader
Keywords: net.java.games.util.plugins.PluginLoader,PluginLoader class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.java.games.util.plugins
Class PluginLoader

    java.lang.Object
      |
      +--java.lang.ClassLoader
            |
            +--java.security.SecureClassLoader
                  |
                  +--java.net.URLClassLoader
                        |
                        +--net.java.games.util.plugins.PluginLoader

public class PluginLoader
extends java.net.URLClassLoader

This class is used internally by the Plugin system. End users of the system are unlikely to need to be aware of it. This is the class loader used to keep the namespaces of different plugins isolated from each other and from the main app code. One plugin loader is created per Jar file in the sub-directory tree of the plugin directory. In addition to isolating java classes this loader also isolates DLLs such that plugins with conflicting DLL names may be used by simply placing the plugin and its associated DLL in a sub-folder of its own. This class also currently implements methods for testing classes for inheritance of superclasses or interfaces. This code is genericly useful and should really be moved to a seperate ClassUtils class.

Author:
  Jeffrey Kesselman

Constructor Summary
`PluginLoader(java.io.File jf)` Creates a new instance of PluginLodaer If the system property "net.java.games.util.plugins.nolocalnative" is not set then the laoder will look for requried native libs in the same directory as the plugin jar.

Method Summary
`boolean` | `attemptPluginDefine(java.lang.Class pc)` This function is called as part of scanning the Jar for plugins.
`protected java.lang.String` | `findLibrary(java.lang.String libname)` This method is queried by the System.loadLibrary() code to find the actual native name and path to the native library to load.

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
`clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, 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

### PluginLoader

    public PluginLoader(java.io.File jf)
                 throws java.net.MalformedURLException

  Creates a new instance of PluginLodaer If the system property "net.java.games.util.plugins.nolocalnative" is not set then the laoder will look for requried native libs in the same directory as the plugin jar. (Useful for handling name collision between plugins). If it IS set however, then it will fall back to the default way of loading natives. (Necessary for Java Web Start.)

Parameters:
  `jf` - The JarFile to load the Plugins from.
Throws:
  `java.net.MalformedURLException` - Will throw this exception if jf does not refer to a legitimate Jar file.

Method Detail

### findLibrary

    protected java.lang.String findLibrary(java.lang.String libname)

  This method is queried by the System.loadLibrary() code to find the actual native name and path to the native library to load. This subclass implementation of this method ensures that the native library will be loaded from, and only from, the parent directory of the Jar file this loader was created to support. This allows different Plugins with supporting DLLs of the same name to co-exist, each in their own subdirectory.

  Overrides:
    `findLibrary` in class `java.lang.ClassLoader`
  Parameters:
    `libname` - The JNI name of the native library to locate.
  Returns:
    Returns a string describing the actual loation of the native library in the native file system.

### attemptPluginDefine

    public boolean attemptPluginDefine(java.lang.Class pc)

  This function is called as part of scanning the Jar for plugins. It checks to make sure the class passed in is a legitimate plugin, which is to say that it meets the following criteria: (1) Is not itself an interface (2) Implements the Plugin marker interface either directly or through inheritance. interface, either

  Parameters:
    `pc` - The potential plug-in class to vette.
  Returns:
    Returns true if the class meets the criteria for a plugin. Otherwise returns false.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD