org.apache.bval.jsr303.util
Class SecureActions

java.lang.Object
  extended by org.apache.bval.util.PrivilegedActions
      extended by org.apache.bval.jsr303.util.SecureActions

public class SecureActions
extends PrivilegedActions

Description: utility methods to perform actions with AccessController or without.


Constructor Summary
SecureActions()
           
 
Method Summary
static ClassLoader getClassLoader(Class<?> clazz)
          Get class loader of clazz.
static
<T> Constructor<T>
getConstructor(Class<T> clazz, Class<?>... params)
          Get the constructor of clazz matching params.
static ClassLoader getContextClassLoader(Thread thread)
          Get context class loader of thread.
static Field getDeclaredField(Class<?> clazz, String fieldName)
          Get a field declared on a given class.
static Field[] getDeclaredFields(Class<?> clazz)
          Get all fields declared on a given class.
static Method[] getDeclaredMethods(Class<?> clazz)
          Get methods declared on clazz.
static Method getGetter(Class<?> clazz, String methodName)
          Returns the public method with the specified name or null if it does not exist.
static Method getMethod(Class<?> clazz, String methodName)
          Get the method of methodName available on clazz.
static Class<?> loadClass(String className, Class<?> caller)
          Load a class.
static
<T> T
newInstance(Class<T> cls)
          Create a new instance of the class using the default no-arg constructor.
static
<T> T
newInstance(Class<T> cls, Class<?>[] paramTypes, Object[] values)
          Create a new instance of a specified class, rethrowing ValidationException.
 
Methods inherited from class org.apache.bval.util.PrivilegedActions
getAnnotationValue, getLineSeparator, getPathSeparator, getProperty, newInstance, newInstance, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureActions

public SecureActions()
Method Detail

newInstance

public static <T> T newInstance(Class<T> cls)
Create a new instance of the class using the default no-arg constructor. perform newInstance() call with AccessController.doPrivileged() if possible.

Parameters:
cls - - the class (no interface, non-abstract, has accessible default no-arg-constructor)
Returns:
a new instance

newInstance

public static <T> T newInstance(Class<T> cls,
                                Class<?>[] paramTypes,
                                Object[] values)
Create a new instance of a specified class, rethrowing ValidationException.

Type Parameters:
T -
Parameters:
cls - - the class (no interface, non-abstract, has accessible matching constructor)
paramTypes -
values -
Returns:
a new instance

loadClass

public static Class<?> loadClass(String className,
                                 Class<?> caller)
Load a class.

Parameters:
className -
caller -
Returns:
loaded Class instance

getDeclaredField

public static Field getDeclaredField(Class<?> clazz,
                                     String fieldName)
Get a field declared on a given class.

Parameters:
clazz -
fieldName -
Returns:
Field found

getDeclaredFields

public static Field[] getDeclaredFields(Class<?> clazz)
Get all fields declared on a given class.

Parameters:
clazz -
Returns:
Field found

getGetter

public static Method getGetter(Class<?> clazz,
                               String methodName)
Returns the public method with the specified name or null if it does not exist.

Parameters:
clazz -
methodName -
Returns:
Returns the method or null if not found.

getMethod

public static Method getMethod(Class<?> clazz,
                               String methodName)
Get the method of methodName available on clazz.

Parameters:
clazz -
methodName -
Returns:
Method found

getDeclaredMethods

public static Method[] getDeclaredMethods(Class<?> clazz)
Get methods declared on clazz.

Parameters:
clazz -
Returns:
Method array

getClassLoader

public static ClassLoader getClassLoader(Class<?> clazz)
Get class loader of clazz.

Parameters:
clazz -
Returns:
ClassLoader

getContextClassLoader

public static ClassLoader getContextClassLoader(Thread thread)
Get context class loader of thread.

Parameters:
thread -
Returns:
ClassLoader

getConstructor

public static <T> Constructor<T> getConstructor(Class<T> clazz,
                                                Class<?>... params)
Get the constructor of clazz matching params.

Type Parameters:
T -
Parameters:
clazz -
params -
Returns:
Constructor found


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