1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.services.impl; |
16 |
| |
17 |
| import java.util.HashMap; |
18 |
| import java.util.Iterator; |
19 |
| import java.util.List; |
20 |
| import java.util.Map; |
21 |
| |
22 |
| import org.apache.hivemind.Location; |
23 |
| import org.apache.tapestry.IBinding; |
24 |
| import org.apache.tapestry.IComponent; |
25 |
| import org.apache.tapestry.binding.BindingFactory; |
26 |
| import org.apache.tapestry.binding.BindingSource; |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| public class BindingSourceImpl implements BindingSource |
35 |
| { |
36 |
| private List _contributions; |
37 |
| |
38 |
| |
39 |
| |
40 |
| |
41 |
| private Map _factoryMap = new HashMap(); |
42 |
| |
43 |
42
| public void initializeService()
|
44 |
| { |
45 |
42
| Iterator i = _contributions.iterator();
|
46 |
| |
47 |
42
| while (i.hasNext())
|
48 |
| { |
49 |
460
| BindingPrefixContribution c = (BindingPrefixContribution) i.next();
|
50 |
| |
51 |
460
| _factoryMap.put(c.getPrefix(), c.getFactory());
|
52 |
| } |
53 |
| } |
54 |
| |
55 |
1564
| public IBinding createBinding(IComponent component, String bindingDescription,
|
56 |
| String reference, String defaultPrefix, Location location) |
57 |
| { |
58 |
1564
| String prefix = defaultPrefix;
|
59 |
1564
| String path = reference;
|
60 |
| |
61 |
1564
| int colonx = reference.indexOf(':');
|
62 |
| |
63 |
1564
| if (colonx > 1)
|
64 |
| { |
65 |
784
| String pathPrefix = reference.substring(0, colonx);
|
66 |
| |
67 |
784
| if (_factoryMap.containsKey(pathPrefix))
|
68 |
| { |
69 |
783
| prefix = pathPrefix;
|
70 |
| |
71 |
783
| path = reference.substring(colonx + 1);
|
72 |
| } |
73 |
| } |
74 |
| |
75 |
1564
| BindingFactory factory = (BindingFactory) _factoryMap.get(prefix);
|
76 |
| |
77 |
1564
| return factory.createBinding(component, bindingDescription, path, location);
|
78 |
| } |
79 |
| |
80 |
42
| public void setContributions(List contributions)
|
81 |
| { |
82 |
42
| _contributions = contributions;
|
83 |
| } |
84 |
| } |