PageRenderTime 14ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/plugins/javaLoader/javaLoader.cfc

http://raihan.googlecode.com/
ColdFusion CFScript | 83 lines | 56 code | 17 blank | 10 comment | 2 complexity | 657a40dc2c127220c8c1685e525df7b0 MD5 | raw file
 1<cfcomponent output="false">
 2	 <cffunction name="init">
 3		<cfset this.version = "1.1.3">
 4		
 5		<cfreturn this>
 6	</cffunction>
 7	
 8	<cffunction name="javaLoader" returntype="Any" access="public" output="false"  hint="I return the javaloader object ready for you to create ???">
 9		<cfargument name="loadPathsArray" default="#ArrayNew(1)#" type="array" hint="an array of absolute paths to jar files" />
10		
11		<cfscript>
12			var loadPaths = createLoadPath(arguments.loadPathsArray);
13			var javaloader = createJavaLoaderObject(loadPaths);
14		</cfscript>
15		
16		<cfreturn javaloader />
17	</cffunction>
18	
19	<cffunction name="createJavaLoaderObject" hint="I return the javaloader object with the jars loaded" returntype="Any">
20		<cfargument name="loadPaths" required="true" type="array" />
21		
22		<cfscript>
23			var javaloader = createObject("component", "#get('rootComponentPath')#.plugins.javaloader.JavaLoader.Javaloader").init(arguments.loadPaths, 'true');
24		</cfscript>
25		
26		<cfreturn javaloader />
27	</cffunction>
28	
29	<cffunction name="createLoadPath" returntype="array" hint="I return an array of all the jars to load">
30		<cfargument name="loadPathsArray" type="array" default="" />
31		
32		<cfscript>
33			var loadMe = "";
34			var i = "";
35		    // create loadPath array
36			var loadPaths = ArrayNew(1); 
37			// var dirPath = ReturnWebRootTranslated() & "/lib/";
38			// var proxyJar = ReturnWebRootTranslated() & "/plugins/javaloader/javaLoader/support/cfcdynamicproxy/lib/cfcdynamicproxy.jar";
39			var dirPath = GetDirectoryFromPath(GetBaseTemplatePath()) & "/lib/";
40			var proxyJar = GetDirectoryFromPath(GetBaseTemplatePath()) & "/plugins/javaloader/javaLoader/support/cfcdynamicproxy/lib/cfcdynamicproxy.jar";
41		</cfscript>
42		
43		<!--- read directory for jar files --->
44		<cfdirectory 
45		   action = "list"
46		   directory = "#dirPath#"
47		   name = "loadMe"
48		   filter = "*.jar">
49		 
50		<!--- add default jars in lib folder --->
51		<cfloop index="i" from="1" to="#loadMe.RecordCount#">
52		 	<cfset loadPaths[#i#] = dirPath & loadMe.Name[i] />
53		</cfloop>
54		
55		<!--- add explicitily set jars --->
56		<cfloop array="#arguments.loadPathsArray#" index="i">
57			<!--- check if jar exists --->
58			<cfif fileExists(#i#)>
59		 		<cfset ArrayAppend(loadPaths, "#i#") />
60			</cfif>
61		</cfloop>
62
63		<cfset ArrayPrepend(loadPaths, "#proxyJar#") />
64
65		<cfreturn loadPaths />
66	</cffunction>
67	
68	<cffunction name="ReturnWebRootTranslated" access="public" returntype="string" hint="Returns the translated (file system) location of the web root directory">
69		<cfscript>
70		/**
71		* Returns the translated (file system) location of the web root directory.
72		*
73		* @return Returns a string.
74		* @author David Whiterod (whiterod.david@saugov.sa.gov.au)
75		* @version 1, May 9, 2003
76		*/
77		var tmpPath = Replace(CGI.SCRIPT_NAME, "/", "\", "ALL");
78		return Replace(ReplaceNoCase(CGI.PATH_TRANSLATED, tmpPath, "", "ALL"), "\", "/", "ALL");
79		</cfscript>
80	</cffunction>
81	
82	
83</cfcomponent>