1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.components.script.jsr223; |
12 | |
|
13 | |
import org.mule.MuleManager; |
14 | |
import org.mule.umo.UMOEventContext; |
15 | |
import org.mule.umo.lifecycle.InitialisationException; |
16 | |
import org.mule.util.MuleLogger; |
17 | |
|
18 | |
import javax.script.Bindings; |
19 | |
|
20 | 6 | public class AbstractScriptComponent extends Scriptable |
21 | |
{ |
22 | |
private Bindings bindings; |
23 | |
|
24 | |
public void initialise() throws InitialisationException |
25 | |
{ |
26 | 6 | super.initialise(); |
27 | 6 | bindings = getScriptEngine().createBindings(); |
28 | 6 | } |
29 | |
|
30 | |
protected void populateBindings(Bindings namespace, UMOEventContext context) |
31 | |
{ |
32 | 6 | namespace.put("eventContext", context); |
33 | 6 | namespace.put("managementContext", MuleManager.getInstance()); |
34 | 6 | namespace.put("message", context.getMessage()); |
35 | 6 | namespace.put("descriptor", context.getComponentDescriptor()); |
36 | 6 | namespace.put("componentNamespace", this.bindings); |
37 | 6 | namespace.put("log", new MuleLogger(logger)); |
38 | 6 | } |
39 | |
|
40 | |
public Bindings getBindings() |
41 | |
{ |
42 | 6 | return bindings; |
43 | |
} |
44 | |
} |
45 | |
|
46 | |
|