de.smartics.properties.spi.core.util
Class ClassLoaderUtils

Package class diagram package ClassLoaderUtils
java.lang.Object
  extended by de.smartics.properties.spi.core.util.ClassLoaderUtils

public final class ClassLoaderUtils
     
     
extends Object

Utilities dealing with class loaders.


Method Summary
static String calcArchivePath(Class<?> type)
          Determines the path to the class loader root that contains the given type.
static String calcFirstArchivePath(ClassLoader loader, String resource)
          Determines the path to the class loader root that contains the given resource.
static de.smartics.util.lang.classpath.ClassPathContext createClassPathContext(ClassLoader classLoader, String resource)
          Creates the class path context for the given class loader and its derived context root.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

calcArchivePath

public static String calcArchivePath(Class<?> type)
                              throws NullPointerException
Determines the path to the class loader root that contains the given type.

Parameters:
type - the type whose class loader root is requested.
Returns:
the class loader root.
Throws:
NullPointerException - if type is null.

calcFirstArchivePath

public static String calcFirstArchivePath(ClassLoader loader,
                                          String resource)
                                   throws NullPointerException,
                                          IllegalArgumentException
Determines the path to the class loader root that contains the given resource. The first matching path is returned. This call does not check if there is more than one path that serves the given resource .

Parameters:
loader - the loader to load the resource.
resource - the resource whose class loader root is requested.
Returns:
the class loader root for the given resource.
Throws:
NullPointerException - if loader or resource is null.
IllegalArgumentException - if the resource cannot be found by the given class loader.

createClassPathContext

public static de.smartics.util.lang.classpath.ClassPathContext createClassPathContext(ClassLoader classLoader,
                                                                                      String resource)
Creates the class path context for the given class loader and its derived context root. The first matching path is used to calculate the class path root. This call does not check if there is more than one path that serves the given resource.

Parameters:
classLoader - the class loader to access resources.
resource - the resource whose class loader root is requested.
Returns:
the class path context.


Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.