public DestroyMethodPoint[] resolve(final Class<?> type) { // lookup methods List<DestroyMethodPoint> list = new ArrayList<>(); ClassDescriptor cd = new ClassDescriptor(type, false, false, false, null); MethodDescriptor[] allMethods = cd.getAllMethodDescriptors(); for (MethodDescriptor methodDescriptor : allMethods) { Method method = methodDescriptor.getMethod(); PetiteDestroyMethod petiteDestroyMethod = method.getAnnotation(PetiteDestroyMethod.class); if (petiteDestroyMethod == null) { continue; } if (method.getParameterTypes().length > 0) { throw new PetiteException("Arguments are not allowed for Petite destroy method: " + type.getName() + '#' + method.getName()); } list.add(new DestroyMethodPoint(method)); } DestroyMethodPoint[] methods; if (list.isEmpty()) { methods = DestroyMethodPoint.EMPTY; } else { methods = list.toArray(new DestroyMethodPoint[0]); } return methods; }
/** * Registers destroy method. * * @param beanName bean name * @param destroyMethodNames destroy method names */ public void registerPetiteDestroyMethods(final String beanName, String... destroyMethodNames) { BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName); ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type); if (destroyMethodNames == null) { destroyMethodNames = StringPool.EMPTY_ARRAY; } int total = destroyMethodNames.length; DestroyMethodPoint[] destroyMethodPoints = new DestroyMethodPoint[total]; int i; for (i = 0; i < destroyMethodNames.length; i++) { MethodDescriptor md = cd.getMethodDescriptor(destroyMethodNames[i], ClassUtil.EMPTY_CLASS_ARRAY, true); if (md == null) { throw new PetiteException("Destroy method not found: " + beanDefinition.type.getName() + '#' + destroyMethodNames[i]); } destroyMethodPoints[i] = new DestroyMethodPoint(md.getMethod()); } beanDefinition.addDestroyMethodPoints(destroyMethodPoints); }
public DestroyMethodPoint[] resolve(final Class<?> type) { // lookup methods List<DestroyMethodPoint> list = new ArrayList<>(); ClassDescriptor cd = new ClassDescriptor(type, false, false, false, null); MethodDescriptor[] allMethods = cd.getAllMethodDescriptors(); for (MethodDescriptor methodDescriptor : allMethods) { Method method = methodDescriptor.getMethod(); PetiteDestroyMethod petiteDestroyMethod = method.getAnnotation(PetiteDestroyMethod.class); if (petiteDestroyMethod == null) { continue; } if (method.getParameterTypes().length > 0) { throw new PetiteException("Arguments are not allowed for Petite destroy method: " + type.getName() + '#' + method.getName()); } list.add(new DestroyMethodPoint(method)); } DestroyMethodPoint[] methods; if (list.isEmpty()) { methods = DestroyMethodPoint.EMPTY; } else { methods = list.toArray(new DestroyMethodPoint[0]); } return methods; }
/** * Registers destroy method. * * @param beanName bean name * @param destroyMethodNames destroy method names */ public void registerPetiteDestroyMethods(final String beanName, String... destroyMethodNames) { BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName); ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type); if (destroyMethodNames == null) { destroyMethodNames = StringPool.EMPTY_ARRAY; } int total = destroyMethodNames.length; DestroyMethodPoint[] destroyMethodPoints = new DestroyMethodPoint[total]; int i; for (i = 0; i < destroyMethodNames.length; i++) { MethodDescriptor md = cd.getMethodDescriptor(destroyMethodNames[i], ClassUtil.EMPTY_CLASS_ARRAY, true); if (md == null) { throw new PetiteException("Destroy method not found: " + beanDefinition.type.getName() + '#' + destroyMethodNames[i]); } destroyMethodPoints[i] = new DestroyMethodPoint(md.getMethod()); } beanDefinition.addDestroyMethodPoints(destroyMethodPoints); }