KickJava   Java API By Example, From Geeks To Geeks.

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


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.logger.AbstractLogEnabled;
24 import org.apache.avalon.framework.thread.ThreadSafe;
25 import org.apache.excalibur.source.Source;
26 import org.apache.excalibur.source.SourceException;
27 import org.apache.excalibur.source.SourceFactory;
28
29 /**
30  * A factory for the Resource protocol
31  *
32  * @avalon.component
33  * @avalon.service type=SourceFactory
34  * @x-avalon.info name=resource-source
35  * @x-avalon.lifestyle type=singleton
36  *
37  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
38  * @version $Id: ResourceSourceFactory.java,v 1.4 2004/02/28 11:47:24 cziegeler Exp $
39  */

40 public class ResourceSourceFactory
41     extends AbstractLogEnabled
42     implements SourceFactory, ThreadSafe
43 {
44     /**
45      * Get a {@link Source} object.
46      * The factory creates a new {@link Source} object that can be used
47      * by the application. However, when this source object is not needed
48      * anymore it has to be released again using the {@link #release(Source)}
49      * method.
50      *
51      * @param location The URI to resolve - this URI includes the protocol.
52      * @param parameters This is optional.
53      */

54     public Source getSource( String JavaDoc location, Map JavaDoc parameters )
55         throws MalformedURLException JavaDoc, IOException JavaDoc, SourceException
56     {
57         if( getLogger().isDebugEnabled() )
58         {
59             final String JavaDoc message = "Creating source object for " + location;
60             getLogger().debug( message );
61         }
62         return new ResourceSource( location );
63     }
64     
65     /**
66      * Release a {@link Source} object.
67      */

68     public void release( Source source )
69     {
70         if( null != source && getLogger().isDebugEnabled() )
71         {
72             final String JavaDoc message = "Releasing source object for " + source.getURI();
73             getLogger().debug( message );
74         }
75         // do nothing here
76
}
77     
78 }
79
Popular Tags