本文整理汇总了Java中org.springframework.beans.factory.xml.NamespaceHandler类的典型用法代码示例。如果您正苦于以下问题:Java NamespaceHandler类的具体用法?Java NamespaceHandler怎么用?Java NamespaceHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NamespaceHandler类属于org.springframework.beans.factory.xml包,在下文中一共展示了NamespaceHandler类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolve
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
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;
}
示例2: decorateIfRequired
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
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;
}
示例3: xmlns
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
/**
* 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);
}
}
}
示例4: xmlns
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
/**
* 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);
}
}
}
示例5: xmlns
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
/**
* 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);
}
}
}
示例6: resolve
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
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;
}
示例7: resolve
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
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);
}
}
示例8: testCanResolveNamespaceFromBundleAfterAddingPlugin
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
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);
}
示例9: testResolvedMappedHandler
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
@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());
}
示例10: testResolvedMappedHandlerWithNoArgCtor
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
@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());
}
示例11: resolve
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
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);
}
}
示例12: doResolve
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
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;
}
示例13: testCanResolveNamespaceFromBundleAfterAddingPlugin
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
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);
}
示例14: resolve
import org.springframework.beans.factory.xml.NamespaceHandler; //导入依赖的package包/类
@Override
public NamespaceHandler resolve(String namespaceUri) {
if ("http://camel.apache.org/schema/spring".equals(namespaceUri)) {
return camelHandler;
} else {
return delegate.resolve(namespaceUri);
}
}