KickJava   Java API By Example, From Geeks To Geeks.

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


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.thread.ThreadSafe;
24 import org.apache.excalibur.source.Source;
25 import org.apache.excalibur.source.SourceFactory;
26 import org.apache.excalibur.source.URIAbsolutizer;
27 import org.apache.excalibur.source.SourceUtil;
28
29 /**
30  * A factory for filesystem-based sources (see {@link FileSource}).
31  *
32  * @avalon.component
33  * @avalon.service type=SourceFactory
34  * @x-avalon.info name=file-source
35  * @x-avalon.lifestyle type=singleton
36  *
37  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
38  * @version $Id: FileSourceFactory.java,v 1.4 2004/02/28 11:47:24 cziegeler Exp $
39  */

40 public class FileSourceFactory implements SourceFactory, ThreadSafe, URIAbsolutizer
41 {
42
43     /**
44      * @see org.apache.excalibur.source.SourceFactory#getSource(java.lang.String, java.util.Map)
45      */

46     public Source getSource(String JavaDoc location, Map JavaDoc parameters) throws IOException JavaDoc, MalformedURLException JavaDoc
47     {
48         return new FileSource(location);
49     }
50
51     /**
52      * Does nothing, since {@link FileSource}s don't need to be released.
53      *
54      * @see org.apache.excalibur.source.SourceFactory#release(org.apache.excalibur.source.Source)
55      */

56     public void release(Source source)
57     {
58         // Nothing to do here
59
}
60
61     public String JavaDoc absolutize(String JavaDoc baseURI, String JavaDoc location)
62     {
63         // Call the absolutize utility method with false for the normalizePath argument.
64
// This avoids the removal of "../" from the path.
65
// This way, the "../" will be resolved by the operating system, which might
66
// do things differently e.g. in case of symbolic links.
67
return SourceUtil.absolutize(baseURI, location, false, false);
68     }
69 }
70
Popular Tags