Upgrade XQuery to SI 4.3.x
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.integration.version>2.2.0.RC2</spring.integration.version>
|
||||
<spring.integration.version>4.3.19.RELEASE</spring.integration.version>
|
||||
<junit.version>4.10</junit.version>
|
||||
</properties>
|
||||
|
||||
@@ -112,4 +112,4 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,11 +30,11 @@ import javax.xml.xquery.XQResultSequence;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.xml.DefaultXmlPayloadConverter;
|
||||
import org.springframework.integration.xml.XmlPayloadConverter;
|
||||
import org.springframework.integration.xquery.support.AbstractXQueryResultMapper;
|
||||
@@ -45,10 +45,11 @@ import org.springframework.integration.xquery.support.StringResultMapper;
|
||||
import org.springframework.integration.xquery.support.XQueryParameter;
|
||||
import org.springframework.integration.xquery.support.XQueryResultMapper;
|
||||
import org.springframework.integration.xquery.support.XQueryUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* The common logic for performing the common xquery operations would reside in this
|
||||
@@ -60,6 +61,7 @@ import org.w3c.dom.Node;
|
||||
* to a custom object type
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
@@ -170,6 +172,7 @@ public class XQueryExecutor implements InitializingBean,BeanClassLoaderAware {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
Assert.notNull(classLoader, "Non null class loader instance expected");
|
||||
this.classLoader = classLoader;
|
||||
@@ -364,7 +367,7 @@ public class XQueryExecutor implements InitializingBean,BeanClassLoaderAware {
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public <T> void setResultMappers(Map<Class<T>, XQueryResultMapper<T>> mappers) {
|
||||
Assert.notNull(mappers);
|
||||
Assert.notNull(mappers, "mappers cannot be null");
|
||||
this.resultMappers = new HashMap<Class<T>, XQueryResultMapper<T>>(mappers);
|
||||
//not iterate through them and set the format
|
||||
for(Object mapper:resultMappers.values()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,9 +18,9 @@ package org.springframework.integration.xquery.router;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.router.AbstractMappingMessageRouter;
|
||||
import org.springframework.integration.xquery.core.XQueryExecutor;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -28,6 +28,7 @@ import org.springframework.util.Assert;
|
||||
* to which the message will be routed
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
@@ -39,7 +40,7 @@ public class XQueryRouter extends AbstractMappingMessageRouter {
|
||||
private Class<?> resultType;
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
public void onInit() throws Exception {
|
||||
super.onInit();
|
||||
Assert.notNull(executor,"No XQueryExecutor instance provided");
|
||||
if(resultType == null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,19 +21,22 @@ import java.util.List;
|
||||
import javax.xml.xquery.XQItemType;
|
||||
import javax.xml.xquery.XQResultSequence;
|
||||
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.messaging.MessagingException;
|
||||
|
||||
/**
|
||||
* The Result mapper implementation that maps the {@link XQResultSequence} to {@link Boolean}
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class BooleanResultMapper extends AbstractXQueryResultMapper<Boolean> {
|
||||
|
||||
@Override
|
||||
public List<Boolean> mapResults(XQResultSequence result) {
|
||||
List<Boolean> results = new ArrayList<Boolean>();
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,19 +21,22 @@ import java.util.List;
|
||||
import javax.xml.xquery.XQItemType;
|
||||
import javax.xml.xquery.XQResultSequence;
|
||||
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.messaging.MessagingException;
|
||||
|
||||
/**
|
||||
* The Result mapper implementation that maps the {@link XQResultSequence} to {@link Node}
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class NodeResultMapper extends AbstractXQueryResultMapper<Node> {
|
||||
|
||||
@Override
|
||||
public List<Node> mapResults(XQResultSequence result) {
|
||||
List<Node> results = new ArrayList<Node>();
|
||||
try {
|
||||
@@ -49,4 +52,5 @@ public class NodeResultMapper extends AbstractXQueryResultMapper<Node> {
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,20 +21,23 @@ import java.util.List;
|
||||
import javax.xml.xquery.XQItemType;
|
||||
import javax.xml.xquery.XQResultSequence;
|
||||
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The Result mapper implementation that maps the {@link XQResultSequence} to {@link Number}
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class NumberResultMapper extends AbstractXQueryResultMapper<Number> {
|
||||
|
||||
@Override
|
||||
public List<Number> mapResults(XQResultSequence result) {
|
||||
List<Number> results = new ArrayList<Number>();
|
||||
try {
|
||||
@@ -62,4 +65,4 @@ public class NumberResultMapper extends AbstractXQueryResultMapper<Number> {
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,19 +21,22 @@ import java.util.List;
|
||||
import javax.xml.xquery.XQItemType;
|
||||
import javax.xml.xquery.XQResultSequence;
|
||||
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.messaging.MessagingException;
|
||||
|
||||
/**
|
||||
* The Result mapper implementation that maps the {@link XQResultSequence} to {@link String}
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class StringResultMapper extends AbstractXQueryResultMapper<String> {
|
||||
|
||||
@Override
|
||||
public List<String> mapResults(XQResultSequence result) {
|
||||
List<String> results = new ArrayList<String>();
|
||||
try {
|
||||
@@ -66,4 +69,4 @@ public class StringResultMapper extends AbstractXQueryResultMapper<String> {
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +17,8 @@ package org.springframework.integration.xquery.support;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.util.StringUtils;
|
||||
* instance
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
|
||||
@@ -23,8 +23,9 @@ import java.net.URL;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -33,6 +34,7 @@ import org.springframework.util.Assert;
|
||||
* by the router, transformer etc along with all the parsers for these components
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,12 +17,13 @@ package org.springframework.integration.xquery.transformer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.integration.transformer.AbstractTransformer;
|
||||
import org.springframework.integration.xquery.core.XQueryExecutor;
|
||||
import org.springframework.integration.xquery.support.XQueryResultMapper;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,6 +41,7 @@ import org.w3c.dom.Node;
|
||||
* provided then the value of the {@link #resultType} defaults to {@link String}.
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,10 +18,9 @@ import java.util.Map;
|
||||
|
||||
import javax.xml.xquery.XQDataSource;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import net.sf.saxon.xqj.SaxonXQDataSource;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -32,11 +31,14 @@ import org.springframework.integration.xquery.DummyXmlPayloadConverter;
|
||||
import org.springframework.integration.xquery.router.XQueryRouter;
|
||||
import org.springframework.integration.xquery.support.XQueryParameter;
|
||||
|
||||
import net.sf.saxon.xqj.SaxonXQDataSource;
|
||||
|
||||
|
||||
/**
|
||||
* The test case for the XQuery router parser
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,11 +21,10 @@ import java.util.Map;
|
||||
import javax.xml.xquery.XQDataSource;
|
||||
import javax.xml.xquery.XQResultSequence;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import net.sf.saxon.xqj.SaxonXQDataSource;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -40,10 +39,13 @@ import org.springframework.integration.xquery.transformer.XQueryTransformer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import net.sf.saxon.xqj.SaxonXQDataSource;
|
||||
|
||||
/**
|
||||
* The test class for XQuery Transformer parser
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
@@ -137,6 +139,7 @@ public class XQueryTransformerParserTests {
|
||||
|
||||
public static class DummyXQueryResultMapper implements XQueryResultMapper<String> {
|
||||
|
||||
@Override
|
||||
public List<String> mapResults(XQResultSequence result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,10 +27,10 @@ import javax.xml.xquery.XQResultSequence;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.xquery.support.AbstractXQueryResultMapper;
|
||||
@@ -40,12 +40,14 @@ import org.springframework.integration.xquery.support.NumberResultMapper;
|
||||
import org.springframework.integration.xquery.support.StringResultMapper;
|
||||
import org.springframework.integration.xquery.support.XQueryParameter;
|
||||
import org.springframework.integration.xquery.support.XQueryResultMapper;
|
||||
import org.w3c.dom.Node;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
|
||||
/**
|
||||
* The base test class for the XQueryExecutor tests
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
@@ -97,6 +99,7 @@ public abstract class AbstractXQueryExecutorTests {
|
||||
executor.setXQuery("'Hello'");
|
||||
Map map = new HashMap();
|
||||
map.put(MyCustomClass.class, new XQueryResultMapper<MyCustomClass>() {
|
||||
@Override
|
||||
public List<MyCustomClass> mapResults(XQResultSequence result) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
@@ -647,6 +650,7 @@ public abstract class AbstractXQueryExecutorTests {
|
||||
|
||||
private class MyCustomClass {}
|
||||
private class CustomNodeMapper implements XQueryResultMapper<Node> {
|
||||
@Override
|
||||
public List<Node> mapResults(XQResultSequence result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,9 +17,9 @@ package org.springframework.integration.xquery.router;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.xquery.core.XQueryExecutor;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,12 +19,12 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.Message;
|
||||
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* The test class for {@link XQueryParameter} class
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,20 +20,21 @@ import java.util.List;
|
||||
|
||||
import javax.xml.xquery.XQResultSequence;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.xquery.core.XQueryExecutor;
|
||||
import org.springframework.integration.xquery.support.XQueryResultMapper;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* The Test class for the {@link XQueryTransformer} class
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
@@ -220,6 +221,7 @@ public class XQueryTransformerTests {
|
||||
|
||||
private class DummyXQueryResultMapper implements XQueryResultMapper<Integer> {
|
||||
|
||||
@Override
|
||||
public List<Integer> mapResults(XQResultSequence result) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user