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.generation;
18:
19: import java.io.IOException;
20: import java.util.Map;
21:
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.cocoon.ProcessingException;
26: import org.apache.cocoon.environment.SourceResolver;
27: import org.apache.cocoon.generation.ServiceableGenerator;
28: import org.apache.cocoon.portal.PortalManager;
29: import org.apache.cocoon.portal.PortalService;
30: import org.xml.sax.SAXException;
31:
32: /**
33: * This generator renders the complete portal.
34: * More precisly, this generator is the starting point for the portal
35: * rendering. The generator delegates the rendering process to
36: * to {@link PortalManager} component.
37: * This generator needs one runtime configuration: the name of
38: * the portal to render as a sitemap parameter named "portal-name".
39: *
40: * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
41: * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
42: *
43: * @version CVS $Id: PortalGenerator.java 433543 2006-08-22 06:22:54Z crossley $
44: */
45: public class PortalGenerator extends ServiceableGenerator {
46:
47: /** The portal service. */
48: protected PortalService portalService;
49:
50: /**
51: * @see org.apache.avalon.framework.activity.Disposable#dispose()
52: */
53: public void dispose() {
54: if (this .manager != null) {
55: this .manager.release(this .portalService);
56: this .portalService = null;
57: }
58: super .dispose();
59: }
60:
61: /**
62: * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
63: */
64: public void service(ServiceManager manager) throws ServiceException {
65: super .service(manager);
66: this .portalService = (PortalService) this .manager
67: .lookup(PortalService.ROLE);
68: }
69:
70: /* (non-Javadoc)
71: * @see org.apache.cocoon.generation.Generator#generate()
72: */
73: public void generate() throws IOException, SAXException,
74: ProcessingException {
75: // start the portal rendering
76: // 1. event processing
77: // 2. rendering
78: PortalManager pm = this .portalService.getComponentManager()
79: .getPortalManager();
80: pm.process();
81: pm.showPortal(this .xmlConsumer, this .parameters);
82: }
83:
84: /* (non-Javadoc)
85: * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
86: */
87: public void setup(SourceResolver resolver, Map objectModel,
88: String src, Parameters par) throws ProcessingException,
89: SAXException, IOException {
90: super .setup(resolver, objectModel, src, par);
91:
92: // This is a fix: if we don't use the link service here, we get
93: // in some rare cases a wrong uri!
94: this.portalService.getComponentManager().getLinkService()
95: .getRefreshLinkURI();
96: }
97:
98: }
|