1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.components.script.jsr223; |
12 | |
|
13 | |
import org.mule.umo.UMOEventContext; |
14 | |
import org.mule.umo.lifecycle.Callable; |
15 | |
|
16 | |
import javax.script.Bindings; |
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | 4 | public class ScriptComponent extends AbstractScriptComponent implements Callable |
24 | |
{ |
25 | |
|
26 | |
protected void populateBindings(Bindings namespace, UMOEventContext context) |
27 | |
{ |
28 | 4 | super.populateBindings(namespace, context); |
29 | 4 | namespace.put("result", new Object()); |
30 | 4 | } |
31 | |
|
32 | |
public Object onCall(UMOEventContext eventContext) throws Exception |
33 | |
{ |
34 | 4 | Bindings bindings = this.getBindings(); |
35 | 4 | populateBindings(bindings, eventContext); |
36 | 4 | Object result = runScript(bindings); |
37 | 4 | if (result == null) |
38 | |
{ |
39 | 0 | result = bindings.get("result"); |
40 | |
} |
41 | 4 | return result; |
42 | |
} |
43 | |
|
44 | |
} |