|
SOAj Core v. 1.3 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.soaj.core.util.SjUtilReflection
public class SjUtilReflection
This utility class contains static convenience methods for reflective processing.
Copyright (c) 2006 - 2009 by Global Technology Consulting Group, Inc. at gtcGroup.com .
| Field Summary | |
|---|---|
private static java.lang.String |
CLASS_NAME
Class name. |
| Constructor Summary | |
|---|---|
private |
SjUtilReflection()
Constructor - Private |
| Method Summary | ||
|---|---|---|
static boolean |
containsGetInstanceMethod(java.lang.Class<?> aClass)
This method determines if a public 'getInstance' Method is
available. |
|
static boolean |
containsNonPublicArgumentConstructorWithoutAnnotation(java.lang.Class<?> aClass,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
This method determines if an accessible 'public' argument constructor is available. |
|
static boolean |
containsNonPublicNoArgumentConstructor(java.lang.Class<?> aClass)
This method determines if a non-public accessible no-argument Constructor
| |
static boolean |
containsNonPublicNoArgumentConstructorWithoutAnnotation(java.lang.Class<?> aClass,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
This method determines if a non-public accessible no-argument constructor is available. |
|
static boolean |
containsPublicArgumentConstructor(java.lang.Class<?> aClass)
This method determines if an accessible 'public' argument constructor is available. |
|
static boolean |
containsPublicArgumentConstructorWithoutAnnotation(java.lang.Class<?> aClass,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
This method determines if an accessible 'public' argument constructor is available. |
|
static boolean |
containsPublicConstructor(java.lang.Class<?> aClass)
This method determines if an accessible 'public' no constructor is available. |
|
static boolean |
containsPublicNoArgumentConstructor(java.lang.Class<?> aClass)
This method determines if an accessible 'public' no argument constructor is available. |
|
static boolean |
containsPublicNoArgumentConstructorWithoutAnnotation(java.lang.Class<?> aClass,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
This method determines if an accessible 'public' no argument constructor is available. |
|
private static java.lang.ClassLoader |
getClassLoader()
Returns the class classLoader for this class. |
|
static SjAttributesForStreaming |
getResourceAsStream(java.lang.String resourceName)
This method attempts returning an InputStream with the
resources class loader. |
|
static java.lang.Object |
instantiateInstance(java.lang.Class<?> aClass,
boolean suppressException,
java.lang.Object[] constructorParameterValues,
java.lang.Class<?>... parameterTypes)
This method returns an instance of type Object. |
|
static java.lang.Object |
instantiateInstance(java.lang.Object[] constructorParameterValues,
boolean suppressException,
java.lang.Class<?> aClass,
java.lang.reflect.Constructor<?>[] constructors)
This method returns an instance of type Object. |
|
static java.lang.Object |
instantiateInstance(java.lang.Object[] constructorParameterValues,
boolean suppressException,
java.lang.Class<?> aClass,
java.util.List<java.lang.reflect.Constructor<?>> constructorList)
This method returns an instance of type Object. |
|
static java.lang.Object |
instantiateInstance(java.lang.String className,
boolean suppressException,
java.lang.Object[] constructorParameterValues,
java.lang.Class<?>... parameterTypes)
This method returns an instance of type Object. |
|
static java.lang.Object |
instantiateNoArgumentInstance(java.lang.String className)
This method returns an instance of type Object. |
|
static java.lang.Object |
instantiateNoArgumentInstance(java.lang.String className,
boolean suppressException)
This method returns an instance of type Object. |
|
static java.lang.Object |
instantiateNonPublicInstanceWithParameters(java.lang.Object[] constructorParameterValues,
boolean suppressException,
java.lang.Class<?> aClass)
This method returns an instance of type Object. |
|
static java.lang.Object |
instantiatePublicInstanceWithParameters(java.lang.Object[] constructorParameterValues,
boolean suppressException,
java.lang.Class<?> aClass)
This method returns an instance of type Object. |
|
static java.lang.Object |
instantiatePublicInstanceWithParameters(SjPopulatedClassName className,
java.lang.Object[] constructorParameterValues,
boolean suppressException)
This method returns an instance of type Object. |
|
static java.lang.Object |
instantiateViaGetInstanceMethod(java.lang.Class<?> aClass,
java.lang.Class<?>[] methodParameterTypes,
java.lang.Object[] methodParameterValues,
boolean suppressException)
This method returns an instance of type Object using a
static factory method. |
|
static java.lang.Object |
instantiateViaGetInstanceMethod(SjPopulatedClassName className,
java.lang.Class<?>[] methodParameterTypes,
java.lang.Object[] methodParameterValues,
boolean suppressException)
This method returns an instance of type Object using a
static factory method. |
|
static java.lang.Object |
instantiateViaNoArgumentConstructor(java.lang.Class<?> aClass,
java.lang.reflect.Constructor<?> constructor)
This method returns an instance of type Object by invoking
the no-argument constructor. |
|
static java.lang.Object |
instantiateViaNoArgumentConstructor(java.lang.Class<?> aClass,
java.lang.reflect.Constructor<?> constructor,
boolean suppressException)
This method returns an instance of type Object by invoking
the no-argument constructor. |
|
static java.lang.Object |
instantiateViaNonPublicNoArgumentConstructor(java.lang.Class<?> aClass,
boolean suppressException)
This method returns an instance of type Object by invoking a
non-public no-argument constructor. |
|
static java.lang.Object |
instantiateViaPublicNoArgumentConstructor(java.lang.Class<?> aClass)
This method returns an instance of type Object by invoking a
'public' no-argument constructor. |
|
static java.lang.Object |
instantiateViaPublicNoArgumentConstructor(java.lang.Class<?> aClass,
boolean suppressException)
This method returns an instance of type Object by invoking a
'public' no-argument constructor. |
|
static boolean |
isConstructorAccessible(java.lang.reflect.Constructor<?> constructor)
This method verifies a constructor is accessible. |
|
private static java.util.List<java.lang.reflect.Constructor<?>> |
iterateForNonPublicArgumentConstructors(java.lang.reflect.Constructor<?>[] constructors)
This method iterates through an array of constructors in pursuit of all accessible argument versions which are returned as a list. |
|
private static java.lang.reflect.Constructor<?> |
iterateForNonPublicNoArgumentConstructor(java.lang.reflect.Constructor<?>[] constructors)
This method iterates through an array of constructors in pursuit of a no argument version. |
|
private static java.util.List<java.lang.reflect.Constructor<?>> |
iterateForPublicArgumentConstructors(java.lang.reflect.Constructor<?>[] constructors)
This method iterates through an array of constructors in pursuit of all accessible argument versions which are returned as a list. |
|
private static java.lang.reflect.Constructor<?> |
iterateForPublicNoArgumentConstructor(java.lang.reflect.Constructor<?>[] constructors)
This method iterates through an array of constructors in pursuit of a no argument version. |
|
static java.lang.Class<java.lang.Object> |
retrieveClass(java.lang.String className)
This method attempts retrieving a class with this classes class classLoader, and if unsuccessful then a " Thread" class
classLoader. |
|
static
|
retrieveClass(java.lang.String className,
java.lang.Class<T> classType)
This method attempts retrieving a class with this classes class classLoader, and if unsuccessful then a " Thread" class
classLoader. |
|
static java.lang.reflect.Method |
retrieveGetInstanceMethod(java.lang.Class<?> aClass)
This method returns a public static 'getInstance' Method or
null. |
|
static java.util.List<java.lang.reflect.Constructor<?>> |
retrieveNonPublicArgumentConstructors(java.lang.Class<?> aClass)
This method returns a list of accessible argument Constructors. |
|
static java.lang.reflect.Constructor<?> |
retrieveNonPublicNoArgumentConstructor(java.lang.Class<?> aClass)
This method returns an accessible no-argument Constructor or
null. |
|
static java.util.List<java.lang.reflect.Constructor<?>> |
retrievePublicArgumentConstructors(java.lang.Class<?> aClass)
This method returns a list of accessible 'public' argument Constructors. |
|
static java.lang.reflect.Constructor<?> |
retrievePublicNoArgumentConstructor(java.lang.Class<?> aClass)
This method returns an accessible 'public' no-argument Constructor or null. |
|
private static void |
throwInstantiationException(java.lang.String className,
java.lang.String methodName,
boolean suppressException)
|
|
private static void |
throwInstantiationException(java.lang.String className,
java.lang.String methodName,
java.lang.Exception exception,
boolean suppressException)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.lang.String CLASS_NAME
| Constructor Detail |
|---|
private SjUtilReflection()
| Method Detail |
|---|
public static java.lang.Object instantiateNoArgumentInstance(java.lang.String className)
Object. An exception
is thrown upon failure.
className - The fully qualified name of the desired class to be
instantiated.
public static java.lang.Object instantiateNoArgumentInstance(java.lang.String className,
boolean suppressException)
throws SjCoreExceptionInstantiating
Object. If unable to
instantiate, an exception is thrown or null returned
depending upon a client boolean parameter.
className - The fully qualified name of the desired class to be
instantiated.suppressException - Indicates whether an exception is thrown or null
returned in the event of an instantiation failure.
null.
SjCoreExceptionInstantiating
public static java.lang.Object instantiatePublicInstanceWithParameters(SjPopulatedClassName className,
java.lang.Object[] constructorParameterValues,
boolean suppressException)
Object. If unable to
instantiate, the method signature includes a parameter indicating whether
to throw an exception or return a null.
className - The fully qualified name of the desired class to be
instantiated.constructorParameterValues - An object array of constructor values.suppressException - Indicates whether an exception is thrown or null
returned in the event of an instantiation failure.
null.
public static java.lang.Object instantiatePublicInstanceWithParameters(java.lang.Object[] constructorParameterValues,
boolean suppressException,
java.lang.Class<?> aClass)
throws SjCoreExceptionInstantiating
Object. If unable to
instantiate, the method signature includes a parameter indicating whether
to throw an exception or return a null.
constructorParameterValues - An object array of constructor values.suppressException - Indicates whether an exception is thrown or null
returned in the event of an instantiation failure.aClass - The class to be instantiated.
null.
SjCoreExceptionInstantiating
public static java.lang.Object instantiateNonPublicInstanceWithParameters(java.lang.Object[] constructorParameterValues,
boolean suppressException,
java.lang.Class<?> aClass)
throws SjCoreExceptionInstantiating
Object. If unable to
instantiate, the method signature includes a parameter indicating whether
to throw an exception or return a null.
constructorParameterValues - An object array of constructor values.suppressException - Indicates whether an exception is thrown or null
returned in the event of an instantiation failure.aClass - The class to be instantiated.
null.
SjCoreExceptionInstantiating
public static java.lang.Object instantiateInstance(java.lang.Class<?> aClass,
boolean suppressException,
java.lang.Object[] constructorParameterValues,
java.lang.Class<?>... parameterTypes)
Object. If unable to
instantiate, the method signature includes a parameter indicating whether
to throw an exception or return a null.
aClass - constructorParameterValues - suppressException - parameterTypes -
null.
public static java.lang.Object instantiateInstance(java.lang.String className,
boolean suppressException,
java.lang.Object[] constructorParameterValues,
java.lang.Class<?>... parameterTypes)
Object. If unable to
instantiate, the method signature includes a parameter indicating whether
to throw an exception or return a null.
className - constructorParameterValues - suppressException - parameterTypes -
null.
public static java.lang.Object instantiateInstance(java.lang.Object[] constructorParameterValues,
boolean suppressException,
java.lang.Class<?> aClass,
java.lang.reflect.Constructor<?>[] constructors)
Object. If unable to
instantiate, the method signature includes a parameter indicating whether
to throw an exception or return a null.
constructorParameterValues - suppressException - aClass - constructors -
null.
public static java.lang.Object instantiateInstance(java.lang.Object[] constructorParameterValues,
boolean suppressException,
java.lang.Class<?> aClass,
java.util.List<java.lang.reflect.Constructor<?>> constructorList)
Object. If unable to
instantiate, the method signature includes a parameter indicating whether
to throw an exception or return a null.
constructorParameterValues - suppressException - aClass - constructorList -
null.
public static java.lang.Object instantiateViaGetInstanceMethod(SjPopulatedClassName className,
java.lang.Class<?>[] methodParameterTypes,
java.lang.Object[] methodParameterValues,
boolean suppressException)
Object using a
static factory method. If unable to instantiate, the method signature
includes a parameter indicating whether to throw an exception or return a
null.
className - The fully qualified name of the class to be instantiated.methodParameterTypes - An object array containing types satisfying the static factory
method signature.methodParameterValues - An object array containing values satisfying the static
factory method signature.suppressException - Indicates whether an exception is thrown or null
returned in the event of an instantiation failure.
null.
public static java.lang.Object instantiateViaGetInstanceMethod(java.lang.Class<?> aClass,
java.lang.Class<?>[] methodParameterTypes,
java.lang.Object[] methodParameterValues,
boolean suppressException)
Object using a
static factory method. If unable to instantiate, the method signature
includes a parameter indicating whether to throw an exception or return a
null.
aClass - The class to be instantiated.methodParameterTypes - An object array containing types satisfying the static factory
method signature.methodParameterValues - An object array containing values satisfying the static
factory method signature.suppressException - Indicates whether an exception is thrown or null
returned in the event of an instantiation failure.
null.public static boolean containsPublicConstructor(java.lang.Class<?> aClass)
aClass - The class to be instantiated.
Constructor is
available.public static boolean containsPublicNoArgumentConstructor(java.lang.Class<?> aClass)
aClass - The class to be instantiated.
Constructor is available.
public static boolean containsPublicNoArgumentConstructorWithoutAnnotation(java.lang.Class<?> aClass,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
aClass - The class to be instantiated.annotation - An annotation that if present causes a return of 'false'.
Constructor is available.public static boolean containsPublicArgumentConstructor(java.lang.Class<?> aClass)
aClass - The class to be instantiated.
Constructor is available.
public static boolean containsPublicArgumentConstructorWithoutAnnotation(java.lang.Class<?> aClass,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
aClass - The class to be instantiated.annotation - An annotation that if present causes a return of 'false'.
Constructor is available.public static boolean containsNonPublicNoArgumentConstructor(java.lang.Class<?> aClass)
Constructor
aClass - The class to be instantiated.
Constructor is
available.
public static boolean containsNonPublicNoArgumentConstructorWithoutAnnotation(java.lang.Class<?> aClass,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
aClass - The class to be instantiated.annotation - An annotation that if present causes a return of 'false'.
Constructor is
available.
public static boolean containsNonPublicArgumentConstructorWithoutAnnotation(java.lang.Class<?> aClass,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
aClass - The class to be instantiated.annotation - An annotation that if present causes a return of 'false'.
Constructor is available.public static boolean containsGetInstanceMethod(java.lang.Class<?> aClass)
Method is
available.
aClass - The class to be instantiated.
Method is
available.
public static java.lang.Object instantiateViaPublicNoArgumentConstructor(java.lang.Class<?> aClass)
throws SjCoreExceptionInstantiating
Object by invoking a
'public' no-argument constructor. A class may have many constructors.
This overloaded version does not suppress exceptions.
aClass - The class to be instantiated.
Object (instance).
SjCoreExceptionInstantiating
public static java.lang.Object instantiateViaPublicNoArgumentConstructor(java.lang.Class<?> aClass,
boolean suppressException)
throws SjCoreExceptionInstantiating
Object by invoking a
'public' no-argument constructor. A class may have many constructors.
Support is provided for suppressing an exception.
aClass - The class to be instantiated.suppressException - Indicates no exception thrown.
Object (instance) or null
(if exception suppressed).
SjCoreExceptionInstantiating
public static java.lang.Object instantiateViaNonPublicNoArgumentConstructor(java.lang.Class<?> aClass,
boolean suppressException)
throws SjCoreExceptionInstantiating
Object by invoking a
non-public no-argument constructor. A class may have many constructors.
Support is provided for suppressing an exception.
aClass - The class to be instantiated.suppressException - Indicates no exception thrown.
Object (instance) or null
(if exception suppressed).
SjCoreExceptionInstantiating
public static java.lang.Object instantiateViaNoArgumentConstructor(java.lang.Class<?> aClass,
java.lang.reflect.Constructor<?> constructor)
throws SjCoreExceptionInstantiating
Object by invoking
the no-argument constructor. This overloaded version does not suppress
exceptions.
aClass - The class to be instantiated.constructor - A no argument constructor.
Object (instance).
SjCoreExceptionInstantiating
public static java.lang.Object instantiateViaNoArgumentConstructor(java.lang.Class<?> aClass,
java.lang.reflect.Constructor<?> constructor,
boolean suppressException)
throws SjCoreExceptionInstantiating
Object by invoking
the no-argument constructor. Support is provided for suppressing an
exception.
aClass - The class to be instantiated.constructor - A no argument constructor.suppressException - Indicates no exception thrown.
Object (instance) or null
(if exception suppressed).
SjCoreExceptionInstantiating
public static <T> java.lang.Class<T> retrieveClass(java.lang.String className,
java.lang.Class<T> classType)
throws java.lang.ClassNotFoundException
Thread" class
classLoader.
T - className - The fully qualified name of the class to be instantiated.classType -
java.lang.ClassNotFoundException
public static java.lang.Class<java.lang.Object> retrieveClass(java.lang.String className)
throws java.lang.ClassNotFoundException
Thread" class
classLoader.
className - The fully qualified name of the class to be instantiated.
java.lang.ClassNotFoundExceptionpublic static java.lang.reflect.Constructor<?> retrievePublicNoArgumentConstructor(java.lang.Class<?> aClass)
Constructor or null.
aClass - The class to be instantiated.
Constructor
or null.public static java.util.List<java.lang.reflect.Constructor<?>> retrievePublicArgumentConstructors(java.lang.Class<?> aClass)
Constructors.
aClass - The class to be instantiated.
Constructor s.public static java.lang.reflect.Constructor<?> retrieveNonPublicNoArgumentConstructor(java.lang.Class<?> aClass)
Constructor or
null.
aClass - The class to be instantiated.
Constructor
or null.public static java.util.List<java.lang.reflect.Constructor<?>> retrieveNonPublicArgumentConstructors(java.lang.Class<?> aClass)
Constructors.
aClass - The class to be instantiated.
Constructors.public static java.lang.reflect.Method retrieveGetInstanceMethod(java.lang.Class<?> aClass)
Method or
null.
aClass - The class to be instantiated.
Method or
null.public static boolean isConstructorAccessible(java.lang.reflect.Constructor<?> constructor)
constructor - The constructor to be interrogated.
public static SjAttributesForStreaming getResourceAsStream(java.lang.String resourceName)
throws java.io.IOException
InputStream with the
resources class loader. Failing that, a "Thread" class
loader is attempted.
resourceName - The resource name.
java.io.IOExceptionprivate static java.lang.ClassLoader getClassLoader()
private static java.lang.reflect.Constructor<?> iterateForPublicNoArgumentConstructor(java.lang.reflect.Constructor<?>[] constructors)
constructors -
private static java.lang.reflect.Constructor<?> iterateForNonPublicNoArgumentConstructor(java.lang.reflect.Constructor<?>[] constructors)
constructors -
private static java.util.List<java.lang.reflect.Constructor<?>> iterateForPublicArgumentConstructors(java.lang.reflect.Constructor<?>[] constructors)
constructors -
private static java.util.List<java.lang.reflect.Constructor<?>> iterateForNonPublicArgumentConstructors(java.lang.reflect.Constructor<?>[] constructors)
constructors -
private static void throwInstantiationException(java.lang.String className,
java.lang.String methodName,
boolean suppressException)
throws SjCoreExceptionInstantiating
className - methodName - suppressException -
SjCoreExceptionInstantiating
private static void throwInstantiationException(java.lang.String className,
java.lang.String methodName,
java.lang.Exception exception,
boolean suppressException)
throws SjCoreExceptionInstantiating
className - methodName - exception - suppressException -
SjCoreExceptionInstantiating
|
SOAj Core v. 1.3 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright (c) 2006 - 2009 by Global Technology Consulting Group, Inc. at gtcGroup.com.
Use is authorized, provided the source is acknowledged by inclusion of this copyright notice.