org.java.plugin.extension.util
Class ClasspathUtils

java.lang.Object
  extended by org.java.plugin.extension.util.ClasspathUtils

public class ClasspathUtils
extends java.lang.Object

Various functions to locate URLs to scan The original Version of this class was writen by Bill Burke.

Version:
$Revision: 1 $
Author:
Bill Burke, Thasso Griebel (thasso.griebel@gmail.com))

Constructor Summary
ClasspathUtils()
           
 
Method Summary
static java.net.URL findClassBase(java.lang.Class clazz)
          Find the classpath for the particular class
static java.net.URL[] findClassPaths()
          Uses the java.class.path system property to obtain a list of URLs that represent the CLASSPATH
static java.net.URL[] findClassPaths(java.lang.String... paths)
          Uses the java.class.path system property to obtain a list of URLs that represent the CLASSPATH

paths is used as a filter to only include paths that have the specific relative file within it

static java.net.URL findResourceBase(java.lang.String baseResource)
          Find the classpath URL for a specific classpath resource.
static java.net.URL findResourceBase(java.lang.String baseResource, java.lang.ClassLoader loader)
          Find the classpath URL for a specific classpath resource.
static java.net.URL[] findResourceBases(java.lang.String baseResource)
          Find the classpath URLs for a specific classpath resource.
static java.net.URL[] findResourceBases(java.lang.String baseResource, java.lang.ClassLoader loader)
          Find the classpath URLs for a specific classpath resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClasspathUtils

public ClasspathUtils()
Method Detail

findResourceBases

public static java.net.URL[] findResourceBases(java.lang.String baseResource,
                                               java.lang.ClassLoader loader)
Find the classpath URLs for a specific classpath resource. The classpath URL is extracted from loader.getResources() using the baseResource.

Parameters:
baseResource -
loader - to be used to resolve the resources
Returns:
urls to resource

findResourceBases

public static java.net.URL[] findResourceBases(java.lang.String baseResource)
Find the classpath URLs for a specific classpath resource. The classpath URL is extracted from loader.getResources() using the baseResource. This uses Thread.getContextClassLoader() as ClassLoader.

Parameters:
baseResource - the resource
Returns:
urls to resource

findResourceBase

public static java.net.URL findResourceBase(java.lang.String baseResource)
Find the classpath URL for a specific classpath resource. The classpath URL is extracted from Thread.currentThread().getContextClassLoader().getResource() using the baseResource.

Parameters:
baseResource -
Returns:
url to resource

findResourceBase

public static java.net.URL findResourceBase(java.lang.String baseResource,
                                            java.lang.ClassLoader loader)
Find the classpath URL for a specific classpath resource. The classpath URL is extracted from loader.getResource() using the baseResource.This uses Thread.getContextClassLoader() as ClassLoader.

Parameters:
baseResource -
loader -
Returns:

findClassBase

public static java.net.URL findClassBase(java.lang.Class clazz)
Find the classpath for the particular class

Parameters:
clazz -
Returns:
url to specified class file

findClassPaths

public static java.net.URL[] findClassPaths()
Uses the java.class.path system property to obtain a list of URLs that represent the CLASSPATH

Returns:
urls in classpath

findClassPaths

public static java.net.URL[] findClassPaths(java.lang.String... paths)
Uses the java.class.path system property to obtain a list of URLs that represent the CLASSPATH

paths is used as a filter to only include paths that have the specific relative file within it

Parameters:
paths - comma list of files that should exist in a particular path
Returns:
urls in classpath


Copyright © 2010. All Rights Reserved.