org.apache.myfaces.extensions.cdi.core.api.util
Class ClassUtils

java.lang.Object
  extended by org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils

public class ClassUtils
extends Object

Author:
Gerhard Petracek

Constructor Summary
ClassUtils()
           
 
Method Summary
static ClassLoader getClassLoader(Object o)
          Detect the right ClassLoader.
static String getJarVersion(Class targetClass)
           
static Object instantiateClassForName(String className)
           
static Class loadClassForName(String name)
           
static
<T> T
tryToInstantiateClass(Class<T> targetClass)
           
static
<T> T
tryToInstantiateClass(Class targetClass, Class<T> type)
           
static Object tryToInstantiateClassForName(String className)
           
static
<T> T
tryToInstantiateClassForName(String className, Class<T> targetType)
           
static Class tryToLoadClassForName(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassUtils

public ClassUtils()
Method Detail

getClassLoader

public static ClassLoader getClassLoader(Object o)
Detect the right ClassLoader. The lookup order is determined by:
  1. ContextClassLoader of the current Thread
  2. ClassLoader of the given Object 'o'
  3. ClassLoader of this very CodiUtils class

Parameters:
o - if not null it may get used to detect the classloader.
Returns:
The ClassLoader which should get used to create new instances

tryToLoadClassForName

public static Class tryToLoadClassForName(String name)

loadClassForName

public static Class loadClassForName(String name)
                              throws ClassNotFoundException
Throws:
ClassNotFoundException

tryToInstantiateClass

public static <T> T tryToInstantiateClass(Class<T> targetClass)

tryToInstantiateClass

public static <T> T tryToInstantiateClass(Class targetClass,
                                          Class<T> type)

tryToInstantiateClassForName

public static <T> T tryToInstantiateClassForName(String className,
                                                 Class<T> targetType)

tryToInstantiateClassForName

public static Object tryToInstantiateClassForName(String className)

instantiateClassForName

public static Object instantiateClassForName(String className)
                                      throws ClassNotFoundException,
                                             IllegalAccessException,
                                             InstantiationException
Throws:
ClassNotFoundException
IllegalAccessException
InstantiationException

getJarVersion

public static String getJarVersion(Class targetClass)


Copyright © 2010-2011 The Apache Software Foundation. All Rights Reserved.