Source Code Cross Referenced for ParanoidClassLoader.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » servlet » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.servlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.servlet;
018:
019:        import java.io.File;
020:        import java.io.IOException;
021:        import java.net.URL;
022:        import java.net.URLClassLoader;
023:        import java.net.URLStreamHandlerFactory;
024:
025:        /**
026:         * The <code>ParanoidClassLoader</code> reverses the search order for classes.
027:         * It checks this classloader before it checks its parent.
028:         * 
029:         * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch </a>
030:         * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez </a>
031:         * @version CVS $Id: ParanoidClassLoader.java 30932 2004-07-29 17:35:38Z
032:         *          vgritsenko $
033:         */
034:
035:        public class ParanoidClassLoader extends URLClassLoader {
036:
037:            /**
038:             * Default constructor has no parents or initial <code>URL</code>s.
039:             */
040:            public ParanoidClassLoader() {
041:                this (null, null, null);
042:            }
043:
044:            /**
045:             * Alternate constructor to define a parent.
046:             */
047:            public ParanoidClassLoader(final ClassLoader parent) {
048:                this (new URL[0], parent, null);
049:            }
050:
051:            /**
052:             * Alternate constructor to define initial <code>URL</code>s.
053:             */
054:            public ParanoidClassLoader(final URL[] urls) {
055:                this (urls, null, null);
056:            }
057:
058:            /**
059:             * Alternate constructor to define a parent and initial <code>URL</code>
060:             * s.
061:             */
062:            public ParanoidClassLoader(final URL[] urls,
063:                    final ClassLoader parent) {
064:                this (urls, parent, null);
065:            }
066:
067:            /**
068:             * Alternate constructor to define a parent, initial <code>URL</code>s,
069:             * and a default <code>URLStreamHandlerFactory</code>.
070:             */
071:            public ParanoidClassLoader(final URL[] urls,
072:                    final ClassLoader parent,
073:                    final URLStreamHandlerFactory factory) {
074:                super (urls, parent, factory);
075:            }
076:
077:            /**
078:             * Extends <code>URLClassLoader</code>'s initialization methods so we
079:             * return a <code>ParanoidClassLoad</code> instead.
080:             */
081:            public static final URLClassLoader newInstance(final URL[] urls) {
082:                return new ParanoidClassLoader(urls);
083:            }
084:
085:            /**
086:             * Extends <code>URLClassLoader</code>'s initialization methods so we
087:             * return a <code>ParanoidClassLoad</code> instead.
088:             */
089:            public static final URLClassLoader newInstance(final URL[] urls,
090:                    final ClassLoader parent) {
091:                return new ParanoidClassLoader(urls, parent);
092:            }
093:
094:            /**
095:             * Loads the class from this <code>ClassLoader</class>.  If the
096:             * class does not exist in this one, we check the parent.  Please
097:             * note that this is the exact opposite of the
098:             * <code>ClassLoader</code> spec.  We use it to work around
099:             * inconsistent class loaders from third party vendors.
100:             *
101:             * @param     name the name of the class
102:             * @param     resolve if <code>true</code> then resolve the class
103:             * @return    the resulting <code>Class</code> object
104:             * @exception ClassNotFoundException if the class could not be found
105:             */
106:            public final Class loadClass(String name, boolean resolve)
107:                    throws ClassNotFoundException {
108:                // First check if it's already loaded
109:                Class clazz = findLoadedClass(name);
110:
111:                if (clazz == null) {
112:
113:                    try {
114:                        clazz = findClass(name);
115:                        //System.err.println("Paranoid load : " + name);
116:                    } catch (ClassNotFoundException cnfe) {
117:                        ClassLoader parent = getParent();
118:                        if (parent != null) {
119:                            // Ask to parent ClassLoader (can also throw a CNFE).
120:                            clazz = parent.loadClass(name);
121:                        } else {
122:                            // Propagate exception
123:                            throw cnfe;
124:                        }
125:                    }
126:                }
127:
128:                if (resolve) {
129:                    resolveClass(clazz);
130:                }
131:
132:                return clazz;
133:            }
134:
135:            /**
136:             * Gets a resource from this <code>ClassLoader</class>.  If the
137:             * resource does not exist in this one, we check the parent.
138:             * Please note that this is the exact opposite of the
139:             * <code>ClassLoader</code> spec.  We use it to work around
140:             * inconsistent class loaders from third party vendors.
141:             *
142:             * @param name of resource
143:             */
144:            public final URL getResource(final String name) {
145:
146:                URL resource = findResource(name);
147:                ClassLoader parent = this .getParent();
148:                if (resource == null && parent != null) {
149:                    resource = parent.getResource(name);
150:                }
151:
152:                return resource;
153:            }
154:
155:            /**
156:             * Adds a new directory of class files.
157:             * 
158:             * @param file
159:             *            for jar or directory
160:             * @throws IOException
161:             */
162:            public final void addDirectory(File file) throws IOException {
163:                this .addURL(file.getCanonicalFile().toURL());
164:            }
165:
166:            /**
167:             * Adds a new URL
168:             */
169:
170:            public void addURL(URL url) {
171:                super.addURL(url);
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.