Java Doc for ClasspathUtils.java in  » Build » ANT » org » apache » tools » ant » util » 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 » Build » ANT » org.apache.tools.ant.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.tools.ant.util.ClasspathUtils

ClasspathUtils
public class ClasspathUtils (Code)
Offers some helper methods on the Path structure in ant.

The basic idea behind this utility class is to use it from inside the different Ant objects (and user defined objects) that need classLoading for their operation. Normally those would have a setClasspathRef() {for the @classpathref} and/or a createClasspath() {for the nested <classpath>} Typically one would have in your Ant Task or DataType


 ClasspathUtils.Delegate cpDelegate;
 public void init() {
 this.cpDelegate = ClasspathUtils.getDelegate(this);
 super.init();
 }
 public void setClasspathRef(Reference r) {
 this.cpDelegate.setClasspathRef(r);
 }
 public Path createClasspath() {
 return this.cpDelegate.createClasspath();
 }
 public void setClassname(String fqcn) {
 this.cpDelegate.setClassname(fqcn);
 }
 

At execution time, when you actually need the classloading you can just:


 Object o = this.cpDelegate.newInstance();
 

since:
   Ant 1.6

Inner Class :public static class Delegate

Field Summary
final public static  StringREUSE_LOADER_REF
     Name of the magic property that controls classloader reuse in Ant 1.4.


Method Summary
public static  ClassLoadergetClassLoaderForPath(Project p, Reference ref)
     Convenience overloaded version of ClasspathUtils.getClassLoaderForPath(Project,Reference,boolean) .
public static  ClassLoadergetClassLoaderForPath(Project p, Reference ref, boolean reverseLoader)
     Convenience overloaded version of ClasspathUtils.getClassLoaderForPath(Project,Path,String,boolean) .

Delegates to the other one after extracting the referenced Path from the Project.

public static  ClassLoadergetClassLoaderForPath(Project p, Path path, String loaderId)
     Convenience overloaded version of ClasspathUtils.getClassLoaderForPath(Project,Path,String,boolean) .
public static  ClassLoadergetClassLoaderForPath(Project p, Path path, String loaderId, boolean reverseLoader)
     Convenience overloaded version of ClasspathUtils.getClassLoaderForPath(Project,Path,String,boolean,boolean) .
public static  ClassLoadergetClassLoaderForPath(Project p, Path path, String loaderId, boolean reverseLoader, boolean reuseLoader)
     Gets a classloader that loads classes from the classpath defined in the path argument.
public static  DelegategetDelegate(ProjectComponent component)
     Obtains a delegate that helps out with classic classpath configuration.
public static  ClassLoadergetUniqueClassLoaderForPath(Project p, Path path, boolean reverseLoader)
     Gets a fresh, different, previously unused classloader that uses the passed path as its classpath.
public static  ObjectnewInstance(String className, ClassLoader userDefinedLoader)
     Creates a fresh object instance of the specified classname.

This uses the userDefinedLoader to load the specified class, and then makes an instance using the default no-argument constructor.


Parameters:
  className - the full qualified class name to load.
Parameters:
  userDefinedLoader - the classloader to use.
public static  ObjectnewInstance(String className, ClassLoader userDefinedLoader, Class expectedType)
     Creates a fresh object instance of the specified classname.

This uses the userDefinedLoader to load the specified class, and then makes an instance using the default no-argument constructor.


Parameters:
  className - the full qualified class name to load.
Parameters:
  userDefinedLoader - the classloader to use.
Parameters:
  expectedType - the Class that the result should be assignmentcompatible with.

Field Detail
REUSE_LOADER_REF
final public static String REUSE_LOADER_REF(Code)
Name of the magic property that controls classloader reuse in Ant 1.4.





Method Detail
getClassLoaderForPath
public static ClassLoader getClassLoaderForPath(Project p, Reference ref)(Code)
Convenience overloaded version of ClasspathUtils.getClassLoaderForPath(Project,Reference,boolean) .

Assumes the logical 'false' for the reverseLoader.


Parameters:
  p - the project
Parameters:
  ref - the reference The class loader



getClassLoaderForPath
public static ClassLoader getClassLoaderForPath(Project p, Reference ref, boolean reverseLoader)(Code)
Convenience overloaded version of ClasspathUtils.getClassLoaderForPath(Project,Path,String,boolean) .

Delegates to the other one after extracting the referenced Path from the Project. This checks also that the passed Reference is pointing to a Path all right.


Parameters:
  p - current Ant project
Parameters:
  ref - Reference to Path structure
Parameters:
  reverseLoader - if set to true this new loader will takeprecedence over its parent (which is contra the regularclassloader behaviour) The class loader



getClassLoaderForPath
public static ClassLoader getClassLoaderForPath(Project p, Path path, String loaderId)(Code)
Convenience overloaded version of ClasspathUtils.getClassLoaderForPath(Project,Path,String,boolean) .

Assumes the logical 'false' for the reverseLoader.


Parameters:
  p - current Ant project
Parameters:
  path - the path
Parameters:
  loaderId - the loader id string The class loader



getClassLoaderForPath
public static ClassLoader getClassLoaderForPath(Project p, Path path, String loaderId, boolean reverseLoader)(Code)
Convenience overloaded version of ClasspathUtils.getClassLoaderForPath(Project,Path,String,boolean,boolean) .

Sets value for 'reuseLoader' to true if the magic property has been set.


Parameters:
  p - the project
Parameters:
  path - the path
Parameters:
  loaderId - the loader id string
Parameters:
  reverseLoader - if set to true this new loader will takeprecedence over its parent (which is contra the regularclassloader behaviour) The class loader



getClassLoaderForPath
public static ClassLoader getClassLoaderForPath(Project p, Path path, String loaderId, boolean reverseLoader, boolean reuseLoader)(Code)
Gets a classloader that loads classes from the classpath defined in the path argument.

Based on the setting of the magic property 'ant.reuse.loader' this will try to reuse the previously created loader with that id, and of course store it there upon creation.


Parameters:
  p - Ant Project where the handled components are living in.
Parameters:
  path - Path object to be used as classpath for this classloader
Parameters:
  loaderId - identification for this Loader,
Parameters:
  reverseLoader - if set to true this new loader will takeprecedence over its parent (which is contra the regularclassloader behaviour)
Parameters:
  reuseLoader - if true reuse the loader if it is found ClassLoader that uses the Path as its classpath.



getDelegate
public static Delegate getDelegate(ProjectComponent component)(Code)
Obtains a delegate that helps out with classic classpath configuration.
Parameters:
  component - your projectComponent that needs the assistence the helper, delegate.
See Also:   ClasspathUtils.Delegate



getUniqueClassLoaderForPath
public static ClassLoader getUniqueClassLoaderForPath(Project p, Path path, boolean reverseLoader)(Code)
Gets a fresh, different, previously unused classloader that uses the passed path as its classpath.

This method completely ignores the ant.reuse.loader magic property and should be used with caution.


Parameters:
  p - Ant Project where the handled components are living in.
Parameters:
  path - the classpath for this loader
Parameters:
  reverseLoader - if set to true this new loader will takeprecedence over its parent (which is contra the regularclassloader behaviour) The fresh, different, previously unused class loader.



newInstance
public static Object newInstance(String className, ClassLoader userDefinedLoader)(Code)
Creates a fresh object instance of the specified classname.

This uses the userDefinedLoader to load the specified class, and then makes an instance using the default no-argument constructor.


Parameters:
  className - the full qualified class name to load.
Parameters:
  userDefinedLoader - the classloader to use. The fresh object instance
throws:
  BuildException - when loading or instantiation failed.



newInstance
public static Object newInstance(String className, ClassLoader userDefinedLoader, Class expectedType)(Code)
Creates a fresh object instance of the specified classname.

This uses the userDefinedLoader to load the specified class, and then makes an instance using the default no-argument constructor.


Parameters:
  className - the full qualified class name to load.
Parameters:
  userDefinedLoader - the classloader to use.
Parameters:
  expectedType - the Class that the result should be assignmentcompatible with. (No ClassCastException will be thrown in casethe result of this method is casted to the expectedType) The fresh object instance
throws:
  BuildException - when loading or instantiation failed.
since:
   Ant 1.7



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(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.