Load Classes To Instantiate (Load_Classes2Instantiate.bsh v1.1 by Jakub (Kuba) Holy)
Submitted by Sunday, 6 February, 2005 - 13:57
on
Load compiled classes not on the class path whose instances you want to create.
This macro is useful for users of BeanShell - it defines a function that loads compiled classes and returns them in a hashtable.
Load classes given by the user into a Hashtable mapping full class name to Class. Either all classes under a given directory are loaded (see loadAllClassesRecurs( packageBaseDirName )) or the user is presented with a browser to select the classes to load (ctrl+click for multiple selection!!!; see loadClassesWithBrowser(view)) and then is asked to say what's the directory part of the path and what's a fully qualified name of one of the selected classes.
USAGE:
Notice: This macro is not intended to be run directly. Instead, you open it in a buffer, evaluate it and use its methods from beanshell.
See the source file for an example of a script to setup instances of classes I want to test, for help with file browser and additional info. Inside I refer to this script under the name Load_Classes2Instantiate while your is probalby named Load_Classes_To_Instantiate
CHANGELOG:
Updated the example script to load & instantiate classes to test.
Load classes given by the user into a Hashtable mapping full class name to Class. Either all classes under a given directory are loaded (see loadAllClassesRecurs( packageBaseDirName )) or the user is presented with a browser to select the classes to load (ctrl+click for multiple selection!!!; see loadClassesWithBrowser(view)) and then is asked to say what's the directory part of the path and what's a fully qualified name of one of the selected classes.
USAGE:
- Open the macro in a buffer and evaluate the buffer in beanshell to make the functions available
- theClassHashtable = loadClassFromFile();
- myClass = theClassHashtable.get("mypackage.MyClass");
- a) - no-argument constructor:
myObj = myClass.newInstance(); - b) - constructor taking an integer and string:
myObj = myClass.getConstructor(new Class[]{Integer.TYPE, String.class})
.newInstance( new Object[]{ 5, "xx" });
Notice: This macro is not intended to be run directly. Instead, you open it in a buffer, evaluate it and use its methods from beanshell.
See the source file for an example of a script to setup instances of classes I want to test, for help with file browser and additional info. Inside I refer to this script under the name Load_Classes2Instantiate while your is probalby named Load_Classes_To_Instantiate
CHANGELOG:
Updated the example script to load & instantiate classes to test.
Updated on 02/06/2005 - 17:26
Downloads: 1804