Source Code Cross Referenced for DocumentFactory.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » utils » 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 » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2001 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.utils;
007:
008:        import java.io.IOException;
009:        import java.io.InputStream;
010:
011:        import javax.xml.parsers.DocumentBuilder;
012:        import javax.xml.parsers.DocumentBuilderFactory;
013:
014:        import org.apache.commons.logging.Log;
015:        import org.apache.commons.logging.LogFactory;
016:        import org.w3c.dom.Document;
017:        import org.xml.sax.EntityResolver;
018:        import org.xml.sax.InputSource;
019:        import org.xml.sax.SAXException;
020:
021:        /**
022:         * Produces an empty Document implementation
023:         * @author Bernie Durfee, bdurfee@interactivebusiness.com
024:         * @version $Revision: 36684 $
025:         */
026:        public class DocumentFactory {
027:
028:            private static final Log log = LogFactory
029:                    .getLog(DocumentFactory.class);
030:
031:            protected static DocumentFactory _instance;
032:            protected static final LocalDocumentBuilder localDocBuilder = new LocalDocumentBuilder();
033:            protected DocumentBuilderFactory dbFactory = null;
034:
035:            protected static synchronized DocumentFactory instance() {
036:                if (_instance == null) {
037:                    _instance = new DocumentFactory();
038:                }
039:                return _instance;
040:            }
041:
042:            protected DocumentFactory() {
043:
044:                try {
045:                    dbFactory = DocumentBuilderFactory.newInstance();
046:                    dbFactory.setNamespaceAware(true);
047:                    dbFactory.setValidating(false);
048:                } catch (Exception e) {
049:                    log
050:                            .error(
051:                                    "DocumentFactory: unable to initialize DocumentBuilderFactory",
052:                                    e);
053:                }
054:            }
055:
056:            /**
057:             * Returns a new copy of a Document implementation. This will
058:             * return an <code>IPortalDocument</code> implementation.
059:             * @return an empty org.w3c.dom.Document implementation
060:             */
061:            public static Document getNewDocument() {
062:                return newDocumentBuilder().newDocument();
063:            }
064:
065:            /**
066:             * Returns a new copy of a Document implementation.
067:             * @return an empty org.w3c.dom.Document implementation
068:             */
069:            static Document __getNewDocument() {
070:                Document doc = newDocumentBuilder().newDocument();
071:                return doc;
072:            }
073:
074:            /**
075:             * @param stream
076:             * @return Document
077:             * @throws IOException
078:             * @throws SAXException
079:             * @deprecated Does not provide document identifier in exceptions.
080:             */
081:            public static Document getDocumentFromStream(InputStream stream)
082:                    throws IOException, SAXException {
083:                DocumentBuilder builder = newDocumentBuilder();
084:                Document doc = builder.parse(stream);
085:                return doc;
086:            }
087:
088:            /**
089:             * @param stream
090:             * @param er
091:             * @return Document
092:             * @throws IOException
093:             * @throws SAXException
094:             * @deprecated Does not provide document identifier in exceptions.
095:             */
096:            public static Document getDocumentFromStream(InputStream stream,
097:                    EntityResolver er) throws IOException, SAXException {
098:                DocumentBuilder builder = newDocumentBuilder();
099:                builder.setEntityResolver(er);
100:                Document doc = builder.parse(stream);
101:                return doc;
102:            }
103:
104:            public static Document getDocumentFromStream(InputStream stream,
105:                    String publicId) throws IOException, SAXException {
106:                DocumentBuilder builder = newDocumentBuilder();
107:                InputSource source = new InputSource(stream);
108:                source.setPublicId(publicId);
109:                Document doc = builder.parse(source);
110:                return doc;
111:            }
112:
113:            public static Document getDocumentFromStream(InputStream stream,
114:                    EntityResolver er, String publicId) throws IOException,
115:                    SAXException {
116:                DocumentBuilder builder = newDocumentBuilder();
117:                builder.setEntityResolver(er);
118:                InputSource source = new InputSource(stream);
119:                source.setPublicId(publicId);
120:                Document doc = builder.parse(source);
121:                return doc;
122:            }
123:
124:            public static DocumentBuilder newDocumentBuilder() {
125:                DocumentBuilder builder = (DocumentBuilder) localDocBuilder
126:                        .get();
127:                return builder;
128:            }
129:
130:            protected static class LocalDocumentBuilder extends ThreadLocal {
131:                protected Object initialValue() {
132:                    Object r = null;
133:                    try {
134:                        r = instance().dbFactory.newDocumentBuilder();
135:                    } catch (Exception e) {
136:                        log.error(e, e);
137:                    }
138:                    return r;
139:                }
140:            }
141:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.