/** * Invokes an annotation method. * * @param annotationn the annotation has to be introspected. * @param method the method name to execute. * @return the annotation method value, null if any error occurs. */ private static Object invokeAnnotationMethod(Annotation annotation, String method) { try { return MethodUtils.invokeExactMethod(annotation, method, null); } catch (Throwable t) { return null; } }
MethodUtils.invokeExactMethod(parent, methodName, new Object[]{ child }, paramTypes);
MethodUtils.invokeExactMethod(parent, methodName, new Object[]{ child }, paramTypes);
MethodUtils.invokeExactMethod(child, methodName, new Object[]{ parent }, paramTypes);
if (useExactMatch) { result = MethodUtils.invokeExactMethod(target, methodName, paramValues, paramTypes);
return invokeExactMethod(object, methodName, args); parameterTypes[i] = args[i].getClass(); return invokeExactMethod(object, methodName, args, parameterTypes);
return invokeExactMethod(object, methodName, args); parameterTypes[i] = args[i].getClass(); return invokeExactMethod(object, methodName, args, parameterTypes);
Order copy = (Order) MethodUtils.invokeExactMethod(original, methodName, null); for (Field field : fields) { Object copyValue = field.get(copy);
/** * Invokes an annotation method to get a value, possibly returning null if no value or if the method doesn't exist. */ private Object invokeAnnotationMethod(Annotation annotation, String methodName) { try { return MethodUtils.invokeExactMethod(annotation, methodName, null); } catch (Exception e) { // Ignore. return null; } }
private void clearCollection(Object bean, String propertyName) { log.debug("clearing the current content of the collection/map"); try { Object col = PropertyUtils.getProperty(bean, propertyName); if (col != null) { MethodUtils.invokeExactMethod(col, "clear", new Object[]{}); } } catch (Exception e) { log.debug("no clear method found on collection {}", propertyName); } }
public Object sendMessage(String serviceFactoryName, String serviceName, String methodName, Class<?>[] parameterTypes, Object[] args, Long timeout) throws Exception { Map<String, Object> m = map.get(serviceFactoryName); if (m == null) { throw new IllegalStateException("Not existe service for serviceFactoryName " + serviceFactoryName); } Object o = m.get(serviceName); if (o == null) { throw new IllegalStateException("Not existe service for serviceFactoryName " + serviceFactoryName); } return MethodUtils.invokeExactMethod(o, methodName, args, parameterTypes); } }
protected boolean getHit(Collection<Object> propertyValues, String regularExpression) { boolean hit = false; for (Object valueWrapper : propertyValues) { String single; try { single = (String) MethodUtils.invokeExactMethod(valueWrapper, "getName", null); } catch (Exception e) { single = valueWrapper.toString(); } if (single.matches(regularExpression)) { hit = true; break; } } return hit; }
/** * Calls the objects destroy method is it exists. */ private static void destroy(Object o) throws IllegalAccessException, InvocationTargetException { if (o == null) return; log.info("Destroying " + o + "..."); try { log.info("Check if there is a destroy method..."); MethodUtils.invokeExactMethod(o, "destroy", (Object[])null); log.info("destroy method invoked..."); } catch (NoSuchMethodException e) { log.info("No destroy method..."); } }
@Override public String getStringValue(Enum enumValue) { try { return (String) MethodUtils.invokeExactMethod(enumValue, "value", null); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof IllegalArgumentException) { throw (IllegalArgumentException) e.getTargetException(); } throw new RuntimeException(e.getTargetException()); } catch (NoSuchMethodException | IllegalAccessException e) { throw new RuntimeException(e); } }
/** * Convenience method which uses reflection to invoke a method * on the Request. */ private Object invokeRequestMethod(String name, Object[] args) { try { return MethodUtils.invokeExactMethod(request, name, args); } catch (NoSuchMethodException e) { if (log.isDebugEnabled()) { log.debug("Method '" +name + "' not defined for javax.servlet.http.HttpServletRequest"); } } catch (InvocationTargetException e) { log.error("Error invoking method '" +name + "' ", e.getTargetException()); } catch (IllegalAccessException e) { log.error("Error invoking method '" +name + "' ", e); } return null; }
Object getPropertyValue(SyndEntry entry, String property) { Object propertyValue = StringUtils.EMPTY; String getterName = getCamelCaseProperty(property); try { propertyValue = MethodUtils.invokeExactMethod(entry, getterName, null); } catch (Exception e) { if (log.isWarnEnabled()) { log.warn("Property {} can't be retrieved from the feed and will be treated as if it was empty during filtering", property); } } return propertyValue; }
private Session getCurrentSession() { DataDefinition dataDefinition = dataDefinitionService .get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY); Object dataAccessService = FieldUtils.getProtectedFieldValue("dataAccessService", dataDefinition); Object hibernateService = FieldUtils.getProtectedFieldValue("hibernateService", dataAccessService); try { return (Session) MethodUtils.invokeExactMethod(hibernateService, "getCurrentSession", new Object[0]); } catch (NoSuchMethodException e) { throw new IllegalStateException(e.getMessage(), e); } catch (IllegalAccessException e) { throw new IllegalStateException(e.getMessage(), e); } catch (InvocationTargetException e) { throw new IllegalStateException(e.getMessage(), e); } } }
/** {@inheritDoc} */ @Override @SuppressWarnings("PMD.SignatureDeclareThrowsException") public void end() throws Exception { Element subsection = (Element)super.digester.pop(); String description = extractNoteContent(subsection); MethodUtils.invokeExactMethod(digester.peek(), "setValue", description); }
@Override @SuppressWarnings("PMD.SignatureDeclareThrowsException") public void end(final String namespace, final String name) throws Exception { Element subsection = getDigester().pop(); String description = extractNodeContent(subsection); MethodUtils.invokeExactMethod(getDigester().peek(), "setValue", description); }
@Override @SuppressWarnings("PMD.SignatureDeclareThrowsException") public void end(final String namespace, final String name) throws Exception { Element subsection = (Element)getDigester().pop(); String description = extractNoteContent(subsection); MethodUtils.invokeExactMethod(getDigester().peek(), "setValue", description); }