本文整理汇总了Java中org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor类的典型用法代码示例。如果您正苦于以下问题:Java InitDestroyAnnotationBeanPostProcessor类的具体用法?Java InitDestroyAnnotationBeanPostProcessor怎么用?Java InitDestroyAnnotationBeanPostProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InitDestroyAnnotationBeanPostProcessor类属于org.springframework.beans.factory.annotation包,在下文中一共展示了InitDestroyAnnotationBeanPostProcessor类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例4: reset
import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor; //导入依赖的package包/类
/**
* Reset all post processors associated with a bean factory.
*
* @param beanFactory beanFactory to use
*/
public static void reset(DefaultListableBeanFactory beanFactory) {
Class<?> c = getReflectionUtilsClassOrNull();
if (c != null) {
try {
Method m = c.getDeclaredMethod("clearCache");
m.invoke(c);
} catch (Exception version42Failed) {
try {
// spring 4.0.x, 4.1.x without clearCache method, clear manually
Field declaredMethodsCache = c.getDeclaredField("declaredMethodsCache");
declaredMethodsCache.setAccessible(true);
((Map)declaredMethodsCache.get(null)).clear();
Field declaredFieldsCache = c.getDeclaredField("declaredFieldsCache");
declaredFieldsCache.setAccessible(true);
((Map)declaredFieldsCache.get(null)).clear();
} catch (Exception version40Failed) {
LOGGER.debug("Failed to clear internal method/field cache, it's normal with spring 4.1x or lower", version40Failed);
}
}
LOGGER.trace("Cleared Spring 4.2+ internal method/field cache.");
}
for (BeanPostProcessor bpp : beanFactory.getBeanPostProcessors()) {
if (bpp instanceof AutowiredAnnotationBeanPostProcessor) {
resetAutowiredAnnotationBeanPostProcessorCache((AutowiredAnnotationBeanPostProcessor)bpp);
} else if (bpp instanceof InitDestroyAnnotationBeanPostProcessor) {
resetInitDestroyAnnotationBeanPostProcessorCache((InitDestroyAnnotationBeanPostProcessor)bpp);
}
}
}
开发者ID:HotswapProjects,项目名称:HotswapAgent,代码行数:37,代码来源:ResetBeanPostProcessorCaches.java
示例5: resetInitDestroyAnnotationBeanPostProcessorCache
import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor; //导入依赖的package包/类
public static void resetInitDestroyAnnotationBeanPostProcessorCache(InitDestroyAnnotationBeanPostProcessor bpp) {
try {
Field field = InitDestroyAnnotationBeanPostProcessor.class.getDeclaredField("lifecycleMetadataCache");
field.setAccessible(true);
Map lifecycleMetadataCache = (Map) field.get(bpp);
lifecycleMetadataCache.clear();
LOGGER.trace("Cache cleared: InitDestroyAnnotationBeanPostProcessor.lifecycleMetadataCache");
} catch (Exception e) {
throw new IllegalStateException("Unable to clear InitDestroyAnnotationBeanPostProcessor.lifecycleMetadataCache", e);
}
}
开发者ID:HotswapProjects,项目名称:HotswapAgent,代码行数:12,代码来源:ResetBeanPostProcessorCaches.java
注:本文中的org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论