Class ReflectionAPIUtils
- java.lang.Object
-
- com.priint.pubserver.parameterparser.ReflectionAPIUtils
-
public class ReflectionAPIUtils extends java.lang.ObjectUtility class for easier working with Java Reflection API.
-
-
Constructor Summary
Constructors Constructor Description ReflectionAPIUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ObjectcallBeanMethod(java.lang.String globalName, java.lang.String methodName, java.lang.Object[] params, java.lang.Object bean)Calls a method of a EJB with given argumentsstatic java.lang.ObjectcallBeanMethod(java.lang.String globalName, java.lang.String methodName, java.lang.Object[] params, java.lang.Object bean, boolean throwException)Calls a method of a EJB with given argumentsstatic java.lang.ObjectcallPluginMethod(java.lang.String mappedName, java.lang.String methodName, java.lang.Object[] params)Calls a method of a plug-in with given argumentsstatic java.lang.ObjectcallPluginMethodUnchecked(java.lang.String mappedName, java.lang.String methodName, java.lang.Object[] params)Calls a method of a plug-in with given argumentsstatic java.lang.ObjectcallPluginMethodWithException(java.lang.String mappedName, java.lang.String methodName, java.lang.Object[] params, boolean throwException)Calls a method of a plug-in with given argumentsstatic java.lang.ObjectcallStaticMethod(java.lang.String className, java.lang.String methodName, java.lang.Object[] params)Calls a static method in a class with given argumentsstatic java.lang.ObjectcallStaticMethodUnchecked(java.lang.String className, java.lang.String methodName, java.lang.Object[] params)Calls a static method in a class with given argumentsstatic java.lang.ObjectcastType(java.lang.Object obj, java.lang.Class<?> type)Called before method invocation on each method argumentstatic booleanusesInterface(java.lang.Class<?> clazz, java.lang.Class<?> interfaceClass)Checks if a class implements an interfacestatic booleanusesInterface(java.lang.Class<?> clazz, java.lang.String interfaceClassName)Checks if a class implements an interface
-
-
-
Method Detail
-
usesInterface
public static boolean usesInterface(java.lang.Class<?> clazz, java.lang.Class<?> interfaceClass)Checks if a class implements an interface- Parameters:
clazz- class to checkinterfaceClass- interface class- Returns:
- true if the class implements the interface
-
usesInterface
public static boolean usesInterface(java.lang.Class<?> clazz, java.lang.String interfaceClassName)Checks if a class implements an interface- Parameters:
clazz- class to checkinterfaceClassName- full qualified class name of the interface- Returns:
- true if the class implements the interface
-
callStaticMethod
public static java.lang.Object callStaticMethod(java.lang.String className, java.lang.String methodName, java.lang.Object[] params)Calls a static method in a class with given argumentsExceptions will be swallowed and only create an entry in the log.
- Parameters:
className- full name of the classmethodName- name of the methodparams- arguments- Returns:
- result of the method call or null in case of an exception.
-
callStaticMethodUnchecked
public static java.lang.Object callStaticMethodUnchecked(java.lang.String className, java.lang.String methodName, java.lang.Object[] params) throws java.lang.ExceptionCalls a static method in a class with given argumentsExceptions will be passed through as is.
- Parameters:
className- full name of the classmethodName- name of the methodparams- arguments- Returns:
- result of the method call
- Throws:
java.lang.Exception- thrown if either class and method are not valid or the call fails
-
callPluginMethod
public static java.lang.Object callPluginMethod(java.lang.String mappedName, java.lang.String methodName, java.lang.Object[] params)Calls a method of a plug-in with given argumentsExceptions will be swallowed and only create an entry in the log if in debug mode.
- Parameters:
mappedName- JNDI name of the plug-inmethodName- name of the methodparams- arguments- Returns:
- result of the method call or null in case of an exception.
-
callPluginMethodUnchecked
public static java.lang.Object callPluginMethodUnchecked(java.lang.String mappedName, java.lang.String methodName, java.lang.Object[] params) throws ParameterInterpreterExceptionCalls a method of a plug-in with given argumentsAll exceptions will be wrapped into a ParameterInterpreterException.
- Parameters:
mappedName- JNDI name of the plug-inmethodName- name of the methodparams- arguments- Returns:
- result of the method call
- Throws:
ParameterInterpreterException- is thrown if either plugin is not available or method are not valid or the call fails
-
callPluginMethodWithException
public static java.lang.Object callPluginMethodWithException(java.lang.String mappedName, java.lang.String methodName, java.lang.Object[] params, boolean throwException) throws ParameterInterpreterExceptionCalls a method of a plug-in with given arguments- Parameters:
mappedName- JNDI name of the plug-inmethodName- name of the methodparams- argumentsthrowException-- Returns:
- result of the method call
- Throws:
ParameterInterpreterException- is thrown if either plugin is not available or method are not valid or the call fails
-
callBeanMethod
public static java.lang.Object callBeanMethod(java.lang.String globalName, java.lang.String methodName, java.lang.Object[] params, java.lang.Object bean, boolean throwException) throws ParameterInterpreterExceptionCalls a method of a EJB with given argumentsExceptions will be swallowed and only create an entry in the log.
- Parameters:
globalName-methodName-params-bean-- Throws:
ParameterInterpreterException
-
callBeanMethod
public static java.lang.Object callBeanMethod(java.lang.String globalName, java.lang.String methodName, java.lang.Object[] params, java.lang.Object bean) throws ParameterInterpreterExceptionCalls a method of a EJB with given arguments- Parameters:
globalName-methodName-params-bean-- Returns:
- Throws:
ParameterInterpreterException
-
castType
public static java.lang.Object castType(java.lang.Object obj, java.lang.Class<?> type)Called before method invocation on each method argumentIn case of cast problems an error string will be returned as argument content.
- Parameters:
obj-type-- Returns:
-
-