Search in sources :

Example 1 with DefaultNamespaceHandlerResolver

use of org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver in project spring-framework by spring-projects.

the class DefaultNamespaceHandlerResolverTests method testResolvedMappedHandlerWithNoArgCtor.

@Test
public void testResolvedMappedHandlerWithNoArgCtor() {
    DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver();
    NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
    assertThat(handler).as("Handler should not be null.").isNotNull();
    assertThat(handler.getClass()).as("Incorrect handler loaded").isEqualTo(UtilNamespaceHandler.class);
}
Also used : NamespaceHandler(org.springframework.beans.factory.xml.NamespaceHandler) UtilNamespaceHandler(org.springframework.beans.factory.xml.UtilNamespaceHandler) DefaultNamespaceHandlerResolver(org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultNamespaceHandlerResolver

use of org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver in project spring-framework by spring-projects.

the class DefaultNamespaceHandlerResolverTests method testResolvedMappedHandler.

@Test
public void testResolvedMappedHandler() {
    DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(getClass().getClassLoader());
    NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
    assertThat(handler).as("Handler should not be null.").isNotNull();
    assertThat(handler.getClass()).as("Incorrect handler loaded").isEqualTo(UtilNamespaceHandler.class);
}
Also used : NamespaceHandler(org.springframework.beans.factory.xml.NamespaceHandler) UtilNamespaceHandler(org.springframework.beans.factory.xml.UtilNamespaceHandler) DefaultNamespaceHandlerResolver(org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver) Test(org.junit.jupiter.api.Test)

Example 3 with DefaultNamespaceHandlerResolver

use of org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver in project spring-framework by spring-projects.

the class TestNamespaceHandler method setUp.

@BeforeEach
public void setUp() throws Exception {
    NamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(CLASS.getClassLoader(), NS_PROPS);
    this.beanFactory = new GenericApplicationContext();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
    reader.setNamespaceHandlerResolver(resolver);
    reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
    reader.setEntityResolver(new DummySchemaResolver());
    reader.loadBeanDefinitions(getResource());
    this.beanFactory.refresh();
}
Also used : GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) NamespaceHandlerResolver(org.springframework.beans.factory.xml.NamespaceHandlerResolver) DefaultNamespaceHandlerResolver(org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver) XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) DefaultNamespaceHandlerResolver(org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with DefaultNamespaceHandlerResolver

use of org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver in project grails-core by grails.

the class BeanBuilder method initializeBeanBuilderForClassLoader.

protected void initializeBeanBuilderForClassLoader(ClassLoader classLoader) {
    xmlBeanDefinitionReader.setBeanClassLoader(classLoader);
    namespaceHandlerResolver = new DefaultNamespaceHandlerResolver(this.classLoader);
    readerContext = new XmlReaderContext(beanBuildResource, new FailFastProblemReporter(), new EmptyReaderEventListener(), new NullSourceExtractor(), xmlBeanDefinitionReader, namespaceHandlerResolver);
}
Also used : EmptyReaderEventListener(org.springframework.beans.factory.parsing.EmptyReaderEventListener) XmlReaderContext(org.springframework.beans.factory.xml.XmlReaderContext) DefaultNamespaceHandlerResolver(org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver) NullSourceExtractor(org.springframework.beans.factory.parsing.NullSourceExtractor) FailFastProblemReporter(org.springframework.beans.factory.parsing.FailFastProblemReporter)

Example 5 with DefaultNamespaceHandlerResolver

use of org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver in project cxf by apache.

the class BusApplicationContext method initBeanDefinitionReader.

@Override
protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
    // spring context on the classpath
    if (nsHandlerResolver == null) {
        nsHandlerResolver = new DefaultNamespaceHandlerResolver();
    }
    reader.setNamespaceHandlerResolver(nsHandlerResolver);
    String mode = getSpringValidationMode();
    if (null != mode) {
        reader.setValidationModeName(mode);
    }
    reader.setNamespaceAware(true);
    setEntityResolvers(reader);
}
Also used : DefaultNamespaceHandlerResolver(org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver)

Aggregations

DefaultNamespaceHandlerResolver (org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver)5 Test (org.junit.jupiter.api.Test)2 NamespaceHandler (org.springframework.beans.factory.xml.NamespaceHandler)2 UtilNamespaceHandler (org.springframework.beans.factory.xml.UtilNamespaceHandler)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1 EmptyReaderEventListener (org.springframework.beans.factory.parsing.EmptyReaderEventListener)1 FailFastProblemReporter (org.springframework.beans.factory.parsing.FailFastProblemReporter)1 NullSourceExtractor (org.springframework.beans.factory.parsing.NullSourceExtractor)1 NamespaceHandlerResolver (org.springframework.beans.factory.xml.NamespaceHandlerResolver)1 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)1 XmlReaderContext (org.springframework.beans.factory.xml.XmlReaderContext)1 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)1