1 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 33 public class ClasspathAssetFactory implements AssetFactory 34 { 35 private IEngineService _assetService; 36 37 public IAsset createAsset(Resource baseResource, String path, Locale locale, Location location) 38 { 39 Resource asset = baseResource.getRelativeResource(path); 40 Resource localized = asset.getLocalization(locale); 41 42 if (localized == null) 43 throw new ApplicationRuntimeException(AssetMessages.missingAsset(path, baseResource), 44 location, null); 45 46 return new PrivateAsset((ClasspathResource) localized, _assetService, location); 47 } 48 49 public IAsset createAsset(Resource resource, Location location) 50 { 51 ClasspathResource cr = (ClasspathResource) resource; 52 53 return new PrivateAsset(cr, _assetService, location); 54 } 55 56 public void setAssetService(IEngineService assetService) 57 { 58 _assetService = assetService; 59 } 60 } | Popular Tags |