Some dependency hygiene and update to Boot 1.5.10

The web module doesn't really need to depend on tomcat and all of
the Spring Boot web stack, but users need a way to grab that stuff
quickly if they want it (hence the new starter).

Also removed all spring-boot-starter dependencies from core and
context modules.
This commit is contained in:
Dave Syer
2018-02-23 12:12:06 +00:00
parent b7d75c676e
commit bf41055dc7
16 changed files with 107 additions and 63 deletions

View File

@@ -10,7 +10,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>1.3.7.RELEASE</version>
<version>1.3.8.RELEASE</version>
<relativePath />
</parent>
@@ -58,6 +58,7 @@
<module>spring-cloud-function-stream</module>
<module>spring-cloud-function-task</module>
<module>spring-cloud-function-web</module>
<module>spring-cloud-starter-function-web</module>
<module>spring-cloud-function-samples</module>
<module>spring-cloud-function-deployer</module>
<module>spring-cloud-function-adapters</module>

View File

@@ -15,6 +15,10 @@
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-core</artifactId>

View File

@@ -18,17 +18,9 @@
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -29,7 +29,6 @@ import java.util.stream.Stream;
import org.reactivestreams.Publisher;
import org.springframework.context.annotation.Bean;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
@@ -37,16 +36,15 @@ import reactor.core.publisher.Flux;
/**
* <p>
* Miscellaneous utility operations to interrogate functional
* components (beans) configured in BeanFactory.
* Miscellaneous utility operations to interrogate functional components (beans)
* configured in BeanFactory.
* </p>
* <p>
* It is important to understand that it is not a general purpose utility
* to interrogate "any" functional component. Certain operations may/will
* not work as expected due to java type erasure. While BeanFactory is not
* the requirement, this utility is targeting only the components
* defined in such way where they could be configured as
* @{@link Component} or @{@link Bean} within BeanFactory.
* It is important to understand that it is not a general purpose utility to interrogate
* "any" functional component. Certain operations may/will not work as expected due to
* java type erasure. While BeanFactory is not the requirement, this utility is targeting
* only the components defined in such way where they could be configured beans within
* BeanFactory.
* </p>
* It is primarily used internally by the framework.
*
@@ -63,7 +61,8 @@ public abstract class FunctionFactoryUtils {
public static boolean isFluxConsumer(Consumer<?> consumer) {
return consumer instanceof FunctionFactoryMetadata
? isFluxConsumer(((FunctionFactoryMetadata<?>) consumer).getFactoryMethod())
? isFluxConsumer(
((FunctionFactoryMetadata<?>) consumer).getFactoryMethod())
: isFlux(1, getParameterizedTypeNames(consumer, Consumer.class));
}
@@ -73,7 +72,8 @@ public abstract class FunctionFactoryUtils {
public static boolean isFluxSupplier(Supplier<?> supplier) {
return supplier instanceof FunctionFactoryMetadata
? isFluxSupplier(((FunctionFactoryMetadata<?>) supplier).getFactoryMethod())
? isFluxSupplier(
((FunctionFactoryMetadata<?>) supplier).getFactoryMethod())
: isFlux(1, getParameterizedTypeNames(supplier, Supplier.class));
}
@@ -83,7 +83,8 @@ public abstract class FunctionFactoryUtils {
public static boolean isFluxFunction(Function<?, ?> function) {
return function instanceof FunctionFactoryMetadata
? isFluxFunction(((FunctionFactoryMetadata<?>) function).getFactoryMethod())
? isFluxFunction(
((FunctionFactoryMetadata<?>) function).getFactoryMethod())
: isFlux(1, getParameterizedTypeNames(function, Function.class));
}
@@ -91,26 +92,29 @@ public abstract class FunctionFactoryUtils {
return isFlux(2, getParameterizedTypeNamesForMethod(method, Function.class));
}
private static String[] getParameterizedTypeNamesForMethod(Method method, Class<?> interfaceClass) {
private static String[] getParameterizedTypeNamesForMethod(Method method,
Class<?> interfaceClass) {
String[] types = retrieveTypes(method.getGenericReturnType(), interfaceClass);
return types == null ? new String[0] : types;
}
private static String[] getParameterizedTypeNames(Object source, Class<?> interfaceClass) {
private static String[] getParameterizedTypeNames(Object source,
Class<?> interfaceClass) {
return Stream.of(source.getClass().getGenericInterfaces())
.map(gi -> retrieveTypes(gi, interfaceClass))
.filter(s -> s != null)
.findFirst()
.orElse(getSerializedLambdaParameterizedTypeNames(source));
.map(gi -> retrieveTypes(gi, interfaceClass)).filter(s -> s != null)
.findFirst().orElse(getSerializedLambdaParameterizedTypeNames(source));
}
private static String[] retrieveTypes(Type genericInterface, Class<?> interfaceClass){
private static String[] retrieveTypes(Type genericInterface,
Class<?> interfaceClass) {
if ((genericInterface instanceof ParameterizedType) && interfaceClass
.getTypeName().equals(((ParameterizedType) genericInterface).getRawType().getTypeName())) {
.getTypeName().equals(((ParameterizedType) genericInterface).getRawType()
.getTypeName())) {
ParameterizedType type = (ParameterizedType) genericInterface;
Type[] args = type.getActualTypeArguments();
if (args != null) {
return Stream.of(args).map(arg -> arg.getTypeName()).toArray(String[]::new);
return Stream.of(args).map(arg -> arg.getTypeName())
.toArray(String[]::new);
}
}
return null;
@@ -124,7 +128,8 @@ public abstract class FunctionFactoryUtils {
ReflectionUtils.makeAccessible(method);
SerializedLambda serializedLambda = (SerializedLambda) ReflectionUtils
.invokeMethod(method, source);
String signature = serializedLambda.getImplMethodSignature().replaceAll("[()]","");
String signature = serializedLambda.getImplMethodSignature().replaceAll("[()]",
"");
List<String> typeNames = Stream.of(signature.split(";"))
.map(t -> t.substring(1).replace('/', '.')).collect(Collectors.toList());
@@ -132,7 +137,9 @@ public abstract class FunctionFactoryUtils {
return typeNames.toArray(new String[typeNames.size()]);
}
private static boolean isFlux(int length, String... types){
return !ObjectUtils.isEmpty(types) && types.length == length && Stream.of(types).allMatch(type -> type.startsWith(FLUX_CLASS_NAME) || type.startsWith(PUBLISHER_CLASS_NAME));
private static boolean isFlux(int length, String... types) {
return !ObjectUtils.isEmpty(types) && types.length == length
&& Stream.of(types).allMatch(type -> type.startsWith(FLUX_CLASS_NAME)
|| type.startsWith(PUBLISHER_CLASS_NAME));
}
}

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>spring-cloud-dependencies-parent</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>1.3.5.RELEASE</version>
<version>1.3.8.RELEASE</version>
<relativePath/>
</parent>
<artifactId>spring-cloud-function-dependencies</artifactId>
@@ -14,7 +14,7 @@
<name>Spring Cloud Function Dependencies</name>
<description>Spring Cloud Function Dependencies</description>
<properties>
<reactor-bom.version>Bismuth-SR4</reactor-bom.version>
<reactor-bom.version>Bismuth-SR6</reactor-bom.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -55,6 +55,11 @@
<artifactId>spring-cloud-function-web</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-function-web</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-deployer</artifactId>

View File

@@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<version>1.5.10.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
@@ -37,7 +37,7 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
<artifactId>spring-cloud-starter-function-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>

View File

@@ -34,7 +34,7 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
<artifactId>spring-cloud-starter-function-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<version>1.5.10.RELEASE</version>
<relativePath/>
</parent>
@@ -28,7 +28,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
<artifactId>spring-cloud-starter-function-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>

View File

@@ -12,7 +12,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<version>1.5.10.RELEASE</version>
<relativePath />
</parent>
@@ -28,7 +28,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
<artifactId>spring-cloud-starter-function-web</artifactId>
</dependency>
</dependencies>

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<version>1.5.10.RELEASE</version>
<relativePath/>
</parent>
@@ -27,7 +27,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
<artifactId>spring-cloud-starter-function-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<version>1.5.10.RELEASE</version>
<relativePath/>
</parent>
@@ -31,7 +31,7 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
<artifactId>spring-cloud-starter-function-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<version>1.5.10.RELEASE</version>
<relativePath/>
</parent>
@@ -27,7 +27,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
<artifactId>spring-cloud-starter-function-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>

View File

@@ -16,18 +16,8 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
</exclusions>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
@@ -36,13 +26,28 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-context</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Stream;
@@ -28,7 +29,6 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.el.stream.Optional;
import org.reactivestreams.Publisher;
import org.springframework.cloud.function.context.catalog.FunctionInspector;

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-parent</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>spring-cloud-starter-function-web</artifactId>
<name>spring-cloud-starter-starter-function-web</name>
<description>Spring Cloud Starter</description>
<url>https://projects.spring.io/spring-cloud</url>
<organization>
<name>Pivotal Software, Inc.</name>
<url>https://www.spring.io</url>
</organization>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1 @@
provides: spring-cloud-security