Ejemplo n.º 1
0
  private void introspectDestroy(ArrayList<ConfigProgram> destroyList, AnnotatedType<?> type)
      throws ConfigException {
    if (type == null || type.equals(Object.class)) return;

    if (type.isAnnotationPresent(Interceptor.class)) {
      return;
    }

    for (AnnotatedMethod<?> method : type.getMethods()) {
      if (method.isAnnotationPresent(PreDestroy.class)) {
        Method javaMethod = method.getJavaMember();

        Class<?>[] types = javaMethod.getParameterTypes();

        if (types.length == 0) {
        } else if (types.length == 1 && types[0].equals(InvocationContext.class)) {
          // XXX:
          continue;
        } else
          throw new ConfigException(
              location(javaMethod) + L.l("@PreDestroy is requires zero arguments"));

        PreDestroyInject destroyProgram = new PreDestroyInject(javaMethod);

        if (!destroyList.contains(destroyProgram)) destroyList.add(destroyProgram);
      }
    }
  }