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.generation;
18:
19: import org.apache.avalon.framework.parameters.Parameters;
20: import org.apache.cocoon.ProcessingException;
21: import org.apache.cocoon.environment.SourceResolver;
22: import org.apache.cocoon.xml.AbstractXMLProducer;
23: import org.xml.sax.SAXException;
24:
25: import java.io.IOException;
26: import java.util.Map;
27:
28: /**
29: * An abstract class that can be used to implement an own generator.
30: * If you need other components, use the {@link ServiceableGenerator}
31: * instead.
32: *
33: * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
34: * (Apache Software Foundation)
35: * @version CVS $Id: AbstractGenerator.java 433543 2006-08-22 06:22:54Z crossley $
36: */
37: public abstract class AbstractGenerator extends AbstractXMLProducer
38: implements Generator {
39:
40: /** The current <code>SourceResolver</code>. */
41: protected SourceResolver resolver;
42: /** The current <code>Map</code> objectModel. */
43: protected Map objectModel;
44: /** The current <code>Parameters</code>. */
45: protected Parameters parameters;
46: /** The source URI associated with the request or <b>null</b>. */
47: protected String source;
48:
49: /**
50: * Set the <code>SourceResolver</code>, object model <code>Map</code>,
51: * the source and sitemap <code>Parameters</code> used to process the request.
52: */
53: public void setup(SourceResolver resolver, Map objectModel,
54: String src, Parameters par) throws ProcessingException,
55: SAXException, IOException {
56: this .resolver = resolver;
57: this .objectModel = objectModel;
58: this .source = src;
59: this .parameters = par;
60: }
61:
62: /**
63: * Recycle the generator by removing references
64: */
65: public void recycle() {
66: super.recycle();
67: this.resolver = null;
68: this.objectModel = null;
69: this.source = null;
70: this.parameters = null;
71: }
72:
73: }
|