com.kuka.common
Class ResolveUtil

java.lang.Object
  extended by com.kuka.common.ResolveUtil

public final class ResolveUtil
extends Object

Utility class to get resources like URLs or classes.

This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

Method Summary
static void addClassLoader(ClassLoader loader)
          Adds a class loader to the utilities class.
static Class<?> loadClass(Class<?> applicationContext, String className)
          Loads a class through a given context.
static Class<?> loadClass(String className)
          Loads a class through a given context.
static void removeClassLoader(ClassLoader loader)
          Removes the class loader from the utilities class.
static URL resolve(Class<?> applicationContext, String resourceName)
          Resolves a URL from the given context.
static URL resolve(String resourceName)
          Resolves a URL from the given context.
static URL tryResolve(Class<?> applicationContext, String resourceName)
          Resolves a URL from the given context.
static URL tryResolve(String resourceName)
          Resolves a URL from the given context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addClassLoader

public static void addClassLoader(ClassLoader loader)
Adds a class loader to the utilities class. This loader will be used to resolve resources.

Parameters:
loader - The class loader. May not be null.

removeClassLoader

public static void removeClassLoader(ClassLoader loader)
Removes the class loader from the utilities class.

Parameters:
loader - The class loader. May not be null.

resolve

public static URL resolve(Class<?> applicationContext,
                          String resourceName)
Resolves a URL from the given context. Fails if URL cannot be resolved.

Tries to load the resource in the following way:

1. try application context (if not null)

2. try additional class loaders

3. try system class loader

4. try to get the resource as a file.

Parameters:
applicationContext - The context.
resourceName - The resource name.
Returns:
The resolved URL.

resolve

public static URL resolve(String resourceName)
Resolves a URL from the given context. Fails if URL cannot be resolved.

Tries to load the resource in the following way:

1. try additional class loaders

2. try system class loader

3. try to get the resource as a file.

Parameters:
resourceName - The resource name.
Returns:
The resolved URL.

tryResolve

public static URL tryResolve(String resourceName)
Resolves a URL from the given context. Returns null if URL cannot be resolved.

Tries to load the resource in the following way:

1. try additional class loaders

2. try system class loader

3. try to get the resource as a file.

Parameters:
resourceName - The resource name.
Returns:
The resolved URL or null if it was not resolved.

tryResolve

public static URL tryResolve(Class<?> applicationContext,
                             String resourceName)
Resolves a URL from the given context. Returns null if URL cannot be resolved.

Tries to load the resource in the following way:

1. try application context (if not null)

2. try additional class loaders

3. try system class loader

4. try to get the resource as a file.

Parameters:
applicationContext - The context. May be null.
resourceName - The resource name.
Returns:
The resolved URL or null if it was not resolved.

loadClass

public static Class<?> loadClass(String className)
Loads a class through a given context. Fails if the class was not loaded.

This method additionally uses the statically registered class loaders of this class.

It performs two attempts to load the class from a class loader:

1. ClassLoader from additionally registered class loader.

2. System - class loader.

Parameters:
className - The name of the class.
Returns:
The loaded class.

loadClass

public static Class<?> loadClass(Class<?> applicationContext,
                                 String className)
Loads a class through a given context. Fails if the class was not loaded.

This method additionally uses the statically registered class loaders of this class.

It performs three attempts to load the class from a class loader:

1. ClassLoader from the given application context (if not null).

2. ClassLoader from additionally registered class loader.

3. System - class loader.

Parameters:
applicationContext - The context class. May be null.
className - The name of the class.
Returns:
The loaded class.


Copyright © 2019. All rights reserved.