当前位置: 首页>>代码示例>>Java>>正文


Java InitDestroyAnnotationBeanPostProcessor.setInitAnnotationType方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.setInitAnnotationType方法的典型用法代码示例。如果您正苦于以下问题:Java InitDestroyAnnotationBeanPostProcessor.setInitAnnotationType方法的具体用法?Java InitDestroyAnnotationBeanPostProcessor.setInitAnnotationType怎么用?Java InitDestroyAnnotationBeanPostProcessor.setInitAnnotationType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor的用法示例。


在下文中一共展示了InitDestroyAnnotationBeanPostProcessor.setInitAnnotationType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPostConstructAndPreDestroyWithManualConfiguration

import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor; //导入方法依赖的package包/类
@Test
public void testPostConstructAndPreDestroyWithManualConfiguration() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	InitDestroyAnnotationBeanPostProcessor bpp = new InitDestroyAnnotationBeanPostProcessor();
	bpp.setInitAnnotationType(PostConstruct.class);
	bpp.setDestroyAnnotationType(PreDestroy.class);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(AnnotatedInitDestroyBean.class));

	AnnotatedInitDestroyBean bean = (AnnotatedInitDestroyBean) bf.getBean("annotatedBean");
	assertTrue(bean.initCalled);
	bf.destroySingletons();
	assertTrue(bean.destroyCalled);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:CommonAnnotationBeanPostProcessorTests.java

示例2: testSerializationWithManualConfiguration

import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor; //导入方法依赖的package包/类
@Test
public void testSerializationWithManualConfiguration() throws Exception {
	InitDestroyAnnotationBeanPostProcessor bpp = new InitDestroyAnnotationBeanPostProcessor();
	bpp.setInitAnnotationType(PostConstruct.class);
	bpp.setDestroyAnnotationType(PreDestroy.class);
	InitDestroyAnnotationBeanPostProcessor bpp2 = (InitDestroyAnnotationBeanPostProcessor)
			SerializationTestUtils.serializeAndDeserialize(bpp);

	AnnotatedInitDestroyBean bean = new AnnotatedInitDestroyBean();
	bpp2.postProcessBeforeDestruction(bean, "annotatedBean");
	assertTrue(bean.destroyCalled);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:CommonAnnotationBeanPostProcessorTests.java

示例3: postProcessBeanFactory

import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor; //导入方法依赖的package包/类
@Override
public void postProcessBeanFactory(BundleContext context, ConfigurableListableBeanFactory factory) throws BeansException, InvalidSyntaxException, BundleException {
    // We need to set the beanfactory by hand. This MAY be a bug in spring-dm but I'm not sure yet
    LogEnabledBeanPostProcessor loggingProcessor = new LogEnabledBeanPostProcessor();
    loggingProcessor.setBeanFactory(factory);
    loggingProcessor.setLogProvider(logProvider);
    loggingProcessor.setOrder(0);
    factory.addBeanPostProcessor(loggingProcessor);
    
    OSGIResourceAnnotationBeanPostProcessor resourceProcessor = new OSGIResourceAnnotationBeanPostProcessor();
    resourceProcessor.setBeanClassLoader(factory.getBeanClassLoader());
    resourceProcessor.setBeanFactory(factory);
    resourceProcessor.setBundleContext(context);
    resourceProcessor.setTimeout(60 * 1000);
    factory.addBeanPostProcessor(resourceProcessor);
    
    OSGIPersistenceUnitAnnotationBeanPostProcessor persistenceProcessor = new OSGIPersistenceUnitAnnotationBeanPostProcessor();
    persistenceProcessor.setBeanClassLoader(factory.getBeanClassLoader());
    persistenceProcessor.setBeanFactory(factory);
    persistenceProcessor.setBundleContext(context);
    persistenceProcessor.setTimeout(60 * 1000);
    factory.addBeanPostProcessor(persistenceProcessor);
    
    ConfigurableBeanPostProcessor configurationProcessor = new ConfigurableBeanPostProcessor();
    configurationProcessor.setBeanFactory(factory);
    configurationProcessor.setConfigurationProvider(confProvider);
    configurationProcessor.setOrder(2);
    factory.addBeanPostProcessor(configurationProcessor);
    
    InitDestroyAnnotationBeanPostProcessor annotationProcessor = new InitDestroyAnnotationBeanPostProcessor();
    annotationProcessor.setInitAnnotationType(PostConstruct.class);
    annotationProcessor.setDestroyAnnotationType(PreDestroy.class);
    factory.addBeanPostProcessor(annotationProcessor);


}
 
开发者ID:twachan,项目名称:James,代码行数:37,代码来源:OsgiLifecycleBeanFactoryPostProcessor.java


注:本文中的org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.setInitAnnotationType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。