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