Java Doc for PathableClassLoader.java in  » Library » apache-common-Logging » org » apache » commons » logging » 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 » Library » apache common Logging » org.apache.commons.logging 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.net.URLClassLoader
   org.apache.commons.logging.PathableClassLoader

PathableClassLoader
public class PathableClassLoader extends URLClassLoader (Code)
A ClassLoader which sees only specified classes, and which can be set to do parent-first or child-first path lookup.

Note that this classloader is not "industrial strength"; users looking for such a class may wish to look at the Tomcat sourcecode instead. In particular, this class may not be threadsafe.

Note that the ClassLoader.getResources method isn't overloaded here. It would be nice to ensure that when child-first lookup is set the resources from the child are returned earlier in the list than the resources from the parent. However overriding this method isn't possible as the java 1.4 version of ClassLoader declares this method final (though the java 1.5 version has removed the final qualifier). As the ClassLoader javadoc doesn't specify the order in which resources are returned, it's valid to return the resources in any order (just untidy) so the inherited implementation is technically ok.




Constructor Summary
public  PathableClassLoader(ClassLoader parent)
     Constructor.

Method Summary
public  voidaddLogicalLib(String[] logicalLibs)
     Specify a collection of logical libraries.
public  voidaddLogicalLib(String logicalLib)
     Specify a logical library to be included in the classpath used to locate classes.
public  voidaddURL(URL url)
     Allow caller to explicitly add paths.
public  URLgetResource(String name)
     Same as parent class method except that when parentFirst is false the resource is looked for in the local classpath before the parent loader is consulted.
public  InputStreamgetResourceAsStream(String name)
     Same as parent class method except that when parentFirst is false the resource is looked for in the local classpath before the parent loader is consulted.
public  EnumerationgetResourcesInOrder(String name)
     Emulate a proper implementation of getResources which respects the setting for parentFirst.
protected  ClassloadClass(String name, boolean resolve)
     Override ClassLoader method.
public  voidsetParentFirst(boolean state)
     Specify whether this classloader should ask the parent classloader to resolve a class first, before trying to resolve it via its own classpath.
public  voiduseExplicitLoader(String prefix, ClassLoader loader)
     Specify a classloader to use for specific java packages.
public  voiduseSystemLoader(String prefix)
     For classes with the specified prefix, get them from the system classpath which is active at the point this method is called.


Constructor Detail
PathableClassLoader
public PathableClassLoader(ClassLoader parent)(Code)
Constructor.




Method Detail
addLogicalLib
public void addLogicalLib(String[] logicalLibs)(Code)
Specify a collection of logical libraries. See addLogicalLib.



addLogicalLib
public void addLogicalLib(String logicalLib)(Code)
Specify a logical library to be included in the classpath used to locate classes.

The specified lib name is used as a key into the system properties; there is expected to be a system property defined with that name whose value is a url that indicates where that logical library can be found. Typically this is the name of a jar file, or a directory containing class files.

Using logical library names allows the calling code to specify its desired classpath without knowing the exact location of the necessary classes.




addURL
public void addURL(URL url)(Code)
Allow caller to explicitly add paths. Generally this not a good idea; use addLogicalLib instead, then define the location for that logical library in the build.xml file.



getResource
public URL getResource(String name)(Code)
Same as parent class method except that when parentFirst is false the resource is looked for in the local classpath before the parent loader is consulted.



getResourceAsStream
public InputStream getResourceAsStream(String name)(Code)
Same as parent class method except that when parentFirst is false the resource is looked for in the local classpath before the parent loader is consulted.



getResourcesInOrder
public Enumeration getResourcesInOrder(String name) throws IOException(Code)
Emulate a proper implementation of getResources which respects the setting for parentFirst.

Note that it's not possible to override the inherited getResources, as it's declared final in java1.4 (thought that's been removed for 1.5). The inherited implementation always behaves as if parentFirst=true.




loadClass
protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException(Code)
Override ClassLoader method.

For each explicitly mapped package prefix, if the name matches the prefix associated with that entry then attempt to load the class via that entries' classloader.




setParentFirst
public void setParentFirst(boolean state)(Code)
Specify whether this classloader should ask the parent classloader to resolve a class first, before trying to resolve it via its own classpath.

Checking with the parent first is the normal approach for java, but components within containers such as servlet engines can use child-first lookup instead, to allow the components to override libs which are visible in shared classloaders provided by the container.

Note that the method getResources always behaves as if parentFirst=true, because of limitations in java 1.4; see the javadoc for method getResourcesInOrder for details.

This value defaults to true.




useExplicitLoader
public void useExplicitLoader(String prefix, ClassLoader loader)(Code)
Specify a classloader to use for specific java packages.



useSystemLoader
public void useSystemLoader(String prefix)(Code)
For classes with the specified prefix, get them from the system classpath which is active at the point this method is called.

This method is just a shortcut for

 useExplicitLoader(prefix, ClassLoader.getSystemClassLoader());
 



Methods inherited from java.net.URLClassLoader
protected void addURL(URL url)(Code)(Java Doc)
protected Package definePackage(String name, Manifest man, URL url) throws IllegalArgumentException(Code)(Java Doc)
protected Class findClass(String name) throws ClassNotFoundException(Code)(Java Doc)
public URL findResource(String name)(Code)(Java Doc)
public Enumeration<URL> findResources(String name) throws IOException(Code)(Java Doc)
protected PermissionCollection getPermissions(CodeSource codesource)(Code)(Java Doc)
public URL[] getURLs()(Code)(Java Doc)
public static URLClassLoader newInstance(URL[] urls, ClassLoader parent)(Code)(Java Doc)
public static URLClassLoader newInstance(URL[] urls)(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.