Package org.springframework.util.ReflectionUtils

Examples of org.springframework.util.ReflectionUtils.MethodCallback


    private static Map<String, Function> discoverDeclaredFunctions(Class<?> type) {

      final Map<String, Function> map = new HashMap<String, Function>();

      ReflectionUtils.doWithMethods(type, new MethodCallback() {

        @Override
        public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
          if (Modifier.isPublic(method.getModifiers()) && Modifier.isStatic(method.getModifiers())) {
            map.put(method.getName(), new Function(method, null));
View Full Code Here


        return;
      }

      final PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(type);

      ReflectionUtils.doWithMethods(type, new MethodCallback() {

        @Override
        public void doWith(Method method) {

          RootObjectInformation.this.methods.add(method);
View Full Code Here

    final Map<Class<?>, HandlerMethod> candidateMethods = new HashMap<Class<?>, HandlerMethod>();
    final Map<Class<?>, HandlerMethod> candidateMessageMethods = new HashMap<Class<?>, HandlerMethod>();
    final Class<?> targetClass = this.getTargetClass(targetObject);
    MethodFilter methodFilter = new UniqueMethodFilter(targetClass);
    ReflectionUtils.doWithMethods(targetClass, new MethodCallback() {
      @Override
      public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
        boolean matchesAnnotation = false;
        if (method.isBridge()) {
          return;
View Full Code Here

    return bean;
  }

  public Object postProcessAfterInitialization(final Object bean, String beanName) {
    final Class<?> targetClass = AopUtils.getTargetClass(bean);
    ReflectionUtils.doWithMethods(targetClass, new MethodCallback() {
      public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
        Scheduled annotation = AnnotationUtils.getAnnotation(method, Scheduled.class);
        if (annotation != null) {
          Assert.isTrue(void.class.equals(method.getReturnType()),
              "Only void-returning methods may be annotated with @Scheduled.");
View Full Code Here

    return bean;
  }

  public Object postProcessAfterInitialization(final Object bean, String beanName) {
    final Class<?> targetClass = AopUtils.getTargetClass(bean);
    ReflectionUtils.doWithMethods(targetClass, new MethodCallback() {
      public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
        Scheduled annotation = AnnotationUtils.getAnnotation(method, Scheduled.class);
        if (annotation != null) {
          Assert.isTrue(void.class.equals(method.getReturnType()),
              "Only void-returning methods may be annotated with @Scheduled.");
View Full Code Here

            Method setResultsMethod = ReflectionUtils.findMethod(returnTypeClass, setterMethodName, resultReturnTypeClass);
            final AtomicReference<Method> altSetResultsMethod = new AtomicReference<Method>();

            // issue with ReflectionUtils, setterResultsMethod sometimes null from the command line (not getter?)
            if (setResultsMethod == null) {
                ReflectionUtils.doWithMethods(returnTypeClass, new MethodCallback() {
                    @Override
                    public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
                        if (setterMethodName.equals(method.getName())) {
                            altSetResultsMethod.set(method);
                        logger.debug("Unable to use ReflectionUtils to find setter. returnTypeClass={}  method={} resultReturnTypeClass={}",
View Full Code Here

    }

    if (clazz.isInterface()) {
      final List<Method> methods = new ArrayList<Method>();

      ReflectionUtils.doWithMethods(clazz, new MethodCallback() {
        @Override
        public void doWith(Method method) throws IllegalArgumentException,
            IllegalAccessException {
          methods.add(method);
        }
View Full Code Here

    }

    if (clazz.isInterface()) {
      final List<Method> methods = new ArrayList<Method>();

      ReflectionUtils.doWithMethods(clazz, new MethodCallback() {
        @Override
        public void doWith(Method method)
            throws IllegalArgumentException, IllegalAccessException {
          methods.add(method);
        }
View Full Code Here

    final List<ModelFieldBean> modelFields = new ArrayList<ModelFieldBean>();
    final List<AbstractAssociation> associations = new ArrayList<AbstractAssociation>();

    if (clazz.isInterface()) {
      ReflectionUtils.doWithMethods(clazz, new MethodCallback() {
        @Override
        public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
         
          Class<?> javaType = method.getReturnType();   
          if (javaType.equals(Void.TYPE)) {
View Full Code Here

                    }
                }
            }
        };

        MethodCallback methodCallback = new ReflectionUtils.MethodCallback() {
            public void doWith(Method method) throws IllegalArgumentException,
                    IllegalAccessException {
                if (method.isSynthetic()) {
                    return;
                }
                if (!Modifier.isPublic(method.getModifiers())) {
                    return;
                }
                if (Modifier.isStatic(method.getModifiers())
                        && method.getReturnType() != Void.class) {
                    if (method.getParameterTypes().length == 0) {
                        String name = method.getName();
                        if (name.indexOf('$') == -1) {
                            if (name.length() > 3 && name.startsWith("get")
                                    && Character.isUpperCase(name.charAt(3))) {
                                name = name.substring(3);
                            } else if (name.length() > 2
                                    && name.startsWith("is")
                                    && Character.isUpperCase(name.charAt(2))
                                    && (method.getReturnType() == Boolean.class ||
                                        method.getReturnType() == boolean.class)) {
                                name = name.substring(2);
                            }
                            PropertyFetcher fetcher = new GetterPropertyFetcher(
                                    method, true);
                            staticFetchers.put(name, fetcher);
                            staticFetchers.put(StringUtils.uncapitalize(name), fetcher);
                        }
                    }
                }
            }
        };

        List<Class<?>> allClasses = resolveAllClasses(clazz);
        for (Class<?> c : allClasses) {
            Field[] fields = c.getDeclaredFields();
            for (Field field : fields) {
                try {
                    fieldCallback.doWith(field);
                } catch (IllegalAccessException ex) {
                    throw new IllegalStateException(
                            "Shouldn't be illegal to access field '"
                                    + field.getName() + "': " + ex);
                }
            }
            Method[] methods = c.getDeclaredMethods();
            for (Method method : methods) {
                try {
                    methodCallback.doWith(method);
                } catch (IllegalAccessException ex) {
                    throw new IllegalStateException(
                            "Shouldn't be illegal to access method '"
                                    + method.getName() + "': " + ex);
                }
View Full Code Here

TOP

Related Classes of org.springframework.util.ReflectionUtils.MethodCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.