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


Java XmlBeanDefinitionReader类代码示例

本文整理汇总了Java中org.springframework.beans.factory.xml.XmlBeanDefinitionReader的典型用法代码示例。如果您正苦于以下问题:Java XmlBeanDefinitionReader类的具体用法?Java XmlBeanDefinitionReader怎么用?Java XmlBeanDefinitionReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XmlBeanDefinitionReader类属于org.springframework.beans.factory.xml包,在下文中一共展示了XmlBeanDefinitionReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

	final ProtectionDomain empty = new ProtectionDomain(null,
			new Permissions());

	provider = new SecurityContextProvider() {
		private final AccessControlContext acc = new AccessControlContext(
				new ProtectionDomain[] { empty });

		@Override
		public AccessControlContext getAccessControlContext() {
			return acc;
		}
	};

	DefaultResourceLoader drl = new DefaultResourceLoader();
	Resource config = drl
			.getResource("/org/springframework/beans/factory/support/security/callbacks.xml");
	beanFactory = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(config);
	beanFactory.setSecurityContextProvider(provider);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:CallbacksSecurityTests.java

示例2: setUp

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的package包/类
protected void setUp() throws Exception {

		BundleContext bundleContext = new MockBundleContext() {
			// service reference already registered
			public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
				return new ServiceReference[0];
			}
		};

		appContext = new GenericApplicationContext();
		appContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
		appContext.setClassLoader(getClass().getClassLoader());

		XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
		// reader.setEventListener(this.listener);
		reader.loadBeanDefinitions(new ClassPathResource("osgiReferenceNestedBeans.xml", getClass()));
		appContext.refresh();
	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:19,代码来源:NestedReferencesTest.java

示例3: setUp

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的package包/类
protected void setUp() throws Exception {
	BundleContext bundleContext = new MockBundleContext() {
		// service reference already registered
		public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
			return new ServiceReference[] { new MockServiceReference(new String[] { Serializable.class.getName() }) };
		}
	};

	appContext = new GenericApplicationContext();
	appContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
	appContext.setClassLoader(getClass().getClassLoader());

	XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
	reader.loadBeanDefinitions(new ClassPathResource("osgiDefaults.xml", getClass()));
	appContext.refresh();
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:17,代码来源:OsgiDefaultsTests.java

示例4: setUp

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的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

示例5: setUp

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的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

示例6: setUp

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的package包/类
protected void setUp() throws Exception {
	BundleContext bundleContext = new MockBundleContext() {

		// service reference already registered
		public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
			return new ServiceReference[] { new MockServiceReference(new String[] { Cloneable.class.getName() }) };
		}
	};

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

	reader = new XmlBeanDefinitionReader(context);
	reader.loadBeanDefinitions(new ClassPathResource(CONFIG, getClass()));
	context.refresh();
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:SpringDmRfc124Test.java

示例7: setUp

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的package包/类
protected void setUp() throws Exception {
	bundleContext = new MockBundleContext();

	context = new GenericApplicationContext();
	context.setClassLoader(getClass().getClassLoader());
	context.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
	SpringBlueprintConverterService converterService =
			new SpringBlueprintConverterService(null, context.getBeanFactory());
	converterService.add(new GenericConverter());
	context.getBeanFactory().setConversionService(converterService);

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

	blueprintContainer = new SpringBlueprintContainer(context);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:19,代码来源:GenericsTest.java

示例8: setUp

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的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

示例9: setUp

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的package包/类
protected void setUp() throws Exception {
	bundleContext = new MockBundleContext();

	context = new GenericApplicationContext();
	context.setClassLoader(getClass().getClassLoader());
	context.getBeanFactory().setConversionService(
			new SpringBlueprintConverterService(null, context.getBeanFactory()));
	context.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));

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

	blueprintContainer = new SpringBlueprintContainer(context);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:17,代码来源:TestBlueprintBuiltinConvertersTest.java

示例10: loadBeanDefinitions

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的package包/类
/**
 * Loads the bean definitions via an XmlBeanDefinitionReader.
 * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
 * @see #initBeanDefinitionReader
 * @see #loadBeanDefinitions
 */
@Override
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException {
	// Create a new XmlBeanDefinitionReader for the given BeanFactory.
	XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);

	// Configure the bean definition reader with this context's
	// resource loading environment.
	beanDefinitionReader.setEnvironment(getEnvironment());
	beanDefinitionReader.setResourceLoader(this);
	beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));

	// Allow a subclass to provide custom initialization of the reader,
	// then proceed with actually loading the bean definitions.
	initBeanDefinitionReader(beanDefinitionReader);
	loadBeanDefinitions(beanDefinitionReader);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:XmlWebApplicationContext.java

示例11: loadBeanDefinitions

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的package包/类
/**
 * Loads the bean definitions via an XmlBeanDefinitionReader.
 * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
 * @see #initBeanDefinitionReader
 * @see #loadBeanDefinitions
 */
@Override
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException {
	// Create a new XmlBeanDefinitionReader for the given BeanFactory.
	XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);

	// Configure the bean definition reader with this context's
	// resource loading environment.
	beanDefinitionReader.setEnvironment(this.getEnvironment());
	beanDefinitionReader.setResourceLoader(this);
	beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));

	// Allow a subclass to provide custom initialization of the reader,
	// then proceed with actually loading the bean definitions.
	initBeanDefinitionReader(beanDefinitionReader);
	loadBeanDefinitions(beanDefinitionReader);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:AbstractXmlApplicationContext.java

示例12: testSinglePattern

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的package包/类
@Test
public void testSinglePattern() throws Throwable {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
	ITestBean advised = (ITestBean) bf.getBean("settersAdvised");
	// Interceptor behind regexp advisor
	NopInterceptor nop = (NopInterceptor) bf.getBean("nopInterceptor");
	assertEquals(0, nop.getCount());

	int newAge = 12;
	// Not advised
	advised.exceptional(null);
	assertEquals(0, nop.getCount());
	advised.setAge(newAge);
	assertEquals(newAge, advised.getAge());
	// Only setter fired
	assertEquals(1, nop.getCount());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:RegexpMethodPointcutAdvisorIntegrationTests.java

示例13: testMultiplePatterns

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的package包/类
@Test
public void testMultiplePatterns() throws Throwable {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
	// This is a CGLIB proxy, so we can proxy it to the target class
	TestBean advised = (TestBean) bf.getBean("settersAndAbsquatulateAdvised");
	// Interceptor behind regexp advisor
	NopInterceptor nop = (NopInterceptor) bf.getBean("nopInterceptor");
	assertEquals(0, nop.getCount());

	int newAge = 12;
	// Not advised
	advised.exceptional(null);
	assertEquals(0, nop.getCount());

	// This is proxied
	advised.absquatulate();
	assertEquals(1, nop.getCount());
	advised.setAge(newAge);
	assertEquals(newAge, advised.getAge());
	// Only setter fired
	assertEquals(2, nop.getCount());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:RegexpMethodPointcutAdvisorIntegrationTests.java

示例14: testPropertyPathFactoryBeanWithPrototypeResult

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的package包/类
@Test
public void testPropertyPathFactoryBeanWithPrototypeResult() {
	DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONTEXT);
	assertNull(xbf.getType("tb.spouse"));
	assertEquals(TestBean.class, xbf.getType("propertyPath3"));
	Object result1 = xbf.getBean("tb.spouse");
	Object result2 = xbf.getBean("propertyPath3");
	Object result3 = xbf.getBean("propertyPath3");
	assertTrue(result1 instanceof TestBean);
	assertTrue(result2 instanceof TestBean);
	assertTrue(result3 instanceof TestBean);
	assertEquals(11, ((TestBean) result1).getAge());
	assertEquals(11, ((TestBean) result2).getAge());
	assertEquals(11, ((TestBean) result3).getAge());
	assertTrue(result1 != result2);
	assertTrue(result1 != result3);
	assertTrue(result2 != result3);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:PropertyPathFactoryBeanTests.java

示例15: main

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
        ClassPathResource classPathResource = new ClassPathResource("beans.xml");
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);

        reader.loadBeanDefinitions(classPathResource);

        Person person = factory.getBean("person",Person.class);
        System.out.println(person.getHand());

        System.out.println(person.getName());
        System.out.println(classPathResource.getURL());
        System.out.println(classPathResource.getFile().getAbsolutePath());

        String fileUrl = classPathResource.getFile().getAbsolutePath();
        ApplicationContext context = new FileSystemXmlApplicationContext("/Users/fahai/soft/project/meta/src/main/resources/beans.xml");
        Person person1 = (Person) factory.getBean("person");
//        System.out.println(person1.getName());
//        DefaultListableBeanFactory


    }
 
开发者ID:programTang,项目名称:meta,代码行数:23,代码来源:TestDefaultListableBeanFactory.java


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