Java Doc for ResourceFinder.java in  » J2EE » openejb3 » org » apache » openejb » client » 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 » J2EE » openejb3 » org.apache.openejb.client 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.openejb.client.ResourceFinder

ResourceFinder
public class ResourceFinder (Code)
Note: This class is a copy of the xbean-finder ResourceFinder class. Any changes should be make to the xbean-finder source first and then copied to this class. Also, this class should be kept in sync with the xbean-finder code.
author:
   David Blevins



Constructor Summary
public  ResourceFinder(URL... urls)
    
public  ResourceFinder(String path)
    
public  ResourceFinder(String path, URL... urls)
    
public  ResourceFinder(String path, ClassLoader classLoader)
    
public  ResourceFinder(String path, ClassLoader classLoader, URL... urls)
    

Method Summary
public  URLfind(String uri)
    
public  List<URL>findAll(String uri)
    
public  List<Class>findAllClasses(String uri)
     Executes findAllStrings assuming the strings are the names of a classes that should be loaded and returned.
public  List<Class>findAllImplementations(Class interfase)
     Assumes the class specified points to a file in the classpath that contains the name of a class that implements or is a subclass of the specfied class.
public  List<Properties>findAllProperties(String uri)
     Finds the corresponding resources and reads them in as a properties files

Any URL that cannot be read in as a properties file will cause an exception to be thrown.

public  List<String>findAllStrings(String uri)
     Reads the contents of the found URLs as a list of String 's and returns them.
public  List<Class>findAvailableClasses(String uri)
     Executes findAvailableStrings assuming the strings are the names of a classes that should be loaded and returned.
public  List<Class>findAvailableImplementations(Class interfase)
     Assumes the class specified points to a file in the classpath that contains the name of a class that implements or is a subclass of the specfied class.
public  List<Properties>findAvailableProperties(String uri)
     Finds the corresponding resources and reads them in as a properties files

Any URL that cannot be read in as a properties file will be added to the 'resourcesNotLoaded' collection.

public  List<String>findAvailableStrings(String uri)
     Reads the contents of the found URLs as a Strings and returns them.
public  ClassfindClass(String uri)
     Executes ResourceFinder.findString(String) assuming the contents URL found is the name of a class that should be loaded and returned.
public  ClassfindImplementation(Class interfase)
     Assumes the class specified points to a file in the classpath that contains the name of a class that implements or is a subclass of the specfied class.
public  PropertiesfindProperties(String uri)
    
public  StringfindString(String uri)
     Reads the contents of the URL as a String 's and returns it.
public  Map<String, URL>getResourcesMap(String uri)
    
public  List<String>getResourcesNotLoaded()
     Returns a list of resources that could not be loaded in the last invoked findAvailable* or mapAvailable* methods.
public  Map<String, Class>mapAllClasses(String uri)
     Executes mapAllStrings assuming the value of each entry in the map is the name of a class that should be loaded.
public  Map<String, Class>mapAllImplementations(Class interfase)
     Assumes the class specified points to a directory in the classpath that holds files containing the name of a class that implements or is a subclass of the specfied class.
public  Map<String, Properties>mapAllProperties(String uri)
     Finds the corresponding resources and reads them in as a properties files

Any URL that cannot be read in as a properties file will cause an exception to be thrown.

public  Map<String, String>mapAllStrings(String uri)
     Reads the contents of all non-directory URLs immediately under the specified location and returns them in a map keyed by the file name.
public  Map<String, Class>mapAvailableClasses(String uri)
     Executes mapAvailableStrings assuming the value of each entry in the map is the name of a class that should be loaded.
public  Map<String, Class>mapAvailableImplementations(Class interfase)
     Assumes the class specified points to a directory in the classpath that holds files containing the name of a class that implements or is a subclass of the specfied class.
public  Map<String, Properties>mapAvailableProperties(String uri)
     Finds the corresponding resources and reads them in as a properties files

Any URL that cannot be read in as a properties file will be added to the 'resourcesNotLoaded' collection.

public  Map<String, String>mapAvailableStrings(String uri)
     Reads the contents of all non-directory URLs immediately under the specified location and returns them in a map keyed by the file name.


Constructor Detail
ResourceFinder
public ResourceFinder(URL... urls)(Code)



ResourceFinder
public ResourceFinder(String path)(Code)



ResourceFinder
public ResourceFinder(String path, URL... urls)(Code)



ResourceFinder
public ResourceFinder(String path, ClassLoader classLoader)(Code)



ResourceFinder
public ResourceFinder(String path, ClassLoader classLoader, URL... urls)(Code)




Method Detail
find
public URL find(String uri) throws IOException(Code)



findAll
public List<URL> findAll(String uri) throws IOException(Code)



findAllClasses
public List<Class> findAllClasses(String uri) throws IOException, ClassNotFoundException(Code)
Executes findAllStrings assuming the strings are the names of a classes that should be loaded and returned.

Any URL or class that cannot be loaded will cause an exception to be thrown.
Parameters:
  uri -
throws:
  IOException -
throws:
  ClassNotFoundException -




findAllImplementations
public List<Class> findAllImplementations(Class interfase) throws IOException, ClassNotFoundException(Code)
Assumes the class specified points to a file in the classpath that contains the name of a class that implements or is a subclass of the specfied class.

Any class that cannot be loaded or assigned to the specified interface will be cause an exception to be thrown.

Example classpath:

META-INF/java.io.InputStream # contains the classname org.acme.AcmeInputStream META-INF/java.io.InputStream # contains the classname org.widget.NeatoInputStream META-INF/java.io.InputStream # contains the classname com.foo.BarInputStream

ResourceFinder finder = new ResourceFinder("META-INF/"); List classes = finder.findAllImplementations(java.io.InputStream.class); classes.contains("org.acme.AcmeInputStream"); // true classes.contains("org.widget.NeatoInputStream"); // true classes.contains("com.foo.BarInputStream"); // true
Parameters:
  interfase - a superclass or interface
throws:
  IOException - if the URL cannot be read
throws:
  ClassNotFoundException - if the class found is not loadable
throws:
  ClassCastException - if the class found is not assignable to the specified superclass or interface




findAllProperties
public List<Properties> findAllProperties(String uri) throws IOException(Code)
Finds the corresponding resources and reads them in as a properties files

Any URL that cannot be read in as a properties file will cause an exception to be thrown.

Example classpath:

META-INF/app.properties META-INF/app.properties META-INF/app.properties

ResourceFinder finder = new ResourceFinder("META-INF/"); List appProps = finder.findAllProperties("app.properties");
Parameters:
  uri -
throws:
  IOException - if the URL cannot be read or is not in properties file format




findAllStrings
public List<String> findAllStrings(String uri) throws IOException(Code)
Reads the contents of the found URLs as a list of String 's and returns them.
Parameters:
  uri - a list of the content of each resource URL found
throws:
  IOException - if any of the found URLs are unable to be read.



findAvailableClasses
public List<Class> findAvailableClasses(String uri) throws IOException(Code)
Executes findAvailableStrings assuming the strings are the names of a classes that should be loaded and returned.

Any class that cannot be loaded will be skipped and placed in the 'resourcesNotLoaded' collection.
Parameters:
  uri -
throws:
  IOException - if classLoader.getResources throws an exception




findAvailableImplementations
public List<Class> findAvailableImplementations(Class interfase) throws IOException(Code)
Assumes the class specified points to a file in the classpath that contains the name of a class that implements or is a subclass of the specfied class.

Any class that cannot be loaded or are not assignable to the specified class will be skipped and placed in the 'resourcesNotLoaded' collection.

Example classpath:

META-INF/java.io.InputStream # contains the classname org.acme.AcmeInputStream META-INF/java.io.InputStream # contains the classname org.widget.NeatoInputStream META-INF/java.io.InputStream # contains the classname com.foo.BarInputStream

ResourceFinder finder = new ResourceFinder("META-INF/"); List classes = finder.findAllImplementations(java.io.InputStream.class); classes.contains("org.acme.AcmeInputStream"); // true classes.contains("org.widget.NeatoInputStream"); // true classes.contains("com.foo.BarInputStream"); // true
Parameters:
  interfase - a superclass or interface
throws:
  IOException - if classLoader.getResources throws an exception




findAvailableProperties
public List<Properties> findAvailableProperties(String uri) throws IOException(Code)
Finds the corresponding resources and reads them in as a properties files

Any URL that cannot be read in as a properties file will be added to the 'resourcesNotLoaded' collection.

Example classpath:

META-INF/app.properties META-INF/app.properties META-INF/app.properties

ResourceFinder finder = new ResourceFinder("META-INF/"); List appProps = finder.findAvailableProperties("app.properties");
Parameters:
  uri -
throws:
  IOException - if classLoader.getResources throws an exception




findAvailableStrings
public List<String> findAvailableStrings(String uri) throws IOException(Code)
Reads the contents of the found URLs as a Strings and returns them. Individual URLs that cannot be read are skipped and added to the list of 'resourcesNotLoaded'
Parameters:
  uri - a list of the content of each resource URL found
throws:
  IOException - if classLoader.getResources throws an exception



findClass
public Class findClass(String uri) throws IOException, ClassNotFoundException(Code)
Executes ResourceFinder.findString(String) assuming the contents URL found is the name of a class that should be loaded and returned.
Parameters:
  uri -
throws:
  IOException -
throws:
  ClassNotFoundException -



findImplementation
public Class findImplementation(Class interfase) throws IOException, ClassNotFoundException(Code)
Assumes the class specified points to a file in the classpath that contains the name of a class that implements or is a subclass of the specfied class.

Any class that cannot be loaded will be cause an exception to be thrown.

Example classpath:

META-INF/java.io.InputStream # contains the classname org.acme.AcmeInputStream META-INF/java.io.OutputStream

ResourceFinder finder = new ResourceFinder("META-INF/"); Class clazz = finder.findImplementation(java.io.InputStream.class); clazz.getName(); // returns "org.acme.AcmeInputStream"
Parameters:
  interfase - a superclass or interface
throws:
  IOException - if the URL cannot be read
throws:
  ClassNotFoundException - if the class found is not loadable
throws:
  ClassCastException - if the class found is not assignable to the specified superclass or interface




findProperties
public Properties findProperties(String uri) throws IOException(Code)
Finds the corresponding resource and reads it in as a properties file

Example classpath:

META-INF/widget.properties

ResourceFinder finder = new ResourceFinder("META-INF/"); Properties widgetProps = finder.findProperties("widget.properties");
Parameters:
  uri -
throws:
  IOException - if the URL cannot be read or is not in properties file format




findString
public String findString(String uri) throws IOException(Code)
Reads the contents of the URL as a String 's and returns it.
Parameters:
  uri - a stringified content of a resource
throws:
  IOException - if a resource pointed out by the uri param could not be find
See Also:   ClassLoader.getResource(String)



getResourcesMap
public Map<String, URL> getResourcesMap(String uri) throws IOException(Code)



getResourcesNotLoaded
public List<String> getResourcesNotLoaded()(Code)
Returns a list of resources that could not be loaded in the last invoked findAvailable* or mapAvailable* methods.

The list will only contain entries of resources that match the requirements of the last invoked findAvailable* or mapAvailable* methods, but were unable to be loaded and included in their results.

The list returned is unmodifiable and the results of this method will change after each invocation of a findAvailable* or mapAvailable* methods.

This method is not thread safe.




mapAllClasses
public Map<String, Class> mapAllClasses(String uri) throws IOException, ClassNotFoundException(Code)
Executes mapAllStrings assuming the value of each entry in the map is the name of a class that should be loaded.

Any class that cannot be loaded will be cause an exception to be thrown.

Example classpath:

META-INF/xmlparsers/xerces META-INF/xmlparsers/crimson

ResourceFinder finder = new ResourceFinder("META-INF/"); Map map = finder.mapAvailableStrings("xmlparsers"); map.contains("xerces"); // true map.contains("crimson"); // true Class xercesClass = map.get("xerces"); Class crimsonClass = map.get("crimson");
Parameters:
  uri -
throws:
  IOException -
throws:
  ClassNotFoundException -




mapAllImplementations
public Map<String, Class> mapAllImplementations(Class interfase) throws IOException, ClassNotFoundException(Code)
Assumes the class specified points to a directory in the classpath that holds files containing the name of a class that implements or is a subclass of the specfied class.

Any class that cannot be loaded or assigned to the specified interface will be cause an exception to be thrown.

Example classpath:

META-INF/java.net.URLStreamHandler/jar META-INF/java.net.URLStreamHandler/file META-INF/java.net.URLStreamHandler/http

ResourceFinder finder = new ResourceFinder("META-INF/"); Map map = finder.mapAllImplementations(java.net.URLStreamHandler.class); Class jarUrlHandler = map.get("jar"); Class fileUrlHandler = map.get("file"); Class httpUrlHandler = map.get("http");
Parameters:
  interfase - a superclass or interface
throws:
  IOException - if the URL cannot be read
throws:
  ClassNotFoundException - if the class found is not loadable
throws:
  ClassCastException - if the class found is not assignable to the specified superclass or interface




mapAllProperties
public Map<String, Properties> mapAllProperties(String uri) throws IOException(Code)
Finds the corresponding resources and reads them in as a properties files

Any URL that cannot be read in as a properties file will cause an exception to be thrown.

Example classpath:

META-INF/jdbcDrivers/oracle.properties META-INF/jdbcDrivers/mysql.props META-INF/jdbcDrivers/derby

ResourceFinder finder = new ResourceFinder("META-INF/"); List driversList = finder.findAvailableProperties("jdbcDrivers"); Properties oracleProps = driversList.get("oracle.properties"); Properties mysqlProps = driversList.get("mysql.props"); Properties derbyProps = driversList.get("derby");
Parameters:
  uri -
throws:
  IOException - if the URL cannot be read or is not in properties file format




mapAllStrings
public Map<String, String> mapAllStrings(String uri) throws IOException(Code)
Reads the contents of all non-directory URLs immediately under the specified location and returns them in a map keyed by the file name.

Any URLs that cannot be read will cause an exception to be thrown.

Example classpath:

META-INF/serializables/one META-INF/serializables/two META-INF/serializables/three META-INF/serializables/four/foo.txt

ResourceFinder finder = new ResourceFinder("META-INF/"); Map map = finder.mapAvailableStrings("serializables"); map.contains("one"); // true map.contains("two"); // true map.contains("three"); // true map.contains("four"); // false
Parameters:
  uri - a list of the content of each resource URL found
throws:
  IOException - if any of the urls cannot be read




mapAvailableClasses
public Map<String, Class> mapAvailableClasses(String uri) throws IOException(Code)
Executes mapAvailableStrings assuming the value of each entry in the map is the name of a class that should be loaded.

Any class that cannot be loaded will be skipped and placed in the 'resourcesNotLoaded' collection.

Example classpath:

META-INF/xmlparsers/xerces META-INF/xmlparsers/crimson

ResourceFinder finder = new ResourceFinder("META-INF/"); Map map = finder.mapAvailableStrings("xmlparsers"); map.contains("xerces"); // true map.contains("crimson"); // true Class xercesClass = map.get("xerces"); Class crimsonClass = map.get("crimson");
Parameters:
  uri -
throws:
  IOException - if classLoader.getResources throws an exception




mapAvailableImplementations
public Map<String, Class> mapAvailableImplementations(Class interfase) throws IOException(Code)
Assumes the class specified points to a directory in the classpath that holds files containing the name of a class that implements or is a subclass of the specfied class.

Any class that cannot be loaded or are not assignable to the specified class will be skipped and placed in the 'resourcesNotLoaded' collection.

Example classpath:

META-INF/java.net.URLStreamHandler/jar META-INF/java.net.URLStreamHandler/file META-INF/java.net.URLStreamHandler/http

ResourceFinder finder = new ResourceFinder("META-INF/"); Map map = finder.mapAllImplementations(java.net.URLStreamHandler.class); Class jarUrlHandler = map.get("jar"); Class fileUrlHandler = map.get("file"); Class httpUrlHandler = map.get("http");
Parameters:
  interfase - a superclass or interface
throws:
  IOException - if classLoader.getResources throws an exception




mapAvailableProperties
public Map<String, Properties> mapAvailableProperties(String uri) throws IOException(Code)
Finds the corresponding resources and reads them in as a properties files

Any URL that cannot be read in as a properties file will be added to the 'resourcesNotLoaded' collection.

Example classpath:

META-INF/jdbcDrivers/oracle.properties META-INF/jdbcDrivers/mysql.props META-INF/jdbcDrivers/derby

ResourceFinder finder = new ResourceFinder("META-INF/"); List driversList = finder.findAvailableProperties("jdbcDrivers"); Properties oracleProps = driversList.get("oracle.properties"); Properties mysqlProps = driversList.get("mysql.props"); Properties derbyProps = driversList.get("derby");
Parameters:
  uri -
throws:
  IOException - if classLoader.getResources throws an exception




mapAvailableStrings
public Map<String, String> mapAvailableStrings(String uri) throws IOException(Code)
Reads the contents of all non-directory URLs immediately under the specified location and returns them in a map keyed by the file name.

Individual URLs that cannot be read are skipped and added to the list of 'resourcesNotLoaded'

Example classpath:

META-INF/serializables/one META-INF/serializables/two # not readable META-INF/serializables/three META-INF/serializables/four/foo.txt

ResourceFinder finder = new ResourceFinder("META-INF/"); Map map = finder.mapAvailableStrings("serializables"); map.contains("one"); // true map.contains("two"); // false map.contains("three"); // true map.contains("four"); // false
Parameters:
  uri - a list of the content of each resource URL found
throws:
  IOException - if classLoader.getResources throws an exception




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.