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: package org.apache.cocoon.components.source;
18:
19: import org.apache.avalon.framework.component.ComponentManager;
20: import org.apache.avalon.framework.logger.AbstractLogEnabled;
21: import org.apache.cocoon.ProcessingException;
22: import org.apache.cocoon.environment.Environment;
23: import org.apache.cocoon.environment.Source;
24: import org.apache.cocoon.Processor;
25:
26: import java.io.IOException;
27: import java.net.MalformedURLException;
28: import java.net.URL;
29:
30: /**
31: * This class implements the cocoon: protocol.
32: * It cannot be configured like the other source factories
33: * as it needs the current <code>Sitemap</code> as input.
34: *
35: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
36: * @version CVS $Id: CocoonSourceFactory.java 433543 2006-08-22 06:22:54Z crossley $
37: */
38: public final class CocoonSourceFactory extends AbstractLogEnabled
39: implements SourceFactory {
40:
41: /** The component manager */
42: private ComponentManager manager;
43:
44: public CocoonSourceFactory(Processor processor,
45: ComponentManager manager) {
46: this .manager = manager;
47: }
48:
49: /**
50: * Resolve the source
51: */
52: public Source getSource(Environment environment, String location)
53: throws ProcessingException, IOException,
54: MalformedURLException {
55: if (environment == null)
56: throw new ProcessingException(
57: "CocoonSourceFactory: environment is required.");
58: return new SitemapSource(this .manager, location, this
59: .getLogger());
60: }
61:
62: /**
63: * Resolve the source
64: */
65: public Source getSource(Environment environment, URL base,
66: String location) throws ProcessingException, IOException,
67: MalformedURLException {
68: if (environment == null)
69: throw new ProcessingException(
70: "CocoonSourceFactory: environment is required.");
71: return this.getSource(environment, base.toExternalForm()
72: + location);
73: }
74: }
|