Java Code Examples for org.springframework.beans.factory.config.ConfigurableListableBeanFactory
The following examples show how to use
org.springframework.beans.factory.config.ConfigurableListableBeanFactory.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: java-technology-stack Author: codeEngraver File: ConfigurationClassPostProcessor.java License: MIT License | 6 votes |
/** * Prepare the Configuration classes for servicing bean requests at runtime * by replacing them with CGLIB-enhanced subclasses. */ @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { int factoryId = System.identityHashCode(beanFactory); if (this.factoriesPostProcessed.contains(factoryId)) { throw new IllegalStateException( "postProcessBeanFactory already called on this post-processor against " + beanFactory); } this.factoriesPostProcessed.add(factoryId); if (!this.registriesPostProcessed.contains(factoryId)) { // BeanDefinitionRegistryPostProcessor hook apparently not supported... // Simply call processConfigurationClasses lazily at this point then. processConfigBeanDefinitions((BeanDefinitionRegistry) beanFactory); } enhanceConfigurationClasses(beanFactory); beanFactory.addBeanPostProcessor(new ImportAwareBeanPostProcessor(beanFactory)); }
Example #2
Source Project: loc-framework Author: lord-of-code File: LocDataSourceAutoConfiguration.java License: MIT License | 6 votes |
private void createBean(ConfigurableListableBeanFactory configurableListableBeanFactory, String prefixName, JdbcProperties jdbcProperties) { String jdbcUrl = jdbcProperties.getJdbcUrl(); checkArgument(!Strings.isNullOrEmpty(jdbcUrl), prefixName + " url is null or empty"); log.info("prefixName is {}, jdbc properties is {}", prefixName, jdbcProperties); HikariDataSource hikariDataSource = createHikariDataSource(jdbcProperties); DataSourceSpy dataSource = new DataSourceSpy(hikariDataSource); DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource); AnnotationTransactionAspect.aspectOf().setTransactionManager(transactionManager); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); register(configurableListableBeanFactory, dataSource, prefixName + "DataSource", prefixName + "Ds"); register(configurableListableBeanFactory, jdbcTemplate, prefixName + "JdbcTemplate", prefixName + "Jt"); register(configurableListableBeanFactory, transactionManager, prefixName + "TransactionManager", prefixName + "Tx"); }
Example #3
Source Project: spring-boot-starter-dubbo Author: halober File: DubboAutoConfiguration.java License: Apache License 2.0 | 6 votes |
private void registerConsumer(ConsumerConfig consumer, ConfigurableListableBeanFactory beanFactory) { if (consumer != null) { String beanName = consumer.getId(); if (StringUtils.isEmpty(beanName)) { beanName = "consumerConfig"; } String filter = consumer.getFilter(); if (StringUtils.isEmpty(filter)) { filter = "regerConsumerFilter"; } else { filter = filter.trim() + ",regerConsumerFilter"; } logger.debug("添加consumerFilter后的Filter, {}", filter); consumer.setFilter(filter); beanFactory.registerSingleton(beanName, consumer); } else { logger.debug("dubbo 没有配置默认的消费者参数"); } }
Example #4
Source Project: kfs Author: kuali File: DefaultListableBeanFactory.java License: GNU Affero General Public License v3.0 | 6 votes |
@Override public boolean isAutowireCandidate(String beanName, DependencyDescriptor descriptor) throws NoSuchBeanDefinitionException { // Consider FactoryBeans as autowiring candidates. boolean isFactoryBean = (descriptor != null && descriptor.getDependencyType() != null && FactoryBean.class.isAssignableFrom(descriptor.getDependencyType())); if (isFactoryBean) { beanName = BeanFactoryUtils.transformedBeanName(beanName); } if (containsBeanDefinition(beanName)) { return isAutowireCandidate(beanName, getMergedLocalBeanDefinition(beanName), descriptor); } else if (containsSingleton(beanName)) { return isAutowireCandidate(beanName, new RootBeanDefinition(getType(beanName)), descriptor); } else if (getParentBeanFactory() instanceof ConfigurableListableBeanFactory) { // No bean definition found in this factory -> delegate to parent. return ((ConfigurableListableBeanFactory) getParentBeanFactory()).isAutowireCandidate(beanName, descriptor); } else { return true; } }
Example #5
Source Project: es Author: zhangkaitao File: SpeedUpSpringProcessor.java License: Apache License 2.0 | 6 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if(!(beanFactory instanceof DefaultListableBeanFactory)) { log.error("if speed up spring, bean factory must be type of DefaultListableBeanFactory"); return; } DefaultListableBeanFactory listableBeanFactory = (DefaultListableBeanFactory) beanFactory; for(String beanName : listableBeanFactory.getBeanDefinitionNames()) { BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName); //如果匹配模式 就移除掉 if(needRemove(beanName, beanDefinition)) { listableBeanFactory.removeBeanDefinition(beanName); continue; } //否则设置为lazy if(needLazyInit(beanName)) { beanDefinition.setLazyInit(true); } } }
Example #6
Source Project: lams Author: lamsfoundation File: DefaultListableBeanFactory.java License: GNU General Public License v2.0 | 6 votes |
/** * Determine whether the specified bean definition qualifies as an autowire candidate, * to be injected into other beans which declare a dependency of matching type. * @param beanName the name of the bean definition to check * @param descriptor the descriptor of the dependency to resolve * @param resolver the AutowireCandidateResolver to use for the actual resolution algorithm * @return whether the bean should be considered as autowire candidate */ protected boolean isAutowireCandidate(String beanName, DependencyDescriptor descriptor, AutowireCandidateResolver resolver) throws NoSuchBeanDefinitionException { String beanDefinitionName = BeanFactoryUtils.transformedBeanName(beanName); if (containsBeanDefinition(beanDefinitionName)) { return isAutowireCandidate(beanName, getMergedLocalBeanDefinition(beanDefinitionName), descriptor, resolver); } else if (containsSingleton(beanName)) { return isAutowireCandidate(beanName, new RootBeanDefinition(getType(beanName)), descriptor, resolver); } BeanFactory parent = getParentBeanFactory(); if (parent instanceof DefaultListableBeanFactory) { // No bean definition found in this factory -> delegate to parent. return ((DefaultListableBeanFactory) parent).isAutowireCandidate(beanName, descriptor, resolver); } else if (parent instanceof ConfigurableListableBeanFactory) { // If no DefaultListableBeanFactory, can't pass the resolver along. return ((ConfigurableListableBeanFactory) parent).isAutowireCandidate(beanName, descriptor); } else { return true; } }
Example #7
Source Project: dubbo3 Author: linux-china File: AnnotationBean.java License: Apache License 2.0 | 6 votes |
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (annotationPackage == null || annotationPackage.length() == 0) { return; } if (beanFactory instanceof BeanDefinitionRegistry) { try { // init scanner Class<?> scannerClass = ReflectUtils.forName("org.springframework.context.annotation.ClassPathBeanDefinitionScanner"); Object scanner = scannerClass.getConstructor(new Class<?>[] {BeanDefinitionRegistry.class, boolean.class}).newInstance(beanFactory, true); // add filter Class<?> filterClass = ReflectUtils.forName("org.springframework.core.type.filter.AnnotationTypeFilter"); Object filter = filterClass.getConstructor(Class.class).newInstance(DubboService.class); Method addIncludeFilter = scannerClass.getMethod("addIncludeFilter", ReflectUtils.forName("org.springframework.core.type.filter.TypeFilter")); addIncludeFilter.invoke(scanner, filter); // scan packages String[] packages = Constants.COMMA_SPLIT_PATTERN.split(annotationPackage); Method scan = scannerClass.getMethod("scan", String[].class); scan.invoke(scanner, new Object[] {packages}); } catch (Throwable e) { // spring 2.0 } } }
Example #8
Source Project: zxl Author: xiaolongzuo File: CreateTablePostProcessor.java License: Apache License 2.0 | 6 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { Set<Class<?>> classes = ReflectUtil.findAllClasses(applicationContext.getClassLoader(), hbaseDomainPackages); for (Class<?> clazz : classes) { if (!HBaseUtil.isTable(clazz)) { continue; } List<String> columnFamiliesList = new ArrayList<String>(); for (Field field : ReflectUtil.getAllFields(clazz)) { if (HBaseUtil.isFamily(field)) { columnFamiliesList.add(field.getName()); } } Object timeToLiveBean = applicationContext.getBean("timeToLive"); Integer timeToLive = TIME_TO_LIVE; if (timeToLiveBean != null) { timeToLive = Integer.valueOf(timeToLiveBean.toString()); } HBaseFactory.createTable(clazz.getSimpleName(), ArrayUtil.listToArray(columnFamiliesList), timeToLive); } }
Example #9
Source Project: spring4-understanding Author: langtianya File: WebApplicationContextUtils.java License: Apache License 2.0 | 6 votes |
public static void registerFacesDependencies(ConfigurableListableBeanFactory beanFactory) { beanFactory.registerResolvableDependency(FacesContext.class, new ObjectFactory<FacesContext>() { @Override public FacesContext getObject() { return FacesContext.getCurrentInstance(); } @Override public String toString() { return "Current JSF FacesContext"; } }); beanFactory.registerResolvableDependency(ExternalContext.class, new ObjectFactory<ExternalContext>() { @Override public ExternalContext getObject() { return FacesContext.getCurrentInstance().getExternalContext(); } @Override public String toString() { return "Current JSF ExternalContext"; } }); }
Example #10
Source Project: lams Author: lamsfoundation File: BeanFactoryAnnotationUtils.java License: GNU General Public License v2.0 | 6 votes |
/** * Obtain a bean of type {@code T} from the given {@code BeanFactory} declaring a * qualifier (e.g. via {@code <qualifier>} or {@code @Qualifier}) matching the given * qualifier, or having a bean name matching the given qualifier. * @param beanFactory the BeanFactory to get the target bean from * @param beanType the type of bean to retrieve * @param qualifier the qualifier for selecting between multiple bean matches * @return the matching bean of type {@code T} (never {@code null}) * @throws NoUniqueBeanDefinitionException if multiple matching beans of type {@code T} found * @throws NoSuchBeanDefinitionException if no matching bean of type {@code T} found * @throws BeansException if the bean could not be created * @see BeanFactory#getBean(Class) */ public static <T> T qualifiedBeanOfType(BeanFactory beanFactory, Class<T> beanType, String qualifier) throws BeansException { Assert.notNull(beanFactory, "BeanFactory must not be null"); if (beanFactory instanceof ConfigurableListableBeanFactory) { // Full qualifier matching supported. return qualifiedBeanOfType((ConfigurableListableBeanFactory) beanFactory, beanType, qualifier); } else if (beanFactory.containsBean(qualifier)) { // Fallback: target bean at least found by bean name. return beanFactory.getBean(qualifier, beanType); } else { throw new NoSuchBeanDefinitionException(qualifier, "No matching " + beanType.getSimpleName() + " bean found for bean name '" + qualifier + "'! (Note: Qualifier matching not supported because given " + "BeanFactory does not implement ConfigurableListableBeanFactory.)"); } }
Example #11
Source Project: spring-cloud-connectors Author: spring-cloud File: AbstractCloudServiceConnectorFactory.java License: Apache License 2.0 | 6 votes |
@Override public void afterPropertiesSet() throws Exception { ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory) getBeanFactory(); if (cloud == null) { if (beanFactory.getBeansOfType(CloudFactory.class).isEmpty()) { beanFactory.registerSingleton(CLOUD_FACTORY_BEAN_NAME, new CloudFactory()); } CloudFactory cloudFactory = beanFactory.getBeansOfType(CloudFactory.class).values().iterator().next(); cloud = cloudFactory.getCloud(); } if (!StringUtils.hasText(serviceId)) { List<? extends ServiceInfo> infos = cloud.getServiceInfos(serviceConnectorType); if (infos.size() != 1) { throw new CloudException("Expected 1 service matching " + serviceConnectorType.getName() + " type, but found " + infos.size()); } serviceId = infos.get(0).getId(); } super.afterPropertiesSet(); }
Example #12
Source Project: spring-cloud-function Author: spring-cloud File: SingletonTests.java License: Apache License 2.0 | 6 votes |
@Bean public static BeanDefinitionRegistryPostProcessor processor() { return new BeanDefinitionRegistryPostProcessor() { @Override public void postProcessBeanFactory( ConfigurableListableBeanFactory beanFactory) throws BeansException { } @Override public void postProcessBeanDefinitionRegistry( BeanDefinitionRegistry registry) throws BeansException { // Simulates what happens when you add a compiled function RootBeanDefinition beanDefinition = new RootBeanDefinition( MySupplier.class); registry.registerBeanDefinition("words", beanDefinition); } }; }
Example #13
Source Project: spring4-understanding Author: langtianya File: WebApplicationContextUtils.java License: Apache License 2.0 | 6 votes |
/** * Register web-specific scopes ("request", "session", "globalSession", "application") * with the given BeanFactory, as used by the WebApplicationContext. * @param beanFactory the BeanFactory to configure * @param sc the ServletContext that we're running within */ public static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory, ServletContext sc) { beanFactory.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope()); beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope(false)); beanFactory.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true)); if (sc != null) { ServletContextScope appScope = new ServletContextScope(sc); beanFactory.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope); // Register as ServletContext attribute, for ContextCleanupListener to detect it. sc.setAttribute(ServletContextScope.class.getName(), appScope); } beanFactory.registerResolvableDependency(ServletRequest.class, new RequestObjectFactory()); beanFactory.registerResolvableDependency(ServletResponse.class, new ResponseObjectFactory()); beanFactory.registerResolvableDependency(HttpSession.class, new SessionObjectFactory()); beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory()); if (jsfPresent) { FacesDependencyRegistrar.registerFacesDependencies(beanFactory); } }
Example #14
Source Project: rabbitmq-mock Author: fridujo File: ConfigClientTestConfiguration.java License: Apache License 2.0 | 6 votes |
@Override public void initialize(ConfigurableApplicationContext configurableApplicationContext) { RestTemplate configServerClient = new RestTemplate(); MockRestServiceServer mockConfigServer = MockRestServiceServer.bindTo(configServerClient).build(); configServerClient.getInterceptors().add(0, new LoggingHttpInterceptor()); // {@code putIfAbsent} here is important as we do not want to override values when context is refreshed ConfigServerValues configServerValues = new ConfigServerValues(mockConfigServer) .putIfAbsent(ConfigClient.USER_ROLE_KEY, "admin"); ConfigurableListableBeanFactory beanFactory = configurableApplicationContext.getBeanFactory(); try { beanFactory .getBean(ConfigServicePropertySourceLocator.class) .setRestTemplate(configServerClient); beanFactory.registerSingleton("configServerClient", configServerClient); beanFactory.registerSingleton("mockConfigServer", mockConfigServer); beanFactory.registerSingleton("configServerValues", configServerValues); } catch (NoSuchBeanDefinitionException e) { // too soon, ConfigServicePropertySourceLocator is not defined } }
Example #15
Source Project: YuRPC Author: xincao9 File: YuRPCAutoConfiguration.java License: Apache License 2.0 | 5 votes |
/** * 后置处理组件工厂 * * @param beanFactory 容器上下文 * @throws BeansException 组件异常 */ @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (server || client) { try { beanFactory.addBeanPostProcessor(yuRPCBeanPostProcessor); } catch (Throwable e) { throw new BeansException(e.getMessage()) { }; } } }
Example #16
Source Project: webanno Author: webanno File: ExportedComponentPostProcessor.java License: Apache License 2.0 | 5 votes |
private ConfigurableListableBeanFactory getParentBeanFactory() { BeanFactory parent = beanFactory.getParentBeanFactory(); return (parent instanceof ConfigurableListableBeanFactory) ? (ConfigurableListableBeanFactory) parent : null; }
Example #17
Source Project: tutorials Author: eugenp File: IOCContainerAppUnitTest.java License: MIT License | 5 votes |
@Test public void whenBFPostProcessorAndBPProcessorRegisteredManually_thenReturnTrue() { Resource res = new ClassPathResource("ioc-container-difference-example.xml"); ConfigurableListableBeanFactory factory = new XmlBeanFactory(res); CustomBeanFactoryPostProcessor beanFactoryPostProcessor = new CustomBeanFactoryPostProcessor(); beanFactoryPostProcessor.postProcessBeanFactory(factory); assertTrue(CustomBeanFactoryPostProcessor.isBeanFactoryPostProcessorRegistered()); CustomBeanPostProcessor beanPostProcessor = new CustomBeanPostProcessor(); factory.addBeanPostProcessor(beanPostProcessor); Student student = (Student) factory.getBean("student"); assertTrue(CustomBeanPostProcessor.isBeanPostProcessorRegistered()); }
Example #18
Source Project: java-technology-stack Author: codeEngraver File: ConditionEvaluator.java License: MIT License | 5 votes |
@Nullable private ConfigurableListableBeanFactory deduceBeanFactory(@Nullable BeanDefinitionRegistry source) { if (source instanceof ConfigurableListableBeanFactory) { return (ConfigurableListableBeanFactory) source; } if (source instanceof ConfigurableApplicationContext) { return (((ConfigurableApplicationContext) source).getBeanFactory()); } return null; }
Example #19
Source Project: lams Author: lamsfoundation File: CustomAutowireConfigurer.java License: GNU General Public License v2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (this.customQualifierTypes != null) { if (!(beanFactory instanceof DefaultListableBeanFactory)) { throw new IllegalStateException( "CustomAutowireConfigurer needs to operate on a DefaultListableBeanFactory"); } DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory) beanFactory; if (!(dlbf.getAutowireCandidateResolver() instanceof QualifierAnnotationAutowireCandidateResolver)) { dlbf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver()); } QualifierAnnotationAutowireCandidateResolver resolver = (QualifierAnnotationAutowireCandidateResolver) dlbf.getAutowireCandidateResolver(); for (Object value : this.customQualifierTypes) { Class<? extends Annotation> customType = null; if (value instanceof Class) { customType = (Class<? extends Annotation>) value; } else if (value instanceof String) { String className = (String) value; customType = (Class<? extends Annotation>) ClassUtils.resolveClassName(className, this.beanClassLoader); } else { throw new IllegalArgumentException( "Invalid value [" + value + "] for custom qualifier type: needs to be Class or String."); } if (!Annotation.class.isAssignableFrom(customType)) { throw new IllegalArgumentException( "Qualifier type [" + customType.getName() + "] needs to be annotation type"); } resolver.addQualifierType(customType); } } }
Example #20
Source Project: seed Author: jadyer File: JasyptConfiguration.java License: Apache License 2.0 | 5 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { MutablePropertySources propertySources = ((ConfigurableEnvironment)environment).getPropertySources(); for(org.springframework.core.env.PropertySource<?> obj : propertySources){ if(obj instanceof ResourcePropertySource){ propertySources.replace(obj.getName(), new PropertySourceWrapper((ResourcePropertySource)obj)); } } }
Example #21
Source Project: disconf Author: knightliao File: ReloadingPropertyPlaceholderConfigurer.java License: Apache License 2.0 | 5 votes |
/** * copy & paste, just so we can insert our own visitor. * 启动时 进行配置的解析 */ protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException { BeanDefinitionVisitor visitor = new ReloadingPropertyPlaceholderConfigurer.PlaceholderResolvingBeanDefinitionVisitor(props); String[] beanNames = beanFactoryToProcess.getBeanDefinitionNames(); for (int i = 0; i < beanNames.length; i++) { // Check that we're not parsing our own bean definition, // to avoid failing on unresolvable placeholders in net.unicon.iamlabs.spring.properties.example.net // .unicon.iamlabs.spring.properties file locations. if (!(beanNames[i].equals(this.beanName) && beanFactoryToProcess.equals(this.beanFactory))) { this.currentBeanName = beanNames[i]; try { BeanDefinition bd = beanFactoryToProcess.getBeanDefinition(beanNames[i]); try { visitor.visitBeanDefinition(bd); } catch (BeanDefinitionStoreException ex) { throw new BeanDefinitionStoreException(bd.getResourceDescription(), beanNames[i], ex.getMessage()); } } finally { currentBeanName = null; } } } StringValueResolver stringValueResolver = new PlaceholderResolvingStringValueResolver(props); // New in Spring 2.5: resolve placeholders in alias target names and aliases as well. beanFactoryToProcess.resolveAliases(stringValueResolver); // New in Spring 3.0: resolve placeholders in embedded values such as annotation attributes. beanFactoryToProcess.addEmbeddedValueResolver(stringValueResolver); }
Example #22
Source Project: lams Author: lamsfoundation File: AbstractRefreshableWebApplicationContext.java License: GNU General Public License v2.0 | 5 votes |
/** * Register request/session scopes, a {@link ServletContextAwareProcessor}, etc. */ @Override protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { beanFactory.addBeanPostProcessor(new ServletContextAwareProcessor(this.servletContext, this.servletConfig)); beanFactory.ignoreDependencyInterface(ServletContextAware.class); beanFactory.ignoreDependencyInterface(ServletConfigAware.class); WebApplicationContextUtils.registerWebApplicationScopes(beanFactory, this.servletContext); WebApplicationContextUtils.registerEnvironmentBeans(beanFactory, this.servletContext, this.servletConfig); }
Example #23
Source Project: SpringCloud-Shop Author: suxiongwei File: FeignBeanFactoryPostProcessor.java License: Apache License 2.0 | 5 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (containsBeanDefinition(beanFactory, "feignContext", "eurekaAutoServiceRegistration")) { BeanDefinition bd = beanFactory.getBeanDefinition("feignContext"); bd.setDependsOn("eurekaAutoServiceRegistration"); } }
Example #24
Source Project: spring-vault Author: spring-projects File: VaultPropertySourceRegistrar.java License: Apache License 2.0 | 5 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { ConfigurableEnvironment env = beanFactory.getBean(ConfigurableEnvironment.class); MutablePropertySources propertySources = env.getPropertySources(); registerPropertySources( beanFactory.getBeansOfType(org.springframework.vault.core.env.VaultPropertySource.class).values(), propertySources); registerPropertySources(beanFactory .getBeansOfType(org.springframework.vault.core.env.LeaseAwareVaultPropertySource.class).values(), propertySources); }
Example #25
Source Project: spring-init Author: spring-projects-experimental File: SampleConfiguration.java License: Apache License 2.0 | 5 votes |
@Bean public CommandLineRunner runner(Bar bar, ConfigurableListableBeanFactory beans) { return args -> { System.out.println("Message: " + message); System.out.println("Bar: " + bar); System.out.println("Foo: " + bar.getFoo()); System.err.println("Class count: " + ManagementFactory.getClassLoadingMXBean() .getTotalLoadedClassCount()); System.err.println("Bean count: " + beans.getBeanDefinitionNames().length); System.err.println( "Bean names: " + Arrays.asList(beans.getBeanDefinitionNames())); }; }
Example #26
Source Project: spring4-understanding Author: langtianya File: AbstractAdvisorAutoProxyCreator.java License: Apache License 2.0 | 5 votes |
@Override public void setBeanFactory(BeanFactory beanFactory) { super.setBeanFactory(beanFactory); if (!(beanFactory instanceof ConfigurableListableBeanFactory)) { throw new IllegalStateException("Cannot use AdvisorAutoProxyCreator without a ConfigurableListableBeanFactory"); } initBeanFactory((ConfigurableListableBeanFactory) beanFactory); }
Example #27
Source Project: spring4-understanding Author: langtianya File: PostProcessorRegistrationDelegate.java License: Apache License 2.0 | 5 votes |
/** * Invoke the given BeanFactoryPostProcessor beans. */ private static void invokeBeanFactoryPostProcessors( Collection<? extends BeanFactoryPostProcessor> postProcessors, ConfigurableListableBeanFactory beanFactory) { for (BeanFactoryPostProcessor postProcessor : postProcessors) { postProcessor.postProcessBeanFactory(beanFactory); } }
Example #28
Source Project: olat Author: huihoo File: ExtensionsAdminController.java License: Apache License 2.0 | 5 votes |
/** * hmmm, does not work yet, how to get a list with all overwritten beans like the output from to the log.info * http://www.docjar.com/html/api/org/springframework/beans/factory/support/DefaultListableBeanFactory.java.html * * @return */ private List getOverwrittenBeans() { final ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(CoreSpringFactory.servletContext); final XmlWebApplicationContext context = (XmlWebApplicationContext) applicationContext; final ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); final String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames(); for (int i = 0; i < beanDefinitionNames.length; i++) { final String beanName = beanDefinitionNames[i]; if (!beanName.contains("#")) { final BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName); // System.out.println(beanDef.getOriginatingBeanDefinition()); } } return null; }
Example #29
Source Project: qconfig Author: qunarcorp File: QConfigAnnotationProcessor.java License: MIT License | 5 votes |
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { if (applicationContext instanceof ConfigurableApplicationContext) { ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory(); if (beanFactory != null) { filenameToPropsMap = loadQConfigFilesInAnnotation(beanFactory, beanClassLoader); } } }
Example #30
Source Project: attic-rave Author: apache File: OverridablePropertyPlaceholderConfigurer.java License: Apache License 2.0 | 5 votes |
@Override protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException { super.processProperties(beanFactoryToProcess, props); // load the application properties into a map that is exposed via public getter resolvedProps = new HashMap<String, String>(); for (Object key : props.keySet()) { String keyStr = key.toString(); resolvedProps.put(keyStr, resolvePlaceholder(keyStr, props, SYSTEM_PROPERTIES_MODE_OVERRIDE)); } }