List of usage examples for org.springframework.beans BeanUtils findMethod
@Nullable public static Method findMethod(Class<?> clazz, String methodName, Class<?>... paramTypes)
From source file:com.apporiented.hermesftp.utils.IOUtils.java
/** * Closes a file, socket, stream, writer etc. without throwing exceptions. Any exception is * catched and logged. In contrast to the "Commons IO" method <code>closeQuietly()</code> this * method closes any object that has a <code>close()</code>-method and is not restricted to * readers, writers and streams./*from w ww. j ava 2 s . co m*/ * * @param o The object to be closed. * @return True, if object could be closed. */ public static boolean closeGracefully(Object o) { boolean result; try { Method closeMethod = BeanUtils.findMethod(o.getClass(), "close", null); closeMethod.invoke(o, (Object[]) null); result = true; } catch (IllegalArgumentException e) { result = false; } catch (IllegalAccessException e) { result = false; } catch (InvocationTargetException e) { result = false; } catch (NullPointerException e) { result = false; } return result; }
From source file:org.carewebframework.ui.test.MockEnvironment.java
/** * Makes ZK believe the current thread is an event thread. * //from w w w. j a v a2s . co m * @param value If true, the current thread becomes an event thread. If false, it is not an * event thread. * @throws Exception Unspecified exception. */ public void inEventListener(boolean value) throws Exception { Method inEventListener = BeanUtils.findMethod(EventProcessor.class, "inEventListener", boolean.class); inEventListener.setAccessible(true); inEventListener.invoke(null, value); }
From source file:org.carewebframework.cal.ui.reporting.controller.AbstractController.java
/** * Retrieves a property value of the specified data type. It examines the property value for a * type-compatible value. Failing that, it returns the specified default value. * * @param propName Name of property from which to retrieve the value. * @param clazz Expected data type of the property value. * @param dflt Default value to use if a suitable one cannot be found. * @return The value./*from w ww . j a va 2s . com*/ */ @SuppressWarnings("unchecked") protected <V> V getPropertyValue(String propName, Class<V> clazz, V dflt) { V value = null; if (propName != null) { propName = propName.replace("%", propertyPrefix == null ? "" : propertyPrefix); String val = StringUtils.trimToNull(PropertyUtil.getValue(propName)); if (log.isDebugEnabled()) { log.debug("Property " + propName + " value: " + val); } if (clazz == String.class) { value = (V) (val); } else { Method method = BeanUtils.findMethod(clazz, "valueOf", String.class); if (method != null && method.getReturnType() == clazz) { value = (V) parseString(method, val, null); } } } return value == null ? dflt : value; }
From source file:org.eclipse.gemini.blueprint.compendium.internal.cm.ManagedFactoryDisposableInvoker.java
private Method detectCustomSpringMethod(Class<?> beanClass, String methodName) { Method m = BeanUtils.findMethod(beanClass, methodName, null); if (m == null) { m = BeanUtils.findMethod(beanClass, methodName, new Class[] { boolean.class }); }/*from w w w. j a va 2 s.com*/ return m; }
From source file:org.eclipse.gemini.blueprint.compendium.internal.cm.ManagedFactoryDisposableInvoker.java
private Method detectCustomOsgiMethod(Class<?> beanClass, String methodName) { return BeanUtils.findMethod(beanClass, methodName, new Class[] { int.class }); }