Java 类org.springframework.beans.factory.xml.NamespaceHandler 实例源码

项目:gemini.blueprint    文件:DelegatedNamespaceHandlerResolver.java   
public NamespaceHandler resolve(String namespaceUri) {
    boolean trace = log.isTraceEnabled();

    for (Iterator<Map.Entry<NamespaceHandlerResolver, String>> iterator = resolvers.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<NamespaceHandlerResolver, String> entry = iterator.next();
        NamespaceHandlerResolver handlerResolver = entry.getKey();
        if (trace)
            log.trace("Trying to resolve namespace [" + namespaceUri + "] through resolver " + entry.getValue());
        NamespaceHandler handler = handlerResolver.resolve(namespaceUri);

        String resolvedMsg = (handler != null ? "" : "not ");
        if (trace)
            log.trace("Namespace [" + namespaceUri + "] was " + resolvedMsg + "resolved through handler resolver "
                    + entry.getValue());

        if (handler != null) {
            return handler;
        }

    }
    return null;
}
项目:gemini.blueprint    文件:ParsingUtils.java   
public static BeanDefinitionHolder decorateIfRequired(Node node, BeanDefinitionHolder originalDef,
        ParserContext parserContext) {

    String namespaceUri = node.getNamespaceURI();
    if (!parserContext.getDelegate().isDefaultNamespace(namespaceUri) && !isRFC124Namespace(namespaceUri)) {
        NamespaceHandler handler =
                parserContext.getReaderContext().getNamespaceHandlerResolver().resolve(namespaceUri);
        if (handler != null) {
            return handler.decorate(node, originalDef, new ParserContext(parserContext.getReaderContext(),
                    parserContext.getDelegate()));
        } else if (namespaceUri.startsWith("http://www.springframework.org/")) {
            parserContext.getReaderContext().error(
                    "Unable to locate Spring NamespaceHandler for XML schema namespace [" + namespaceUri + "]",
                    node);
        } else {
            // A custom namespace, not to be handled by Spring - maybe "xml:...".
        }
    }
    return originalDef;
}
项目:lams    文件:GroovyBeanDefinitionReader.java   
/**
 * Define a Spring namespace definition to use.
 * @param definition the namespace definition
 */
public void xmlns(Map<String, String> definition) {
    if (!definition.isEmpty()) {
        for (Map.Entry<String,String> entry : definition.entrySet()) {
            String namespace = entry.getKey();
            String uri = entry.getValue();
            if (uri == null) {
                throw new IllegalArgumentException("Namespace definition must supply a non-null URI");
            }
            NamespaceHandler namespaceHandler = this.xmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve(uri);
            if (namespaceHandler == null) {
                throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri,
                        new Location(new DescriptiveResource(("Groovy")))));
            }
            this.namespaces.put(namespace, uri);
        }
    }
}
项目:spring4-understanding    文件:GroovyBeanDefinitionReader.java   
/**
 * Define a Spring XML namespace definition to use.
 * @param definition the namespace definition
 */
public void xmlns(Map<String, String> definition) {
    if (!definition.isEmpty()) {
        for (Map.Entry<String,String> entry : definition.entrySet()) {
            String namespace = entry.getKey();
            String uri = entry.getValue();
            if (uri == null) {
                throw new IllegalArgumentException("Namespace definition must supply a non-null URI");
            }
            NamespaceHandler namespaceHandler = this.groovyDslXmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve(
                uri);
            if (namespaceHandler == null) {
                throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri,
                        new Location(new DescriptiveResource(("Groovy")))));
            }
            this.namespaces.put(namespace, uri);
        }
    }
}
项目:spring    文件:GroovyBeanDefinitionReader.java   
/**
 * Define a Spring XML namespace definition to use.
 * @param definition the namespace definition
 */
public void xmlns(Map<String, String> definition) {
    if (!definition.isEmpty()) {
        for (Map.Entry<String,String> entry : definition.entrySet()) {
            String namespace = entry.getKey();
            String uri = entry.getValue();
            if (uri == null) {
                throw new IllegalArgumentException("Namespace definition must supply a non-null URI");
            }
            NamespaceHandler namespaceHandler =
                    this.groovyDslXmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve(uri);
            if (namespaceHandler == null) {
                throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri,
                        new Location(new DescriptiveResource(("Groovy")))));
            }
            this.namespaces.put(namespace, uri);
        }
    }
}
项目:spring-osgi    文件:DelegatedNamespaceHandlerResolver.java   
public NamespaceHandler resolve(String namespaceUri) {
    boolean trace = log.isTraceEnabled();

    for (Iterator iterator = resolvers.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry entry = (Map.Entry) iterator.next();
        NamespaceHandlerResolver handlerResolver = (NamespaceHandlerResolver) entry.getKey();
        if (trace)
            log.trace("Trying to resolve namespace [" + namespaceUri + "] through resolver " + entry.getValue());
        NamespaceHandler handler = handlerResolver.resolve(namespaceUri);

        String resolvedMsg = (handler != null ? "" : "not ");
        if (trace)
            log.trace("Namespace [" + namespaceUri + "] was " + resolvedMsg + "resolved through handler resolver "
                    + entry.getValue());

        if (handler != null) {
            return handler;
        }

    }
    return null;
}
项目:gemini.blueprint    文件:NamespacePlugins.java   
public NamespaceHandler resolve(final String namespaceUri) {
    if (System.getSecurityManager() != null) {
        return AccessController.doPrivileged(new PrivilegedAction<NamespaceHandler>() {

            public NamespaceHandler run() {
                return doResolve(namespaceUri);
            }
        });

    } else {
        return doResolve(namespaceUri);
    }
}
项目:gemini.blueprint    文件:NamespacePluginsTest.java   
public void testCanResolveNamespaceFromBundleAfterAddingPlugin() throws IOException, SAXException {
    Bundle b = new MockBundle();
    this.namespacePlugins.addPlugin(b, false, true);
    NamespaceHandler handler = this.namespacePlugins.resolve("http://www.springframework.org/schema/testme");
    assertNotNull("should find handler", handler);
    assertTrue("should be TestHandler", handler instanceof TestHandler);
}
项目:spring4-understanding    文件:DefaultNamespaceHandlerResolverTests.java   
@Test
public void testResolvedMappedHandler() {
    DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(getClass().getClassLoader());
    NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
    assertNotNull("Handler should not be null.", handler);
    assertEquals("Incorrect handler loaded", UtilNamespaceHandler.class, handler.getClass());
}
项目:spring4-understanding    文件:DefaultNamespaceHandlerResolverTests.java   
@Test
public void testResolvedMappedHandlerWithNoArgCtor() {
    DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver();
    NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
    assertNotNull("Handler should not be null.", handler);
    assertEquals("Incorrect handler loaded", UtilNamespaceHandler.class, handler.getClass());
}
项目:class-guard    文件:DefaultNamespaceHandlerResolverTests.java   
@Test
public void testResolvedMappedHandler() {
    DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(getClass().getClassLoader());
    NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
    assertNotNull("Handler should not be null.", handler);
    assertEquals("Incorrect handler loaded", UtilNamespaceHandler.class, handler.getClass());
}
项目:class-guard    文件:DefaultNamespaceHandlerResolverTests.java   
@Test
public void testResolvedMappedHandlerWithNoArgCtor() {
    DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver();
    NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
    assertNotNull("Handler should not be null.", handler);
    assertEquals("Incorrect handler loaded", UtilNamespaceHandler.class, handler.getClass());
}
项目:spring-osgi    文件:NamespacePlugins.java   
public NamespaceHandler resolve(final String namespaceUri) {
    if (System.getSecurityManager() != null) {
        return (NamespaceHandler) AccessController.doPrivileged(new PrivilegedAction() {

            public Object run() {
                return doResolve(namespaceUri);
            }
        });

    }
    else {
        return doResolve(namespaceUri);
    }
}
项目:spring-osgi    文件:NamespacePlugins.java   
private NamespaceHandler doResolve(String namespaceUri) {
    boolean debug = log.isDebugEnabled();

    if (debug)
        log.debug("Trying to resolving namespace handler for " + namespaceUri);

    for (Iterator i = plugins.values().iterator(); i.hasNext();) {
        Plugin plugin = (Plugin) i.next();
        try {
            NamespaceHandler handler = plugin.resolve(namespaceUri);
            if (handler != null) {
                if (debug)
                    log.debug("Namespace handler for " + namespaceUri + " found inside "
                            + OsgiStringUtils.nullSafeNameAndSymName(plugin.getBundle()));

                return handler;
            }
        }
        catch (IllegalArgumentException ex) {
            if (debug)
                log.debug("Namespace handler for " + namespaceUri + " not found inside "
                        + OsgiStringUtils.nullSafeNameAndSymName(plugin.getBundle()));

        }
    }
    return null;
}
项目:spring-osgi    文件:NamespacePluginsTest.java   
public void testCanResolveNamespaceFromBundleAfterAddingPlugin() throws IOException, SAXException {
    Bundle b = new MockBundle();
    this.namespacePlugins.addHandler(b);
    NamespaceHandler handler = this.namespacePlugins.resolve("http://www.springframework.org/schema/testme");
    assertNotNull("should find handler", handler);
    assertTrue("should be TestHandler", handler instanceof TestHandler);
}
项目:wildfly-camel    文件:SpringCamelContextBootstrap.java   
@Override
public NamespaceHandler resolve(String namespaceUri) {
    if ("http://camel.apache.org/schema/spring".equals(namespaceUri)) {
        return camelHandler;
    } else {
        return delegate.resolve(namespaceUri);
    }
}
项目:gemini.blueprint    文件:NamespacePlugins.java   
public NamespaceHandler resolve(String namespaceUri) {
    return namespace.resolve(namespaceUri);
}
项目:spring-osgi    文件:NamespacePlugins.java   
public NamespaceHandler resolve(String namespaceUri) {
    return namespace.resolve(namespaceUri);
}