當前位置: 首頁>>代碼示例>>Java>>正文


Java BeanFactoryPostProcessor類代碼示例

本文整理匯總了Java中org.springframework.beans.factory.config.BeanFactoryPostProcessor的典型用法代碼示例。如果您正苦於以下問題:Java BeanFactoryPostProcessor類的具體用法?Java BeanFactoryPostProcessor怎麽用?Java BeanFactoryPostProcessor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BeanFactoryPostProcessor類屬於org.springframework.beans.factory.config包,在下文中一共展示了BeanFactoryPostProcessor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
protected void setUp() throws Exception {
	bundleContext = new MockBundleContext();
	applicationContext = new GenericApplicationContext();
	applicationContext.setClassLoader(getClass().getClassLoader());
	applicationContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
	applicationContext.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {

		public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
			beanFactory.addPropertyEditorRegistrar(new BlueprintEditorRegistrar());
		}
	});
	reader = new XmlBeanDefinitionReader(applicationContext);
	reader.setDocumentLoader(new PublicBlueprintDocumentLoader());
	reader.loadBeanDefinitions(new ClassPathResource(getConfig(), getClass()));
	applicationContext.refresh();
	blueprintContainer = new SpringBlueprintContainer(applicationContext);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:18,代碼來源:BaseMetadataTest.java

示例2: setUp

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
protected void setUp() throws Exception {
	bundleContext = new MockBundleContext();

	context = new GenericApplicationContext();
	context.setClassLoader(getClass().getClassLoader());
	context.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
	context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {

		public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
			beanFactory.addPropertyEditorRegistrar(new BlueprintEditorRegistrar());
		}
	});

	reader = new XmlBeanDefinitionReader(context);
	reader.setDocumentLoader(new PublicBlueprintDocumentLoader());
	reader.loadBeanDefinitions(new ClassPathResource(CONFIG, getClass()));
	context.refresh();

	blueprintContainer = new SpringBlueprintContainer(context);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:21,代碼來源:NestedDefinitionMetadataTest.java

示例3: setUp

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
protected void setUp() throws Exception {
	bundleContext = new MockBundleContext();

	context = new GenericApplicationContext();
	context.setClassLoader(getClass().getClassLoader());
	context.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
	context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {

		public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
			beanFactory.addPropertyEditorRegistrar(new BlueprintEditorRegistrar());
			beanFactory.registerSingleton("blueprintContainer",
					new SpringBlueprintContainer(context));
		}
	});

	reader = new XmlBeanDefinitionReader(context);
	reader.setDocumentLoader(new PublicBlueprintDocumentLoader());
	reader.loadBeanDefinitions(new ClassPathResource(CONFIG, getClass()));
	context.refresh();

	blueprintContainer = new SpringBlueprintContainer(context);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:23,代碼來源:TestLazyBeansTest.java

示例4: beanFactoryPostProcessor

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
@Bean
public BeanFactoryPostProcessor beanFactoryPostProcessor(ApplicationContext applicationContext) {
    return new BeanFactoryPostProcessor() {

        @Override
        public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
            if (beanFactory instanceof BeanDefinitionRegistry) {
                try {
                    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
                    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(registry);
                    scanner.setResourceLoader(applicationContext);
                    scanner.scan("com.quancheng.saluki.boot.web");
                } catch (Throwable e) {
                    log.error(e.getMessage(), e);
                }
            }

        }

    };
}
 
開發者ID:venus-boot,項目名稱:saluki,代碼行數:22,代碼來源:MonitorAutoconfiguration.java

示例5: buildAppContext

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
public static ApplicationContext buildAppContext(ApplicationContext parent, Stream<TestBean> beans, Collection<BeanFactoryPostProcessor> postProcessors) {
	final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
	final GenericApplicationContext applicationContext = new GenericApplicationContext(beanFactory, parent);

	postProcessors.forEach(applicationContext::addBeanFactoryPostProcessor);

	beans.forEach(entry -> {
		final String factoryBean = entry.getName() + "_factory";
		beanFactory.registerSingleton(factoryBean, (Supplier<Object>) entry::getBean);
		beanFactory.registerBeanDefinition(entry.getName(), BeanDefinitionBuilder
				.rootBeanDefinition(entry.getBean() != null ? entry.getBean().getClass() : Object.class)
				.setFactoryMethodOnBean("get", factoryBean)
				.getBeanDefinition());
	});

	applicationContext.refresh();

	return applicationContext;
}
 
開發者ID:pchudzik,項目名稱:springmock,代碼行數:20,代碼來源:ApplicationContextCreator.java

示例6: testFactoryBeansWithAutowiring

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
@Test
public void testFactoryBeansWithAutowiring() throws Exception {
	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(factory).loadBeanDefinitions(WITH_AUTOWIRING_CONTEXT);

	BeanFactoryPostProcessor ppc = (BeanFactoryPostProcessor) factory.getBean("propertyPlaceholderConfigurer");
	ppc.postProcessBeanFactory(factory);

	assertNull(factory.getType("betaFactory"));

	Alpha alpha = (Alpha) factory.getBean("alpha");
	Beta beta = (Beta) factory.getBean("beta");
	Gamma gamma = (Gamma) factory.getBean("gamma");
	Gamma gamma2 = (Gamma) factory.getBean("gammaFactory");

	assertSame(beta, alpha.getBeta());
	assertSame(gamma, beta.getGamma());
	assertSame(gamma2, beta.getGamma());
	assertEquals("yourName", beta.getName());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:21,代碼來源:FactoryBeanTests.java

示例7: applicationContext

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
protected WebApplicationContext applicationContext() {
    if (applicationContext == null) {
        AnnotationConfigWebApplicationContext webApplicationContext = new AnnotationConfigWebApplicationContext();

        Set<Class<?>> annotatedClasses = annotatedClasses();
        if (annotatedClasses != null) {
            annotatedClasses.iterator().forEachRemaining(webApplicationContext::register);
        }

        Set<? extends BeanFactoryPostProcessor> beanFactoryPostProcessors = beanFactoryPostProcessors();
        if (beanFactoryPostProcessors != null) {
            beanFactoryPostProcessors.iterator().forEachRemaining(webApplicationContext::addBeanFactoryPostProcessor);
        }

        if (this.rootApplicationContext != null) {
            webApplicationContext.setParent(this.rootApplicationContext);
            webApplicationContext.setEnvironment((ConfigurableEnvironment) rootApplicationContext.getEnvironment());
        }

        applicationContext = webApplicationContext;
    }

    return (WebApplicationContext) applicationContext;
}
 
開發者ID:gravitee-io,項目名稱:graviteeio-access-management,代碼行數:25,代碼來源:SpringServletContext.java

示例8: jsfScopeAnnotationsConfigurer

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
@Bean
@ConditionalOnProperty(value = "jsf.scope-configurer.jsf.enabled", havingValue = "true", matchIfMissing = true)
public static BeanFactoryPostProcessor jsfScopeAnnotationsConfigurer(Environment environment) {
	CustomScopeAnnotationConfigurer scopeAnnotationConfigurer = new CustomScopeAnnotationConfigurer();

	scopeAnnotationConfigurer.setOrder(environment.getProperty("jsf.scope-configurer.jsf.order", Integer.class, Ordered.LOWEST_PRECEDENCE));

	scopeAnnotationConfigurer.addMapping(NoneScoped.class, ConfigurableBeanFactory.SCOPE_PROTOTYPE);
	scopeAnnotationConfigurer.addMapping(RequestScoped.class, WebApplicationContext.SCOPE_REQUEST);
	scopeAnnotationConfigurer.addMapping(javax.faces.bean.ViewScoped.class, ViewScope.SCOPE_VIEW);
	scopeAnnotationConfigurer.addMapping(javax.faces.view.ViewScoped.class, ViewScope.SCOPE_VIEW);
	scopeAnnotationConfigurer.addMapping(SessionScoped.class, WebApplicationContext.SCOPE_SESSION);
	scopeAnnotationConfigurer.addMapping(ApplicationScoped.class, WebApplicationContext.SCOPE_APPLICATION);

	return scopeAnnotationConfigurer;
}
 
開發者ID:joinfaces,項目名稱:joinfaces,代碼行數:17,代碼來源:JsfScopeAnnotationsAutoConfiguration.java

示例9: testServletContextListener

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
private void testServletContextListener(ServletContext servletContext) throws Exception {
    ResteasyAutoConfiguration resteasyAutoConfiguration = new ResteasyAutoConfiguration();
    BeanFactoryPostProcessor beanFactoryPostProcessor = ResteasyAutoConfiguration.springBeanProcessor();
    ServletContextListener servletContextListener = resteasyAutoConfiguration.resteasyBootstrapListener(beanFactoryPostProcessor);
    Assert.assertNotNull(servletContextListener);

    ServletContextEvent sce = new ServletContextEvent(servletContext);
    servletContextListener.contextInitialized(sce);

    ResteasyProviderFactory servletContextProviderFactory = (ResteasyProviderFactory) servletContext.getAttribute(ResteasyProviderFactory.class.getName());
    Dispatcher servletContextDispatcher = (Dispatcher) servletContext.getAttribute(Dispatcher.class.getName());
    Registry servletContextRegistry = (Registry) servletContext.getAttribute(Registry.class.getName());

    Assert.assertNotNull(servletContextProviderFactory);
    Assert.assertNotNull(servletContextDispatcher);
    Assert.assertNotNull(servletContextRegistry);

    // Exercising fully cobertura branch coverage
    servletContextListener.contextDestroyed(sce);
    ServletContextListener servletContextListener2 = resteasyAutoConfiguration.resteasyBootstrapListener(beanFactoryPostProcessor);
    servletContextListener2.contextDestroyed(sce);
}
 
開發者ID:paypal,項目名稱:resteasy-spring-boot,代碼行數:23,代碼來源:ResteasyAutoConfigurationTest.java

示例10: testFactoryBeansWithAutowiring

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
@Test
public void testFactoryBeansWithAutowiring() throws Exception {
	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(factory).loadBeanDefinitions(WITH_AUTOWIRING_CONTEXT);

	BeanFactoryPostProcessor ppc = (BeanFactoryPostProcessor) factory.getBean("propertyPlaceholderConfigurer");
	ppc.postProcessBeanFactory(factory);

	Alpha alpha = (Alpha) factory.getBean("alpha");
	Beta beta = (Beta) factory.getBean("beta");
	Gamma gamma = (Gamma) factory.getBean("gamma");
	Gamma gamma2 = (Gamma) factory.getBean("gammaFactory");
	assertSame(beta, alpha.getBeta());
	assertSame(gamma, beta.getGamma());
	assertSame(gamma2, beta.getGamma());
	assertEquals("yourName", beta.getName());
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:18,代碼來源:FactoryBeanTests.java

示例11: parseInternal_singleElementDefined_beanDefinitionCreated

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
@Test
public void parseInternal_singleElementDefined_beanDefinitionCreated() throws Exception {
    //Arrange
    HttpServer httpServer = MetaDataServer.setupHttpServer();
    HttpContext instanceIdHttpContext = httpServer.createContext("/latest/meta-data/instance-id", new MetaDataServer.HttpResponseWriterHandler("testInstanceId"));
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);

    //Act
    reader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass()));

    //Assert
    BeanFactoryPostProcessor postProcessor = beanFactory.getBean("AmazonEc2InstanceDataPropertySourcePostProcessor", BeanFactoryPostProcessor.class);
    assertNotNull(postProcessor);
    assertEquals(1, beanFactory.getBeanDefinitionCount());

    httpServer.removeContext(instanceIdHttpContext);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-aws,代碼行數:19,代碼來源:ContextInstanceDataPropertySourceBeanDefinitionParserTest.java

示例12: propertyOverrideConfigurer

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
/**
 * Overrides properties configured on beans.
 */
@Bean()
@Lazy(false)
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public static BeanFactoryPostProcessor propertyOverrideConfigurer() {
    PropertyOverrideConfigurer theOverrideConfigurer = new PropertyOverrideConfigurer();

    final Properties thePropertiesHolder = new Properties();
    /* Task refresh interval. */
    thePropertiesHolder.put("starterService.taskReschedulingCronExpression", "0/20 * * * * ?");
    /* Transport service configuration refresh interval. */
    thePropertiesHolder.put("starterService.transportServiceConfigurationRefreshCronExpression", "0/30 * * * * ?");
    /* Task execution status reports cleanup interval. */
    thePropertiesHolder.put("starterService.taskExecutionStatusCleanupCronExpression", "0/30 0/15 * * * ?");

    theOverrideConfigurer.setProperties(thePropertiesHolder);
    theOverrideConfigurer.setIgnoreInvalidKeys(false);
    theOverrideConfigurer.setIgnoreResourceNotFound(false);
    theOverrideConfigurer.setOrder(0);
    return theOverrideConfigurer;
}
 
開發者ID:krizsan,項目名稱:message-cowboy,代碼行數:24,代碼來源:ProductionPropertyOverrides.java

示例13: propertyOverrideConfigurer

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
/**
 * Overrides properties configured on beans.
 */
@Bean()
@Lazy(false)
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public static BeanFactoryPostProcessor propertyOverrideConfigurer() {
    PropertyOverrideConfigurer theOverrideConfigurer = new PropertyOverrideConfigurer();

    final Properties thePropertiesHolder = new Properties();
    /* Task refresh interval. */
    thePropertiesHolder.put("starterService.taskReschedulingCronExpression", "* 4/30 * * * ?");
    /* Transport service configuration refresh interval. */
    thePropertiesHolder.put("starterService.transportServiceConfigurationRefreshCronExpression", "* 5/30 * * * ?");
    /* Task execution status reports cleanup interval. */
    thePropertiesHolder.put("starterService.taskExecutionStatusCleanupCronExpression", "0/5 * * * * ?");

    theOverrideConfigurer.setProperties(thePropertiesHolder);
    theOverrideConfigurer.setIgnoreInvalidKeys(false);
    theOverrideConfigurer.setIgnoreResourceNotFound(false);
    theOverrideConfigurer.setOrder(0);
    return theOverrideConfigurer;
}
 
開發者ID:krizsan,項目名稱:message-cowboy,代碼行數:24,代碼來源:TaskExecutionStatusCleanupTestConfiguration.java

示例14: BlueprintContainerProcessor

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
public BlueprintContainerProcessor(EventAdminDispatcher dispatcher, BlueprintListenerManager listenerManager,
		Bundle extenderBundle) {
	this.dispatcher = dispatcher;
	this.listenerManager = listenerManager;
	this.extenderBundle = extenderBundle;

	Class<?> processorClass =
			ClassUtils.resolveClassName(
					"org.eclipse.gemini.blueprint.blueprint.container.support.internal.config.CycleOrderingProcessor",
					BundleContextAware.class.getClassLoader());

	cycleBreaker = (BeanFactoryPostProcessor) BeanUtils.instantiate(processorClass);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:14,代碼來源:BlueprintContainerProcessor.java

示例15: invokeBeanFactoryPostProcessors

import org.springframework.beans.factory.config.BeanFactoryPostProcessor; //導入依賴的package包/類
/**
 * Invoke the given BeanFactoryPostProcessor beans.
 */
private static void invokeBeanFactoryPostProcessors(
		Collection<? extends BeanFactoryPostProcessor> postProcessors, ConfigurableListableBeanFactory beanFactory) {

	for (BeanFactoryPostProcessor postProcessor : postProcessors) {
		postProcessor.postProcessBeanFactory(beanFactory);
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:11,代碼來源:AbstractDelegatedExecutionApplicationContext.java


注:本文中的org.springframework.beans.factory.config.BeanFactoryPostProcessor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。