KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > generation > PortalGenerator


1 /*
2  * Copyright 1999-2002,2004-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.generation;
17
18 import java.io.IOException JavaDoc;
19 import java.util.Map JavaDoc;
20
21 import org.apache.avalon.framework.parameters.Parameters;
22 import org.apache.avalon.framework.service.ServiceException;
23 import org.apache.avalon.framework.service.ServiceManager;
24 import org.apache.cocoon.ProcessingException;
25 import org.apache.cocoon.environment.SourceResolver;
26 import org.apache.cocoon.generation.ServiceableGenerator;
27 import org.apache.cocoon.portal.PortalManager;
28 import org.apache.cocoon.portal.PortalService;
29 import org.xml.sax.SAXException JavaDoc;
30
31 /**
32  * This generator renders the complete portal.
33  * More precisly, this generator is the starting point for the portal
34  * rendering. The generator delegates the rendering process to
35  * to {@link PortalManager} component.
36  * This generator needs one runtime configuration: the name of
37  * the portal to render as a sitemap parameter named "portal-name".
38  *
39  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
40  * @author <a HREF="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
41  *
42  * @version CVS $Id: PortalGenerator.java 158825 2005-03-23 20:00:56Z cziegeler $
43  */

44 public class PortalGenerator
45 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.lookup(PortalService.ROLE);
67     }
68
69     /* (non-Javadoc)
70      * @see org.apache.cocoon.generation.Generator#generate()
71      */

72     public void generate()
73     throws IOException JavaDoc, SAXException JavaDoc, ProcessingException {
74         // start the portal rendering
75
// 1. event processing
76
// 2. rendering
77
PortalManager pm = this.portalService.getComponentManager().getPortalManager();
78         pm.process();
79         pm.showPortal(this.xmlConsumer, this.parameters);
80     }
81
82     /* (non-Javadoc)
83      * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
84      */

85     public void setup(SourceResolver resolver,
86                       Map JavaDoc objectModel,
87                       String JavaDoc src,
88                       Parameters par)
89     throws ProcessingException, SAXException JavaDoc, IOException JavaDoc {
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().getRefreshLinkURI();
95     }
96
97 }
98
Popular Tags