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


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