Java Code Examples for org.springframework.util.ClassUtils#getMethodIfAvailable()
The following examples show how to use
org.springframework.util.ClassUtils#getMethodIfAvailable() .
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: ReflectiveLoadTimeWeaver.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Create a new SimpleLoadTimeWeaver for the given class loader. * @param classLoader the {@code ClassLoader} to delegate to for * weaving (<i>must</i> support the required weaving methods). * @throws IllegalStateException if the supplied {@code ClassLoader} * does not support the required weaving methods */ public ReflectiveLoadTimeWeaver(ClassLoader classLoader) { Assert.notNull(classLoader, "ClassLoader must not be null"); this.classLoader = classLoader; this.addTransformerMethod = ClassUtils.getMethodIfAvailable( this.classLoader.getClass(), ADD_TRANSFORMER_METHOD_NAME, new Class<?>[] {ClassFileTransformer.class}); if (this.addTransformerMethod == null) { throw new IllegalStateException( "ClassLoader [" + classLoader.getClass().getName() + "] does NOT provide an " + "'addTransformer(ClassFileTransformer)' method."); } this.getThrowawayClassLoaderMethod = ClassUtils.getMethodIfAvailable( this.classLoader.getClass(), GET_THROWAWAY_CLASS_LOADER_METHOD_NAME, new Class<?>[0]); // getThrowawayClassLoader method is optional if (this.getThrowawayClassLoaderMethod == null) { if (logger.isInfoEnabled()) { logger.info("The ClassLoader [" + classLoader.getClass().getName() + "] does NOT provide a " + "'getThrowawayClassLoader()' method; SimpleThrowawayClassLoader will be used instead."); } } }
Example 2
Source File: ReflectiveLoadTimeWeaver.java From java-technology-stack with MIT License | 6 votes |
/** * Create a new SimpleLoadTimeWeaver for the given class loader. * @param classLoader the {@code ClassLoader} to delegate to for * weaving (<i>must</i> support the required weaving methods). * @throws IllegalStateException if the supplied {@code ClassLoader} * does not support the required weaving methods */ public ReflectiveLoadTimeWeaver(@Nullable ClassLoader classLoader) { Assert.notNull(classLoader, "ClassLoader must not be null"); this.classLoader = classLoader; Method addTransformerMethod = ClassUtils.getMethodIfAvailable( this.classLoader.getClass(), ADD_TRANSFORMER_METHOD_NAME, ClassFileTransformer.class); if (addTransformerMethod == null) { throw new IllegalStateException( "ClassLoader [" + classLoader.getClass().getName() + "] does NOT provide an " + "'addTransformer(ClassFileTransformer)' method."); } this.addTransformerMethod = addTransformerMethod; Method getThrowawayClassLoaderMethod = ClassUtils.getMethodIfAvailable( this.classLoader.getClass(), GET_THROWAWAY_CLASS_LOADER_METHOD_NAME); // getThrowawayClassLoader method is optional if (getThrowawayClassLoaderMethod == null) { if (logger.isDebugEnabled()) { logger.debug("The ClassLoader [" + classLoader.getClass().getName() + "] does NOT provide a " + "'getThrowawayClassLoader()' method; SimpleThrowawayClassLoader will be used instead."); } } this.getThrowawayClassLoaderMethod = getThrowawayClassLoaderMethod; }
Example 3
Source File: SessionFactoryUtils.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Determine the DataSource of the given SessionFactory. * @param sessionFactory the SessionFactory to check * @return the DataSource, or {@code null} if none found * @see ConnectionProvider */ public static DataSource getDataSource(SessionFactory sessionFactory) { Method getProperties = ClassUtils.getMethodIfAvailable(sessionFactory.getClass(), "getProperties"); if (getProperties != null) { Map<?, ?> props = (Map<?, ?>) ReflectionUtils.invokeMethod(getProperties, sessionFactory); Object dataSourceValue = props.get(Environment.DATASOURCE); if (dataSourceValue instanceof DataSource) { return (DataSource) dataSourceValue; } } if (sessionFactory instanceof SessionFactoryImplementor) { SessionFactoryImplementor sfi = (SessionFactoryImplementor) sessionFactory; try { ConnectionProvider cp = sfi.getServiceRegistry().getService(ConnectionProvider.class); if (cp != null) { return cp.unwrap(DataSource.class); } } catch (UnknownServiceException ex) { if (logger.isDebugEnabled()) { logger.debug("No ConnectionProvider found - cannot determine DataSource for SessionFactory: " + ex); } } } return null; }
Example 4
Source File: ReflectiveLoadTimeWeaver.java From spring-analysis-note with MIT License | 6 votes |
/** * Create a new SimpleLoadTimeWeaver for the given class loader. * @param classLoader the {@code ClassLoader} to delegate to for * weaving (<i>must</i> support the required weaving methods). * @throws IllegalStateException if the supplied {@code ClassLoader} * does not support the required weaving methods */ public ReflectiveLoadTimeWeaver(@Nullable ClassLoader classLoader) { Assert.notNull(classLoader, "ClassLoader must not be null"); this.classLoader = classLoader; Method addTransformerMethod = ClassUtils.getMethodIfAvailable( this.classLoader.getClass(), ADD_TRANSFORMER_METHOD_NAME, ClassFileTransformer.class); if (addTransformerMethod == null) { throw new IllegalStateException( "ClassLoader [" + classLoader.getClass().getName() + "] does NOT provide an " + "'addTransformer(ClassFileTransformer)' method."); } this.addTransformerMethod = addTransformerMethod; Method getThrowawayClassLoaderMethod = ClassUtils.getMethodIfAvailable( this.classLoader.getClass(), GET_THROWAWAY_CLASS_LOADER_METHOD_NAME); // getThrowawayClassLoader method is optional if (getThrowawayClassLoaderMethod == null) { if (logger.isDebugEnabled()) { logger.debug("The ClassLoader [" + classLoader.getClass().getName() + "] does NOT provide a " + "'getThrowawayClassLoader()' method; SimpleThrowawayClassLoader will be used instead."); } } this.getThrowawayClassLoaderMethod = getThrowawayClassLoaderMethod; }
Example 5
Source File: ReflectiveLoadTimeWeaver.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Create a new SimpleLoadTimeWeaver for the given class loader. * @param classLoader the {@code ClassLoader} to delegate to for * weaving (<i>must</i> support the required weaving methods). * @throws IllegalStateException if the supplied {@code ClassLoader} * does not support the required weaving methods */ public ReflectiveLoadTimeWeaver(ClassLoader classLoader) { Assert.notNull(classLoader, "ClassLoader must not be null"); this.classLoader = classLoader; this.addTransformerMethod = ClassUtils.getMethodIfAvailable( this.classLoader.getClass(), ADD_TRANSFORMER_METHOD_NAME, ClassFileTransformer.class); if (this.addTransformerMethod == null) { throw new IllegalStateException( "ClassLoader [" + classLoader.getClass().getName() + "] does NOT provide an " + "'addTransformer(ClassFileTransformer)' method."); } this.getThrowawayClassLoaderMethod = ClassUtils.getMethodIfAvailable( this.classLoader.getClass(), GET_THROWAWAY_CLASS_LOADER_METHOD_NAME); // getThrowawayClassLoader method is optional if (this.getThrowawayClassLoaderMethod == null) { if (logger.isInfoEnabled()) { logger.info("The ClassLoader [" + classLoader.getClass().getName() + "] does NOT provide a " + "'getThrowawayClassLoader()' method; SimpleThrowawayClassLoader will be used instead."); } } }
Example 6
Source File: VelocityToolboxView.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Overridden to check for the ViewContext interface which is part of the * view package of Velocity Tools. This requires a special Velocity context, * like ChainedContext as set up by {@link #createVelocityContext} in this class. */ @Override protected void initTool(Object tool, Context velocityContext) throws Exception { // Velocity Tools 1.3: a class-level "init(Object)" method. Method initMethod = ClassUtils.getMethodIfAvailable(tool.getClass(), "init", Object.class); if (initMethod != null) { ReflectionUtils.invokeMethod(initMethod, tool, velocityContext); } }
Example 7
Source File: ObjectToObjectConverter.java From spring4-understanding with Apache License 2.0 | 5 votes |
private static Method determineToMethod(Class<?> targetClass, Class<?> sourceClass) { if (String.class == targetClass || String.class == sourceClass) { // Do not accept a toString() method or any to methods on String itself return null; } Method method = ClassUtils.getMethodIfAvailable(sourceClass, "to" + targetClass.getSimpleName()); return (method != null && !Modifier.isStatic(method.getModifiers()) && ClassUtils.isAssignable(targetClass, method.getReturnType()) ? method : null); }
Example 8
Source File: GenericTypeAwarePropertyDescriptor.java From blog_demos with Apache License 2.0 | 5 votes |
public GenericTypeAwarePropertyDescriptor(Class<?> beanClass, String propertyName, Method readMethod, Method writeMethod, Class<?> propertyEditorClass) throws IntrospectionException { super(propertyName, null, null); this.beanClass = beanClass; this.propertyEditorClass = propertyEditorClass; Method readMethodToUse = BridgeMethodResolver.findBridgedMethod(readMethod); Method writeMethodToUse = BridgeMethodResolver.findBridgedMethod(writeMethod); if (writeMethodToUse == null && readMethodToUse != null) { // Fallback: Original JavaBeans introspection might not have found matching setter // method due to lack of bridge method resolution, in case of the getter using a // covariant return type whereas the setter is defined for the concrete property type. Method candidate = ClassUtils.getMethodIfAvailable( this.beanClass, "set" + StringUtils.capitalize(getName()), (Class<?>[]) null); if (candidate != null && candidate.getParameterTypes().length == 1) { writeMethodToUse = candidate; } } this.readMethod = readMethodToUse; this.writeMethod = writeMethodToUse; if (this.writeMethod != null && this.readMethod == null) { // Write method not matched against read method: potentially ambiguous through // several overloaded variants, in which case an arbitrary winner has been chosen // by the JDK's JavaBeans Introspector... Set<Method> ambiguousCandidates = new HashSet<Method>(); for (Method method : beanClass.getMethods()) { if (method.getName().equals(writeMethodToUse.getName()) && !method.equals(writeMethodToUse) && !method.isBridge()) { ambiguousCandidates.add(method); } } if (!ambiguousCandidates.isEmpty()) { this.ambiguousWriteMethods = ambiguousCandidates; } } }
Example 9
Source File: ObjectToObjectConverter.java From lams with GNU General Public License v2.0 | 5 votes |
private static Method determineToMethod(Class<?> targetClass, Class<?> sourceClass) { if (String.class == targetClass || String.class == sourceClass) { // Do not accept a toString() method or any to methods on String itself return null; } Method method = ClassUtils.getMethodIfAvailable(sourceClass, "to" + targetClass.getSimpleName()); return (method != null && !Modifier.isStatic(method.getModifiers()) && ClassUtils.isAssignable(targetClass, method.getReturnType()) ? method : null); }
Example 10
Source File: VelocityToolboxView.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Overridden to check for the ViewContext interface which is part of the * view package of Velocity Tools. This requires a special Velocity context, * like ChainedContext as set up by {@link #createVelocityContext} in this class. */ @Override protected void initTool(Object tool, Context velocityContext) throws Exception { // Velocity Tools 1.3: a class-level "init(Object)" method. Method initMethod = ClassUtils.getMethodIfAvailable(tool.getClass(), "init", Object.class); if (initMethod != null) { ReflectionUtils.invokeMethod(initMethod, tool, velocityContext); } }
Example 11
Source File: SessionFactoryUtils.java From java-technology-stack with MIT License | 5 votes |
/** * Determine the DataSource of the given SessionFactory. * @param sessionFactory the SessionFactory to check * @return the DataSource, or {@code null} if none found * @see ConnectionProvider */ @Nullable public static DataSource getDataSource(SessionFactory sessionFactory) { Method getProperties = ClassUtils.getMethodIfAvailable(sessionFactory.getClass(), "getProperties"); if (getProperties != null) { Map<?, ?> props = (Map<?, ?>) ReflectionUtils.invokeMethod(getProperties, sessionFactory); if (props != null) { Object dataSourceValue = props.get(Environment.DATASOURCE); if (dataSourceValue instanceof DataSource) { return (DataSource) dataSourceValue; } } } if (sessionFactory instanceof SessionFactoryImplementor) { SessionFactoryImplementor sfi = (SessionFactoryImplementor) sessionFactory; try { ConnectionProvider cp = sfi.getServiceRegistry().getService(ConnectionProvider.class); if (cp != null) { return cp.unwrap(DataSource.class); } } catch (UnknownServiceException ex) { if (logger.isDebugEnabled()) { logger.debug("No ConnectionProvider found - cannot determine DataSource for SessionFactory: " + ex); } } } return null; }
Example 12
Source File: ObjectToObjectConverter.java From java-technology-stack with MIT License | 5 votes |
@Nullable private static Method determineToMethod(Class<?> targetClass, Class<?> sourceClass) { if (String.class == targetClass || String.class == sourceClass) { // Do not accept a toString() method or any to methods on String itself return null; } Method method = ClassUtils.getMethodIfAvailable(sourceClass, "to" + targetClass.getSimpleName()); return (method != null && !Modifier.isStatic(method.getModifiers()) && ClassUtils.isAssignable(targetClass, method.getReturnType()) ? method : null); }
Example 13
Source File: ZebraRoutingPointcut.java From Zebra with Apache License 2.0 | 5 votes |
boolean match(Method method, Class<?> targetClass) { // origin if (doMatch(method, targetClass)) { return true; } // cglib Class<?> userClass = ClassUtils.getUserClass(targetClass); Method specificMethod = ClassUtils.getMostSpecificMethod(method, userClass); specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod); if (!specificMethod.equals(method)) { if (doMatch(specificMethod, userClass)) { return true; } } // jdk proxy if (Proxy.isProxyClass(targetClass)) { Class<?>[] interfaces = targetClass.getInterfaces(); for (Class<?> interfaceClass : interfaces) { Method interfaceMethod = ClassUtils.getMethodIfAvailable(interfaceClass, method.getName(), method.getParameterTypes()); if (interfaceMethod != null && doMatch(interfaceMethod, interfaceClass)) { return true; } } } return false; }
Example 14
Source File: SessionFactoryUtils.java From spring-analysis-note with MIT License | 5 votes |
/** * Determine the DataSource of the given SessionFactory. * @param sessionFactory the SessionFactory to check * @return the DataSource, or {@code null} if none found * @see ConnectionProvider */ @Nullable public static DataSource getDataSource(SessionFactory sessionFactory) { Method getProperties = ClassUtils.getMethodIfAvailable(sessionFactory.getClass(), "getProperties"); if (getProperties != null) { Map<?, ?> props = (Map<?, ?>) ReflectionUtils.invokeMethod(getProperties, sessionFactory); if (props != null) { Object dataSourceValue = props.get(Environment.DATASOURCE); if (dataSourceValue instanceof DataSource) { return (DataSource) dataSourceValue; } } } if (sessionFactory instanceof SessionFactoryImplementor) { SessionFactoryImplementor sfi = (SessionFactoryImplementor) sessionFactory; try { ConnectionProvider cp = sfi.getServiceRegistry().getService(ConnectionProvider.class); if (cp != null) { return cp.unwrap(DataSource.class); } } catch (UnknownServiceException ex) { if (logger.isDebugEnabled()) { logger.debug("No ConnectionProvider found - cannot determine DataSource for SessionFactory: " + ex); } } } return null; }
Example 15
Source File: ObjectToObjectConverter.java From spring-analysis-note with MIT License | 5 votes |
@Nullable private static Method determineToMethod(Class<?> targetClass, Class<?> sourceClass) { if (String.class == targetClass || String.class == sourceClass) { // Do not accept a toString() method or any to methods on String itself return null; } Method method = ClassUtils.getMethodIfAvailable(sourceClass, "to" + targetClass.getSimpleName()); return (method != null && !Modifier.isStatic(method.getModifiers()) && ClassUtils.isAssignable(targetClass, method.getReturnType()) ? method : null); }
Example 16
Source File: GenericTypeAwarePropertyDescriptor.java From spring4-understanding with Apache License 2.0 | 4 votes |
public GenericTypeAwarePropertyDescriptor(Class<?> beanClass, String propertyName, Method readMethod, Method writeMethod, Class<?> propertyEditorClass) throws IntrospectionException { super(propertyName, null, null); if (beanClass == null) { throw new IntrospectionException("Bean class must not be null"); } this.beanClass = beanClass; Method readMethodToUse = BridgeMethodResolver.findBridgedMethod(readMethod); Method writeMethodToUse = BridgeMethodResolver.findBridgedMethod(writeMethod); if (writeMethodToUse == null && readMethodToUse != null) { // Fallback: Original JavaBeans introspection might not have found matching setter // method due to lack of bridge method resolution, in case of the getter using a // covariant return type whereas the setter is defined for the concrete property type. Method candidate = ClassUtils.getMethodIfAvailable( this.beanClass, "set" + StringUtils.capitalize(getName()), (Class<?>[]) null); if (candidate != null && candidate.getParameterTypes().length == 1) { writeMethodToUse = candidate; } } this.readMethod = readMethodToUse; this.writeMethod = writeMethodToUse; if (this.writeMethod != null) { if (this.readMethod == null) { // Write method not matched against read method: potentially ambiguous through // several overloaded variants, in which case an arbitrary winner has been chosen // by the JDK's JavaBeans Introspector... Set<Method> ambiguousCandidates = new HashSet<Method>(); for (Method method : beanClass.getMethods()) { if (method.getName().equals(writeMethodToUse.getName()) && !method.equals(writeMethodToUse) && !method.isBridge() && method.getParameterTypes().length == writeMethodToUse.getParameterTypes().length) { ambiguousCandidates.add(method); } } if (!ambiguousCandidates.isEmpty()) { this.ambiguousWriteMethods = ambiguousCandidates; } } this.writeMethodParameter = new MethodParameter(this.writeMethod, 0); GenericTypeResolver.resolveParameterType(this.writeMethodParameter, this.beanClass); } if (this.readMethod != null) { this.propertyType = GenericTypeResolver.resolveReturnType(this.readMethod, this.beanClass); } else if (this.writeMethodParameter != null) { this.propertyType = this.writeMethodParameter.getParameterType(); } this.propertyEditorClass = propertyEditorClass; }
Example 17
Source File: GenericTypeAwarePropertyDescriptor.java From lams with GNU General Public License v2.0 | 4 votes |
public GenericTypeAwarePropertyDescriptor(Class<?> beanClass, String propertyName, Method readMethod, Method writeMethod, Class<?> propertyEditorClass) throws IntrospectionException { super(propertyName, null, null); if (beanClass == null) { throw new IntrospectionException("Bean class must not be null"); } this.beanClass = beanClass; Method readMethodToUse = BridgeMethodResolver.findBridgedMethod(readMethod); Method writeMethodToUse = BridgeMethodResolver.findBridgedMethod(writeMethod); if (writeMethodToUse == null && readMethodToUse != null) { // Fallback: Original JavaBeans introspection might not have found matching setter // method due to lack of bridge method resolution, in case of the getter using a // covariant return type whereas the setter is defined for the concrete property type. Method candidate = ClassUtils.getMethodIfAvailable( this.beanClass, "set" + StringUtils.capitalize(getName()), (Class<?>[]) null); if (candidate != null && candidate.getParameterTypes().length == 1) { writeMethodToUse = candidate; } } this.readMethod = readMethodToUse; this.writeMethod = writeMethodToUse; if (this.writeMethod != null) { if (this.readMethod == null) { // Write method not matched against read method: potentially ambiguous through // several overloaded variants, in which case an arbitrary winner has been chosen // by the JDK's JavaBeans Introspector... Set<Method> ambiguousCandidates = new HashSet<Method>(); for (Method method : beanClass.getMethods()) { if (method.getName().equals(writeMethodToUse.getName()) && !method.equals(writeMethodToUse) && !method.isBridge() && method.getParameterTypes().length == writeMethodToUse.getParameterTypes().length) { ambiguousCandidates.add(method); } } if (!ambiguousCandidates.isEmpty()) { this.ambiguousWriteMethods = ambiguousCandidates; } } this.writeMethodParameter = new MethodParameter(this.writeMethod, 0); GenericTypeResolver.resolveParameterType(this.writeMethodParameter, this.beanClass); } if (this.readMethod != null) { this.propertyType = GenericTypeResolver.resolveReturnType(this.readMethod, this.beanClass); } else if (this.writeMethodParameter != null) { this.propertyType = this.writeMethodParameter.getParameterType(); } this.propertyEditorClass = propertyEditorClass; }
Example 18
Source File: GenericTypeAwarePropertyDescriptor.java From java-technology-stack with MIT License | 4 votes |
public GenericTypeAwarePropertyDescriptor(Class<?> beanClass, String propertyName, @Nullable Method readMethod, @Nullable Method writeMethod, Class<?> propertyEditorClass) throws IntrospectionException { super(propertyName, null, null); this.beanClass = beanClass; Method readMethodToUse = (readMethod != null ? BridgeMethodResolver.findBridgedMethod(readMethod) : null); Method writeMethodToUse = (writeMethod != null ? BridgeMethodResolver.findBridgedMethod(writeMethod) : null); if (writeMethodToUse == null && readMethodToUse != null) { // Fallback: Original JavaBeans introspection might not have found matching setter // method due to lack of bridge method resolution, in case of the getter using a // covariant return type whereas the setter is defined for the concrete property type. Method candidate = ClassUtils.getMethodIfAvailable( this.beanClass, "set" + StringUtils.capitalize(getName()), (Class<?>[]) null); if (candidate != null && candidate.getParameterCount() == 1) { writeMethodToUse = candidate; } } this.readMethod = readMethodToUse; this.writeMethod = writeMethodToUse; if (this.writeMethod != null) { if (this.readMethod == null) { // Write method not matched against read method: potentially ambiguous through // several overloaded variants, in which case an arbitrary winner has been chosen // by the JDK's JavaBeans Introspector... Set<Method> ambiguousCandidates = new HashSet<>(); for (Method method : beanClass.getMethods()) { if (method.getName().equals(writeMethodToUse.getName()) && !method.equals(writeMethodToUse) && !method.isBridge() && method.getParameterCount() == writeMethodToUse.getParameterCount()) { ambiguousCandidates.add(method); } } if (!ambiguousCandidates.isEmpty()) { this.ambiguousWriteMethods = ambiguousCandidates; } } this.writeMethodParameter = new MethodParameter(this.writeMethod, 0); GenericTypeResolver.resolveParameterType(this.writeMethodParameter, this.beanClass); } if (this.readMethod != null) { this.propertyType = GenericTypeResolver.resolveReturnType(this.readMethod, this.beanClass); } else if (this.writeMethodParameter != null) { this.propertyType = this.writeMethodParameter.getParameterType(); } this.propertyEditorClass = propertyEditorClass; }
Example 19
Source File: GenericTypeAwarePropertyDescriptor.java From spring-analysis-note with MIT License | 4 votes |
public GenericTypeAwarePropertyDescriptor(Class<?> beanClass, String propertyName, @Nullable Method readMethod, @Nullable Method writeMethod, Class<?> propertyEditorClass) throws IntrospectionException { super(propertyName, null, null); this.beanClass = beanClass; Method readMethodToUse = (readMethod != null ? BridgeMethodResolver.findBridgedMethod(readMethod) : null); Method writeMethodToUse = (writeMethod != null ? BridgeMethodResolver.findBridgedMethod(writeMethod) : null); if (writeMethodToUse == null && readMethodToUse != null) { // Fallback: Original JavaBeans introspection might not have found matching setter // method due to lack of bridge method resolution, in case of the getter using a // covariant return type whereas the setter is defined for the concrete property type. Method candidate = ClassUtils.getMethodIfAvailable( this.beanClass, "set" + StringUtils.capitalize(getName()), (Class<?>[]) null); if (candidate != null && candidate.getParameterCount() == 1) { writeMethodToUse = candidate; } } this.readMethod = readMethodToUse; this.writeMethod = writeMethodToUse; if (this.writeMethod != null) { if (this.readMethod == null) { // Write method not matched against read method: potentially ambiguous through // several overloaded variants, in which case an arbitrary winner has been chosen // by the JDK's JavaBeans Introspector... Set<Method> ambiguousCandidates = new HashSet<>(); for (Method method : beanClass.getMethods()) { if (method.getName().equals(writeMethodToUse.getName()) && !method.equals(writeMethodToUse) && !method.isBridge() && method.getParameterCount() == writeMethodToUse.getParameterCount()) { ambiguousCandidates.add(method); } } if (!ambiguousCandidates.isEmpty()) { this.ambiguousWriteMethods = ambiguousCandidates; } } this.writeMethodParameter = new MethodParameter(this.writeMethod, 0); GenericTypeResolver.resolveParameterType(this.writeMethodParameter, this.beanClass); } if (this.readMethod != null) { this.propertyType = GenericTypeResolver.resolveReturnType(this.readMethod, this.beanClass); } else if (this.writeMethodParameter != null) { this.propertyType = this.writeMethodParameter.getParameterType(); } this.propertyEditorClass = propertyEditorClass; }
Example 20
Source File: JdbcMethodUtils.java From compass with Apache License 2.0 | 3 votes |
/** * 通过反射来执行JDBC接口的方法 * @param interfaceClass * @param methodName * @param argTypes * @param target * @param args * @return * @throws SQLException */ public static Object invokeJdbcMethod(Class<?> interfaceClass,String methodName,Class<?>[] argTypes,Object target,Object[] args) throws SQLException { Method method=ClassUtils.getMethodIfAvailable(interfaceClass, methodName, argTypes); if(method == null) { return null; } return ReflectionUtils.invokeJdbcMethod(method, target, args); }