1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.asset; |
16 |
| |
17 |
| import java.io.InputStream; |
18 |
| import java.net.URL; |
19 |
| |
20 |
| import org.apache.hivemind.ApplicationRuntimeException; |
21 |
| import org.apache.hivemind.Location; |
22 |
| import org.apache.hivemind.Resource; |
23 |
| import org.apache.hivemind.util.ClasspathResource; |
24 |
| import org.apache.hivemind.util.Defense; |
25 |
| import org.apache.tapestry.engine.IEngineService; |
26 |
| import org.apache.tapestry.engine.ILink; |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| public class PrivateAsset extends AbstractAsset |
38 |
| { |
39 |
| private IEngineService _assetService; |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
0
| public PrivateAsset(ClasspathResource resourceLocation, Location location)
|
46 |
| { |
47 |
0
| this(resourceLocation, null, location);
|
48 |
| } |
49 |
| |
50 |
415
| public PrivateAsset(ClasspathResource resourceLocation, IEngineService assetService,
|
51 |
| Location location) |
52 |
| { |
53 |
415
| super(resourceLocation, location);
|
54 |
| |
55 |
415
| Defense.notNull(assetService, "assetService");
|
56 |
| |
57 |
415
| _assetService = assetService;
|
58 |
| } |
59 |
| |
60 |
| |
61 |
| |
62 |
| |
63 |
| |
64 |
| |
65 |
| |
66 |
73
| public String buildURL()
|
67 |
| { |
68 |
73
| String path = getResourceLocation().getPath();
|
69 |
| |
70 |
73
| ILink link = _assetService.getLink(false, path);
|
71 |
| |
72 |
73
| return link.getURL();
|
73 |
| } |
74 |
| |
75 |
1
| public InputStream getResourceAsStream()
|
76 |
| { |
77 |
1
| Resource location = getResourceLocation();
|
78 |
| |
79 |
1
| try
|
80 |
| { |
81 |
1
| URL url = location.getResourceURL();
|
82 |
| |
83 |
1
| return url.openStream();
|
84 |
| } |
85 |
| catch (Exception ex) |
86 |
| { |
87 |
0
| throw new ApplicationRuntimeException(AssetMessages.noSuchResource(location.getPath()));
|
88 |
| } |
89 |
| } |
90 |
| |
91 |
| } |