Class ClassHelper
- java.lang.Object
-
- org.fugerit.java.core.lang.helpers.ClassHelper
-
public class ClassHelper extends Object
This class provides API for instantiating new classes.
- Author:
- Fugerit
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ClassLoader
getDefaultClassLoader()
Return default class loader to instantiate a new class.static InputStream
loadFromClassLoader(Object caller, String path)
static InputStream
loadFromClassLoader(String path, ClassLoader... cl)
static InputStream
loadFromDefaultClassLoader(String path)
static Object
newInstance(String type)
Create a new instance of the given type.static String
toFullClassName(Object c)
static String
toSimpleClassName(Object c)
-
-
-
Method Detail
-
getDefaultClassLoader
public static ClassLoader getDefaultClassLoader()
Return default class loader to instantiate a new class.
The source for this method was taken from struts 1 code RequestUtils : http://svn.apache.org/repos/asf/struts/struts1/trunk/org.fugerit.java.core/src/main/java/org/apache/struts/util/RequestUtils.java
NOTE : As of 8.2.0 removed throw Exception declaration (now in case a
ConfigRuntimeException
will be thrown.- Returns:
- the Default ClassLoader.
-
newInstance
public static Object newInstance(String type) throws ClassNotFoundException, NoSuchMethodException, ConfigException
Create a new instance of the given type.
NOTE : As of 8.2.0 removed throw Exception declaration (now in case a
ConfigRuntimeException
will be thrown.- Parameters:
type
- fully qualified name fo the class for which the new instance will be created- Returns:
- the new istance
- Throws:
ClassNotFoundException
- if the class is not foundNoSuchMethodException
- if the method (default constructor) is not foundConfigException
- in any other case
-
loadFromClassLoader
public static InputStream loadFromClassLoader(String path, ClassLoader... cl)
-
loadFromClassLoader
public static InputStream loadFromClassLoader(Object caller, String path)
-
loadFromDefaultClassLoader
public static InputStream loadFromDefaultClassLoader(String path)
-
-