KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > source > FileSourceFactory


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

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 JavaDoc;
31 import java.net.MalformedURLException JavaDoc;
32 import java.net.URL JavaDoc;
33
34 /**
35  * A factory for 'file:' sources.
36  *
37  * @author <a HREF="mailto:sylvain@apache.org">Sylvain Wallez</a>
38  * @version CVS $Id: FileSourceFactory.java 30932 2004-07-29 17:35:38Z vgritsenko $
39  * @deprecated Use the new avalon source resolving instead
40  */

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 JavaDoc location)
51       throws ProcessingException, MalformedURLException JavaDoc, IOException JavaDoc {
52         Source result = new FileSource(location, this.manager);
53         setupLogger(result);
54         return result;
55     }
56
57     public Source getSource(Environment environment, URL JavaDoc base, String JavaDoc location)
58       throws ProcessingException, MalformedURLException JavaDoc, IOException JavaDoc {
59         return getSource(environment, new URL JavaDoc(base, location).toExternalForm());
60     }
61 }
62     
63
Popular Tags