Source Code Cross Referenced for RendererManager.java in  » Blogger-System » apache-roller-3.1 » org » apache » roller » ui » rendering » 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 » Blogger System » apache roller 3.1 » org.apache.roller.ui.rendering 
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.  The ASF licenses this file to You
004:         * under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.  For additional information regarding
015:         * copyright in this work, please see the NOTICE file in the top level
016:         * directory of this distribution.
017:         */
018:
019:        package org.apache.roller.ui.rendering;
020:
021:        import java.util.HashSet;
022:        import java.util.Iterator;
023:        import java.util.Set;
024:        import org.apache.commons.logging.Log;
025:        import org.apache.commons.logging.LogFactory;
026:        import org.apache.roller.config.RollerConfig;
027:        import org.apache.roller.pojos.Template;
028:
029:        /**
030:         * A governing class for Rollers rendering system.
031:         * 
032:         * The purpose of the RendererManager is to provide a level of abstraction 
033:         * between classes that are rendering content and the implementations of the
034:         * rendering technology.  This allows us to provide easily pluggable rendering
035:         * implementations.
036:         */
037:        public class RendererManager {
038:
039:            private static Log log = LogFactory.getLog(RendererManager.class);
040:
041:            // a set of all renderer factories we are consulting
042:            private static Set rendererFactories = new HashSet();
043:
044:            static {
045:                // lookup set of renderer factories we are going to use
046:                String rollerFactories = RollerConfig
047:                        .getProperty("rendering.rollerRendererFactories");
048:                String userFactories = RollerConfig
049:                        .getProperty("rendering.userRendererFactories");
050:
051:                // instantiate user defined renderer factory classes
052:                if (userFactories != null && userFactories.trim().length() > 0) {
053:
054:                    RendererFactory rendererFactory = null;
055:                    String[] uFactories = userFactories.split(",");
056:                    for (int i = 0; i < uFactories.length; i++) {
057:                        try {
058:                            Class factoryClass = Class.forName(uFactories[i]);
059:                            rendererFactory = (RendererFactory) factoryClass
060:                                    .newInstance();
061:                            rendererFactories.add(rendererFactory);
062:                        } catch (ClassCastException cce) {
063:                            log.error(
064:                                    "It appears that your factory does not implement "
065:                                            + "the RendererFactory interface",
066:                                    cce);
067:                        } catch (Exception e) {
068:                            log.error(
069:                                    "Unable to instantiate renderer factory ["
070:                                            + uFactories[i] + "]", e);
071:                        }
072:                    }
073:                }
074:
075:                // instantiate roller standard renderer factory classes
076:                if (rollerFactories != null
077:                        && rollerFactories.trim().length() > 0) {
078:
079:                    RendererFactory rendererFactory = null;
080:                    String[] rFactories = rollerFactories.split(",");
081:                    for (int i = 0; i < rFactories.length; i++) {
082:                        try {
083:                            Class factoryClass = Class.forName(rFactories[i]);
084:                            rendererFactory = (RendererFactory) factoryClass
085:                                    .newInstance();
086:                            rendererFactories.add(rendererFactory);
087:                        } catch (ClassCastException cce) {
088:                            log.error(
089:                                    "It appears that your factory does not implement "
090:                                            + "the RendererFactory interface",
091:                                    cce);
092:                        } catch (Exception e) {
093:                            log.error(
094:                                    "Unable to instantiate renderer factory ["
095:                                            + rFactories[i] + "]", e);
096:                        }
097:                    }
098:                }
099:
100:                if (rendererFactories.size() < 1) {
101:                    // hmm ... failed to load any renderer factories?
102:                    log
103:                            .warn("Failed to load any renderer factories.  "
104:                                    + "Rendering probably won't function as you expect.");
105:                }
106:
107:                log.info("Renderer Manager Initialized.");
108:            }
109:
110:            // this class is non-instantiable
111:            private RendererManager() {
112:            }
113:
114:            /**
115:             * Find the appropriate Renderer for the given content.
116:             *
117:             * This method checks all renderer factories configured for the Roller
118:             * instance and tries to find a Renderer for the content.  If no Renderer
119:             * can be found then we throw an exception.
120:             */
121:            public static Renderer getRenderer(Template template)
122:                    throws RenderingException {
123:
124:                Renderer renderer = null;
125:
126:                // iterate over our renderer factories and see if one of them
127:                // wants to handle this content
128:                Iterator factories = rendererFactories.iterator();
129:                while (factories.hasNext()) {
130:                    renderer = ((RendererFactory) factories.next())
131:                            .getRenderer(template);
132:
133:                    if (renderer != null) {
134:                        return renderer;
135:                    }
136:                }
137:
138:                throw new RenderingException("No renderer found for template "
139:                        + template.getId() + "!");
140:            }
141:
142:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.