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.transformation;
18:
19: import java.io.IOException;
20: import java.util.Map;
21:
22: import org.apache.avalon.framework.activity.Disposable;
23: import org.apache.avalon.framework.parameters.Parameters;
24: import org.apache.avalon.framework.service.ServiceException;
25: import org.apache.avalon.framework.service.ServiceManager;
26: import org.apache.avalon.framework.service.Serviceable;
27: import org.apache.cocoon.ProcessingException;
28: import org.apache.cocoon.environment.SourceResolver;
29: import org.xml.sax.SAXException;
30:
31: /**
32: * This class can be used as a base class for own transformer implementations
33: * that need to lookup other components.
34: *
35: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
36: * (Apache Software Foundation)
37: * @version CVS $Id: ServiceableTransformer.java 433543 2006-08-22 06:22:54Z crossley $
38: */
39:
40: public abstract class ServiceableTransformer extends
41: AbstractTransformer implements Serviceable, Disposable {
42:
43: /** The current <code>SourceResolver</code>. */
44: protected SourceResolver resolver;
45: /** The current <code>Map</code> objectModel. */
46: protected Map objectModel;
47: /** The current <code>Parameters</code>. */
48: protected Parameters parameters;
49: /** The source URI associated with the request or <b>null</b>. */
50: protected String source;
51: /** The ServiceManager */
52: protected ServiceManager manager;
53:
54: /**
55: * Set the <code>SourceResolver</code>, object model <code>Map</code>,
56: * the source and sitemap <code>Parameters</code> used to process the request.
57: */
58: public void setup(SourceResolver resolver, Map objectModel,
59: String src, Parameters par) throws ProcessingException,
60: SAXException, IOException {
61: this .resolver = resolver;
62: this .objectModel = objectModel;
63: this .source = src;
64: this .parameters = par;
65: }
66:
67: /**
68: * Recycle the generator by removing references
69: */
70: public void recycle() {
71: super .recycle();
72: this .resolver = null;
73: this .objectModel = null;
74: this .source = null;
75: this .parameters = null;
76: }
77:
78: /* (non-Javadoc)
79: * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
80: */
81: public void service(ServiceManager manager) throws ServiceException {
82: this .manager = manager;
83: }
84:
85: /* (non-Javadoc)
86: * @see org.apache.avalon.framework.activity.Disposable#dispose()
87: */
88: public void dispose() {
89: this.manager = null;
90: }
91:
92: }
|