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.portal.impl;
18:
19: import java.util.Iterator;
20: import java.util.Map;
21:
22: import org.apache.avalon.framework.parameters.Parameters;
23: import org.apache.cocoon.ProcessingException;
24: import org.apache.cocoon.portal.PortalManagerAspect;
25: import org.apache.cocoon.portal.PortalManagerAspectPrepareContext;
26: import org.apache.cocoon.portal.PortalManagerAspectRenderContext;
27: import org.apache.cocoon.portal.PortalService;
28: import org.xml.sax.ContentHandler;
29: import org.xml.sax.SAXException;
30:
31: /**
32: * The aspect context is passed to every aspect.
33: * @since 2.1.8
34: * @version SVN $Id: DefaultPortalManagerAspectContext.java 433543 2006-08-22 06:22:54Z crossley $
35: */
36: public final class DefaultPortalManagerAspectContext implements
37: PortalManagerAspectRenderContext,
38: PortalManagerAspectPrepareContext {
39:
40: private final PortalService service;
41: private final Map objectModel;
42: private Iterator iterator;
43: private Iterator configIterator;
44: private Parameters config;
45:
46: public DefaultPortalManagerAspectContext(
47: PortalManagerAspectChain chain, PortalService service,
48: Map objectModel) {
49: this .service = service;
50: this .objectModel = objectModel;
51: this .iterator = chain.getIterator();
52: this .configIterator = chain.getConfigIterator();
53: }
54:
55: /**
56: * @see org.apache.cocoon.portal.PortalManagerAspectPrepareContext#invokeNext()
57: */
58: public void invokeNext() throws ProcessingException {
59: if (this .iterator.hasNext()) {
60: this .config = (Parameters) this .configIterator.next();
61: final PortalManagerAspect aspect = (PortalManagerAspect) iterator
62: .next();
63: aspect.prepare(this , this .service);
64: }
65: }
66:
67: /**
68: * @see org.apache.cocoon.portal.PortalManagerAspectPrepareContext#getAspectParameters()
69: */
70: public Parameters getAspectParameters() {
71: return this .config;
72: }
73:
74: /**
75: * @see org.apache.cocoon.portal.PortalManagerAspectRenderContext#invokeNext(org.xml.sax.ContentHandler, org.apache.avalon.framework.parameters.Parameters)
76: */
77: public void invokeNext(ContentHandler ch, Parameters parameters)
78: throws SAXException {
79: if (this .iterator.hasNext()) {
80: this .config = (Parameters) this .configIterator.next();
81: final PortalManagerAspect aspect = (PortalManagerAspect) iterator
82: .next();
83: aspect.render(this , this .service, ch, parameters);
84: }
85: }
86:
87: /**
88: * @see org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext#getObjectModel()
89: */
90: public Map getObjectModel() {
91: return this.objectModel;
92: }
93: }
|