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


Java DefaultListableBeanFactory.setSerializationId方法代码示例

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


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

示例1: refreshBeanFactory

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
/**
 * This implementation performs an actual refresh of this context's underlying
 * bean factory, shutting down the previous bean factory (if any) and
 * initializing a fresh bean factory for the next phase of the context's lifecycle.
 */
@Override
protected final void refreshBeanFactory() throws BeansException {
	if (hasBeanFactory()) {
		destroyBeans();
		closeBeanFactory();
	}
	try {
		DefaultListableBeanFactory beanFactory = createBeanFactory();
		beanFactory.setSerializationId(getId());
		customizeBeanFactory(beanFactory);
		loadBeanDefinitions(beanFactory);
		synchronized (this.beanFactoryMonitor) {
			this.beanFactory = beanFactory;
		}
	}
	catch (IOException ex) {
		throw new ApplicationContextException("I/O error parsing bean definition source for " + getDisplayName(), ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:AbstractRefreshableApplicationContext.java

示例2: refreshBeanFactory

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
/**��ʵ��ִ�д������ĵĵײ�bean factory��ʵ��ˢ�¡�
 * �ر���ǰ��bean����������еĻ����ͳ�ʼ���������ĵ��������ڵ���һ�׶ε�����bean����
 * <p>
 * This implementation performs an actual refresh of this context's underlying
 * bean factory, shutting down the previous bean factory (if any) and
 * initializing a fresh bean factory for the next phase of the context's lifecycle.
 */
@Override
protected final void refreshBeanFactory() throws BeansException {
	if (hasBeanFactory()) {
		destroyBeans();
		closeBeanFactory();
	}
	try {
		DefaultListableBeanFactory beanFactory = createBeanFactory();
		beanFactory.setSerializationId(getId());
		customizeBeanFactory(beanFactory);
		loadBeanDefinitions(beanFactory);
		synchronized (this.beanFactoryMonitor) {
			this.beanFactory = beanFactory;
		}
	}
	catch (IOException ex) {
		throw new ApplicationContextException("I/O error parsing bean definition source for " + getDisplayName(), ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:AbstractRefreshableApplicationContext.java

示例3: testEntityManagerFactoryIsProxied

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testEntityManagerFactoryIsProxied() throws Exception {
	LocalContainerEntityManagerFactoryBean cefb = parseValidPersistenceUnit();
	EntityManagerFactory emf = cefb.getObject();
	assertSame("EntityManagerFactory reference must be cached after init", emf, cefb.getObject());

	assertNotSame("EMF must be proxied", mockEmf, emf);
	assertTrue(emf.equals(emf));

	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.setSerializationId("emf-bf");
	bf.registerSingleton("emf", cefb);
	cefb.setBeanFactory(bf);
	cefb.setBeanName("emf");
	assertNotNull(SerializationTestUtils.serializeAndDeserialize(emf));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:LocalContainerEntityManagerFactoryBeanTests.java

示例4: testObjectFactorySerialization

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testObjectFactorySerialization() throws Exception {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryInjectionBean.class));
	bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
	bf.setSerializationId("test");

	ObjectFactoryInjectionBean bean = (ObjectFactoryInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bean = (ObjectFactoryInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bf.destroySingletons();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:AutowiredAnnotationBeanPostProcessorTests.java

示例5: testObjectFactoryWithBeanField

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testObjectFactoryWithBeanField() throws Exception {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryFieldInjectionBean.class));
	bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
	bf.setSerializationId("test");

	ObjectFactoryFieldInjectionBean bean = (ObjectFactoryFieldInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bean = (ObjectFactoryFieldInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bf.destroySingletons();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:InjectAnnotationBeanPostProcessorTests.java

示例6: testObjectFactoryWithBeanMethod

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testObjectFactoryWithBeanMethod() throws Exception {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryMethodInjectionBean.class));
	bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
	bf.setSerializationId("test");

	ObjectFactoryMethodInjectionBean bean = (ObjectFactoryMethodInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bean = (ObjectFactoryMethodInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bf.destroySingletons();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:InjectAnnotationBeanPostProcessorTests.java

示例7: testObjectFactoryWithTypedListField

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testObjectFactoryWithTypedListField() throws Exception {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryListFieldInjectionBean.class));
	bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
	bf.setSerializationId("test");

	ObjectFactoryListFieldInjectionBean bean = (ObjectFactoryListFieldInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bean = (ObjectFactoryListFieldInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bf.destroySingletons();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:InjectAnnotationBeanPostProcessorTests.java

示例8: testObjectFactoryWithTypedListMethod

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testObjectFactoryWithTypedListMethod() throws Exception {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryListMethodInjectionBean.class));
	bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
	bf.setSerializationId("test");

	ObjectFactoryListMethodInjectionBean bean = (ObjectFactoryListMethodInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bean = (ObjectFactoryListMethodInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bf.destroySingletons();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:InjectAnnotationBeanPostProcessorTests.java

示例9: testObjectFactoryWithTypedMapField

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testObjectFactoryWithTypedMapField() throws Exception {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryMapFieldInjectionBean.class));
	bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
	bf.setSerializationId("test");

	ObjectFactoryMapFieldInjectionBean bean = (ObjectFactoryMapFieldInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bean = (ObjectFactoryMapFieldInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bf.destroySingletons();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:InjectAnnotationBeanPostProcessorTests.java

示例10: testObjectFactoryWithTypedMapMethod

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testObjectFactoryWithTypedMapMethod() throws Exception {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ObjectFactoryMapMethodInjectionBean.class));
	bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
	bf.setSerializationId("test");

	ObjectFactoryMapMethodInjectionBean bean = (ObjectFactoryMapMethodInjectionBean) bf.getBean("annotatedBean");
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bean = (ObjectFactoryMapMethodInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
	assertSame(bf.getBean("testBean"), bean.getTestBean());
	bf.destroySingletons();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:InjectAnnotationBeanPostProcessorTests.java

示例11: refreshBeanFactory

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
/**
 * This implementation performs an actual refresh of this context's underlying
 * bean factory, shutting down the previous bean factory (if any) and
 * initializing a fresh bean factory for the next phase of the context's lifecycle.
 */
@Override
protected final void refreshBeanFactory() throws BeansException {
	// 已经创建了BeanFactory, 先销毁并关闭该BeanFactory
	if (hasBeanFactory()) {
		destroyBeans();
		closeBeanFactory();
	}
	try {
		DefaultListableBeanFactory beanFactory = createBeanFactory(); // 创建BeanFactory
		beanFactory.setSerializationId(getId());
		customizeBeanFactory(beanFactory);
		loadBeanDefinitions(beanFactory); // 加载BeanDefinition
		synchronized (this.beanFactoryMonitor) {
			this.beanFactory = beanFactory;
		}
	}
	catch (IOException ex) {
		throw new ApplicationContextException("I/O error parsing bean definition source for " + getDisplayName(), ex);
	}
}
 
开发者ID:txazo,项目名称:spring,代码行数:26,代码来源:AbstractRefreshableApplicationContext.java

示例12: testJdkScopedProxy

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testJdkScopedProxy() throws Exception {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(bf).loadBeanDefinitions(TESTBEAN_CONTEXT);
	bf.setSerializationId("X");
	SimpleMapScope scope = new SimpleMapScope();
	bf.registerScope("request", scope);

	ITestBean bean = (ITestBean) bf.getBean("testBean");
	assertNotNull(bean);
	assertTrue(AopUtils.isJdkDynamicProxy(bean));
	assertTrue(bean instanceof ScopedObject);
	ScopedObject scoped = (ScopedObject) bean;
	assertEquals(TestBean.class, scoped.getTargetObject().getClass());
	bean.setAge(101);

	assertTrue(scope.getMap().containsKey("testBeanTarget"));
	assertEquals(TestBean.class, scope.getMap().get("testBeanTarget").getClass());

	ITestBean deserialized = (ITestBean) SerializationTestUtils.serializeAndDeserialize(bean);
	assertNotNull(deserialized);
	assertTrue(AopUtils.isJdkDynamicProxy(deserialized));
	assertEquals(101, bean.getAge());
	assertTrue(deserialized instanceof ScopedObject);
	ScopedObject scopedDeserialized = (ScopedObject) deserialized;
	assertEquals(TestBean.class, scopedDeserialized.getTargetObject().getClass());

	bf.setSerializationId(null);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:ScopedProxyTests.java

示例13: testCglibScopedProxy

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testCglibScopedProxy() throws Exception {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(bf).loadBeanDefinitions(LIST_CONTEXT);
	bf.setSerializationId("Y");
	SimpleMapScope scope = new SimpleMapScope();
	bf.registerScope("request", scope);

	TestBean tb = (TestBean) bf.getBean("testBean");
	assertTrue(AopUtils.isCglibProxy(tb.getFriends()));
	assertTrue(tb.getFriends() instanceof ScopedObject);
	ScopedObject scoped = (ScopedObject) tb.getFriends();
	assertEquals(ArrayList.class, scoped.getTargetObject().getClass());
	tb.getFriends().add("myFriend");

	assertTrue(scope.getMap().containsKey("scopedTarget.scopedList"));
	assertEquals(ArrayList.class, scope.getMap().get("scopedTarget.scopedList").getClass());

	ArrayList<?> deserialized = (ArrayList<?>) SerializationTestUtils.serializeAndDeserialize(tb.getFriends());
	assertNotNull(deserialized);
	assertTrue(AopUtils.isCglibProxy(deserialized));
	assertTrue(deserialized.contains("myFriend"));
	assertTrue(deserialized instanceof ScopedObject);
	ScopedObject scopedDeserialized = (ScopedObject) deserialized;
	assertEquals(ArrayList.class, scopedDeserialized.getTargetObject().getClass());

	bf.setSerializationId(null);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:ScopedProxyTests.java


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