org.apache.commons.lang.reflect.MethodUtils Java Examples
The following examples show how to use
org.apache.commons.lang.reflect.MethodUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HiveMetaStoreUtils.java From incubator-gobblin with Apache License 2.0 | 6 votes |
@VisibleForTesting protected static void inVokeDetermineSchemaOrThrowExceptionMethod(Properties props, Configuration conf) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { String methodName = "determineSchemaOrThrowException"; Method method = MethodUtils.getAccessibleMethod(AvroSerdeUtils.class, methodName, Properties.class); boolean withConf = false; if (method == null) { method = MethodUtils .getAccessibleMethod(AvroSerdeUtils.class, methodName, new Class[]{Configuration.class, Properties.class}); withConf = true; } Preconditions.checkNotNull(method, "Cannot find matching " + methodName); if (!withConf) { MethodUtils.invokeStaticMethod(AvroSerdeUtils.class, methodName, props); } else { MethodUtils.invokeStaticMethod(AvroSerdeUtils.class, methodName, new Object[]{conf, props}); } }
Example #2
Source File: MCRFunctionCallJava.java From mycore with GNU General Public License v3.0 | 6 votes |
@Override public Object call(Context context, List args) throws FunctionCallException { try { String clazzName = (String) (args.get(0)); String methodName = (String) (args.get(1)); LOGGER.debug("XEditor extension function calling {} {}", clazzName, methodName); Class[] argTypes = new Class[args.size() - 2]; Object[] params = new Object[args.size() - 2]; for (int i = 0; i < argTypes.length; i++) { argTypes[i] = args.get(i + 2).getClass(); params[i] = args.get(i + 2); } Class clazz = ClassUtils.getClass(clazzName); Method method = MethodUtils.getMatchingAccessibleMethod(clazz, methodName, argTypes); return method.invoke(null, params); } catch (Exception ex) { LOGGER.warn("Exception in call to external java method", ex); return ex.getMessage(); } }
Example #3
Source File: MCRExternalValidator.java From mycore with GNU General Public License v3.0 | 5 votes |
private Method findMethod(Class<?> argType) { try { Class<?> clazz = ClassUtils.getClass(className); Class<?>[] argTypes = { argType }; return MethodUtils.getMatchingAccessibleMethod(clazz, methodName, argTypes); } catch (ClassNotFoundException ex) { throw new MCRConfigurationException("class configured for external validation not found: " + className); } }
Example #4
Source File: EventsConsistencyTest.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
/** * Bukkit requires a static getHandlerList() method on all event classes, see {@link Event}. * This test checks that such a method is present, and that it is <i>absent</i> if the class * is not instantiable (abstract class). */ @Test public void shouldHaveStaticEventHandlerMethod() { for (Class<?> clazz : classes) { Method handlerListMethod = MethodUtils.getAccessibleMethod(clazz, "getHandlerList", new Class<?>[]{}); if (canBeInstantiated(clazz)) { assertThat("Class " + clazz.getSimpleName() + " has static method getHandlerList()", handlerListMethod != null && Modifier.isStatic(handlerListMethod.getModifiers()), equalTo(true)); } else { assertThat("Non-instantiable class " + clazz.getSimpleName() + " does not have static getHandlerList()", handlerListMethod, nullValue()); } } }
Example #5
Source File: EndpointDistributor.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public static boolean update() { try { return (Boolean)MethodUtils.invokeStaticMethod(Class.forName("be.fgov.ehealth.technicalconnector.bootstrap.bcp.EndpointUpdater"), "update", new Object[0]); } catch (Exception var1) { LOG.error("Unable to update endpoints", var1); return false; } }
Example #6
Source File: ConfigurationModuleTrustStore.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public void run() { try { MethodUtils.invokeStaticMethod(Class.forName("be.fgov.ehealth.technicalconnector.bootstrap.tsl.TrustStoreUpdater"), "launch", new Object[0]); } catch (Exception var2) { LOG.error("Unable to update truststores", var2); } }
Example #7
Source File: ConfigurationModuleTrustStore.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public void run() { try { MethodUtils.invokeStaticMethod(Class.forName("be.fgov.ehealth.technicalconnector.bootstrap.tsl.TrustStoreUpdater"), "launch", new Object[0]); } catch (Exception var2) { LOG.error("Unable to update truststores", var2); } }
Example #8
Source File: EndpointDistributor.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public static boolean update() { try { return ((Boolean)MethodUtils.invokeStaticMethod(Class.forName("be.fgov.ehealth.technicalconnector.bootstrap.bcp.EndpointUpdater"), "update", new Object[0])).booleanValue(); } catch (Exception var1) { LOG.error("Unable to update endpoints", var1); return false; } }
Example #9
Source File: ConfigurationModuleTrustStore.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public void run() { try { MethodUtils.invokeStaticMethod(Class.forName("be.fgov.ehealth.technicalconnector.bootstrap.tsl.TrustStoreUpdater"), "launch", new Object[0]); } catch (Exception var2) { LOG.error("Unable to update truststores", var2); } }
Example #10
Source File: EndpointDistributor.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public static boolean update() { try { return ((Boolean)MethodUtils.invokeStaticMethod(Class.forName("be.fgov.ehealth.technicalconnector.bootstrap.bcp.EndpointUpdater"), "update", new Object[0])); } catch (Exception var1) { LOG.error("Unable to update endpoints", var1); return false; } }
Example #11
Source File: ConfigurationModuleTrustStore.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public void run() { try { MethodUtils.invokeStaticMethod(Class.forName("be.fgov.ehealth.technicalconnector.bootstrap.tsl.TrustStoreUpdater"), "launch", new Object[0]); } catch (Exception var2) { LOG.error("Unable to update truststores", var2); } }
Example #12
Source File: ConfigurationModuleTrustStore.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public void run() { try { MethodUtils.invokeStaticMethod(Class.forName("be.fgov.ehealth.technicalconnector.bootstrap.tsl.TrustStoreUpdater"), "launch", new Object[0]); } catch (Exception var2) { LOG.error("Unable to update truststores", var2); } }
Example #13
Source File: TaskThroughput.java From hiped2 with Apache License 2.0 | 4 votes |
public static long extractLongFieldValue(TaskMetrics m, String fieldName) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return (Long) MethodUtils.invokeMethod(m, fieldName, null); }
Example #14
Source File: DataSkewMetrics.java From hiped2 with Apache License 2.0 | 4 votes |
public static long extractLongFieldValue(TaskMetrics m, String fieldName) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return (Long) MethodUtils.invokeMethod(m, fieldName, null); }
Example #15
Source File: JobHistoryHelper.java From hiped2 with Apache License 2.0 | 4 votes |
public static long extractLongFieldValue(TaskMetrics m, String fieldName) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return (Long) MethodUtils.invokeMethod(m, fieldName, null); }
Example #16
Source File: MetricSummary.java From hiped2 with Apache License 2.0 | 4 votes |
public static long extractLongFieldValue(TaskMetrics m, String fieldName) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return (Long) MethodUtils.invokeMethod(m, fieldName, null); }
Example #17
Source File: PropertyUtils.java From openhab1-addons with Eclipse Public License 2.0 | 4 votes |
/** * Returns the getter value from the object instance, nested properties are * possible. If the propertyName is for example temperature.current, the * methods getTemperature().getCurrent() are called. */ public static Object getPropertyValue(Object instance, String property) throws Exception { Object object = getNestedObject(instance, property); String getMethod = toGetterString(PropertyResolver.last(property)); return MethodUtils.invokeMethod(object, getMethod, null); }