1 17 package org.apache.excalibur.source.impl; 18 19 import java.io.IOException ; 20 import java.net.MalformedURLException ; 21 import java.util.Map ; 22 23 import org.apache.avalon.framework.container.ContainerUtil; 24 import org.apache.avalon.framework.logger.AbstractLogEnabled; 25 import org.apache.avalon.framework.parameters.ParameterException; 26 import org.apache.avalon.framework.parameters.Parameterizable; 27 import org.apache.avalon.framework.parameters.Parameters; 28 import org.apache.avalon.framework.thread.ThreadSafe; 29 import org.apache.excalibur.source.Source; 30 import org.apache.excalibur.source.SourceException; 31 import org.apache.excalibur.source.SourceFactory; 32 33 44 public class HTTPClientSourceFactory extends AbstractLogEnabled 45 implements SourceFactory, Parameterizable, ThreadSafe 46 { 47 50 private Parameters m_parameters; 51 52 55 public Source getSource( final String uri, final Map sourceParams ) 56 throws MalformedURLException , IOException 57 { 58 try 59 { 60 final HTTPClientSource source = 61 new HTTPClientSource( uri, sourceParams ); 62 ContainerUtil.enableLogging( source, getLogger() ); 63 ContainerUtil.parameterize( source, m_parameters ); 64 ContainerUtil.initialize( source ); 65 return source; 66 } 67 catch ( final MalformedURLException e ) 68 { 69 throw e; 70 } 71 catch ( final IOException e ) 72 { 73 throw e; 74 } 75 catch ( final Exception e ) 76 { 77 final StringBuffer message = new StringBuffer (); 78 message.append( "Exception thrown while creating " ); 79 message.append( HTTPClientSource.class.getName() ); 80 81 throw new SourceException( message.toString(), e ); 82 } 83 } 84 85 91 public void parameterize( final Parameters params ) 92 throws ParameterException 93 { 94 m_parameters = params; 95 } 96 97 102 public void release( final Source source ) 103 { 104 } 106 } 107 | Popular Tags |