INT-3655: Remove Reactor Function Usage
JIRA: https://jira.spring.io/browse/INT-3655 In addition, change `GatewayProxyFactoryBean` to the logic to ensure that the Reactor is really `optional` INT-3655: Doc Polishing
This commit is contained in:
committed by
Gary Russell
parent
c8275a06d7
commit
75ff56962a
@@ -110,7 +110,7 @@ subprojects { subproject ->
|
||||
pahoMqttClientVersion = '0.4.0'
|
||||
postgresVersion = '9.1-901-1.jdbc4'
|
||||
reactorVersion = '2.0.0.RC1'
|
||||
reactorSpringVersion = '2.0.0.M2'
|
||||
reactorSpringVersion = '2.0.0.RC1'
|
||||
romeToolsVersion = '1.5.0'
|
||||
saajApiVersion = '1.3.5'
|
||||
saajImplVersion = '1.3.23'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -86,6 +86,9 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
|
||||
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
private static final boolean reactorPresent = ClassUtils.isPresent("reactor.Environment",
|
||||
GatewayProxyFactoryBean.class.getClassLoader());
|
||||
|
||||
private volatile Class<?> serviceInterface;
|
||||
|
||||
private volatile MessageChannel defaultRequestChannel;
|
||||
@@ -116,7 +119,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
|
||||
private volatile Class<?> asyncSubmitListenableType;
|
||||
|
||||
private volatile Environment reactorEnvironment;
|
||||
private volatile Object reactorEnvironment;
|
||||
|
||||
private volatile boolean initialized;
|
||||
|
||||
@@ -255,7 +258,10 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
* @param reactorEnvironment the Reactor Environment.
|
||||
* @since 4.1
|
||||
*/
|
||||
public void setReactorEnvironment(Environment reactorEnvironment) {
|
||||
public void setReactorEnvironment(Object reactorEnvironment) {
|
||||
if (!Environment.class.getName().equals(reactorEnvironment.getClass().getName())) {
|
||||
throw new IllegalArgumentException("The 'reactorEnvironment' must be instance of 'reactor.Environment'");
|
||||
}
|
||||
this.reactorEnvironment = reactorEnvironment;
|
||||
}
|
||||
|
||||
@@ -354,11 +360,11 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Promise.class.isAssignableFrom(returnType)) {
|
||||
if (reactorPresent && Promise.class.isAssignableFrom(returnType)) {
|
||||
if (this.reactorEnvironment == null) {
|
||||
throw new IllegalStateException("'reactorEnvironment' is required in case of 'Promise' return type.");
|
||||
}
|
||||
return Promises.<Object>task(this.reactorEnvironment,
|
||||
return Promises.<Object>task((Environment) this.reactorEnvironment,
|
||||
Functions.supplier(new AsyncInvocationTask(invocation)));
|
||||
}
|
||||
return this.doInvoke(invocation);
|
||||
@@ -584,7 +590,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
if (Future.class.isAssignableFrom(expectedReturnType)) {
|
||||
return (T) source;
|
||||
}
|
||||
if (Promise.class.isAssignableFrom(expectedReturnType)) {
|
||||
if (reactorPresent && Promise.class.isAssignableFrom(expectedReturnType)) {
|
||||
return (T) source;
|
||||
}
|
||||
if (this.getConversionService() != null) {
|
||||
@@ -596,7 +602,8 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
}
|
||||
|
||||
private static boolean hasReturnParameterizedWithMessage(Method method) {
|
||||
if (Future.class.isAssignableFrom(method.getReturnType()) || Promise.class.isAssignableFrom(method.getReturnType())) {
|
||||
if (Future.class.isAssignableFrom(method.getReturnType())
|
||||
|| (reactorPresent && Promise.class.isAssignableFrom(method.getReturnType()))) {
|
||||
Type returnType = method.getGenericReturnType();
|
||||
if (returnType instanceof ParameterizedType) {
|
||||
Type[] typeArgs = ((ParameterizedType) returnType).getActualTypeArguments();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -24,12 +24,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
|
||||
import org.springframework.integration.util.Function;
|
||||
import org.springframework.integration.util.FunctionIterator;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
|
||||
import reactor.fn.Function;
|
||||
|
||||
/**
|
||||
* Base class for Message-splitting handlers.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2015 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.util;
|
||||
|
||||
/**
|
||||
* Implementations of this class perform work on the given parameter
|
||||
* and return a result of an optionally different type.
|
||||
*
|
||||
* <p>This is a copy of Java 8 {@code Function} interface.
|
||||
*
|
||||
* @param <T> The type of the input to the apply operation
|
||||
* @param <R> The type of the result of the apply operation
|
||||
*
|
||||
* @author Jon Brisbin
|
||||
* @author Stephane Maldini
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface Function<T, R> {
|
||||
|
||||
/**
|
||||
* Execute the logic of the action, accepting the given parameter.
|
||||
* @param t The parameter to pass to the action.
|
||||
* @return result
|
||||
*/
|
||||
R apply(T t);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2015 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,8 +19,6 @@ package org.springframework.integration.util;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import reactor.fn.Function;
|
||||
|
||||
/**
|
||||
* An {@link Iterator} implementation to convert each item from the target
|
||||
* {@link #iterator} to a new object applying the {@link #function} on {@link #next()}.
|
||||
|
||||
@@ -94,5 +94,19 @@
|
||||
to 1. The annotation now defaults this attribute to 1.
|
||||
</para>
|
||||
</section>
|
||||
<section id="4.2-api-changes">
|
||||
<title>API Changes</title>
|
||||
<para>
|
||||
<classname>o.s.integtation.util.FunctionIterator</classname> now requires a
|
||||
<interfacename>o.s.integration.util.Function</interfacename> instead of a
|
||||
<interfacename>reactor.function.Function</interfacename>. This was done to remove
|
||||
an unnecessary hard dependency on Reactor. Any uses of this iterator will need to
|
||||
change the import.
|
||||
</para>
|
||||
<para>
|
||||
Of course, Reactor is still supported for functionality such as the <code>Promise</code>
|
||||
gateway; the dependency was removed for those users who don't need it.
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
|
||||
Reference in New Issue
Block a user