Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
ofbiz-rhino
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
b3c08c71
authored
2014-04-18 17:34:13 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Allow for multiple pre-loaded config files.
1 parent
74582d6e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
src/com/brainfood/ofbiz/rhino/OfbizRhinoContainer.java
src/com/brainfood/rhino/Require.java
src/com/brainfood/ofbiz/rhino/OfbizRhinoContainer.java
View file @
b3c08c7
...
...
@@ -89,13 +89,17 @@ public class OfbizRhinoContainer extends RhinoContainer<OfbizRhinoContainer> {
private
static
final
UtilCache
<
String
,
Require
>
cache
=
UtilCache
.
getOrCreateUtilCache
(
"OfbizRhinoContainer.Require"
,
0
,
5
,
10000
,
false
,
false
);
public
static
Require
getOrCreateRequire
(
String
appLocation
,
String
configPath
,
String
...
deps
)
throws
Exception
{
public
static
Require
getOrCreateRequire
(
String
appLocation
,
List
<
String
>
configPaths
,
List
<
String
>
deps
)
throws
Exception
{
return
getOrCreateRequire
(
appLocation
,
configPaths
.
toArray
(
new
String
[
configPaths
.
size
()]),
deps
.
toArray
(
new
String
[
deps
.
size
()]));
}
public
static
Require
getOrCreateRequire
(
String
appLocation
,
String
[]
configPaths
,
String
[]
deps
)
throws
Exception
{
Require
require
=
cache
.
get
(
appLocation
);
if
(
require
==
null
)
{
File
base
=
new
File
(
FlexibleLocation
.
resolveLocation
(
appLocation
).
getPath
());
OfbizRhinoContainer
container
=
new
OfbizRhinoContainer
(
base
);
File
rLocation
=
new
File
(
FlexibleLocation
.
resolveLocation
(
"component://ofbiz-rhino/lib/r.js"
).
getPath
());
require
=
new
Require
(
container
,
rLocation
,
configPath
);
require
=
new
Require
(
container
,
rLocation
,
configPath
s
);
for
(
String
dep:
deps
)
{
require
.
require
(
dep
);
}
...
...
src/com/brainfood/rhino/Require.java
View file @
b3c08c7
...
...
@@ -19,9 +19,9 @@ public class Require {
private
final
Loader
loader
;
private
final
Function
require
;
public
Require
(
RhinoContainer
<?>
container
,
File
rLocation
,
String
configPath
)
throws
Exception
{
public
Require
(
RhinoContainer
<?>
container
,
File
rLocation
,
String
...
configPaths
)
throws
Exception
{
this
.
container
=
container
;
this
.
loader
=
new
Loader
(
container
,
rLocation
,
configPath
);
this
.
loader
=
new
Loader
(
container
,
rLocation
,
configPath
s
);
this
.
require
=
container
.
run
(
loader
);
}
...
...
@@ -74,12 +74,12 @@ public class Require {
public
static
class
Loader
extends
InContext
<
Function
>
{
private
final
RhinoContainer
<?>
container
;
private
final
File
rLocation
;
private
final
String
configPath
;
private
final
String
[]
configPaths
;
public
Loader
(
RhinoContainer
<?>
container
,
File
rLocation
,
String
configPath
)
{
public
Loader
(
RhinoContainer
<?>
container
,
File
rLocation
,
String
...
configPaths
)
{
this
.
container
=
container
;
this
.
rLocation
=
rLocation
;
this
.
configPath
=
configPath
;
this
.
configPath
s
=
configPaths
;
}
@Override
...
...
@@ -94,7 +94,7 @@ public class Require {
Scriptable
argsObj
=
cx
.
newArray
(
this
,
new
Object
[]
{});
defineProperty
(
"arguments"
,
argsObj
,
ScriptableObject
.
DONTENUM
);
if
(
configPath
!=
null
&&
configPath
.
length
()
>
0
)
{
for
(
String
configPath:
configPaths
)
{
container
.
processSource
(
cx
,
this
,
configPath
);
}
int
optLevel
=
cx
.
getOptimizationLevel
();
...
...
@@ -114,10 +114,6 @@ public class Require {
public
void
load
(
Context
cx
,
Object
[]
args
,
Function
funObj
)
throws
FileNotFoundException
,
IOException
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
String
path
=
Context
.
toString
(
args
[
i
]);
if
(
path
.
endsWith
(
"/jquery.js"
))
{
container
.
print
(
cx
,
this
,
new
Object
[]
{
"Skipping file "
+
path
},
funObj
);
continue
;
}
container
.
print
(
cx
,
this
,
new
Object
[]
{
"Loading file "
+
path
},
funObj
);
container
.
processSource
(
cx
,
this
,
path
);
}
...
...
Please
register
or
sign in
to post a comment