Source Code Cross Referenced for ClassStuff.java in  » Web-Server » Rimfaxe-Web-Server » javax » xml » transform » 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 Server » Rimfaxe Web Server » javax.xml.transform 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: ClassStuff.java,v 1.2 2001/11/29 22:38:26 db Exp $
003:         * Copyright (C) 2001 David Brownell
004:         * 
005:         * This file is part of GNU JAXP, a library.
006:         *
007:         * GNU JAXP is free software; you can redistribute it and/or modify
008:         * it under the terms of the GNU General Public License as published by
009:         * the Free Software Foundation; either version 2 of the License, or
010:         * (at your option) any later version.
011:         * 
012:         * GNU JAXP is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         *
021:         * As a special exception, if you link this library with other files to
022:         * produce an executable, this library does not by itself cause the
023:         * resulting executable to be covered by the GNU General Public License.
024:         * This exception does not however invalidate any other reasons why the
025:         * executable file might be covered by the GNU General Public License. 
026:         */
027:
028:        package javax.xml.transform;
029:
030:        import java.io.BufferedReader;
031:        import java.io.File;
032:        import java.io.FileInputStream;
033:        import java.io.InputStream;
034:        import java.io.InputStreamReader;
035:        import java.lang.reflect.Method;
036:        import java.util.Properties;
037:
038:        // $Id: ClassStuff.java,v 1.2 2001/11/29 22:38:26 db Exp $
039:
040:        /**
041:         * Package-private utility methods for sharing
042:         * magic related to class loading.
043:         * NOTE:  This is cloned in javax.xml.parsers,
044:         * where a different exception is thrown (bleech).
045:         * Keep changes to the two copies in sync.
046:         *
047:         * @author David Brownell
048:         * @version	$Id: ClassStuff.java,v 1.2 2001/11/29 22:38:26 db Exp $
049:         */
050:        final class ClassStuff {
051:            private ClassStuff() {
052:            }
053:
054:            /**
055:             * Get the default factory using the four-stage defaulting
056:             * mechanism defined by JAXP.
057:             */
058:            static Object createFactory(String label, String defaultClass)
059:                    throws TransformerFactoryConfigurationError {
060:                String name = null;
061:                ClassLoader loader = null;
062:
063:                // figure out which class loader to use.
064:                // source compiles on jdk 1.1, but works with jdk 1.2+ security
065:                try {
066:                    Method m = null;
067:
068:                    // Can we use JDK 1.2 APIs?  Preferred: security policies apply.
069:                    m = Thread.class.getMethod("getContextClassLoader", null);
070:                    loader = (ClassLoader) m.invoke(Thread.currentThread(),
071:                            null);
072:                } catch (NoSuchMethodException e) {
073:                    // Assume that we are running JDK 1.1; use current ClassLoader
074:                    loader = ClassStuff.class.getClassLoader();
075:                } catch (Exception e) {
076:                    // "should not happen"
077:                    throw new UnknownError(e.getMessage());
078:                }
079:
080:                // 1. Check System Property
081:                // ... normally fails in applet environments
082:                try {
083:                    name = System.getProperty(label);
084:                } catch (SecurityException e) { /* IGNORE */
085:                }
086:
087:                // 2. Check in $JAVA_HOME/lib/jaxp.properties
088:                try {
089:                    if (name == null) {
090:                        String javaHome;
091:                        File file;
092:
093:                        javaHome = System.getProperty("java.home");
094:                        file = new File(new File(javaHome, "lib"),
095:                                "jaxp.properties");
096:                        if (file.exists() == true) {
097:                            FileInputStream in = new FileInputStream(file);
098:                            Properties props = new Properties();
099:
100:                            props.load(in);
101:                            name = props.getProperty(label);
102:                            in.close();
103:                        }
104:                    }
105:                } catch (Exception e) { /* IGNORE */
106:                }
107:
108:                // 3. Check Services API
109:                if (name == null) {
110:                    try {
111:                        String service = "META-INF/services/" + label;
112:                        InputStream in;
113:                        BufferedReader reader;
114:
115:                        if (loader == null)
116:                            in = ClassLoader.getSystemResourceAsStream(service);
117:                        else
118:                            in = loader.getResourceAsStream(service);
119:                        if (in != null) {
120:                            reader = new BufferedReader(new InputStreamReader(
121:                                    in, "UTF8"));
122:                            name = reader.readLine();
123:                            in.close();
124:                        }
125:                    } catch (Exception e2) { /* IGNORE */
126:                    }
127:                }
128:
129:                // 4. Distro-specific fallback
130:                if (name == null)
131:                    name = defaultClass;
132:
133:                // Instantiate!
134:                try {
135:                    Class klass;
136:
137:                    if (loader == null)
138:                        klass = Class.forName(name);
139:                    else
140:                        klass = loader.loadClass(name);
141:                    return klass.newInstance();
142:
143:                } catch (ClassNotFoundException e) {
144:                    throw new TransformerFactoryConfigurationError(e,
145:                            "Factory class " + name + " not found");
146:                } catch (IllegalAccessException e) {
147:                    throw new TransformerFactoryConfigurationError(e,
148:                            "Factory class " + name
149:                                    + " found but cannot be loaded");
150:                } catch (InstantiationException e) {
151:                    throw new TransformerFactoryConfigurationError(e,
152:                            "Factory class " + name
153:                                    + " loaded but cannot be instantiated"
154:                                    + " ((no default constructor?)");
155:                }
156:            }
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.