com.atomikos.util
Class ClassLoadingHelper

java.lang.Object
  extended by com.atomikos.util.ClassLoadingHelper

public class ClassLoadingHelper
extends Object

A helper class for class loading.


Constructor Summary
ClassLoadingHelper()
           
 
Method Summary
static Class loadClass(String className)
          Loads a class with the given name.
static URL loadResourceFromClasspath(Class clazz, String resourceName)
          Attempts to load a given resource from the classpath.
static Object newProxyInstance(List classLoadersToTry, Class[] interfaces, InvocationHandler delegate)
          Creates a new dynamic proxy instance for the given delegate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassLoadingHelper

public ClassLoadingHelper()
Method Detail

newProxyInstance

public static Object newProxyInstance(List classLoadersToTry,
                                      Class[] interfaces,
                                      InvocationHandler delegate)
                               throws IllegalArgumentException
Creates a new dynamic proxy instance for the given delegate.

Parameters:
classLoadersToTry - The class loaders to try, in the specified list order.
interfaces - The interfaces to add to the returned proxy.
delegate - The underlying object that will receive the calls on the proxy.
Returns:
The proxy.
Throws:
IllegalArgumentException - If any of the interfaces involved could not be loaded.

loadClass

public static Class loadClass(String className)
                       throws ClassNotFoundException
Loads a class with the given name.

Parameters:
className -
Returns:
The class object
Throws:
ClassNotFoundException - If not found

loadResourceFromClasspath

public static URL loadResourceFromClasspath(Class clazz,
                                            String resourceName)
Attempts to load a given resource from the classpath.

Parameters:
clazz - The class to use as reference re classpath.
resourceName - The name of the resource
Returns:
The URL to the resource, or null if not found.


Copyright © 2011. All Rights Reserved.