Source Code Cross Referenced for DefaultPortalComponentManager.java in  » Web-Framework » cocoon » org » apache » cocoon » portal » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » cocoon » org.apache.cocoon.portal.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.portal.impl;
018:
019:        import java.util.HashMap;
020:        import java.util.Iterator;
021:        import java.util.Map;
022:
023:        import org.apache.avalon.framework.CascadingRuntimeException;
024:        import org.apache.avalon.framework.activity.Disposable;
025:        import org.apache.avalon.framework.configuration.Configurable;
026:        import org.apache.avalon.framework.configuration.Configuration;
027:        import org.apache.avalon.framework.configuration.ConfigurationException;
028:        import org.apache.avalon.framework.context.Context;
029:        import org.apache.avalon.framework.logger.AbstractLogEnabled;
030:        import org.apache.avalon.framework.service.ServiceException;
031:        import org.apache.avalon.framework.service.ServiceManager;
032:        import org.apache.avalon.framework.service.ServiceSelector;
033:        import org.apache.avalon.framework.service.Serviceable;
034:        import org.apache.avalon.framework.thread.ThreadSafe;
035:        import org.apache.cocoon.portal.LinkService;
036:        import org.apache.cocoon.portal.PortalComponentManager;
037:        import org.apache.cocoon.portal.PortalManager;
038:        import org.apache.cocoon.portal.PortalService;
039:        import org.apache.cocoon.portal.coplet.CopletFactory;
040:        import org.apache.cocoon.portal.event.EventManager;
041:        import org.apache.cocoon.portal.layout.LayoutFactory;
042:        import org.apache.cocoon.portal.layout.renderer.Renderer;
043:        import org.apache.cocoon.portal.profile.ProfileManager;
044:
045:        /**
046:         * Default {@link PortalComponentManager} implementation
047:         *
048:         * @see org.apache.cocoon.portal.PortalComponentManager
049:         *
050:         * TODO Handle non ThreadSafe components
051:         *
052:         * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
053:         *
054:         * @version CVS $Id: DefaultPortalComponentManager.java 433543 2006-08-22 06:22:54Z crossley $
055:         */
056:        public class DefaultPortalComponentManager extends AbstractLogEnabled
057:                implements  PortalComponentManager, Serviceable, Disposable,
058:                ThreadSafe, Configurable {
059:
060:            /** The avalon component manager */
061:            protected ServiceManager manager;
062:
063:            /** The portal service */
064:            protected final PortalService portalService;
065:
066:            protected String profileManagerRole;
067:            protected ProfileManager profileManager;
068:
069:            protected String linkServiceRole;
070:            protected LinkService linkService;
071:
072:            protected String rendererSelectorRole;
073:            protected ServiceSelector rendererSelector;
074:
075:            protected Map renderers;
076:
077:            protected String copletFactoryRole;
078:            protected CopletFactory copletFactory;
079:
080:            protected String layoutFactoryRole;
081:            protected LayoutFactory layoutFactory;
082:
083:            protected String eventManagerRole;
084:            protected EventManager eventManager;
085:
086:            protected String portalManagerRole;
087:            protected PortalManager portalManager;
088:
089:            protected final Context context;
090:
091:            /**
092:             * Create a new portal component manager. Each portal has a own
093:             * component manager that manages all central components for this
094:             * portal.
095:             * This implementation stores the portal service (a global singleton)
096:             * to pass it to the other components (TODO).
097:             * @param service The portal service.
098:             */
099:            public DefaultPortalComponentManager(final PortalService service,
100:                    Context context) {
101:                this .portalService = service;
102:                this .context = context;
103:            }
104:
105:            /* (non-Javadoc)
106:             * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
107:             */
108:            public void service(ServiceManager manager) throws ServiceException {
109:                this .manager = manager;
110:            }
111:
112:            /* (non-Javadoc)
113:             * @see org.apache.cocoon.portal.PortalComponentManager#getLinkService()
114:             */
115:            public LinkService getLinkService() {
116:                if (null == this .linkService) {
117:                    try {
118:                        this .linkService = (LinkService) this .manager
119:                                .lookup(this .linkServiceRole);
120:                    } catch (ServiceException e) {
121:                        throw new CascadingRuntimeException(
122:                                "Unable to lookup link service with role "
123:                                        + this .linkServiceRole, e);
124:                    }
125:                }
126:                return this .linkService;
127:            }
128:
129:            /* (non-Javadoc)
130:             * @see org.apache.cocoon.portal.PortalComponentManager#getProfileManager()
131:             */
132:            public ProfileManager getProfileManager() {
133:                if (null == this .profileManager) {
134:                    try {
135:                        this .profileManager = (ProfileManager) this .manager
136:                                .lookup(this .profileManagerRole);
137:                    } catch (ServiceException e) {
138:                        throw new CascadingRuntimeException(
139:                                "Unable to lookup profile manager with role "
140:                                        + this .profileManagerRole, e);
141:                    }
142:                }
143:                return this .profileManager;
144:            }
145:
146:            /* (non-Javadoc)
147:             * @see org.apache.cocoon.portal.PortalComponentManager#getEventManager()
148:             */
149:            public EventManager getEventManager() {
150:                if (null == this .eventManager) {
151:                    try {
152:                        this .eventManager = (EventManager) this .manager
153:                                .lookup(this .eventManagerRole);
154:                    } catch (ServiceException e) {
155:                        throw new CascadingRuntimeException(
156:                                "Unable to lookup event manager with role "
157:                                        + this .eventManagerRole, e);
158:                    }
159:                }
160:                return this .eventManager;
161:            }
162:
163:            /* (non-Javadoc)
164:             * @see org.apache.avalon.framework.activity.Disposable#dispose()
165:             */
166:            public void dispose() {
167:                if (this .manager != null) {
168:                    if (this .rendererSelector != null) {
169:                        Iterator i = this .renderers.values().iterator();
170:                        while (i.hasNext()) {
171:                            this .rendererSelector.release(i.next());
172:                        }
173:                        this .manager.release(this .rendererSelector);
174:                        this .rendererSelector = null;
175:                        this .renderers = null;
176:                    }
177:                    this .manager.release(this .profileManager);
178:                    this .profileManager = null;
179:                    this .manager.release(this .linkService);
180:                    this .linkService = null;
181:                    this .manager.release(this .copletFactory);
182:                    this .copletFactory = null;
183:                    this .manager.release(this .layoutFactory);
184:                    this .layoutFactory = null;
185:                    this .manager.release(this .eventManager);
186:                    this .eventManager = null;
187:                    this .manager.release(this .portalManager);
188:                    this .portalManager = null;
189:                    this .manager = null;
190:                }
191:            }
192:
193:            /* (non-Javadoc)
194:             * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
195:             */
196:            public void configure(Configuration config)
197:                    throws ConfigurationException {
198:                this .profileManagerRole = config.getChild("profile-manager")
199:                        .getValue(ProfileManager.ROLE);
200:                this .linkServiceRole = config.getChild("link-service")
201:                        .getValue(LinkService.ROLE);
202:                this .rendererSelectorRole = config
203:                        .getChild("renderer-selector").getValue(
204:                                Renderer.ROLE + "Selector");
205:                this .copletFactoryRole = config.getChild("coplet-factory")
206:                        .getValue(CopletFactory.ROLE);
207:                this .layoutFactoryRole = config.getChild("layout-factory")
208:                        .getValue(LayoutFactory.ROLE);
209:                this .eventManagerRole = config.getChild("event-manager")
210:                        .getValue(EventManager.ROLE);
211:                this .portalManagerRole = config.getChild("portal-manager")
212:                        .getValue(PortalManager.ROLE);
213:            }
214:
215:            /* (non-Javadoc)
216:             * @see org.apache.cocoon.portal.PortalComponentManager#getRenderer(java.lang.String)
217:             */
218:            public Renderer getRenderer(String hint) {
219:                if (rendererSelector == null) {
220:                    try {
221:                        this .rendererSelector = (ServiceSelector) this .manager
222:                                .lookup(this .rendererSelectorRole);
223:                    } catch (ServiceException e) {
224:                        throw new CascadingRuntimeException(
225:                                "Unable to lookup renderer selector with role "
226:                                        + this .rendererSelectorRole, e);
227:                    }
228:                    this .renderers = new HashMap();
229:                }
230:                Renderer o = (Renderer) this .renderers.get(hint);
231:                if (o == null) {
232:                    try {
233:                        o = (Renderer) this .rendererSelector.select(hint);
234:                        this .renderers.put(hint, o);
235:                    } catch (ServiceException e) {
236:                        throw new CascadingRuntimeException(
237:                                "Unable to lookup renderer with hint " + hint,
238:                                e);
239:                    }
240:                }
241:                return o;
242:            }
243:
244:            /* (non-Javadoc)
245:             * @see org.apache.cocoon.portal.PortalComponentManager#getCopletFactory()
246:             */
247:            public CopletFactory getCopletFactory() {
248:                if (null == this .copletFactory) {
249:                    try {
250:                        this .copletFactory = (CopletFactory) this .manager
251:                                .lookup(this .copletFactoryRole);
252:                    } catch (ServiceException e) {
253:                        throw new CascadingRuntimeException(
254:                                "Unable to lookup coplet factory with role "
255:                                        + this .copletFactoryRole, e);
256:                    }
257:                }
258:                return this .copletFactory;
259:            }
260:
261:            /* (non-Javadoc)
262:             * @see org.apache.cocoon.portal.PortalComponentManager#getLayoutFactory()
263:             */
264:            public LayoutFactory getLayoutFactory() {
265:                if (null == this .layoutFactory) {
266:                    try {
267:                        this .layoutFactory = (LayoutFactory) this .manager
268:                                .lookup(this .layoutFactoryRole);
269:                    } catch (ServiceException e) {
270:                        throw new CascadingRuntimeException(
271:                                "Unable to lookup layout factory with role "
272:                                        + this .layoutFactoryRole, e);
273:                    }
274:                }
275:                return this .layoutFactory;
276:            }
277:
278:            /**
279:             * @see org.apache.cocoon.portal.PortalComponentManager#getPortalManager()
280:             */
281:            public PortalManager getPortalManager() {
282:                if (null == this .portalManager) {
283:                    try {
284:                        this .portalManager = (PortalManager) this .manager
285:                                .lookup(this .portalManagerRole);
286:                    } catch (ServiceException e) {
287:                        throw new CascadingRuntimeException(
288:                                "Unable to lookup portal manager with role "
289:                                        + this .portalManagerRole, e);
290:                    }
291:                }
292:                return this .portalManager;
293:            }
294:
295:            /**
296:             * @see org.apache.cocoon.portal.PortalComponentManager#getComponentContext()
297:             */
298:            public Context getComponentContext() {
299:                return this.context;
300:            }
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.