本文整理匯總了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);
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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
}