KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > transformation > ServiceableTransformer


1 /*
2  * Copyright 1999-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 package org.apache.cocoon.transformation;
17
18 import java.io.IOException JavaDoc;
19 import java.util.Map JavaDoc;
20
21 import org.apache.avalon.framework.activity.Disposable;
22 import org.apache.avalon.framework.parameters.Parameters;
23 import org.apache.avalon.framework.service.ServiceException;
24 import org.apache.avalon.framework.service.ServiceManager;
25 import org.apache.avalon.framework.service.Serviceable;
26 import org.apache.cocoon.ProcessingException;
27 import org.apache.cocoon.environment.SourceResolver;
28 import org.xml.sax.SAXException JavaDoc;
29
30 /**
31  * This class can be used as a base class for own transformer implementations
32  * that need to lookup other components.
33  *
34  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
35  * (Apache Software Foundation)
36  * @version CVS $Id: ServiceableTransformer.java 30932 2004-07-29 17:35:38Z vgritsenko $
37  */

38
39 public abstract class ServiceableTransformer
40     extends AbstractTransformer
41     implements Serviceable, Disposable {
42
43     /** The current <code>SourceResolver</code>. */
44     protected SourceResolver resolver;
45     /** The current <code>Map</code> objectModel. */
46     protected Map JavaDoc 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 JavaDoc 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 JavaDoc objectModel, String JavaDoc src, Parameters par)
59     throws ProcessingException, SAXException JavaDoc, IOException JavaDoc {
60         this.resolver = resolver;
61         this.objectModel = objectModel;
62         this.source = src;
63         this.parameters = par;
64     }
65
66     /**
67      * Recycle the generator by removing references
68      */

69     public void recycle() {
70         super.recycle();
71         this.resolver = null;
72         this.objectModel = null;
73         this.source = null;
74         this.parameters = null;
75     }
76     
77     /* (non-Javadoc)
78      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
79      */

80     public void service(ServiceManager manager) throws ServiceException {
81         this.manager = manager;
82     }
83
84     /* (non-Javadoc)
85      * @see org.apache.avalon.framework.activity.Disposable#dispose()
86      */

87     public void dispose() {
88         this.manager = null;
89     }
90
91 }
92
Popular Tags