1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.asset; |
16 |
| |
17 |
| import java.util.Locale; |
18 |
| |
19 |
| import org.apache.hivemind.ApplicationRuntimeException; |
20 |
| import org.apache.hivemind.Location; |
21 |
| import org.apache.hivemind.Resource; |
22 |
| import org.apache.hivemind.util.ClasspathResource; |
23 |
| import org.apache.tapestry.IAsset; |
24 |
| import org.apache.tapestry.engine.IEngineService; |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| public class ClasspathAssetFactory implements AssetFactory |
34 |
| { |
35 |
| private IEngineService _assetService; |
36 |
| |
37 |
50
| public IAsset createAsset(Resource baseResource, String path, Locale locale, Location location)
|
38 |
| { |
39 |
50
| Resource asset = baseResource.getRelativeResource(path);
|
40 |
50
| Resource localized = asset.getLocalization(locale);
|
41 |
| |
42 |
50
| if (localized == null)
|
43 |
0
| throw new ApplicationRuntimeException(AssetMessages.missingAsset(path, baseResource),
|
44 |
| location, null); |
45 |
| |
46 |
50
| return new PrivateAsset((ClasspathResource) localized, _assetService, location);
|
47 |
| } |
48 |
| |
49 |
25
| public IAsset createAsset(Resource resource, Location location)
|
50 |
| { |
51 |
25
| ClasspathResource cr = (ClasspathResource) resource;
|
52 |
| |
53 |
25
| return new PrivateAsset(cr, _assetService, location);
|
54 |
| } |
55 |
| |
56 |
27
| public void setAssetService(IEngineService assetService)
|
57 |
| { |
58 |
27
| _assetService = assetService;
|
59 |
| } |
60 |
| } |