Skip to content

Commit 5afcb58

Browse files
committed
Bump to javaloader 1.2
1 parent b4542e1 commit 5afcb58

13 files changed

+69
-56
lines changed

javaloader/JavaCompiler.cfc

100644100755
File mode changed.

javaloader/JavaLoader.cfc

100644100755
+63-25
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Purpose: Utlitity class for loading Java Classes
1717
instance.static.uuid = "A0608BEC-0AEB-B46A-0E1E1EC5F3CE7C9C";
1818
</cfscript>
1919

20-
<cfimport taglib="tags" prefix="jl">
2120

2221
<!------------------------------------------- PUBLIC ------------------------------------------->
2322

@@ -104,9 +103,9 @@ Purpose: Utlitity class for loading Java Classes
104103

105104
<cffunction name="switchThreadContextClassLoader" hint="Sometimes you will need to switch out the ThreadContextClassLoader with the classloader used by JavaLoader.<br/>
106105
It has :
107-
switchThreadContextClassLoader(function object, [classLoader=getURLClassLoader()])
108-
switchThreadContextClassLoader(function name, [classLoader=getURLClassLoader()])
109-
switchThreadContextClassLoader(object, function name, [classLoader=getURLClassLoader()])
106+
switchThreadContextClassLoader(function object, [struct function arguments], [classLoader=getURLClassLoader()])
107+
switchThreadContextClassLoader(function name, [struct function arguments], [classLoader=getURLClassLoader()])
108+
switchThreadContextClassLoader(object, function name, [struct function arguments], [classLoader=getURLClassLoader()])
110109
This method can be used in 3 different ways:
111110
<ol>
112111
<li>Pass it the UDF itself</li>
@@ -116,21 +115,61 @@ Purpose: Utlitity class for loading Java Classes
116115
access="public" returntype="any" output="false">
117116
<cfscript>
118117
var local = {};
118+
var func = 0; //need this as cf8 doesn't like the structure with functions.
119119
var System = createObject("java", "java.lang.System");
120120
var Thread = createObject("java", "java.lang.Thread");
121121
var currentClassloader = Thread.currentThread().getContextClassLoader();
122-
123-
if(structCount(arguments) == 2 && !isSimpleValue(arguments[2]))
124-
{
125-
classLoader = arguments[2];
122+
var classLoader = "";
123+
124+
if (structCount(arguments) == 4)
125+
{
126+
// the last 2 arguments are the function arguments and class loader
127+
classLoader = arguments[4];
128+
local.funcArgs = arguments[3];
129+
}
130+
else if (structCount(arguments) == 3)
131+
{
132+
// 2nd argument could be classloader or function arguments
133+
if (isInstanceOf(arguments[2],"java.lang.ClassLoader"))
134+
{
135+
classLoader = arguments[2];
136+
}
137+
else if (isStruct(arguments[2]))
138+
{
139+
local.funcArgs = arguments[2];
140+
}
141+
142+
// 3rd argument could be classloader or function arguments
143+
if (isInstanceOf(arguments[3],"java.lang.ClassLoader"))
144+
{
145+
classLoader = arguments[3];
146+
}
147+
else if (isStruct(arguments[3]))
148+
{
149+
local.funcArgs = arguments[3];
150+
}
151+
}
152+
else if (structCount(arguments) == 2)
153+
{
154+
// the 2nd argument could be a class loader or function arguments
155+
if (isInstanceOf(arguments[2],"java.lang.ClassLoader"))
156+
{
157+
classLoader = arguments[2];
158+
}
159+
else if (isStruct(arguments[2]))
160+
{
161+
local.funcArgs = arguments[2];
162+
}
126163
}
127-
else if(structCount(arguments) == 3)
164+
165+
if (!structKeyExists(local,"funcArgs"))
128166
{
129-
classLoader = arguments[3];
167+
local.funcArgs = {};
130168
}
131-
else //assume we are still in JL
169+
170+
if (isSimpleValue(classLoader))
132171
{
133-
classLoader = getURLClassLoader();
172+
classLoader = getURLClassLoader();
134173
}
135174
</cfscript>
136175

@@ -140,14 +179,14 @@ Purpose: Utlitity class for loading Java Classes
140179
</cfscript>
141180

142181
<cfif isSimpleValue(arguments[1])>
143-
<cfinvoke method="#arguments[1]#" returnvariable="local.return" />
182+
<cfinvoke method="#arguments[1]#" returnvariable="local.return" argumentCollection="#local.funcArgs#" />
144183
<cfelseif isCustomFunction(arguments[1])>
145184
<cfscript>
146-
local.func = arguments[1];
147-
local.return = local.func();
185+
func = arguments[1];
186+
local.return = func(argumentCollection = local.funcArgs);
148187
</cfscript>
149188
<cfelseif isObject(arguments[1]) AND isSimpleValue(arguments[2])>
150-
<cfinvoke component="#arguments[1]#" method="#arguments[2]#" returnvariable="local.return" />
189+
<cfinvoke component="#arguments[1]#" method="#arguments[2]#" returnvariable="local.return" argumentCollection="#local.funcArgs#" />
151190
<cfelse>
152191
<cfthrow type="javaloader.InvalidInvocationException" message="Unable to determine what method to invoke" detail="Please check the documentation for switchThreadContextClassLoader."/>
153192
</cfif>
@@ -172,7 +211,7 @@ Purpose: Utlitity class for loading Java Classes
172211
</cffunction>
173212

174213
<cffunction name="getVersion" hint="Retrieves the version of the loader you are using" access="public" returntype="string" output="false">
175-
<cfreturn "1.1">
214+
<cfreturn "1.2">
176215
</cffunction>
177216

178217
<!------------------------------------------- PACKAGE ------------------------------------------->
@@ -275,7 +314,7 @@ Purpose: Utlitity class for loading Java Classes
275314
for(; counter lte len; counter = counter + 1)
276315
{
277316
dir = directories[counter];
278-
directoryCopy(dir, path);
317+
$directoryCopy(dir, path);
279318
}
280319

281320
//then we compile it, and grab that jar
@@ -330,10 +369,9 @@ Purpose: Utlitity class for loading Java Classes
330369
var counter = 0;
331370
</cfscript>
332371

333-
<!--- cf7 syntax. Yuck. --->
334372
<cfloop from="1" to="#len#" index="counter">
335373
<cfset dir = directories[counter]>
336-
<jl:directory action="list" directory="#dir#" recurse="true"
374+
<cfdirectory action="list" directory="#dir#" recurse="true"
337375
type="file"
338376
sort="dateLastModified desc"
339377
name="qLastModified">
@@ -438,11 +476,11 @@ Purpose: Utlitity class for loading Java Classes
438476
<cfdirectory action="list" name="qJars" directory="#path#" filter="*.jar" sort="name desc"/>
439477
<cfloop query="qJars">
440478
<cfscript>
441-
libName = ListGetAt(name, 1, "-");
479+
libName = ListGetAt(qJars.name, 1, "-");
442480
//let's not use the lib's that have the same name, but a lower datestamp
443481
if(NOT ListFind(jarList, libName))
444482
{
445-
ArrayAppend(aJars, path & "/" & name);
483+
ArrayAppend(aJars, path & "/" & qJars.name);
446484
jarList = ListAppend(jarList, libName);
447485
}
448486
</cfscript>
@@ -544,7 +582,7 @@ Copies a directory.
544582
@author Joe Rinehart ([email protected])
545583
@version 1, July 27, 2005
546584
--->
547-
<cffunction name="directoryCopy" access="private" output="true">
585+
<cffunction name="$directoryCopy" access="private" output="true">
548586
<cfargument name="source" required="true" type="string">
549587
<cfargument name="destination" required="true" type="string">
550588
<cfargument name="nameconflict" required="true" default="overwrite">
@@ -562,9 +600,9 @@ Copies a directory.
562600
<cfif contents.type eq "file">
563601
<cffile action="copy" source="#arguments.source#/#name#" destination="#arguments.destination#/#name#" nameconflict="#arguments.nameConflict#">
564602
<cfelseif contents.type eq "dir">
565-
<cfset directoryCopy(arguments.source & dirDelim & name, arguments.destination & dirDelim & name) />
603+
<cfset $directoryCopy(arguments.source & dirDelim & name, arguments.destination & dirDelim & name) />
566604
</cfif>
567605
</cfloop>
568606
</cffunction>
569607

570-
</cfcomponent>
608+
</cfcomponent>

javaloader/JavaProxy.cfc

100644100755
+3-3
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,16 @@ Mark Mandel 27/08/2007 Created
121121
</cffunction>
122122

123123
<cffunction name="_buildArgumentArray" hint="builds an argument array out of the arguments" access="private" returntype="array" output="false">
124-
<cfargument name="arguments" hint="the arguments passed through" type="struct" required="Yes">
124+
<cfargument name="args" hint="the arguments passed through" type="struct" required="Yes">
125125
<cfscript>
126-
var len = StructCount(arguments);
126+
var len = StructCount(args);
127127
var objArray = _getArray().newInstance(_getObjectClass(), len);
128128
var counter = 1;
129129
var obj = 0;
130130

131131
for(; counter <= len; counter++)
132132
{
133-
obj = arguments[counter];
133+
obj = args[counter];
134134
_getArray().set(objArray, counter - 1, obj);
135135
}
136136

-7.02 KB
Binary file not shown.

javaloader/lib/classloader-20120103162851.jar

100644100755
File mode changed.

javaloader/lib/classloader-src.zip

100644100755
File mode changed.

javaloader/licence.txt

100644100755
File mode changed.

javaloader/readme.txt

100644100755
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
JavaLoader v1.0
1+
JavaLoader v1.2
22
Author: Mark Mandel
3-
Date: 10 September 2010
3+
Date: 22 March 2017
44

55
Documentation can now be found at:
6-
http://www.compoundtheory.com/javaloader/docs/
6+
https://github.com/markmandel/JavaLoader/wiki

javaloader/support/cfcdynamicproxy/lib/cfcdynamicproxy-src.zip

100644100755
File mode changed.

javaloader/support/cfcdynamicproxy/lib/cfcdynamicproxy.jar

100644100755
File mode changed.

javaloader/support/spring/lib/spring-coldfusion-src.zip

100644100755
File mode changed.

javaloader/support/spring/lib/spring-coldfusion.jar

100644100755
File mode changed.

javaloader/tags/directory.cfm

-25
This file was deleted.

0 commit comments

Comments
 (0)