org.gjt.universe
Class UPM

java.lang.Object
  |
  +--org.gjt.universe.UPM

public final class UPM
extends java.lang.Object


Nested Class Summary
private static class UPM.GroupKVP
           
static class UPM.PluginInfo
          Class PluginInfo: Contains the basic data about each plugin that has been loaded.
 
Field Summary
protected static java.lang.String[] categories
           
protected static boolean loadClassesAtStartup
           
protected static java.util.Vector piVector
           
 
Constructor Summary
private UPM()
           
 
Method Summary
private static boolean checkVersion(java.lang.String pluginVersion)
           
static boolean doesCategoryExist(java.lang.String category)
          returns if the category exists.
private static UPM.PluginInfo[] findAllMatchingCategory(java.lang.String category)
          private methods..
private static UPM.PluginInfo findClass(java.lang.String className)
           
private static java.lang.String findValueWithin(ManifestItems.KVPair[] kvp, java.lang.String what)
           
static java.lang.String[] getCategories()
          returns an array which contains all the categories that have been loaded.
static java.lang.String[] getClassNamesForCategory(java.lang.String category)
          returns the class names for each class of a given category.
private static java.lang.String[] getJarFilesFromDir(java.io.File dir)
           
static int getNumInCategory(java.lang.String category)
          returns the # of plugins for a given category.
private static void getPIForBeans(java.lang.String jarfile, ManifestItems mi)
           
static UPM.PluginInfo[] getPluginInfo()
          returns PluginInfo for each plugin that was loaded.
static void init(java.io.File directory)
          This initializes UPM.
static void init(java.io.File[] directories)
          This initializes UPM.
static java.lang.Object newInstance(java.lang.Class c)
          UTILITY METHOD: DOES NOT REQUIRE UPM INITIALIZATION Given a class object 'c', instantiate it.
static java.lang.Object newInstance(java.lang.String classname)
          Instantiate an object; in this case, "classname".
static java.lang.Object newInstanceChecked(java.lang.Class c, java.lang.Class cast)
          UTILITY METHOD: DOES NOT REQUIRE UPM INITIALIZATION Same as newInstance(), but will generate a user-friendly error if Class 'c' does not extend/implement 'cast'.
static java.lang.Object[] newInstances(java.lang.String category)
          Instantiates all classes of a given category.
static boolean preloadCategory(java.lang.String category)
          Preload an entire category of classes.
static boolean preloadClass(java.lang.String classname)
          preload Class 'classname'; subsequent calls to newInstance() will then execute faster.
private static ManifestItems readManifestFromJar(java.lang.String jarfile)
           
static void setLoadClassesAtStartup(boolean value)
          This method determines if classes are preloaded (automatically) during init().
static void unloadCategory(java.lang.String category)
          Unload an entire category of classes.
static void unloadClass(java.lang.String classname)
          unloads a class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loadClassesAtStartup

protected static boolean loadClassesAtStartup

piVector

protected static java.util.Vector piVector

categories

protected static java.lang.String[] categories
Constructor Detail

UPM

private UPM()
Method Detail

init

public static void init(java.io.File directory)
This initializes UPM. It scans the directory "directory" for .jar files. This must be called before any other method is called, except the utility methods.


init

public static void init(java.io.File[] directories)
This initializes UPM. It scans each directory in the array. This must be called before any other method is called, except the utility methods.


setLoadClassesAtStartup

public static void setLoadClassesAtStartup(boolean value)
This method determines if classes are preloaded (automatically) during init(). Thus it must be called before init().


getPluginInfo

public static UPM.PluginInfo[] getPluginInfo()
returns PluginInfo for each plugin that was loaded. This is useful for diagnostics, so the user can see what extensions & what type are loaded.


getCategories

public static java.lang.String[] getCategories()
returns an array which contains all the categories that have been loaded.


doesCategoryExist

public static boolean doesCategoryExist(java.lang.String category)
returns if the category exists. A category will not exist if no plugins of that category were loaded.


getNumInCategory

public static int getNumInCategory(java.lang.String category)
returns the # of plugins for a given category.


getClassNamesForCategory

public static java.lang.String[] getClassNamesForCategory(java.lang.String category)
returns the class names for each class of a given category. This would permit loading of a specific class of a given type.


preloadClass

public static boolean preloadClass(java.lang.String classname)
preload Class 'classname'; subsequent calls to newInstance() will then execute faster.


unloadClass

public static void unloadClass(java.lang.String classname)
unloads a class. This should conserve memory, at the expense of newInstance() execution speed.


preloadCategory

public static boolean preloadCategory(java.lang.String category)
Preload an entire category of classes.


unloadCategory

public static void unloadCategory(java.lang.String category)
Unload an entire category of classes.


newInstance

public static java.lang.Object newInstance(java.lang.String classname)
Instantiate an object; in this case, "classname". This works *exactly* the same as the 'new' keyword. Note that there must be a public zero-argument constructor in the class.


newInstances

public static java.lang.Object[] newInstances(java.lang.String category)
Instantiates all classes of a given category.


newInstance

public static java.lang.Object newInstance(java.lang.Class c)
UTILITY METHOD: DOES NOT REQUIRE UPM INITIALIZATION Given a class object 'c', instantiate it. Note that this method will give user-friendly output as to why the instantiation fails, if it does. This is equivalent to using "new". e.g.: Planet p = (Planet)newInstance( Class.forname("universe.scheme.Planet_001"))


newInstanceChecked

public static java.lang.Object newInstanceChecked(java.lang.Class c,
                                                  java.lang.Class cast)
UTILITY METHOD: DOES NOT REQUIRE UPM INITIALIZATION Same as newInstance(), but will generate a user-friendly error if Class 'c' does not extend/implement 'cast'. Note that 'cast' may be either a class OR an interface. example useage: class foo extends bar; class notfoo newInstanceChecked(foo, bar); // ok (foo derived from bar) newInstanceChecked(foo, notfoo); // error since foo does not implement/extend notfoo


findAllMatchingCategory

private static UPM.PluginInfo[] findAllMatchingCategory(java.lang.String category)
private methods..


findClass

private static UPM.PluginInfo findClass(java.lang.String className)

getJarFilesFromDir

private static java.lang.String[] getJarFilesFromDir(java.io.File dir)

readManifestFromJar

private static ManifestItems readManifestFromJar(java.lang.String jarfile)

getPIForBeans

private static void getPIForBeans(java.lang.String jarfile,
                                  ManifestItems mi)

findValueWithin

private static java.lang.String findValueWithin(ManifestItems.KVPair[] kvp,
                                                java.lang.String what)

checkVersion

private static boolean checkVersion(java.lang.String pluginVersion)


Copyright © 2001 Universe Dev Team All Rights Reserved.