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