當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。