org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor Java Examples

The following examples show how to use org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor. 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 File: AnnotationConditionalOnPropertyBootstrap.java    From thinking-in-spring-boot-samples with Apache License 2.0 6 votes vote down vote up
@Bean
public BeanDefinitionRegistryPostProcessor postProcessor(ConfigurableEnvironment environment) {
    return new BeanDefinitionRegistryPostProcessor() {
        @Override
        public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
            MutablePropertySources propertySources = environment.getPropertySources();
            Map<String, Object> source = new HashMap<>();
            source.put("enabled", "true");
            propertySources.addFirst(new MapPropertySource("for @ConditionalOnProperty", source));
        }

        @Override
        public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        }
    };
}
 
Example #2
Source File: SingletonTests.java    From spring-cloud-function with Apache License 2.0 6 votes vote down vote up
@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 #3
Source File: SingletonTests.java    From spring-cloud-function with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: PostProcessorRegistrationDelegate.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Invoke the given BeanDefinitionRegistryPostProcessor beans.
 */
private static void invokeBeanDefinitionRegistryPostProcessors(
		Collection<? extends BeanDefinitionRegistryPostProcessor> postProcessors, BeanDefinitionRegistry registry) {

	for (BeanDefinitionRegistryPostProcessor postProcessor : postProcessors) {
		postProcessor.postProcessBeanDefinitionRegistry(registry);
	}
}
 
Example #5
Source File: ConfigurationClassPostProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Bean
public static BeanDefinitionRegistryPostProcessor bdrpp() {
	return new BeanDefinitionRegistryPostProcessor() {
		@Override
		public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
			registry.registerBeanDefinition("myTestBean", new RootBeanDefinition(TestBean.class));
		}
		@Override
		public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
		}
	};
}
 
Example #6
Source File: PostProcessorRegistrationDelegate.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Invoke the given BeanDefinitionRegistryPostProcessor beans.
 */
private static void invokeBeanDefinitionRegistryPostProcessors(
		Collection<? extends BeanDefinitionRegistryPostProcessor> postProcessors, BeanDefinitionRegistry registry) {

	for (BeanDefinitionRegistryPostProcessor postProcessor : postProcessors) {
		postProcessor.postProcessBeanDefinitionRegistry(registry);
	}
}
 
Example #7
Source File: ConfigurationClassPostProcessorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Bean
public static BeanDefinitionRegistryPostProcessor bdrpp() {
	return new BeanDefinitionRegistryPostProcessor() {
		@Override
		public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
			registry.registerBeanDefinition("myTestBean", new RootBeanDefinition(TestBean.class));
		}
		@Override
		public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
		}
	};
}
 
Example #8
Source File: PostProcessorRegistrationDelegate.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invoke the given BeanDefinitionRegistryPostProcessor beans.
 */
private static void invokeBeanDefinitionRegistryPostProcessors(
		Collection<? extends BeanDefinitionRegistryPostProcessor> postProcessors, BeanDefinitionRegistry registry) {

	for (BeanDefinitionRegistryPostProcessor postProcessor : postProcessors) {
		postProcessor.postProcessBeanDefinitionRegistry(registry);
	}
}
 
Example #9
Source File: PostProcessorRegistrationDelegate.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Invoke the given BeanDefinitionRegistryPostProcessor beans.
 */
private static void invokeBeanDefinitionRegistryPostProcessors(
		Collection<? extends BeanDefinitionRegistryPostProcessor> postProcessors, BeanDefinitionRegistry registry) {

	for (BeanDefinitionRegistryPostProcessor postProcessor : postProcessors) {
		postProcessor.postProcessBeanDefinitionRegistry(registry);
	}
}
 
Example #10
Source File: FilterCleanupConfig.java    From spring-boot-security-saml-samples with MIT License 5 votes vote down vote up
@Bean
public static BeanDefinitionRegistryPostProcessor removeUnwantedAutomaticFilterRegistration() {
    return new BeanDefinitionRegistryPostProcessor() {
        @Override
        public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
        }

        @Override
        public void postProcessBeanFactory(ConfigurableListableBeanFactory bf) throws BeansException {
            DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) bf;
            Set<String> filtersToDisable = ImmutableSet.of("samlEntryPoint", "samlFilter", "samlIDPDiscovery", "metadataDisplayFilter",
                    "samlWebSSOHoKProcessingFilter", "samlWebSSOProcessingFilter",
                    "samlLogoutProcessingFilter", "samlLogoutFilter", "metadataGeneratorFilter");
            Arrays.stream(beanFactory.getBeanNamesForType(javax.servlet.Filter.class))
                    .filter(filtersToDisable::contains)
                    .forEach(name -> {
                        BeanDefinition definition = BeanDefinitionBuilder
                                .genericBeanDefinition(FilterRegistrationBean.class)
                                .setScope(BeanDefinition.SCOPE_SINGLETON)
                                .addConstructorArgReference(name)
                                .addConstructorArgValue(new ServletRegistrationBean[]{})
                                .addPropertyValue("enabled", false)
                                .getBeanDefinition();
                        beanFactory.registerBeanDefinition(name + "FilterRegistrationBean", definition);
                    });
        }
    };
}
 
Example #11
Source File: VelocityToolsAutoConfiguration.java    From velocity-spring-boot-project with Apache License 2.0 4 votes vote down vote up
@Bean
public BeanDefinitionRegistryPostProcessor velocityToolsBeanDefinitionRegistryPostProcessor(
        VelocityToolsRepository velocityToolsRepository) {
    return new VelocityToolsBeanDefinitionRegistryPostProcessor(velocityToolsRepository);
}