1
2
3
4
5
6
7
8
9
10 package org.mule.module.scripting.component;
11
12 import org.mule.api.registry.Registry;
13
14 import java.util.Collection;
15 import java.util.Map;
16 import java.util.Set;
17
18 import javax.script.Bindings;
19
20
21
22
23
24
25 public class RegistryLookupBindings implements Bindings
26 {
27 private final Bindings delegate;
28 private final Registry registry;
29
30 public RegistryLookupBindings(Registry registry, Bindings delegate)
31 {
32 this.registry = registry;
33 this.delegate = delegate;
34 }
35
36 public Object put(String name, Object value)
37 {
38 return delegate.put(name, value);
39 }
40
41 public void putAll(Map<? extends String, ? extends Object> toMerge)
42 {
43 delegate.putAll(toMerge);
44 }
45
46 public boolean containsKey(Object key)
47 {
48 boolean containsKey = delegate.containsKey(key);
49 if (!containsKey)
50 {
51 return registry.lookupObject(key.toString()) != null;
52 }
53 return containsKey;
54 }
55
56 public Object get(Object key)
57 {
58 Object object = delegate.get(key);
59 if (object == null)
60 {
61 object = registry.lookupObject(key.toString());
62 }
63 return object;
64 }
65
66 public Object remove(Object key)
67 {
68 return delegate.remove(key);
69 }
70
71 public int size()
72 {
73 return delegate.size();
74 }
75
76 public boolean isEmpty()
77 {
78 return delegate.isEmpty();
79 }
80
81 public boolean containsValue(Object value)
82 {
83 return delegate.containsValue(value);
84 }
85
86 public void clear()
87 {
88 delegate.clear();
89 }
90
91 public Set<String> keySet()
92 {
93 return delegate.keySet();
94 }
95
96 public Collection<Object> values()
97 {
98 return delegate.values();
99 }
100
101 public Set<java.util.Map.Entry<String, Object>> entrySet()
102 {
103 return delegate.entrySet();
104 }
105
106 public boolean equals(Object o)
107 {
108 return delegate.equals(o);
109 }
110
111 public int hashCode()
112 {
113 return delegate.hashCode();
114 }
115
116
117 }