Source Code Cross Referenced for LayoutLoader.java in  » Web-Framework » TURBINE » org » apache » turbine » modules » 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 » TURBINE » org.apache.turbine.modules 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.turbine.modules;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *   http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import java.util.List;
023:
024:        import org.apache.commons.logging.Log;
025:        import org.apache.commons.logging.LogFactory;
026:
027:        import org.apache.turbine.Turbine;
028:        import org.apache.turbine.TurbineConstants;
029:        import org.apache.turbine.services.assemblerbroker.AssemblerBrokerService;
030:        import org.apache.turbine.services.assemblerbroker.TurbineAssemblerBroker;
031:        import org.apache.turbine.util.ObjectUtils;
032:        import org.apache.turbine.util.RunData;
033:
034:        /**
035:         * The purpose of this class is to allow one to load and execute
036:         * Layout modules.
037:         *
038:         * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
039:         * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
040:         * @version $Id: LayoutLoader.java 534527 2007-05-02 16:10:59Z tv $
041:         */
042:        public class LayoutLoader extends GenericLoader implements  Loader {
043:            /** Serial Version UID */
044:            private static final long serialVersionUID = -1996918946937639892L;
045:
046:            /** Logging */
047:            private static Log log = LogFactory.getLog(LayoutLoader.class);
048:
049:            /** The single instance of this class. */
050:            private static LayoutLoader instance = new LayoutLoader(Turbine
051:                    .getConfiguration().getInt(
052:                            TurbineConstants.LAYOUT_CACHE_SIZE_KEY,
053:                            TurbineConstants.LAYOUT_CACHE_SIZE_DEFAULT));
054:
055:            /** The Assembler Broker Service */
056:            private static AssemblerBrokerService ab = TurbineAssemblerBroker
057:                    .getService();
058:
059:            /**
060:             * These ctor's are private to force clients to use getInstance()
061:             * to access this class.
062:             */
063:            private LayoutLoader() {
064:                super ();
065:            }
066:
067:            /**
068:             * These ctor's are private to force clients to use getInstance()
069:             * to access this class.
070:             */
071:            private LayoutLoader(int i) {
072:                super (i);
073:            }
074:
075:            /**
076:             * Adds an instance of an object into the hashtable.
077:             *
078:             * @param name Name of object.
079:             * @param layout Layout to be associated with name.
080:             */
081:            private void addInstance(String name, Layout layout) {
082:                if (cache()) {
083:                    this .put(name, (Layout) layout);
084:                }
085:            }
086:
087:            /**
088:             * Attempts to load and execute the external layout.
089:             *
090:             * @param data Turbine information.
091:             * @param name Name of object that will execute the layout.
092:             * @exception Exception a generic exception.
093:             */
094:            public void exec(RunData data, String name) throws Exception {
095:                // Execute layout
096:                getInstance(name).build(data);
097:            }
098:
099:            /**
100:             * Pulls out an instance of the object by name.  Name is just the
101:             * single name of the object. This is equal to getInstance but
102:             * returns an Assembler object and is needed to fulfil the Loader
103:             * interface.
104:             *
105:             * @param name Name of object instance.
106:             * @return A Layout with the specified name, or null.
107:             * @exception Exception a generic exception.
108:             */
109:            public Assembler getAssembler(String name) throws Exception {
110:                return getInstance(name);
111:            }
112:
113:            /**
114:             * Pulls out an instance of the Layout by name.  Name is just the
115:             * single name of the Layout.
116:             *
117:             * @param name Name of requested Layout
118:             * @return A Layout with the specified name, or null.
119:             * @exception Exception a generic exception.
120:             */
121:            public Layout getInstance(String name) throws Exception {
122:                Layout layout = null;
123:
124:                // Check if the layout is already in the cache
125:                if (cache() && this .containsKey(name)) {
126:                    layout = (Layout) this .get(name);
127:                    log.debug("Found Layout " + name + " in the cache!");
128:                } else {
129:                    log.debug("Loading Layout " + name
130:                            + " from the Assembler Broker");
131:
132:                    try {
133:                        if (ab != null) {
134:                            // Attempt to load the layout
135:                            layout = (Layout) ab.getAssembler(
136:                                    AssemblerBrokerService.LAYOUT_TYPE, name);
137:                        }
138:                    } catch (ClassCastException cce) {
139:                        // This can alternatively let this exception be thrown
140:                        // So that the ClassCastException is shown in the
141:                        // browser window.  Like this it shows "Screen not Found"
142:                        layout = null;
143:                    }
144:
145:                    if (layout == null) {
146:                        // If we did not find a screen we should try and give
147:                        // the user a reason for that...
148:                        // FIX ME: The AssemblerFactories should each add it's
149:                        // own string here...
150:                        List packages = Turbine.getConfiguration().getList(
151:                                TurbineConstants.MODULE_PACKAGES);
152:
153:                        ObjectUtils.addOnce(packages, GenericLoader
154:                                .getBasePackage());
155:
156:                        throw new ClassNotFoundException(
157:                                "\n\n\tRequested Layout not found: "
158:                                        + name
159:                                        + "\n\tTurbine looked in the following "
160:                                        + "modules.packages path: \n\t"
161:                                        + packages.toString() + "\n");
162:                    } else if (cache()) {
163:                        // The new instance is added to the cache
164:                        addInstance(name, layout);
165:                    }
166:                }
167:                return layout;
168:            }
169:
170:            /**
171:             * The method through which this class is accessed.
172:             *
173:             * @return The single instance of this class.
174:             */
175:            public static LayoutLoader getInstance() {
176:                return instance;
177:            }
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.