1 16 17 package org.apache.cocoon.components.source; 18 19 import org.apache.avalon.framework.component.ComponentException; 20 import org.apache.avalon.framework.component.ComponentManager; 21 import org.apache.avalon.framework.component.Composable; 22 import org.apache.avalon.framework.logger.AbstractLogEnabled; 23 import org.apache.avalon.framework.thread.ThreadSafe; 24 25 import org.apache.cocoon.components.source.SourceFactory; 26 import org.apache.cocoon.environment.Environment; 27 import org.apache.cocoon.environment.Source; 28 import org.apache.cocoon.ProcessingException; 29 30 import java.io.IOException ; 31 import java.net.MalformedURLException ; 32 import java.net.URL ; 33 34 41 public class FileSourceFactory extends AbstractLogEnabled 42 implements SourceFactory, Composable, ThreadSafe { 43 44 private ComponentManager manager; 45 46 public void compose(ComponentManager manager) throws ComponentException { 47 this.manager = manager; 48 } 49 50 public Source getSource(Environment environment, String location) 51 throws ProcessingException, MalformedURLException , IOException { 52 Source result = new FileSource(location, this.manager); 53 setupLogger(result); 54 return result; 55 } 56 57 public Source getSource(Environment environment, URL base, String location) 58 throws ProcessingException, MalformedURLException , IOException { 59 return getSource(environment, new URL (base, location).toExternalForm()); 60 } 61 } 62 63 | Popular Tags |