KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > impl > DefaultPortalManagerAspectContext


1 /*
2  * Copyright 2005 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.portal.impl;
17
18 import java.util.Iterator JavaDoc;
19 import java.util.Map JavaDoc;
20
21 import org.apache.avalon.framework.parameters.Parameters;
22 import org.apache.cocoon.ProcessingException;
23 import org.apache.cocoon.portal.PortalManagerAspect;
24 import org.apache.cocoon.portal.PortalManagerAspectPrepareContext;
25 import org.apache.cocoon.portal.PortalManagerAspectRenderContext;
26 import org.apache.cocoon.portal.PortalService;
27 import org.xml.sax.ContentHandler JavaDoc;
28 import org.xml.sax.SAXException JavaDoc;
29
30 /**
31  * The aspect context is passed to every aspect.
32  * @since 2.1.8
33  * @version SVN $Id: DefaultPortalManagerAspectContext.java 210138 2005-07-11 14:14:26Z cziegeler $
34  */

35 public final class DefaultPortalManagerAspectContext
36     implements PortalManagerAspectRenderContext, PortalManagerAspectPrepareContext {
37
38     private final PortalService service;
39     private final Map JavaDoc objectModel;
40     private Iterator JavaDoc iterator;
41     private Iterator JavaDoc configIterator;
42     private Parameters config;
43     
44     public DefaultPortalManagerAspectContext(PortalManagerAspectChain chain,
45                                              PortalService service,
46                                              Map JavaDoc objectModel) {
47         this.service = service;
48         this.objectModel = objectModel;
49         this.iterator = chain.getIterator();
50         this.configIterator = chain.getConfigIterator();
51     }
52     
53     /**
54      * @see org.apache.cocoon.portal.PortalManagerAspectPrepareContext#invokeNext()
55      */

56     public void invokeNext()
57     throws ProcessingException {
58         if (this.iterator.hasNext()) {
59             this.config = (Parameters)this.configIterator.next();
60             final PortalManagerAspect aspect = (PortalManagerAspect) iterator.next();
61             aspect.prepare(this, this.service);
62         }
63     }
64
65     /**
66      * @see org.apache.cocoon.portal.PortalManagerAspectPrepareContext#getAspectParameters()
67      */

68     public Parameters getAspectParameters() {
69         return this.config;
70     }
71
72     /**
73      * @see org.apache.cocoon.portal.PortalManagerAspectRenderContext#invokeNext(org.xml.sax.ContentHandler, org.apache.avalon.framework.parameters.Parameters)
74      */

75     public void invokeNext(ContentHandler JavaDoc ch, Parameters parameters)
76     throws SAXException JavaDoc {
77         if (this.iterator.hasNext()) {
78             this.config = (Parameters)this.configIterator.next();
79             final PortalManagerAspect aspect = (PortalManagerAspect) iterator.next();
80             aspect.render(this, this.service, ch, parameters);
81         }
82     }
83
84     /**
85      * @see org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext#getObjectModel()
86      */

87     public Map JavaDoc getObjectModel() {
88         return this.objectModel;
89     }
90 }
91
Popular Tags