Esempio n. 1
0
  private void injectProperty(
      Object bean, Class<?> type, Object property, String alias, TypedValueGroup arguments)
      throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    NoSuchMethodException nsme = null;

    if (arguments != null && arguments.size() > 0) {
      Object[] props = new Object[arguments.size() + 1];
      props[0] = property;
      Class<?>[] types = new Class<?>[arguments.size() + 1];
      types[0] = type;

      arguments.reset();
      while (arguments.load(props, 1)) {
        try {
          addSetProperty(bean, types, alias, props);
          return;
        } catch (NoSuchMethodException x) {
          // not a problem
          nsme = x;
        }
      }
    } else {
      try {
        addSetProperty(bean, new Class<?>[] {type}, alias, property);
        return;
      } catch (NoSuchMethodException x) {
        // not a problem
        nsme = x;
      }
    }

    // now try the super classes
    Class<?>[] interfaces = type.getInterfaces();
    for (Class<?> face : interfaces) {
      try {
        injectProperty(bean, face, property, alias, arguments);
        return;
      } catch (NoSuchMethodException x) {
        continue;
      }
    }
    Class<?> supertype = type.getSuperclass();
    if (supertype != null) {
      injectProperty(bean, supertype, property, alias, arguments);
    } else {
      throw nsme;
    }
  }