01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.cocoon.components.source;
19:
20: import org.apache.avalon.framework.component.ComponentException;
21: import org.apache.avalon.framework.component.ComponentManager;
22: import org.apache.avalon.framework.component.Composable;
23: import org.apache.avalon.framework.logger.AbstractLogEnabled;
24: import org.apache.avalon.framework.thread.ThreadSafe;
25:
26: import org.apache.cocoon.components.source.SourceFactory;
27: import org.apache.cocoon.environment.Environment;
28: import org.apache.cocoon.environment.Source;
29: import org.apache.cocoon.ProcessingException;
30:
31: import java.io.IOException;
32: import java.net.MalformedURLException;
33: import java.net.URL;
34:
35: /**
36: * A factory for 'file:' sources.
37: *
38: * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
39: * @version CVS $Id: FileSourceFactory.java 433543 2006-08-22 06:22:54Z crossley $
40: * @deprecated Use the new avalon source resolving instead
41: */
42: public class FileSourceFactory extends AbstractLogEnabled implements
43: SourceFactory, Composable, ThreadSafe {
44:
45: private ComponentManager manager;
46:
47: public void compose(ComponentManager manager)
48: throws ComponentException {
49: this .manager = manager;
50: }
51:
52: public Source getSource(Environment environment, String location)
53: throws ProcessingException, MalformedURLException,
54: IOException {
55: Source result = new FileSource(location, this .manager);
56: setupLogger(result);
57: return result;
58: }
59:
60: public Source getSource(Environment environment, URL base,
61: String location) throws ProcessingException,
62: MalformedURLException, IOException {
63: return getSource(environment, new URL(base, location)
64: .toExternalForm());
65: }
66: }
|