Skip to content

Commit

Permalink
Polish #45
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyblitz committed Jan 3, 2025
1 parent e658590 commit ae37f6d
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.springframework.beans.factory.support.AbstractBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.util.Assert;

import javax.annotation.Nullable;
import java.util.ArrayList;
Expand All @@ -36,7 +37,6 @@

import static io.microsphere.reflect.FieldUtils.getFieldValue;
import static io.microsphere.util.ArrayUtils.of;
import static io.microsphere.util.ClassUtils.cast;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableList;
Expand Down Expand Up @@ -92,7 +92,6 @@ public static <T> List<T> getBeans(ListableBeanFactory beanFactory, String[] bea
return emptyList();
}

// Issue : https://github.com/alibaba/spring-context-support/issues/20
String[] allBeanNames = beanNamesForTypeIncludingAncestors(beanFactory, beanType, true, false);

List<T> beans = new ArrayList<T>(beanNames.length);
Expand Down Expand Up @@ -192,4 +191,11 @@ public static List<BeanPostProcessor> getBeanPostProcessors(@Nullable BeanFactor
return beanPostProcessors;
}

private static <T> T cast(Object beanFactory, Class<T> extendedBeanFactoryType) {
Assert.isInstanceOf(extendedBeanFactoryType, beanFactory,
"The 'beanFactory' argument is not a instance of " + extendedBeanFactoryType +
", is it running in Spring container?");
return extendedBeanFactoryType.cast(beanFactory);
}

}

0 comments on commit ae37f6d

Please sign in to comment.