Source Code Cross Referenced for NavCache.java in  » J2EE » Jaffa » org » jaffa » components » navigation » 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 » J2EE » Jaffa » org.jaffa.components.navigation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //@todo - add code for
002:        //        <xsd:element name="MainLayout" 	        type="xsd:string" minOccurs="0" maxOccurs="1"/>
003:        //        <xsd:element name="FinderLayout" 	type="xsd:string" minOccurs="0" maxOccurs="1"/>
004:        //        <xsd:element name="FinderExcelLayout" 	type="xsd:string" minOccurs="0" maxOccurs="1"/>
005:        //        <xsd:element name="FinderXmlLayout" 	type="xsd:string" minOccurs="0" maxOccurs="1"/>
006:
007:        /*
008:         * ====================================================================
009:         * JAFFA - Java Application Framework For All
010:         *
011:         * Copyright (C) 2002 JAFFA Development Group
012:         *
013:         *     This library is free software; you can redistribute it and/or
014:         *     modify it under the terms of the GNU Lesser General Public
015:         *     License as published by the Free Software Foundation; either
016:         *     version 2.1 of the License, or (at your option) any later version.
017:         *
018:         *     This library is distributed in the hope that it will be useful,
019:         *     but WITHOUT ANY WARRANTY; without even the implied warranty of
020:         *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
021:         *     Lesser General Public License for more details.
022:         *
023:         *     You should have received a copy of the GNU Lesser General Public
024:         *     License along with this library; if not, write to the Free Software
025:         *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026:         *
027:         * Redistribution and use of this software and associated documentation ("Software"),
028:         * with or without modification, are permitted provided that the following conditions are met:
029:         * 1.	Redistributions of source code must retain copyright statements and notices.
030:         *         Redistributions must also contain a copy of this document.
031:         * 2.	Redistributions in binary form must reproduce the above copyright notice,
032:         * 	this list of conditions and the following disclaimer in the documentation
033:         * 	and/or other materials provided with the distribution.
034:         * 3.	The name "JAFFA" must not be used to endorse or promote products derived from
035:         * 	this Software without prior written permission. For written permission,
036:         * 	please contact mail to: jaffagroup@yahoo.com.
037:         * 4.	Products derived from this Software may not be called "JAFFA" nor may "JAFFA"
038:         * 	appear in their names without prior written permission.
039:         * 5.	Due credit should be given to the JAFFA Project (http://jaffa.sourceforge.net).
040:         *
041:         * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
042:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
043:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
044:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
045:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
046:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
047:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
048:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
049:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
050:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
051:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
052:         * SUCH DAMAGE.
053:         * ====================================================================
054:         */
055:        package org.jaffa.components.navigation;
056:
057:        import java.net.MalformedURLException;
058:        import java.net.URL;
059:        import javax.xml.bind.JAXBContext;
060:        import javax.xml.bind.Unmarshaller;
061:        import org.apache.log4j.Logger;
062:        import org.jaffa.components.navigation.domain.GlobalMenu;
063:        import org.jaffa.config.Config;
064:        import org.jaffa.util.URLHelper;
065:        import org.jaffa.util.XmlHelper;
066:
067:        /** This singleton class loads in the global navigation xml and caches it
068:         * to in can be used for constructing instances of NavAccessor's
069:         *
070:         * @author  PaulE
071:         * @version 1.0
072:         */
073:        public class NavCache {
074:
075:            private static final Logger log = Logger.getLogger(NavCache.class);
076:            private static final String DEFAULT_NAVIGATION_LOCATION = "classpath:///resources/navigation.xml";
077:            private static NavCache m_singleton = null;
078:            private GlobalMenu m_menu = null;
079:
080:            /** Creates an instance of NavCache, if not already instantiated.
081:             * @return An instance of the NavCache.
082:             */
083:            public static NavCache getInstance() {
084:                if (m_singleton == null)
085:                    createNavCacheInstance();
086:                return m_singleton;
087:            }
088:
089:            private static synchronized void createNavCacheInstance() {
090:                if (m_singleton == null) {
091:                    String initfile = (String) Config.getProperty(
092:                            Config.PROP_MENULIST_URL,
093:                            DEFAULT_NAVIGATION_LOCATION);
094:
095:                    if (log.isDebugEnabled())
096:                        log
097:                                .debug("Creating an instance of NavCache using file: "
098:                                        + initfile);
099:                    m_singleton = new NavCache(initfile);
100:                }
101:            }
102:
103:            private NavCache(String initFile) {
104:                URL navUrl = null;
105:                try {
106:                    // Create a URL for the resource file...
107:                    navUrl = URLHelper.newExtendedURL(initFile);
108:                } catch (MalformedURLException e) {
109:                    log.fatal("Can't Find Navigation File, Bad URL - "
110:                            + initFile, e);
111:                    throw new SecurityException();
112:                }
113:
114:                try {
115:                    // create a JAXBContext capable of handling classes generated into the package
116:                    JAXBContext jc = JAXBContext
117:                            .newInstance("org.jaffa.components.navigation.domain");
118:
119:                    // create an Unmarshaller
120:                    Unmarshaller u = jc.createUnmarshaller();
121:
122:                    // enable validation
123:                    u.setValidating(true);
124:
125:                    // unmarshal a document into a tree of Java content objects composed of classes from the package.
126:                    m_menu = (GlobalMenu) u.unmarshal(XmlHelper
127:                            .stripDoctypeDeclaration(navUrl));
128:
129:                } catch (Exception e) {
130:                    String str = "Error while parsing the Navigation file "
131:                            + initFile;
132:                    log.fatal(str, e);
133:                    throw new SecurityException(str);
134:                }
135:            }
136:
137:            public GlobalMenu getGlobalMenu() {
138:                return m_menu;
139:            }
140:
141:            public void clearCache() {
142:                m_singleton = null;
143:            }
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.