Class ReflectionAPIUtils
java.lang.Object
com.priint.pubserver.parameterparser.ReflectionAPIUtils
Utility class for easier working with Java Reflection API.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectcallBeanMethod(String globalName, String methodName, Object[] params, Object bean) Calls a method of a EJB with given argumentsstatic ObjectcallBeanMethod(String globalName, String methodName, Object[] params, Object bean, boolean throwException) Calls a method of a EJB with given argumentsstatic ObjectcallPluginMethod(String mappedName, String methodName, Object[] params) Calls a method of a plug-in with given argumentsstatic ObjectcallPluginMethodUnchecked(String mappedName, String methodName, Object[] params) Calls a method of a plug-in with given argumentsstatic ObjectcallPluginMethodWithException(String mappedName, String methodName, Object[] params, boolean throwException) Calls a method of a plug-in with given argumentsstatic ObjectcallStaticMethod(String className, String methodName, Object[] params) Calls a static method in a class with given argumentsstatic ObjectcallStaticMethodUnchecked(String className, String methodName, Object[] params) Calls a static method in a class with given argumentsstatic ObjectCalled before method invocation on each method argumentstatic booleanusesInterface(Class<?> clazz, Class<?> interfaceClass) Checks if a class implements an interfacestatic booleanusesInterface(Class<?> clazz, String interfaceClassName) Checks if a class implements an interface
-
Constructor Details
-
ReflectionAPIUtils
public ReflectionAPIUtils()
-
-
Method Details
-
usesInterface
Checks if a class implements an interface- Parameters:
clazz- class to checkinterfaceClass- interface class- Returns:
- true if the class implements the interface
-
usesInterface
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
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 Object callStaticMethodUnchecked(String className, String methodName, Object[] params) throws Exception Calls 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:
Exception- thrown if either class and method are not valid or the call fails
-
callPluginMethod
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 Object callPluginMethodUnchecked(String mappedName, String methodName, Object[] params) throws ParameterInterpreterException Calls 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 Object callPluginMethodWithException(String mappedName, String methodName, Object[] params, boolean throwException) throws ParameterInterpreterException Calls 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 Object callBeanMethod(String globalName, String methodName, Object[] params, Object bean, boolean throwException) throws ParameterInterpreterException Calls 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 Object callBeanMethod(String globalName, String methodName, Object[] params, Object bean) throws ParameterInterpreterException Calls a method of a EJB with given arguments- Parameters:
globalName-methodName-params-bean-- Returns:
- Throws:
ParameterInterpreterException
-
castType
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:
-