1 16 package org.apache.cocoon.components.xscript; 17 18 import org.apache.excalibur.source.Source; 19 import org.apache.excalibur.source.SourceException; 20 import org.apache.excalibur.source.SourceResolver; 21 import org.apache.excalibur.source.SourceNotFoundException; 22 23 import java.io.IOException ; 24 import java.io.InputStream ; 25 26 33 public class XScriptObjectFromURL extends XScriptObject { 34 35 39 String systemId; 40 41 44 long lastModified; 45 46 47 public XScriptObjectFromURL(XScriptManager manager, String systemId) { 48 super(manager); 49 this.systemId = systemId; 50 } 51 52 public InputStream getInputStream() throws IOException , SourceNotFoundException { 53 SourceResolver resolver = null; 54 Source source = null; 55 try { 56 resolver = (SourceResolver) serviceManager.lookup(SourceResolver.ROLE); 57 source = resolver.resolveURI(this.systemId); 58 return source.getInputStream(); 59 } catch (Exception e) { 60 throw new SourceException("Exception during processing of " + this.systemId, e); 61 } finally { 62 if (resolver != null) { 63 resolver.release(source); 64 serviceManager.release(resolver); 65 } 66 } 67 } 68 69 public long getContentLength() { 70 return -1; 71 } 72 73 public long getLastModified() { 74 return 0; 75 } 76 77 public String toString() { 78 return new StringBuffer ("XScriptObjectFromURL(systemId = ").append(systemId).append(")").toString(); 79 } 80 81 public String getURI() { 82 return "xscript:url:" + systemId; 84 } 85 } 86 | Popular Tags |