Plain Text | 69 lines | 50 code | 19 blank | 0 comment | 0 complexity | aea220055ef876e2d3ee73a4e238ed38 MD5 | raw file
1JavaLoader v0.5 2Author: Mark Mandel 3Date: 2nd October 2007 4 5Installation 6---------------- 7To install the javaloader, either put the javaloader in the 8root of your web application, or make a mapping called 9'javaloader' to the javaloader folder. 10 11 12Utilisation 13---------------- 14To access the JavaLoader CFC, you call createObject on it like so: 15 16createObject("component", "javaloader.JavaLoader").init(loadPaths, 17 [loadColdFusionClassPath,] 18 [parentClassLoader]); 19 20There are three arguments that possible to configure how and what the JavaLoader loads. 21 22* param: loadPaths 23An array of directories of classes, or paths to .jar files to load. 24 25An example would be: 26loadPaths = ArrayNew(1); 27loadPaths = expandPath("icu4j.jar"); 28loadPaths = expandPath("log4j.jar"); 29 30* param: loadColdFusionClassPath (default: false) 31Loads the ColdFusion libraries with the loaded libraries. 32This used to be on by default, however now you must implicitly set it to be true if 33you wish to access any of the libraries that ColdFusion loads at application startup. 34 35* parentClassLoader (null) 36(Expert use only) The parent java.lang.ClassLoader to set when creating the URLClassLoader. 37Note - when setting loadColdFusionClassPath to 'true', this value is overwritten with the 38ColdFusion classloader. 39 40 41To create an instance of a Java Class, you then only need to call: 42 43javaloader.create(className).init(arg1, arg2...); 44 45* param className 46The name of the Java Class to create. 47 48This works exactly the same as createObject("java", className), such that simply calling create(className) 49gives you access to the static properties of the class, but to get an instance through calling the 50Constructor you are required to call create(className).init(); 51 52Example: 53javaloader.create("org.apache.log4j.Logger").init("my log"); 54 55Memory Issues 56---------------- 57Due to a bug in ColdFusion 7 that can cause URLClassLoaders not to be garbage collected, 58it is advised that instances of JavaLoader are stored in the Server scope, so that they 59never time out. 60 61 62Integration 63---------------- 64Previously JavaLoader was a simple CFC that was very portable, and while JavaLoader 65now has dependencies, it can still be integrated into existing applications quite easily. 66 67The only dependency that much be maintained is that the /lib/ folder and its contents 68must sit in the same directory as JavaLoader.cfc Other than that, JavaLoader can be 69integrated into existing applications and frameworks quite easily.