Skip to content

Commit 263abbd

Browse files
committed
finalized for 1.0.0 release
1 parent 304783e commit 263abbd

27 files changed

+165
-151
lines changed

apidocs/Application.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ component{
99

1010
rootPath = REReplaceNoCase( this.mappings[ "/colddoc" ], "apidocs(\\|\/)$", "" );
1111
this.mappings[ "/root" ] = rootPath;
12-
this.mappings[ "/javaloader" ] = rootPath & "modules/javaloader/models";
12+
this.mappings[ "/cbjavaloader" ] = rootPath & "modules/cbjavaloader/models";
1313

1414
// request start
1515
public boolean function onRequestStart(String targetPage){

apidocs/index.cfm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<cfparam name="url.version" default="0">
2-
<cfparam name="url.path" default="#expandPath( "./JavaLoader-APIDocs" )#">
2+
<cfparam name="url.path" default="#expandPath( "./CBJavaLoader-APIDocs" )#">
33
<cfscript>
4-
docName = "JavaLoader-APIDocs";
5-
base = expandPath( "/javaloader" );
4+
docName = "CBJavaLoader-APIDocs";
5+
base = expandPath( "/cbjavaloader" );
66
77
colddoc = new ColdDoc();
8-
strategy = new colddoc.strategy.api.HTMLAPIStrategy( url.path, "JavaLoader v#url.version#" );
8+
strategy = new colddoc.strategy.api.HTMLAPIStrategy( url.path, "CBJavaLoader v#url.version#" );
99
colddoc.setStrategy( strategy );
1010
11-
colddoc.generate( inputSource=base, outputDir=url.path, inputMapping="javaloader" );
11+
colddoc.generate( inputSource=base, outputDir=url.path, inputMapping="cbjavaloader" );
1212
</cfscript>
1313

1414
<!---

handlers/Main.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
component{
55

6-
property name="javaloader" inject="loader@javaloader";
6+
property name="javaloader" inject="loader@cbjavaloader";
77

88
// Index
99
any function index( event,rc, prc ){

modules/javaloader/ModuleConfig.cfc renamed to modules/cbjavaloader/ModuleConfig.cfc

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,65 +11,39 @@ component {
1111
this.author = "Ortus Solutions";
1212
this.webURL = "http://www.ortussolutions.com";
1313
this.description = "A JavaLoader Module for ColdBox";
14-
this.version = "1.0.0.@build.version@";
14+
this.version = "1.0.0+@build.version@";
1515
// If true, looks for views in the parent first, if not found, then in the module. Else vice-versa
1616
this.viewParentLookup = true;
1717
// If true, looks for layouts in the parent first, if not found, then in module. Else vice-versa
1818
this.layoutParentLookup = true;
1919
// Module Entry Point
20-
this.entryPoint = "javaloader";
21-
20+
this.entryPoint = "cbjavaloader";
21+
// CF Mapping
22+
this.cfmapping = "cbjavaloader";
23+
2224
function configure(){
23-
24-
// Java Loader Settings
25-
settings = {
26-
// The array paths to load
27-
loadPaths = getJars( getDirectoryFromPath( getCurrentTemplatePath() ) & "lib" ),
28-
// Load ColdFusion classes with loader
29-
loadColdFusionClassPath = false,
30-
// Attach a custom class loader as a parent
31-
parentClassLoader = "",
32-
// Directories that contain Java source code that are to be dynamically compiled
33-
sourceDirectories = [],
34-
// the directory to build the .jar file for dynamic compilation in, defaults to ./tmp
35-
compileDirectory = getDirectoryFromPath( getCurrentTemplatePath() ) & "model/javaloader/tmp",
36-
// Whether or not the source is trusted, i.e. it is going to change? Defaults to false, so changes will be recompiled and loaded
37-
trustedSource = false
38-
};
39-
40-
// Custom Declared Points
41-
interceptorSettings = {
42-
customInterceptionPoints = ""
43-
};
44-
45-
// Custom Declared Interceptors
46-
interceptors = [
47-
];
48-
4925
// Register Custom DSL, don't map it because it is too late, mapping DSLs are only good by the parent app
5026
controller.getWireBox().registerDSL( namespace="javaloader", path="#moduleMapping#.models.JavaLoaderDSL" );
51-
52-
// Bind Loader Proxy Class
53-
binder.map( "loader@javaloader" )
54-
.to( "#moduleMapping#.models.Loader" );
55-
56-
// Bind Core JavaLoader
57-
binder.map( "jl@javaloader" )
58-
.to( "#moduleMapping#.models.javaloader.JavaLoader" )
59-
.initArg( name="loadPaths", value=settings.loadPaths )
60-
.initArg( name="loadColdFusionClassPath", value=settings.loadColdFusionClassPath )
61-
.initArg( name="parentClassLoader", value=settings.parentClassLoader )
62-
.initArg( name="sourceDirectories", value=settings.sourceDirectories )
63-
.initArg( name="compileDirectory", value=settings.compileDirectory )
64-
.initArg( name="trustedSource", value=settings.trustedSource );
6527
}
6628

6729
/**
6830
* Fired when the module is registered and activated.
6931
*/
7032
function onLoad(){
33+
var settings = controller.getConfigSettings();
34+
// parse parent settings
35+
parseParentSettings();
36+
// Bind Core JavaLoader
37+
binder.map( "jl@cbjavaloader" )
38+
.to( "#moduleMapping#.models.javaloader.JavaLoader" )
39+
.initArg( name="loadPaths", value=settings.javaloader.loadPaths )
40+
.initArg( name="loadColdFusionClassPath", value=settings.javaloader.loadColdFusionClassPath )
41+
.initArg( name="parentClassLoader", value=settings.javaloader.parentClassLoader )
42+
.initArg( name="sourceDirectories", value=settings.javaloader.sourceDirectories )
43+
.initArg( name="compileDirectory", value=settings.javaloader.compileDirectory )
44+
.initArg( name="trustedSource", value=settings.javaloader.trustedSource );
7145
// Load JavaLoader and class loading
72-
wirebox.getInstance( "loader@javaloader" ).setup();
46+
wirebox.getInstance( "loader@cbjavaloader" ).setup();
7347
}
7448

7549
/**
@@ -90,4 +64,32 @@ component {
9064
return directoryList( arguments.dirPath, true, "array", arguments.filter, "name desc" );
9165
}
9266

67+
/**
68+
* parse parent settings
69+
*/
70+
private function parseParentSettings(){
71+
var oConfig = controller.getSetting( "ColdBoxConfig" );
72+
var configStruct = controller.getConfigSettings();
73+
var javaLoaderDSL = oConfig.getPropertyMixin( "javaloader", "variables", structnew() );
74+
75+
//defaults
76+
configStruct.javaloader = {
77+
// The array paths to load
78+
loadPaths = getJars( getDirectoryFromPath( getCurrentTemplatePath() ) & "lib" ),
79+
// Load ColdFusion classes with loader
80+
loadColdFusionClassPath = false,
81+
// Attach a custom class loader as a parent
82+
parentClassLoader = "",
83+
// Directories that contain Java source code that are to be dynamically compiled
84+
sourceDirectories = [],
85+
// the directory to build the .jar file for dynamic compilation in, defaults to ./tmp
86+
compileDirectory = getDirectoryFromPath( getCurrentTemplatePath() ) & "model/javaloader/tmp",
87+
// Whether or not the source is trusted, i.e. it is going to change? Defaults to false, so changes will be recompiled and loaded
88+
trustedSource = false
89+
};
90+
91+
// incorporate settings
92+
structAppend( configStruct.javaloader, javaLoaderDSL, true );
93+
}
94+
9395
}

modules/javaloader/box.json renamed to modules/cbjavaloader/box.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name" : "JavaLoader",
33
"version" : "1.0.0",
44
"author" : "Luis Majano <[email protected]",
5-
"slug" : "javaloader",
5+
"slug" : "cbjavaloader",
66
"type" : "modules",
77
"homepage" : "http://www.coldbox.org",
88
"documentation" : "http://wiki.coldbox.org",
@@ -16,6 +16,6 @@
1616
],
1717
"engines" : [
1818
{ "type" : "railo", "version" : ">4.1" },
19-
{ "type" : "adobe", "version" : ">9.02" },
19+
{ "type" : "adobe", "version" : ">9.02" }
2020
]
2121
}

modules/cbjavaloader/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CHANGELOG
2+
=========
3+
4+
##1.0.0
5+
* Create first module version
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
INSTRUCTIONS
2+
============
3+
4+
Just drop into your **modules** folder or use the box-cli to install
5+
6+
`box install cbjavaloader`
7+
8+
The module has a default folder called `lib` where any jars you drop there will be class loaded automatically. However, we recommed using the `loadpaths` setting for selecting an array of locations to class load, so when the module updates you won't loose those files.
9+
10+
## Models
11+
The module registers the following mapping in WireBox: `loader@cbjavaloader`. Which is the class you will use to class load, append paths and much more. Check out the included API Docs for much more information.
12+
13+
## WireBox DSL
14+
The module also registers a new WireBox DSL called `javaloader`. You can then use this custom DSL for injecting direct java class loaded classes very easily:
15+
16+
```js
17+
property name="name" inject="javaloader:{class-path}";
18+
property name="hello" inject="javaloader:HelloWorld";
19+
property name="buffer" inject="javaloader:org.class.path.StringBuffer";
20+
```
21+
22+
## Settings
23+
Here are the module settings you can place in your `ColdBox.cfc` under an `javaloader` structure:
24+
25+
```js
26+
// JavaLoader settings
27+
javaloader = {
28+
// The array paths to load
29+
loadPaths = getJars( getDirectoryFromPath( getCurrentTemplatePath() ) & "lib" ),
30+
// Load ColdFusion classes with loader
31+
loadColdFusionClassPath = false,
32+
// Attach a custom class loader as a parent
33+
parentClassLoader = "",
34+
// Directories that contain Java source code that are to be dynamically compiled
35+
sourceDirectories = [],
36+
// the directory to build the .jar file for dynamic compilation in, defaults to ./tmp
37+
compileDirectory = getDirectoryFromPath( getCurrentTemplatePath() ) & "model/javaloader/tmp",
38+
// Whether or not the source is trusted, i.e. it is going to change? Defaults to false, so changes will be recompiled and loaded
39+
trustedSource = false
40+
};
41+
```
42+
43+
44+
Below is a simple example:
45+
46+
```js
47+
/**
48+
* My Event Handler Hint
49+
*/
50+
component{
51+
// Inject JavaLoader
52+
property name="javaloader" inject="loader@cbjavaloader";
53+
54+
// Index
55+
any function index( event,rc, prc ){
56+
// creat a java class
57+
prc.hello = javaloader.create( "HelloWorld" ).init().hello();
58+
}
59+
60+
// Run on first init
61+
any function onAppInit( event, rc, prc ){
62+
// on application start, load up more jars
63+
javaloader.appendPaths( getSetting( "ApplicationPath" ) & "jars" );
64+
}
65+
66+
}
67+
```
File renamed without changes.
File renamed without changes.

modules/javaloader/models/JavaLoaderDSL.cfc renamed to modules/cbjavaloader/models/JavaLoaderDSL.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ component implements="coldbox.system.ioc.dsl.IDSLBuilder" accessors="true"{
3737
var className = listLast( arguments.definition.dsl, ":" );
3838

3939
// Get Dependency, if not found, exception is thrown
40-
return variables.injector.getInstance( "loader@javaloader" ).create( className );
40+
return variables.injector.getInstance( "loader@cbjavaloader" ).create( className );
4141
}
4242

4343
}

0 commit comments

Comments
 (0)