List of usage examples for org.springframework.util ReflectionUtils findMethod
@Nullable public static Method findMethod(Class<?> clazz, String name)
From source file:org.cloudfoundry.reconfiguration.spring.AbstractJpaBasedCloudServiceBeanFactoryPostProcessorTest.java
private Object getSession(EntityManager manager) { Method method = ReflectionUtils.findMethod(manager.getClass(), "getDelegate"); return ReflectionUtils.invokeMethod(method, manager); }
From source file:org.grails.plugin.platform.events.registry.DefaultEventsRegistry.java
public String on(String namespace, String topic, Object bean, String callbackName) { return registerHandler(bean, ReflectionUtils.findMethod(bean.getClass(), callbackName), namespace, topic); }
From source file:org.cloudfoundry.reconfiguration.spring.AbstractJpaBasedCloudServiceBeanFactoryPostProcessorTest.java
private Object getSessionFactory(Object session) { Method method = ReflectionUtils.findMethod(session.getClass(), "getFactory"); return ReflectionUtils.invokeMethod(method, session); }
From source file:com.px100systems.util.PropertyAccessor.java
/** * Constructor/*from www. j a v a 2 s .co m*/ * @param srcClass class * @param srcProperty property */ public PropertyAccessor(Class<?> srcClass, String srcProperty) { accessorMethods = new ArrayList<Method>(); mutatorMethods = new ArrayList<Method>(); String[] properties = srcProperty.split("\\."); lastClass = srcClass; for (int i = 0; i < properties.length; i++) { lastField = properties[i]; Method getter = ReflectionUtils.findMethod(lastClass, methodName("get", lastField)); if (getter == null) throw new RuntimeException("Couldn't find getter for " + lastField + " in " + lastClass.getName()); accessorMethods.add(getter); Class<?> fieldType = getter.getReturnType(); if (mutatorMethods != null) { Method setter = ReflectionUtils.findMethod(lastClass, methodName("set", lastField), fieldType); if (setter != null) mutatorMethods.add(setter); else mutatorMethods = null; } if (i < properties.length - 1) lastClass = fieldType; else lastType = fieldType; } }
From source file:org.cloudfoundry.reconfiguration.spring.AbstractHibernateBasedCloudServiceBeanFactoryPostProcessorTest.java
private Object getDialect(SessionFactory factory) { Method method = ReflectionUtils.findMethod(factory.getClass(), "getDialect"); return ReflectionUtils.invokeMethod(method, factory); }
From source file:org.cloudfoundry.reconfiguration.spring.AbstractJpaBasedCloudServiceBeanFactoryPostProcessorTest.java
private Object getDialect(Object factory) { Method method = ReflectionUtils.findMethod(factory.getClass(), "getDialect"); return ReflectionUtils.invokeMethod(method, factory); }
From source file:org.kmnet.com.fw.common.codelist.EnumCodeList.java
/** * Constructor.//ww w .j av a2s. c om * * @param enumClass Enum class of which this codelist consists. Must implement {@link CodeListItem} * @throws java.lang.IllegalArgumentException if the given class does not implement {@link CodeListItem} */ public EnumCodeList(Class<? extends Enum<?>> enumClass) { Assert.isTrue(CodeListItem.class.isAssignableFrom(enumClass), "the given enumClass must implement " + CodeListItem.class); Map<String, String> codeList = new LinkedHashMap<String, String>(); Method method = ReflectionUtils.findMethod(enumClass, "values"); Enum<?>[] result = (Enum<?>[]) ReflectionUtils.invokeMethod(method, enumClass); for (Enum<?> e : result) { CodeListItem item = (CodeListItem) e; codeList.put(item.getCodeValue(), item.getCodeLabel()); } this.codeListMap = Collections.unmodifiableMap(codeList); }
From source file:net.nan21.dnet.core.presenter.converter.ReflookupResolver.java
/** * Get the getter for the ds-field with the given name. * //from w w w . j a v a2s . c o m * @param fieldName * @return * @throws Exception */ private Method _getDsGetter(String fieldName) throws Exception { return ReflectionUtils.findMethod(this.modelClass, "get" + StringUtils.capitalize(fieldName)); }
From source file:net.paslavsky.springrest.SpringRestClientMethodInterceptorTest.java
@BeforeMethod public void setUp() throws Exception { MockitoAnnotations.initMocks(this); initRestTemplate();//from w w w . j a va2s.c o m createTestedInstance(); Mockito.when(methodInvocation.getMethod()).thenReturn(ReflectionUtils.findMethod(getClass(), "testInvoke")); Mockito.when(methodInvocation.getArguments()).thenReturn(new Object[] { "Request" }); Mockito.when(annotationPreprocessor.parse(Mockito.any(Class.class), Mockito.any(Method.class))) .thenReturn(createNewMetadata()); Mockito.when(authenticationManager.getAuthenticationHeaders()).thenReturn(getAuthHttpHeaders()); }
From source file:com.example.config.StartupApplicationListener.java
private Set<Class<?>> sources(ApplicationReadyEvent event) { Method method = ReflectionUtils.findMethod(SpringApplication.class, "getAllSources"); if (method == null) { method = ReflectionUtils.findMethod(SpringApplication.class, "getSources"); }/*from w w w .ja va 2 s . com*/ ReflectionUtils.makeAccessible(method); @SuppressWarnings("unchecked") Set<Object> objects = (Set<Object>) ReflectionUtils.invokeMethod(method, event.getSpringApplication()); Set<Class<?>> result = new LinkedHashSet<>(); for (Object object : objects) { if (object instanceof String) { object = ClassUtils.resolveClassName((String) object, null); } result.add((Class<?>) object); } return result; }