1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
package org.apache.tapestry.enhance; |
16 | |
|
17 | |
import org.apache.hivemind.ApplicationRuntimeException; |
18 | |
import org.apache.hivemind.Locatable; |
19 | |
import org.apache.hivemind.Location; |
20 | |
import org.apache.hivemind.Resource; |
21 | |
import org.apache.hivemind.util.Defense; |
22 | |
import org.apache.tapestry.IScript; |
23 | |
import org.apache.tapestry.engine.IScriptSource; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
public class DeferredScriptImpl implements DeferredScript, Locatable |
30 | |
{ |
31 | |
final Resource _scriptResource; |
32 | |
|
33 | |
final IScriptSource _scriptSource; |
34 | |
|
35 | |
final Location _location; |
36 | |
|
37 | |
public DeferredScriptImpl(Resource resource, IScriptSource source, Location location) |
38 | 0 | { |
39 | 0 | Defense.notNull(resource, "resource"); |
40 | 0 | Defense.notNull(source, "source"); |
41 | |
|
42 | 0 | _scriptResource = resource; |
43 | 0 | _scriptSource = source; |
44 | 0 | _location = location; |
45 | 0 | } |
46 | |
|
47 | |
public IScript getScript() |
48 | |
{ |
49 | |
|
50 | |
|
51 | |
|
52 | |
try |
53 | |
{ |
54 | 0 | return _scriptSource.getScript(_scriptResource); |
55 | |
} |
56 | 0 | catch (Exception ex) |
57 | |
{ |
58 | |
|
59 | |
|
60 | 0 | throw new ApplicationRuntimeException(ex.getMessage(), _location, ex); |
61 | |
} |
62 | |
} |
63 | |
|
64 | |
public Location getLocation() |
65 | |
{ |
66 | 0 | return _location; |
67 | |
} |
68 | |
|
69 | |
public String toString() |
70 | |
{ |
71 | 0 | return "DeferredScriptImpl[" + _scriptResource + "]"; |
72 | |
} |
73 | |
} |