|
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.tapestry.Tapestry; |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| public class ExternalAsset extends AbstractAsset |
|
33 |
| { |
|
34 |
| private String _URL; |
|
35 |
| |
|
36 |
9
| public ExternalAsset(String URL, Location location)
|
|
37 |
| { |
|
38 |
9
| super(null, location);
|
|
39 |
| |
|
40 |
9
| _URL = URL;
|
|
41 |
| } |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
3
| public String buildURL()
|
|
49 |
| { |
|
50 |
3
| return _URL;
|
|
51 |
| } |
|
52 |
| |
|
53 |
0
| public InputStream getResourceAsStream()
|
|
54 |
| { |
|
55 |
0
| URL url;
|
|
56 |
| |
|
57 |
0
| try
|
|
58 |
| { |
|
59 |
0
| url = new URL(_URL);
|
|
60 |
| |
|
61 |
0
| return url.openStream();
|
|
62 |
| } |
|
63 |
| catch (Exception ex) |
|
64 |
| { |
|
65 |
| |
|
66 |
| |
|
67 |
0
| throw new ApplicationRuntimeException(Tapestry.format("ExternalAsset.resource-missing", _URL), ex);
|
|
68 |
| } |
|
69 |
| |
|
70 |
| } |
|
71 |
| |
|
72 |
6
| public String toString()
|
|
73 |
| { |
|
74 |
6
| return "ExternalAsset[" + _URL + "]";
|
|
75 |
| } |
|
76 |
| } |