Skip to content

Commit cc8b7cb

Browse files
committed
Merge branch 'development'
2 parents a2139cd + e287ca5 commit cc8b7cb

17 files changed

+207
-40
lines changed

.gitignore

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
# IDE Stuff
12
.settings
2-
logs/*.log
33
settings.xml
4-
.netbeans
4+
5+
# Logs
6+
logs/*.log
7+
8+
# Test Results
59
tests/results/*
6-
modules/cbvalidation/*
10+
11+
# Dependenncies
712
coldbox/*
813
testbox/*
914
artifacts/*
1015
apidocs/docbox/*
11-
workbench/build.number
16+
workbench/*
1217
build/*

.module.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
project.name=cbjavaloader
2-
project.version=1.3.3
2+
project.version=1.4.0
33
module.name=cbjavaloader

box.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"cbjavaloader Builder",
3-
"version":"1.3.3",
3+
"version":"1.4.0",
44
"slug":"cbjavaloader-shell",
55
"private":false,
66
"defaultPort":0,

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
## 1.4.0
5+
* Updated internal core Javaloader library to latest 1.2 release
6+
* Added automatic dynamic proxy class loading
7+
* Deprecating support for cf10
8+
49
## 1.3.3
510
* Cleanup of testing Application.cfc
611

modules/cbjavaloader/ModuleConfig.cfc

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ component {
88
// Module Properties
99
this.title = "JavaLoader";
1010
this.author = "Ortus Solutions";
11-
this.webURL = "http://www.ortussolutions.com";
11+
this.webURL = "https://www.ortussolutions.com";
1212
this.description = "A JavaLoader Module for ColdBox";
1313
this.version = "@build.version@[email protected]@";
1414
// If true, looks for views in the parent first, if not found, then in the module. Else vice-versa
@@ -17,7 +17,10 @@ component {
1717
this.layoutParentLookup = true;
1818
// CF Mapping
1919
this.cfmapping = "cbjavaloader";
20-
20+
21+
/**
22+
* Configure module
23+
*/
2124
function configure(){
2225
// Register Custom DSL, don't map it because it is too late, mapping DSLs are only good by the parent app
2326
controller.getWireBox()
@@ -31,6 +34,7 @@ component {
3134
var settings = controller.getConfigSettings();
3235
// parse parent settings
3336
parseParentSettings();
37+
3438
// Bind Core JavaLoader
3539
binder.map( "jl@cbjavaloader" )
3640
.to( "#moduleMapping#.models.javaloader.JavaLoader" )
@@ -40,6 +44,7 @@ component {
4044
.initArg( name="sourceDirectories", value=settings.modules.cbjavaloader.settings.sourceDirectories )
4145
.initArg( name="compileDirectory", value=settings.modules.cbjavaloader.settings.compileDirectory )
4246
.initArg( name="trustedSource", value=settings.modules.cbjavaloader.settings.trustedSource );
47+
4348
// Load JavaLoader and class loading
4449
wirebox.getInstance( "loader@cbjavaloader" ).setup();
4550
}
@@ -59,7 +64,13 @@ component {
5964
throw( message="Invalid library path", detail="The path is #arguments.dirPath#", type="JavaLoader.DirectoryNotFoundException" );
6065
}
6166

62-
return directoryList( arguments.dirPath, true, "array", arguments.filter, "name desc" );
67+
return directoryList(
68+
arguments.dirPath,
69+
true,
70+
"array",
71+
arguments.filter,
72+
"name desc"
73+
);
6374
}
6475

6576
/**
@@ -90,6 +101,7 @@ component {
90101
if( !structKeyExists( javaLoaderDSL, "loadPaths" ) ){
91102
javaLoaderDSL.loadPaths = [];
92103
}
104+
93105
// Array of locations
94106
if( isArray( javaLoaderDSL.loadPaths ) ){
95107
var aJarPaths = [];
@@ -102,19 +114,30 @@ component {
102114
}
103115
javaLoaderDSL.loadPaths = aJarPaths;
104116
}
117+
105118
// Single directory? Get all Jars in it
106119
if( isSimpleValue( javaLoaderDSL.loadPaths ) and directoryExists( javaLoaderDSL.loadPaths ) ){
107120
javaLoaderDSL.loadPaths = getJars( javaLoaderDSL.loadPaths );
108-
}
121+
}
122+
109123
// Single Jar?
110124
if( isSimpleValue( javaLoaderDSL.loadPaths ) and fileExists( javaLoaderDSL.loadPaths ) ){
111125
javaLoaderDSL.loadPaths = [ javaLoaderDSL.loadPaths ];
112126
}
127+
113128
// If simple value and no length
114129
if( isSimpleValue( javaLoaderDSL.loadPaths ) and !len( javaLoaderDSL.loadPaths ) ){
115130
javaLoaderDSL.loadPaths = [];
116131
}
117132

133+
// Now that we have figured out the user's settings, let's incorporate ours
134+
135+
// Dynamic Proxy
136+
arrayPrepend(
137+
javaLoaderDSL.loadPaths,
138+
variables.modulePath & "/models/javaloader/support/cfcdynamicproxy/lib/cfcdynamicproxy.jar"
139+
);
140+
118141
// incorporate settings
119142
structAppend( configStruct.modules.cbjavaloader.settings, javaLoaderDSL, true );
120143
}

modules/cbjavaloader/models/javaloader/JavaCompiler.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<cfcomponent hint="Compiles Java source dirs to an array of .jar files." output="false">
1+
<cfcomponent hint="Compiles Java source dirs to an array of .jar files." output="false">
22

33
<!------------------------------------------- PUBLIC ------------------------------------------->
44

modules/cbjavaloader/models/javaloader/JavaLoader.cfc

Lines changed: 124 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!--- Document Information -----------------------------------------------------
1+
<!--- Document Information -----------------------------------------------------
22
33
Title: JavaLoader.cfc
44
@@ -17,6 +17,7 @@ Purpose: Utlitity class for loading Java Classes
1717
instance.static.uuid = "A0608BEC-0AEB-B46A-0E1E1EC5F3CE7C9C";
1818
</cfscript>
1919

20+
2021
<!------------------------------------------- PUBLIC ------------------------------------------->
2122

2223
<cffunction name="init" hint="Constructor" access="public" returntype="JavaLoader" output="false">
@@ -95,8 +96,122 @@ Purpose: Utlitity class for loading Java Classes
9596
<cfreturn instance.ClassLoader />
9697
</cffunction>
9798

99+
<cffunction name="getClassLoadPaths" access="public" returntype="array" output="false">
100+
<cfreturn instance.classLoadPaths />
101+
</cffunction>
102+
103+
104+
<cffunction name="switchThreadContextClassLoader" hint="Sometimes you will need to switch out the ThreadContextClassLoader with the classloader used by JavaLoader.<br/>
105+
It has :
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()])
109+
This method can be used in 3 different ways:
110+
<ol>
111+
<li>Pass it the UDF itself</li>
112+
<li>Pass it the current object and method name that you wish to have called</li>
113+
<li>Inject it into your CFC/Page that you want to use, and call it from there, telling it what function to call (you will need to pass in the URLClassLoader)</li>
114+
</ol>"
115+
access="public" returntype="any" output="false">
116+
<cfscript>
117+
var local = {};
118+
var func = 0; //need this as cf8 doesn't like the structure with functions.
119+
var System = createObject("java", "java.lang.System");
120+
var Thread = createObject("java", "java.lang.Thread");
121+
var currentClassloader = Thread.currentThread().getContextClassLoader();
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+
}
163+
}
164+
165+
if (!structKeyExists(local,"funcArgs"))
166+
{
167+
local.funcArgs = {};
168+
}
169+
170+
if (isSimpleValue(classLoader))
171+
{
172+
classLoader = getURLClassLoader();
173+
}
174+
</cfscript>
175+
176+
<cftry>
177+
<cfscript>
178+
Thread.currentThread().setContextClassLoader(classloader);
179+
</cfscript>
180+
181+
<cfif isSimpleValue(arguments[1])>
182+
<cfinvoke method="#arguments[1]#" returnvariable="local.return" argumentCollection="#local.funcArgs#" />
183+
<cfelseif isCustomFunction(arguments[1])>
184+
<cfscript>
185+
func = arguments[1];
186+
local.return = func(argumentCollection = local.funcArgs);
187+
</cfscript>
188+
<cfelseif isObject(arguments[1]) AND isSimpleValue(arguments[2])>
189+
<cfinvoke component="#arguments[1]#" method="#arguments[2]#" returnvariable="local.return" argumentCollection="#local.funcArgs#" />
190+
<cfelse>
191+
<cfthrow type="javaloader.InvalidInvocationException" message="Unable to determine what method to invoke" detail="Please check the documentation for switchThreadContextClassLoader."/>
192+
</cfif>
193+
194+
<cfcatch>
195+
<cfscript>
196+
Thread.currentThread().setContextClassLoader(currentClassloader);
197+
</cfscript>
198+
<cfrethrow>
199+
</cfcatch>
200+
</cftry>
201+
202+
<cfscript>
203+
//need to do this twice, as cf8 has no finally.
204+
Thread.currentThread().setContextClassLoader(currentClassloader);
205+
206+
if(structKeyExists(local, "return"))
207+
{
208+
return local.return;
209+
}
210+
</cfscript>
211+
</cffunction>
212+
98213
<cffunction name="getVersion" hint="Retrieves the version of the loader you are using" access="public" returntype="string" output="false">
99-
<cfreturn "1.0">
214+
<cfreturn "1.2">
100215
</cffunction>
101216

102217
<!------------------------------------------- PACKAGE ------------------------------------------->
@@ -199,7 +314,7 @@ Purpose: Utlitity class for loading Java Classes
199314
for(; counter lte len; counter = counter + 1)
200315
{
201316
dir = directories[counter];
202-
directoryCopy(dir, path);
317+
$directoryCopy(dir, path);
203318
}
204319

205320
//then we compile it, and grab that jar
@@ -254,14 +369,9 @@ Purpose: Utlitity class for loading Java Classes
254369
var counter = 0;
255370
</cfscript>
256371

257-
<!--- cf7 syntax. Yuck. --->
258372
<cfloop from="1" to="#len#" index="counter">
259373
<cfset dir = directories[counter]>
260-
261-
<cfdirectory
262-
action="list"
263-
directory="#dir#"
264-
recurse="true"
374+
<cfdirectory action="list" directory="#dir#" recurse="true"
265375
type="file"
266376
sort="dateLastModified desc"
267377
name="qLastModified">
@@ -366,11 +476,11 @@ Purpose: Utlitity class for loading Java Classes
366476
<cfdirectory action="list" name="qJars" directory="#path#" filter="*.jar" sort="name desc"/>
367477
<cfloop query="qJars">
368478
<cfscript>
369-
libName = ListGetAt(name, 1, "-");
479+
libName = ListGetAt(qJars.name, 1, "-");
370480
//let's not use the lib's that have the same name, but a lower datestamp
371481
if(NOT ListFind(jarList, libName))
372482
{
373-
ArrayAppend(aJars, path & "/" & name);
483+
ArrayAppend(aJars, path & "/" & qJars.name);
374484
jarList = ListAppend(jarList, libName);
375485
}
376486
</cfscript>
@@ -379,10 +489,6 @@ Purpose: Utlitity class for loading Java Classes
379489
<cfreturn aJars>
380490
</cffunction>
381491

382-
<cffunction name="getClassLoadPaths" access="private" returntype="array" output="false">
383-
<cfreturn instance.classLoadPaths />
384-
</cffunction>
385-
386492
<cffunction name="setClassLoadPaths" access="private" returntype="void" output="false">
387493
<cfargument name="classLoadPaths" type="array" required="true">
388494
<cfset instance.classLoadPaths = arguments.classLoadPaths />
@@ -476,7 +582,7 @@ Copies a directory.
476582
@author Joe Rinehart ([email protected])
477583
@version 1, July 27, 2005
478584
--->
479-
<cffunction name="directoryCopy" access="private" output="true">
585+
<cffunction name="$directoryCopy" access="private" output="true">
480586
<cfargument name="source" required="true" type="string">
481587
<cfargument name="destination" required="true" type="string">
482588
<cfargument name="nameconflict" required="true" default="overwrite">
@@ -494,9 +600,9 @@ Copies a directory.
494600
<cfif contents.type eq "file">
495601
<cffile action="copy" source="#arguments.source#/#name#" destination="#arguments.destination#/#name#" nameconflict="#arguments.nameConflict#">
496602
<cfelseif contents.type eq "dir">
497-
<cfset directoryCopy(arguments.source & dirDelim & name, arguments.destination & dirDelim & name) />
603+
<cfset $directoryCopy(arguments.source & dirDelim & name, arguments.destination & dirDelim & name) />
498604
</cfif>
499605
</cfloop>
500606
</cffunction>
501607

502-
</cfcomponent>
608+
</cfcomponent>

modules/cbjavaloader/models/javaloader/JavaProxy.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!--- Document Information -----------------------------------------------------
1+
<!--- Document Information -----------------------------------------------------
22
33
Title: JavaProxy.cfc
44
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
JavaLoader 1.2
2+
==============
3+
4+
JavaLoader is a library that has been built to ease the use, development and integration of Java within ColdFusion applications.
5+
6+
It has several key features:
7+
8+
1. Dynamically loading Java libraries without having to place them on the ColdFusion classpath
9+
1. Dynamically compiling Java code to be utilised within ColdFusion Applications
10+
1. Providing a Java Dynamic Proxy for ColdFusion Components to allow for seamless interoperability between Java and ColdFusion Components
11+
1. Spring integration with ColdFusion Components
12+
1. and more...
13+
14+
Resources
15+
---------
16+
17+
The homepage for JavaLoader can be found at:
18+
http://www.compoundtheory.com/?action=javaloader.index
19+
20+
To download JavaLoader, [visit RiaForge][1]. ( Trying to keep JavaLoader as the project most downloaded! :) )
21+
22+
Documentation for JavaLoader can be found on the [GitHub Wiki][2].
23+
24+
The source code can be found in the [GitHub repository][3].
25+
26+
Bugs and feature requests can be entered into the [GitHub issue tracker][4].
27+
28+
Support can be found through the [JavaLoader Mailing list][5].
29+
30+
31+
[1]: http://javaloader.riaforge.org/index.cfm?event=action.download
32+
[2]: https://github.com/markmandel/JavaLoader/wiki
33+
[3]: https://github.com/markmandel/JavaLoader
34+
[4]: https://github.com/markmandel/JavaLoader/issues
35+
[5]: https://groups.google.com/forum/#!forum/javaloader-dev
-7.02 KB
Binary file not shown.

0 commit comments

Comments
 (0)