public boolean containsObject(String key) { return (this.beanFactory.containsBean(key) || (this.scope != null && this.scope.resolveContextualObject(key) != null)); }
/** * Check the BeanFactory to see whether the bean named <var>beanName</var> already * exists. Accounts for the fact that the requested bean may be "in creation", i.e.: * we're in the middle of servicing the initial request for this bean. From an enhanced * factory method's perspective, this means that the bean does not actually yet exist, * and that it is now our job to create it for the first time by executing the logic * in the corresponding factory method. * <p>Said another way, this check repurposes * {@link ConfigurableBeanFactory#isCurrentlyInCreation(String)} to determine whether * the container is calling this method or the user is calling this method. * @param beanName name of bean to check for * @return whether <var>beanName</var> already exists in the factory */ private boolean factoryContainsBean(ConfigurableBeanFactory beanFactory, String beanName) { return (beanFactory.containsBean(beanName) && !beanFactory.isCurrentlyInCreation(beanName)); }
@Nullable public Object getObject(String key) { if (this.beanFactory.containsBean(key)) { return this.beanFactory.getBean(key); } else if (this.scope != null) { return this.scope.resolveContextualObject(key); } else { return null; } }
public boolean containsObject(String key) { return (this.beanFactory.containsBean(key) || (this.scope != null && this.scope.resolveContextualObject(key) != null)); }
/** * Check the BeanFactory to see whether the bean named <var>beanName</var> already * exists. Accounts for the fact that the requested bean may be "in creation", i.e.: * we're in the middle of servicing the initial request for this bean. From an enhanced * factory method's perspective, this means that the bean does not actually yet exist, * and that it is now our job to create it for the first time by executing the logic * in the corresponding factory method. * <p>Said another way, this check repurposes * {@link ConfigurableBeanFactory#isCurrentlyInCreation(String)} to determine whether * the container is calling this method or the user is calling this method. * @param beanName name of bean to check for * @return whether <var>beanName</var> already exists in the factory */ private boolean factoryContainsBean(ConfigurableBeanFactory beanFactory, String beanName) { return (beanFactory.containsBean(beanName) && !beanFactory.isCurrentlyInCreation(beanName)); }
@Nullable public Object getObject(String key) { if (this.beanFactory.containsBean(key)) { return this.beanFactory.getBean(key); } else if (this.scope != null) { return this.scope.resolveContextualObject(key); } else { return null; } }
/** * Resolve placeholder property values, e.g. * <br /> * <br /> * "${somePropertyValue}" -> "the actual property value" */ public Object resolvePropertyValue(ConfigurableBeanFactory beanFactory, String beanName, String placeholder) { // resolve string value String strVal = beanFactory.resolveEmbeddedValue(placeholder); BeanDefinition bd = (beanFactory.containsBean(beanName) ? beanFactory .getMergedBeanDefinition(beanName) : null); // resolve expressions like "#{systemProperties.myProp}" return evaluateBeanDefinitionString(beanFactory, strVal, bd); }
ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) factory; for (String autowiredBeanName : autowiredBeanNames) { if (requestingBeanName != null && beanFactory.containsBean(autowiredBeanName)) { beanFactory.registerDependentBean(autowiredBeanName, requestingBeanName);
log.debug("Lookup common - bean:{} local:{} singleton:{}", new Object[] { factory.containsBean("red5.common"), factory.containsLocalBean("red5.common"), factory.containsSingleton("red5.common"), }); parentContext = (ApplicationContext) factory.getBean("red5.common");
ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) factory; for (String autowiredBeanName : autowiredBeanNames) { if (requestingBeanName != null && beanFactory.containsBean(autowiredBeanName)) { beanFactory.registerDependentBean(autowiredBeanName, requestingBeanName);
@Override public void beforeTestClass(TestContext testContext) throws Exception { ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) testContext .getApplicationContext().getAutowireCapableBeanFactory(); if (!beanFactory.containsBean("mockMvcClientHttpRequestFactory")) { this.factory = new MockMvcClientHttpRequestFactory( beanFactory.getBean(MockMvc.class)); beanFactory.registerSingleton("mockMvcClientHttpRequestFactory", this.factory); } else { this.factory = beanFactory.getBean("mockMvcClientHttpRequestFactory", MockMvcClientHttpRequestFactory.class); } }
public boolean containsObject(String key) { return (this.beanFactory.containsBean(key) || (this.scope != null && this.scope.resolveContextualObject(key) != null)); }
public Object getObject(String key) { if (this.beanFactory.containsBean(key)) { return this.beanFactory.getBean(key); } else if (this.scope != null){ return this.scope.resolveContextualObject(key); } else { return null; } }
public boolean containsObject(String key) { return (this.beanFactory.containsBean(key) || (this.scope != null && this.scope.resolveContextualObject(key) != null)); }
/** * Can this module find a bean with the given name in the context. * * @deprecated use {@link org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean} instead */ @Deprecated public boolean hasBean( String beanName ) { return getBeanFactory().containsBean( beanName ); }
private void addBeanFactoryDependency() { if (beanFactory instanceof ConfigurableBeanFactory) { ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory; if (StringUtils.hasText(beanName) && cbf.containsBean(beanName)) { // no need to validate targetBeanName (already did) cbf.registerDependentBean(targetBeanName, BeanFactory.FACTORY_BEAN_PREFIX + beanName); cbf.registerDependentBean(targetBeanName, beanName); } } else { log.warn("The running bean factory cannot support dependencies between beans " + "- importer/exporter dependency cannot be enforced"); } }
public Object getObject(String key) { if (this.beanFactory.containsBean(key)) { return this.beanFactory.getBean(key); } else if (this.scope != null){ return this.scope.resolveContextualObject(key); } else { return null; } }
/** * Can this module find a bean with the given name and of the given type in the context. * * @deprecated use {@link org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean} instead */ @Deprecated public boolean hasBean( String beanName, Class beanType ) { return getBeanFactory().containsBean( beanName ) && getBeanFactory().isTypeMatch( beanName, beanType ); }
private void registerServiceListFactoryBean(Module usingModule, Field field) { ParameterizedType listGenericType = (ParameterizedType) field.getGenericType(); Class<?> serviceType = (Class<?>) listGenericType.getActualTypeArguments()[0]; LOGGER.log(INFO, "ModuleServiceReference from module " + usingModule.getName() + " found for service of type List of " + serviceType); validateModuleUsesServiceType(usingModule, serviceType); validateNamedOrQualifierAnnotationPresent(field, serviceType); String newBeanName = serviceListFactoryBeanName(serviceType); if(!this.beanFactory.containsBean(newBeanName)) { registerAbstractServiceFactoryBean(serviceType, newBeanName, new ServiceListFactoryBean()); } }
private void registerServiceFactoryBean(Module usingModule, Field field) { Class<?> serviceType = field.getType(); LOGGER.log(INFO, "ModuleServiceReference from module " + usingModule.getName() + " found for service of type " + serviceType); String newBeanName = serviceFactoryBeanName(serviceType); validateModuleUsesServiceType(usingModule, serviceType); if(!this.beanFactory.containsBean(newBeanName)) { registerAbstractServiceFactoryBean(serviceType, newBeanName, new ServiceFactoryBean()); } }