to.etc.domui.util.resources
Class ClasspathInventory

java.lang.Object
  extended by to.etc.domui.util.resources.ClasspathInventory

public class ClasspathInventory
extends java.lang.Object

Inventory of all files (.class and other resources) reachable in the classpath. It lazily loads all entries in all directory classpath entries and all .jar entries and caches those as soon as they are needed.

Used in development mode to get timestamps for .class and other files, and the contents of resources.

Author:
Frits Jalvingh Created on Jan 5, 2011

Method Summary
static ClasspathInventory create(java.lang.ClassLoader cl)
          Create an inventory for the specified classloader.
static ClasspathInventory create(java.net.URL[] urls)
          Create an inventory on the specified URLs.
 IModifyableResource findClassSource(java.lang.Class<?> clz)
          Tries to find the .class file for the specified class.
 IModifyableResource findResourceSource(java.lang.String resourcePath)
          Locate the source for some file that is part of the classpath (either a class resource or a .class file itself), and return a timestamp for that thing if found.
static ClasspathInventory getInstance()
          Create and/or return an instance that uses it's own classloader to initialize all classpath entries.
 java.util.List<java.lang.String> getPackageInventory(java.lang.String pkgdirname)
          This scans the entire known classpath and constructs all stuff that is available in the specified package directory.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static ClasspathInventory create(java.net.URL[] urls)
Create an inventory on the specified URLs. Only file: urls are actually used, the rest is ignored.

Parameters:
urls -
Returns:

create

public static ClasspathInventory create(java.lang.ClassLoader cl)
Create an inventory for the specified classloader.

Parameters:
cl -
Returns:

getInstance

public static ClasspathInventory getInstance()
Create and/or return an instance that uses it's own classloader to initialize all classpath entries.

Returns:

findResourceSource

public IModifyableResource findResourceSource(java.lang.String resourcePath)
Locate the source for some file that is part of the classpath (either a class resource or a .class file itself), and return a timestamp for that thing if found. If the resource is not found this returns null.

Parameters:
resourcePath - Absolute resource pathname, preferably without leading /
Returns:
Throws:
java.net.URISyntaxException

findClassSource

public IModifyableResource findClassSource(java.lang.Class<?> clz)
Tries to find the .class file for the specified class.

Parameters:
clz -
Returns:
Throws:
java.net.URISyntaxException

getPackageInventory

@Nonnull
public java.util.List<java.lang.String> getPackageInventory(@Nonnull
                                                                    java.lang.String pkgdirname)
This scans the entire known classpath and constructs all stuff that is available in the specified package directory. These are all files there: .class and others.

Parameters:
pkgdirname -
Returns:

main

public static void main(java.lang.String[] args)