KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > source > impl > HTTPClientSourceFactory


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.excalibur.source.impl;
18
19 import java.io.IOException JavaDoc;
20 import java.net.MalformedURLException JavaDoc;
21 import java.util.Map JavaDoc;
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 /**
34  * {@link HTTPClientSource} Factory class.
35  *
36  * @avalon.component
37  * @avalon.service type=SourceFactory
38  * @x-avalon.info name=httpclient-source
39  * @x-avalon.lifestyle type=singleton
40  *
41  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
42  * @version CVS $Id: HTTPClientSourceFactory.java,v 1.4 2004/02/28 11:47:24 cziegeler Exp $
43  */

44 public class HTTPClientSourceFactory extends AbstractLogEnabled
45     implements SourceFactory, Parameterizable, ThreadSafe
46 {
47     /**
48      * Configuration information.
49      */

50     private Parameters m_parameters;
51
52     /**
53      * Creates a {@link HTTPClientSource} instance.
54      */

55     public Source getSource( final String JavaDoc uri, final Map JavaDoc sourceParams )
56         throws MalformedURLException JavaDoc, IOException JavaDoc
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 JavaDoc e )
68         {
69             throw e;
70         }
71         catch ( final IOException JavaDoc e )
72         {
73             throw e;
74         }
75         catch ( final Exception JavaDoc e )
76         {
77             final StringBuffer JavaDoc message = new StringBuffer JavaDoc();
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     /**
86      * Parameterize this {@link SourceFactory}.
87      *
88      * @param params {@link Parameters} instance
89      * @exception ParameterException if an error occurs
90      */

91     public void parameterize( final Parameters params )
92         throws ParameterException
93     {
94         m_parameters = params;
95     }
96
97     /**
98      * Releases the given {@link Source} object.
99      *
100      * @param source {@link Source} object to be released
101      */

102     public void release( final Source source )
103     {
104         // empty for the moment
105
}
106 }
107
Popular Tags