本文整理了Java中org.springframework.context.ApplicationContext.getBeanDefinitionNames()
方法的一些代码示例,展示了ApplicationContext.getBeanDefinitionNames()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationContext.getBeanDefinitionNames()
方法的具体详情如下:
包路径:org.springframework.context.ApplicationContext
类名称:ApplicationContext
方法名:getBeanDefinitionNames
暂无
Official Spring framework guide
代码示例来源:origin: spring-guides/gs-spring-boot
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
System.out.println("Let's inspect the beans provided by Spring Boot:");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
}
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
public String[] getEntityBeanNames() {
return applicationcontext.getBeanDefinitionNames();
}
代码示例来源:origin: javamelody/javamelody
/**
* @return List des noms de beans Spring.
*/
public List<String> getBeanDefinitionNames() {
return Arrays.asList(context.getBeanDefinitionNames());
}
代码示例来源:origin: stackoverflow.com
public class PrintBeans {
@Autowired
ApplicationContext applicationContext;
public void printBeans() {
System.out.println(Arrays.asList(applicationContext.getBeanDefinitionNames()));
}
}
代码示例来源:origin: stackoverflow.com
for(String s:context.getBeanDefinitionNames()){
System.out.println(s);
for(String t:context.getAliases(s)){
代码示例来源:origin: liuyangming/ByteTCC
public void afterSingletonsInstantiated() {
String[] beanNameArray = this.applicationContext.getBeanDefinitionNames();
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) this.beanFactory;
代码示例来源:origin: spockframework/spock
@Override
public void beforeTestMethod(SpringTestContext testContext) throws Exception {
Object testInstance = testContext.getTestInstance();
if (!(testInstance instanceof Specification)) return;
Specification specification = (Specification)testInstance;
ScanScopedBeans scanScopedBeans = ReflectionUtil.getAnnotationRecursive(specification.getClass(), ScanScopedBeans.class);
Set<String> scopes = scanScopedBeans == null ? Collections.<String>emptySet() :
new HashSet<>(Arrays.asList(scanScopedBeans.value()));
ApplicationContext applicationContext = testContext.getApplicationContext();
String[] mockBeanNames = applicationContext.getBeanDefinitionNames();
List<Object> mockedBeans = new ArrayList<>();
for (String beanName : mockBeanNames) {
BeanDefinition beanDefinition = ((BeanDefinitionRegistry)applicationContext).getBeanDefinition(beanName);
if (beanDefinition.isAbstract() || beanDefinition.isLazyInit()) {
continue;
}
if (beanDefinition.isSingleton() || scanScopedBean(scanScopedBeans, scopes, beanDefinition)) {
Object bean = applicationContext.getBean(beanName);
if (mockUtil.isMock(bean)) {
mockUtil.attachMock(bean, specification);
mockedBeans.add(bean);
}
}
}
testContext.setAttribute(MOCKED_BEANS_LIST, mockedBeans);
}
代码示例来源:origin: PebbleTemplates/pebble
@Override
public Set<String> keySet() {
return new LinkedHashSet<>(Arrays.asList(this.ctx.getBeanDefinitionNames()));
}
代码示例来源:origin: PebbleTemplates/pebble
@Override
public Set<String> keySet() {
return new LinkedHashSet<>(Arrays.asList(this.ctx.getBeanDefinitionNames()));
}
代码示例来源:origin: PebbleTemplates/pebble
@Override
public Set<String> keySet() {
return new LinkedHashSet<>(Arrays.asList(this.ctx.getBeanDefinitionNames()));
}
代码示例来源:origin: gravitee-io/gravitee-gateway
private void registerRepositoryDefinitions(Repository repository, ApplicationContext repoApplicationContext) {
DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory)
((ConfigurableApplicationContext) applicationContext).getBeanFactory();
String [] beanNames = repoApplicationContext.getBeanDefinitionNames();
for(String beanName : beanNames) {
Object repositoryClassInstance = repoApplicationContext.getBean(beanName);
if ((beanName.endsWith("Repository") || beanName.endsWith("Manager")) && ! repository.getClass().equals(repositoryClassInstance.getClass())) {
Class<?> repositoryObjectClass = repositoryClassInstance.getClass();
if (repositoryObjectClass.getInterfaces().length > 0) {
Class<?> repositoryItfClass = repositoryObjectClass.getInterfaces()[0];
LOGGER.debug("Register {} [{}] in gateway context", beanName, repositoryItfClass);
beanFactory.registerSingleton(repositoryItfClass.getName(),
repositoryClassInstance);
}
}
}
}
代码示例来源:origin: spring-projects/spring-hateoas
private Iterable<Class<?>> getBeanTypesWithAnnotation(Class<? extends Annotation> type) {
Set<Class<?>> annotatedTypes = new HashSet<>();
for (String beanName : context.getBeanDefinitionNames()) {
Annotation annotation = context.findAnnotationOnBean(beanName, type);
if (annotation != null) {
annotatedTypes.add(context.getType(beanName));
}
}
return annotatedTypes;
}
}
代码示例来源:origin: timebusker/spring-boot
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
代码示例来源:origin: timebusker/spring-boot
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
代码示例来源:origin: timebusker/spring-boot
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
代码示例来源:origin: timebusker/spring-boot
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
代码示例来源:origin: timebusker/spring-boot
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
代码示例来源:origin: org.springframework.cloud/spring-cloud-context
private void eagerlyInitialize() {
for (String name : this.context.getBeanDefinitionNames()) {
BeanDefinition definition = this.registry.getBeanDefinition(name);
if (this.getName().equals(definition.getScope())
&& !definition.isLazyInit()) {
Object bean = this.context.getBean(name);
if (bean != null) {
bean.getClass();
}
}
}
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-context
@Override
public void afterSingletonsInstantiated() {
// After all beans are initialized explicitly rebind beans from the parent
// so that changes during the initialization of the current context are
// reflected. In particular this can be important when low level services like
// decryption are bootstrapped in the parent, but need to change their
// configuration before the child context is processed.
if (this.context.getParent() != null) {
// TODO: make this optional? (E.g. when creating child contexts that prefer to
// be isolated.)
ConfigurationPropertiesRebinder rebinder = context
.getBean(ConfigurationPropertiesRebinder.class);
for (String name : context.getParent().getBeanDefinitionNames()) {
rebinder.rebind(name);
}
}
}
}
代码示例来源:origin: youseries/urule
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
System.out.println("Load built in actions...");
String[] names=applicationContext.getBeanDefinitionNames();
if(names==null || names.length==0)return;
for(String name:names){
Object obj=null;
try{
obj=applicationContext.getBean(name);
}catch(Exception ex){
continue;
}
if(obj==null){
continue;
}
ActionBean aa=obj.getClass().getAnnotation(ActionBean.class);
if(aa==null){
continue;
}
SpringBean bean=new SpringBean();
bean.setId(name);
bean.setName(aa.name());
bean.setMethods(buildMethod(obj.getClass().getMethods()));
builtInActions.add(bean);
}
}
private List<com.bstek.urule.model.library.action.Method> buildMethod(Method[] methods){
内容来源于网络,如有侵权,请联系作者删除!