Added checkstyle
This commit is contained in:
14
.editorconfig
Normal file
14
.editorconfig
Normal file
@@ -0,0 +1,14 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
110
.mvn/wrapper/MavenWrapperDownloader.java
vendored
Executable file
110
.mvn/wrapper/MavenWrapperDownloader.java
vendored
Executable file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you 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.
|
||||
*/
|
||||
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.nio.channels.*;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MavenWrapperDownloader {
|
||||
|
||||
/**
|
||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
||||
*/
|
||||
private static final String DEFAULT_DOWNLOAD_URL =
|
||||
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
|
||||
|
||||
/**
|
||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
||||
* use instead of the default one.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||
".mvn/wrapper/maven-wrapper.properties";
|
||||
|
||||
/**
|
||||
* Path where the maven-wrapper.jar will be saved to.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_JAR_PATH =
|
||||
".mvn/wrapper/maven-wrapper.jar";
|
||||
|
||||
/**
|
||||
* Name of the property which should be used to override the default download url for the wrapper.
|
||||
*/
|
||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("- Downloader started");
|
||||
File baseDirectory = new File(args[0]);
|
||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||
|
||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||
// wrapperUrl parameter.
|
||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||
String url = DEFAULT_DOWNLOAD_URL;
|
||||
if(mavenWrapperPropertyFile.exists()) {
|
||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||
try {
|
||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||
Properties mavenWrapperProperties = new Properties();
|
||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||
} catch (IOException e) {
|
||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||
} finally {
|
||||
try {
|
||||
if(mavenWrapperPropertyFileInputStream != null) {
|
||||
mavenWrapperPropertyFileInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Ignore ...
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading from: : " + url);
|
||||
|
||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||
if(!outputFile.getParentFile().exists()) {
|
||||
if(!outputFile.getParentFile().mkdirs()) {
|
||||
System.out.println(
|
||||
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||
try {
|
||||
downloadFileFromURL(url, outputFile);
|
||||
System.out.println("Done");
|
||||
System.exit(0);
|
||||
} catch (Throwable e) {
|
||||
System.out.println("- Error downloading");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||
URL website = new URL(urlString);
|
||||
ReadableByteChannel rbc;
|
||||
rbc = Channels.newChannel(website.openStream());
|
||||
FileOutputStream fos = new FileOutputStream(destination);
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
fos.close();
|
||||
rbc.close();
|
||||
}
|
||||
|
||||
}
|
||||
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file → Executable file
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file → Executable file
Binary file not shown.
2
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file → Executable file
2
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file → Executable file
@@ -1 +1 @@
|
||||
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
|
||||
128
.settings.xml
128
.settings.xml
@@ -1,66 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<settings>
|
||||
<servers>
|
||||
<server>
|
||||
<id>repo.spring.io</id>
|
||||
<username>${env.CI_DEPLOY_USERNAME}</username>
|
||||
<password>${env.CI_DEPLOY_PASSWORD}</password>
|
||||
</server>
|
||||
</servers>
|
||||
<profiles>
|
||||
<profile>
|
||||
<!--
|
||||
N.B. this profile is only here to support users and IDEs that do not use Maven 3.3.
|
||||
It isn't needed on the command line if you use the wrapper script (mvnw) or if you use
|
||||
a native Maven with the right version. Eclipse users should points their Maven tooling to
|
||||
this settings file, or copy the profile into their ~/.m2/settings.xml.
|
||||
-->
|
||||
<id>spring</id>
|
||||
<activation><activeByDefault>true</activeByDefault></activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>http://repo.spring.io/libs-snapshot-local</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>http://repo.spring.io/libs-milestone-local</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-releases</id>
|
||||
<name>Spring Releases</name>
|
||||
<url>http://repo.spring.io/release</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>http://repo.spring.io/libs-snapshot-local</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>http://repo.spring.io/libs-milestone-local</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
<servers>
|
||||
<server>
|
||||
<id>repo.spring.io</id>
|
||||
<username>${env.CI_DEPLOY_USERNAME}</username>
|
||||
<password>${env.CI_DEPLOY_PASSWORD}</password>
|
||||
</server>
|
||||
</servers>
|
||||
<profiles>
|
||||
<profile>
|
||||
<!--
|
||||
N.B. this profile is only here to support users and IDEs that do not use Maven 3.3.
|
||||
It isn't needed on the command line if you use the wrapper script (mvnw) or if you use
|
||||
a native Maven with the right version. Eclipse users should points their Maven tooling to
|
||||
this settings file, or copy the profile into their ~/.m2/settings.xml.
|
||||
-->
|
||||
<id>spring</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>http://repo.spring.io/libs-snapshot-local</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>http://repo.spring.io/libs-milestone-local</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-releases</id>
|
||||
<name>Spring Releases</name>
|
||||
<url>http://repo.spring.io/release</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>http://repo.spring.io/libs-snapshot-local</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>http://repo.spring.io/libs-milestone-local</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
</settings>
|
||||
|
||||
0
.springformat
Normal file
0
.springformat
Normal file
19
docs/pom.xml
19
docs/pom.xml
@@ -1,6 +1,7 @@
|
||||
<?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">
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>
|
||||
@@ -16,14 +17,14 @@
|
||||
<main.basedir>${basedir}/..</main.basedir>
|
||||
<docs.whitelisted.branches>1.0.x,1.1.x</docs.whitelisted.branches>
|
||||
</properties>
|
||||
<build>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
|
||||
177
mvnw
vendored
177
mvnw
vendored
@@ -54,38 +54,16 @@ case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
#
|
||||
# Look for the Apple JDKs first to preserve the existing behaviour, and then look
|
||||
# for the new JDKs provided by Oracle.
|
||||
#
|
||||
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
|
||||
#
|
||||
# Apple JDKs
|
||||
#
|
||||
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
|
||||
#
|
||||
# Apple JDKs
|
||||
#
|
||||
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
|
||||
#
|
||||
# Oracle JDKs
|
||||
#
|
||||
export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
|
||||
#
|
||||
# Apple JDKs
|
||||
#
|
||||
export JAVA_HOME=`/usr/libexec/java_home`
|
||||
fi
|
||||
;;
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
@@ -130,7 +108,7 @@ if $cygwin ; then
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Migwn, ensure paths are in UNIX format before anything is touched
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
@@ -184,27 +162,28 @@ fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
local basedir=$(pwd)
|
||||
local wdir=$(pwd)
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
wdir=$(cd "$wdir/.."; pwd)
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
@@ -216,38 +195,92 @@ concat_lines() {
|
||||
fi
|
||||
}
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
wget "$jarUrl" -O "$wrapperJarPath"
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
curl -o "$wrapperJarPath" "$jarUrl"
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
echo "Running version check"
|
||||
VERSION=$( sed '\!<parent!,\!</parent!d' `dirname $0`/pom.xml | grep '<version' | head -1 | sed -e 's/.*<version>//' -e 's!</version>.*$!!' )
|
||||
echo "The found version is [${VERSION}]"
|
||||
|
||||
if echo $VERSION | egrep -q 'M|RC'; then
|
||||
echo Activating \"milestone\" profile for version=\"$VERSION\"
|
||||
echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone"
|
||||
else
|
||||
echo Deactivating \"milestone\" profile for version=\"$VERSION\"
|
||||
echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//')
|
||||
fi
|
||||
|
||||
if echo $VERSION | egrep -q 'RELEASE'; then
|
||||
echo Activating \"central\" profile for version=\"$VERSION\"
|
||||
echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pcentral"
|
||||
else
|
||||
echo Deactivating \"central\" profile for version=\"$VERSION\"
|
||||
echo $MAVEN_ARGS | grep -q central && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pcentral//')
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@"
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||
|
||||
306
mvnw.cmd
vendored
Normal file → Executable file
306
mvnw.cmd
vendored
Normal file → Executable file
@@ -1,145 +1,161 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
|
||||
set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
echo Found %WRAPPER_JAR%
|
||||
) else (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
||||
|
||||
26
pom.xml
26
pom.xml
@@ -1,5 +1,6 @@
|
||||
<?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"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>
|
||||
|
||||
@@ -20,6 +21,12 @@
|
||||
<main.basedir>${basedir}</main.basedir>
|
||||
<spring-cloud-netflix.version>2.1.1.BUILD-SNAPSHOT</spring-cloud-netflix.version>
|
||||
<spring-cloud-commons.version>2.1.1.BUILD-SNAPSHOT</spring-cloud-commons.version>
|
||||
|
||||
<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError>
|
||||
<maven-checkstyle-plugin.failsOnViolation>true
|
||||
</maven-checkstyle-plugin.failsOnViolation>
|
||||
<maven-checkstyle-plugin.includeTestSourceDirectory>true
|
||||
</maven-checkstyle-plugin.includeTestSourceDirectory>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
@@ -53,9 +60,26 @@
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>io.spring.javaformat</groupId>
|
||||
<artifactId>spring-javaformat-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?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"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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,6 +30,7 @@ import org.cloudfoundry.reactor.tokenprovider.PasswordGrantTokenProvider;
|
||||
import org.cloudfoundry.reactor.uaa.ReactorUaaClient;
|
||||
import org.cloudfoundry.routing.RoutingClient;
|
||||
import org.cloudfoundry.uaa.UaaClient;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -46,9 +47,12 @@ import org.springframework.context.annotation.Lazy;
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "spring.cloud.cloudfoundry", name = {"username", "password"})
|
||||
@ConditionalOnClass(name = {"reactor.core.publisher.Flux", "org.cloudfoundry.operations.DefaultCloudFoundryOperations",
|
||||
"org.cloudfoundry.reactor.client.ReactorCloudFoundryClient", "org.reactivestreams.Publisher"})
|
||||
@ConditionalOnProperty(prefix = "spring.cloud.cloudfoundry", name = { "username",
|
||||
"password" })
|
||||
@ConditionalOnClass(name = { "reactor.core.publisher.Flux",
|
||||
"org.cloudfoundry.operations.DefaultCloudFoundryOperations",
|
||||
"org.cloudfoundry.reactor.client.ReactorCloudFoundryClient",
|
||||
"org.reactivestreams.Publisher" })
|
||||
@EnableConfigurationProperties(CloudFoundryProperties.class)
|
||||
public class CloudFoundryClientAutoConfiguration {
|
||||
|
||||
@@ -61,67 +65,59 @@ public class CloudFoundryClientAutoConfiguration {
|
||||
@Bean
|
||||
@Lazy
|
||||
@ConditionalOnMissingBean
|
||||
public CloudFoundryService cloudFoundryService(CloudFoundryOperations cloudFoundryOperations) {
|
||||
public CloudFoundryService cloudFoundryService(
|
||||
CloudFoundryOperations cloudFoundryOperations) {
|
||||
return new CloudFoundryService(cloudFoundryOperations);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
@ConditionalOnMissingBean
|
||||
public DefaultCloudFoundryOperations cloudFoundryOperations(CloudFoundryClient cloudFoundryClient,
|
||||
DopplerClient dopplerClient,
|
||||
RoutingClient routingClient,
|
||||
UaaClient uaaClient) {
|
||||
public DefaultCloudFoundryOperations cloudFoundryOperations(
|
||||
CloudFoundryClient cloudFoundryClient, DopplerClient dopplerClient,
|
||||
RoutingClient routingClient, UaaClient uaaClient) {
|
||||
String organization = this.cloudFoundryProperties.getOrg();
|
||||
String space = this.cloudFoundryProperties.getSpace();
|
||||
return DefaultCloudFoundryOperations
|
||||
.builder()
|
||||
.cloudFoundryClient(cloudFoundryClient)
|
||||
.dopplerClient(dopplerClient)
|
||||
.routingClient(routingClient)
|
||||
.uaaClient(uaaClient)
|
||||
.organization(organization)
|
||||
.space(space)
|
||||
.build();
|
||||
}
|
||||
@Bean
|
||||
@Lazy
|
||||
@ConditionalOnMissingBean
|
||||
public ReactorCloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
|
||||
return ReactorCloudFoundryClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
.build();
|
||||
return DefaultCloudFoundryOperations.builder()
|
||||
.cloudFoundryClient(cloudFoundryClient).dopplerClient(dopplerClient)
|
||||
.routingClient(routingClient).uaaClient(uaaClient)
|
||||
.organization(organization).space(space).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
@ConditionalOnMissingBean
|
||||
public DopplerClient dopplerClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
|
||||
return ReactorDopplerClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
.build();
|
||||
public ReactorCloudFoundryClient cloudFoundryClient(
|
||||
ConnectionContext connectionContext, TokenProvider tokenProvider) {
|
||||
return ReactorCloudFoundryClient.builder().connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
@ConditionalOnMissingBean
|
||||
public RoutingClient routingClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
|
||||
return ReactorRoutingClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
.build();
|
||||
public DopplerClient dopplerClient(ConnectionContext connectionContext,
|
||||
TokenProvider tokenProvider) {
|
||||
return ReactorDopplerClient.builder().connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
@ConditionalOnMissingBean
|
||||
public ReactorUaaClient uaaClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
|
||||
return ReactorUaaClient.builder()
|
||||
.connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider)
|
||||
.build();
|
||||
public RoutingClient routingClient(ConnectionContext connectionContext,
|
||||
TokenProvider tokenProvider) {
|
||||
return ReactorRoutingClient.builder().connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
@ConditionalOnMissingBean
|
||||
public ReactorUaaClient uaaClient(ConnectionContext connectionContext,
|
||||
TokenProvider tokenProvider) {
|
||||
return ReactorUaaClient.builder().connectionContext(connectionContext)
|
||||
.tokenProvider(tokenProvider).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -131,10 +127,8 @@ public class CloudFoundryClientAutoConfiguration {
|
||||
String apiHost = this.cloudFoundryProperties.getUrl();
|
||||
Boolean skipSslValidation = this.cloudFoundryProperties.isSkipSslValidation();
|
||||
|
||||
return DefaultConnectionContext.builder()
|
||||
.apiHost(apiHost)
|
||||
.skipSslValidation(skipSslValidation)
|
||||
.build();
|
||||
return DefaultConnectionContext.builder().apiHost(apiHost)
|
||||
.skipSslValidation(skipSslValidation).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -143,11 +137,8 @@ public class CloudFoundryClientAutoConfiguration {
|
||||
public PasswordGrantTokenProvider tokenProvider() {
|
||||
String username = this.cloudFoundryProperties.getUsername();
|
||||
String password = this.cloudFoundryProperties.getPassword();
|
||||
return PasswordGrantTokenProvider.builder()
|
||||
.password(password)
|
||||
.username(username)
|
||||
return PasswordGrantTokenProvider.builder().password(password).username(username)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -16,17 +16,17 @@
|
||||
|
||||
package org.springframework.cloud.cloudfoundry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Configuration properties for a connection to a Cloud Foundry platform.
|
||||
*
|
||||
@@ -69,6 +69,10 @@ public class CloudFoundryProperties implements InitializingBean {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public void setUrl(String cloudControllerUrl) {
|
||||
this.url = cloudControllerUrl;
|
||||
}
|
||||
|
||||
private String safeUrl(String t) {
|
||||
String input = t.trim().toLowerCase();
|
||||
Pattern p = Pattern.compile("(http(s)?://)(.*)");
|
||||
@@ -82,10 +86,6 @@ public class CloudFoundryProperties implements InitializingBean {
|
||||
return t;
|
||||
}
|
||||
|
||||
public void setUrl(String cloudControllerUrl) {
|
||||
this.url = cloudControllerUrl;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class CloudFoundryProperties implements InitializingBean {
|
||||
}
|
||||
|
||||
public boolean isSkipSslValidation() {
|
||||
return skipSslValidation;
|
||||
return this.skipSslValidation;
|
||||
}
|
||||
|
||||
public boolean getSkipSslValidation() {
|
||||
@@ -146,6 +146,8 @@ public class CloudFoundryProperties implements InitializingBean {
|
||||
vals.put("url", getUrl());
|
||||
vals.put("username", getUsername());
|
||||
vals.put("password", getPassword());
|
||||
vals.forEach((key, value) -> Assert.hasText(value, String.format("'%s' must be provided", key)));
|
||||
vals.forEach((key, value) -> Assert.hasText(value,
|
||||
String.format("'%s' must be provided", key)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.cloudfoundry;
|
||||
|
||||
|
||||
import org.cloudfoundry.operations.CloudFoundryOperations;
|
||||
import org.cloudfoundry.operations.applications.ApplicationDetail;
|
||||
import org.cloudfoundry.operations.applications.GetApplicationRequest;
|
||||
@@ -38,15 +37,17 @@ public class CloudFoundryService {
|
||||
this.cloudFoundryOperations = cloudFoundryOperations;
|
||||
}
|
||||
|
||||
public Flux<Tuple2<ApplicationDetail, InstanceDetail>> getApplicationInstances(String serviceId) {
|
||||
GetApplicationRequest applicationRequest = GetApplicationRequest.builder().name(serviceId).build();
|
||||
return this.cloudFoundryOperations
|
||||
.applications()
|
||||
.get(applicationRequest)
|
||||
public Flux<Tuple2<ApplicationDetail, InstanceDetail>> getApplicationInstances(
|
||||
String serviceId) {
|
||||
GetApplicationRequest applicationRequest = GetApplicationRequest.builder()
|
||||
.name(serviceId).build();
|
||||
return this.cloudFoundryOperations.applications().get(applicationRequest)
|
||||
.flatMapMany(applicationDetail -> {
|
||||
Flux<InstanceDetail> ids = Flux.fromStream(applicationDetail.getInstanceDetails().stream())
|
||||
Flux<InstanceDetail> ids = Flux
|
||||
.fromStream(applicationDetail.getInstanceDetails().stream())
|
||||
.filter(id -> id.getState().equalsIgnoreCase("RUNNING"));
|
||||
Flux<ApplicationDetail> generate = Flux.generate(sink -> sink.next(applicationDetail));
|
||||
Flux<ApplicationDetail> generate = Flux
|
||||
.generate(sink -> sink.next(applicationDetail));
|
||||
return generate.zipWith(ids);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.springframework.cloud.cloudfoundry.CloudFoundryClientAutoConfiguration
|
||||
org.springframework.cloud.cloudfoundry.CloudFoundryClientAutoConfiguration
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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,6 +27,7 @@ import org.cloudfoundry.reactor.uaa.ReactorUaaClient;
|
||||
import org.cloudfoundry.routing.RoutingClient;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
@@ -35,13 +36,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class CloudFoundryClientAutoConfigurationTest {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(CloudFoundryClientAutoConfiguration.class));
|
||||
private final static String[] SPRING_CLOUD_PROPERTIES = {
|
||||
"spring.cloud.cloudfoundry.username", "spring.cloud.cloudfoundry.password", };
|
||||
|
||||
private final static String SPRING_CLOUD_PROPERTIES[] = {
|
||||
"spring.cloud.cloudfoundry.username",
|
||||
"spring.cloud.cloudfoundry.password",
|
||||
};
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(
|
||||
AutoConfigurations.of(CloudFoundryClientAutoConfiguration.class));
|
||||
|
||||
private static boolean requiredPropertiesSet() {
|
||||
for (String k : SPRING_CLOUD_PROPERTIES) {
|
||||
@@ -53,23 +53,19 @@ public class CloudFoundryClientAutoConfigurationTest {
|
||||
}
|
||||
|
||||
private static String envVarFromProperty(String propertyName) {
|
||||
return propertyName
|
||||
.replaceAll("\\.", "_")
|
||||
.toUpperCase();
|
||||
return propertyName.replaceAll("\\.", "_").toUpperCase();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autoConfiguresBeansWithAllProperties() {
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"spring.cloud.cloudfoundry.username=user",
|
||||
"spring.cloud.cloudfoundry.password=secret",
|
||||
"spring.cloud.cloudfoundry.org=myorg",
|
||||
"spring.cloud.cloudfoundry.space=myspace")
|
||||
.run((context) -> {
|
||||
this.contextRunner.withPropertyValues("spring.cloud.cloudfoundry.username=user",
|
||||
"spring.cloud.cloudfoundry.password=secret",
|
||||
"spring.cloud.cloudfoundry.org=myorg",
|
||||
"spring.cloud.cloudfoundry.space=myspace").run((context) -> {
|
||||
assertCloudFoundryClientBeansPresent(context);
|
||||
|
||||
DefaultCloudFoundryOperations operations = context.getBean(DefaultCloudFoundryOperations.class);
|
||||
DefaultCloudFoundryOperations operations = context
|
||||
.getBean(DefaultCloudFoundryOperations.class);
|
||||
assertThat(operations.getOrganization()).isEqualTo("myorg");
|
||||
assertThat(operations.getSpace()).isEqualTo("myspace");
|
||||
});
|
||||
@@ -77,14 +73,12 @@ public class CloudFoundryClientAutoConfigurationTest {
|
||||
|
||||
@Test
|
||||
public void autoConfiguresBeansWithMinimalProperties() {
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"spring.cloud.cloudfoundry.username=user",
|
||||
"spring.cloud.cloudfoundry.password=secret")
|
||||
.run((context) -> {
|
||||
this.contextRunner.withPropertyValues("spring.cloud.cloudfoundry.username=user",
|
||||
"spring.cloud.cloudfoundry.password=secret").run((context) -> {
|
||||
assertCloudFoundryClientBeansPresent(context);
|
||||
|
||||
DefaultCloudFoundryOperations operations = context.getBean(DefaultCloudFoundryOperations.class);
|
||||
DefaultCloudFoundryOperations operations = context
|
||||
.getBean(DefaultCloudFoundryOperations.class);
|
||||
assertThat(operations.getOrganization()).isNullOrEmpty();
|
||||
assertThat(operations.getSpace()).isNullOrEmpty();
|
||||
});
|
||||
@@ -94,23 +88,21 @@ public class CloudFoundryClientAutoConfigurationTest {
|
||||
public void organizationsRetrievedWithUserProvidedProperties() {
|
||||
Assume.assumeTrue(requiredPropertiesSet());
|
||||
|
||||
this.contextRunner
|
||||
.run((context) -> {
|
||||
assertCloudFoundryClientBeansPresent(context);
|
||||
CloudFoundryOperations operations = context.getBean(CloudFoundryOperations.class);
|
||||
this.contextRunner.run((context) -> {
|
||||
assertCloudFoundryClientBeansPresent(context);
|
||||
CloudFoundryOperations operations = context
|
||||
.getBean(CloudFoundryOperations.class);
|
||||
|
||||
OrganizationSummary summary = operations
|
||||
.organizations()
|
||||
.list()
|
||||
.blockFirst();
|
||||
OrganizationSummary summary = operations.organizations().list().blockFirst();
|
||||
|
||||
assertThat(summary).isNotNull();
|
||||
assertThat(summary.getId()).isNotEmpty();
|
||||
assertThat(summary.getName()).isNotEmpty();
|
||||
});
|
||||
assertThat(summary).isNotNull();
|
||||
assertThat(summary.getId()).isNotEmpty();
|
||||
assertThat(summary.getName()).isNotEmpty();
|
||||
});
|
||||
}
|
||||
|
||||
private void assertCloudFoundryClientBeansPresent(AssertableApplicationContext context) {
|
||||
private void assertCloudFoundryClientBeansPresent(
|
||||
AssertableApplicationContext context) {
|
||||
assertThat(context).hasSingleBean(ReactorCloudFoundryClient.class);
|
||||
assertThat(context).hasSingleBean(DefaultCloudFoundryOperations.class);
|
||||
assertThat(context).hasSingleBean(DefaultConnectionContext.class);
|
||||
@@ -119,4 +111,5 @@ public class CloudFoundryClientAutoConfigurationTest {
|
||||
assertThat(context).hasSingleBean(PasswordGrantTokenProvider.class);
|
||||
assertThat(context).hasSingleBean(ReactorUaaClient.class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?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"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?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">
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>
|
||||
<artifactId>spring-cloud-cloudfoundry-discovery</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
@@ -51,4 +52,4 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -42,14 +42,16 @@ import org.springframework.cloud.cloudfoundry.CloudFoundryService;
|
||||
public class CloudFoundryDiscoveryClient implements DiscoveryClient {
|
||||
|
||||
private final CloudFoundryService cloudFoundryService;
|
||||
|
||||
private final CloudFoundryOperations cloudFoundryOperations;
|
||||
|
||||
private final CloudFoundryDiscoveryProperties properties;
|
||||
|
||||
private final String description = "Cloud Foundry " + DiscoveryClient.class.getName() + " implementation";
|
||||
private final String description = "Cloud Foundry " + DiscoveryClient.class.getName()
|
||||
+ " implementation";
|
||||
|
||||
CloudFoundryDiscoveryClient(CloudFoundryOperations cloudFoundryOperations,
|
||||
CloudFoundryService svc,
|
||||
CloudFoundryDiscoveryProperties properties) {
|
||||
CloudFoundryService svc, CloudFoundryDiscoveryProperties properties) {
|
||||
this.cloudFoundryService = svc;
|
||||
this.cloudFoundryOperations = cloudFoundryOperations;
|
||||
this.properties = properties;
|
||||
@@ -62,37 +64,30 @@ public class CloudFoundryDiscoveryClient implements DiscoveryClient {
|
||||
|
||||
@Override
|
||||
public List<ServiceInstance> getInstances(String serviceId) {
|
||||
return cloudFoundryService
|
||||
.getApplicationInstances(serviceId)
|
||||
.map(tuple -> {
|
||||
ApplicationDetail applicationDetail = tuple.getT1();
|
||||
InstanceDetail instanceDetail = tuple.getT2();
|
||||
return this.cloudFoundryService.getApplicationInstances(serviceId).map(tuple -> {
|
||||
ApplicationDetail applicationDetail = tuple.getT1();
|
||||
InstanceDetail instanceDetail = tuple.getT2();
|
||||
|
||||
String applicationId = applicationDetail.getId();
|
||||
String applicationIndex = instanceDetail.getIndex();
|
||||
String name = applicationDetail.getName();
|
||||
String url = applicationDetail.getUrls().size() > 0 ? applicationDetail.getUrls().get(0) : null;
|
||||
boolean secure = (url + "").toLowerCase().startsWith("https");
|
||||
String applicationId = applicationDetail.getId();
|
||||
String applicationIndex = instanceDetail.getIndex();
|
||||
String name = applicationDetail.getName();
|
||||
String url = applicationDetail.getUrls().size() > 0
|
||||
? applicationDetail.getUrls().get(0) : null;
|
||||
boolean secure = (url + "").toLowerCase().startsWith("https");
|
||||
|
||||
HashMap<String, String> metadata = new HashMap<>();
|
||||
metadata.put("applicationId", applicationId);
|
||||
metadata.put("instanceId", applicationIndex);
|
||||
HashMap<String, String> metadata = new HashMap<>();
|
||||
metadata.put("applicationId", applicationId);
|
||||
metadata.put("instanceId", applicationIndex);
|
||||
|
||||
return (ServiceInstance) new DefaultServiceInstance(name, url, 80, secure, metadata);
|
||||
})
|
||||
.collectList()
|
||||
.blockOptional()
|
||||
.orElse(new ArrayList<>());
|
||||
return (ServiceInstance) new DefaultServiceInstance(name, url, 80, secure,
|
||||
metadata);
|
||||
}).collectList().blockOptional().orElse(new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getServices() {
|
||||
return this.cloudFoundryOperations
|
||||
.applications()
|
||||
.list()
|
||||
.map(ApplicationSummary::getName)
|
||||
.collectList()
|
||||
.blockOptional()
|
||||
return this.cloudFoundryOperations.applications().list()
|
||||
.map(ApplicationSummary::getName).collectList().blockOptional()
|
||||
.orElse(new ArrayList<>());
|
||||
}
|
||||
|
||||
@@ -100,4 +95,5 @@ public class CloudFoundryDiscoveryClient implements DiscoveryClient {
|
||||
public int getOrder() {
|
||||
return this.properties.getOrder();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -44,7 +44,9 @@ public class CloudFoundryDiscoveryClientConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CloudFoundryHeartbeatSender cloudFoundryHeartbeatSender(CloudFoundryDiscoveryClient client) {
|
||||
public CloudFoundryHeartbeatSender cloudFoundryHeartbeatSender(
|
||||
CloudFoundryDiscoveryClient client) {
|
||||
return new CloudFoundryHeartbeatSender(client);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
* Copyright 2013-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,7 +21,7 @@ import org.springframework.core.Ordered;
|
||||
|
||||
/**
|
||||
* Properties used for configuring the CloudFoundry implementation of
|
||||
* {@link org.springframework.cloud.client.discovery.DiscoveryClient}
|
||||
* {@link org.springframework.cloud.client.discovery.DiscoveryClient}.
|
||||
*
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*/
|
||||
@@ -37,4 +37,5 @@ public class CloudFoundryDiscoveryClientProperties {
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -41,12 +41,13 @@ public class CloudFoundryDiscoveryProperties {
|
||||
private int defaultServerPort = 80;
|
||||
|
||||
/**
|
||||
* Order of the discovery client used by `CompositeDiscoveryClient` for sorting available clients.
|
||||
* Order of the discovery client used by `CompositeDiscoveryClient` for sorting
|
||||
* available clients.
|
||||
*/
|
||||
private int order = 0;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
@@ -62,7 +63,7 @@ public class CloudFoundryDiscoveryProperties {
|
||||
}
|
||||
|
||||
public int getDefaultServerPort() {
|
||||
return defaultServerPort;
|
||||
return this.defaultServerPort;
|
||||
}
|
||||
|
||||
public void setDefaultServerPort(int defaultServerPort) {
|
||||
@@ -70,7 +71,7 @@ public class CloudFoundryDiscoveryProperties {
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
return this.order;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
@@ -79,11 +80,10 @@ public class CloudFoundryDiscoveryProperties {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CloudFoundryDiscoveryProperties{" +
|
||||
"enabled=" + enabled +
|
||||
", heartbeatFrequency=" + heartbeatFrequency +
|
||||
", defaultServerPort=" + defaultServerPort +
|
||||
", order=" + order +
|
||||
'}';
|
||||
return "CloudFoundryDiscoveryProperties{" + "enabled=" + this.enabled
|
||||
+ ", heartbeatFrequency=" + this.heartbeatFrequency
|
||||
+ ", defaultServerPort=" + this.defaultServerPort + ", order="
|
||||
+ this.order + '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -35,6 +35,7 @@ import org.springframework.stereotype.Component;
|
||||
public class CloudFoundryHeartbeatSender implements ApplicationEventPublisherAware {
|
||||
|
||||
private final CloudFoundryDiscoveryClient client;
|
||||
|
||||
private ApplicationEventPublisher publisher;
|
||||
|
||||
public CloudFoundryHeartbeatSender(CloudFoundryDiscoveryClient client) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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,6 +18,9 @@ package org.springframework.cloud.cloudfoundry.discovery;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.ServerList;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.cloud.cloudfoundry.CloudFoundryService;
|
||||
import org.springframework.cloud.netflix.ribbon.RibbonClientName;
|
||||
@@ -25,9 +28,6 @@ import org.springframework.cloud.netflix.ribbon.RibbonUtils;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.ServerList;
|
||||
|
||||
/**
|
||||
* @author Josh Long
|
||||
*/
|
||||
@@ -47,8 +47,9 @@ public class CloudFoundryRibbonClientConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ServerList<?> ribbonServerList(CloudFoundryService svc, IClientConfig config,
|
||||
CloudFoundryDiscoveryProperties properties) {
|
||||
CloudFoundryServerList cloudFoundryServerList = new CloudFoundryServerList(svc, properties);
|
||||
CloudFoundryDiscoveryProperties properties) {
|
||||
CloudFoundryServerList cloudFoundryServerList = new CloudFoundryServerList(svc,
|
||||
properties);
|
||||
cloudFoundryServerList.initWithNiwsConfig(config);
|
||||
return cloudFoundryServerList;
|
||||
}
|
||||
@@ -58,4 +59,4 @@ public class CloudFoundryRibbonClientConfiguration {
|
||||
RibbonUtils.initializeRibbonDefaults(this.serviceId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -54,4 +54,5 @@ public class CloudFoundryServer extends Server {
|
||||
public MetaInfo getMetaInfo() {
|
||||
return this.metaInfo;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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,24 +19,28 @@ package org.springframework.cloud.cloudfoundry.discovery;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.AbstractServerList;
|
||||
|
||||
import org.springframework.cloud.cloudfoundry.CloudFoundryService;
|
||||
import org.springframework.cloud.netflix.ribbon.RibbonProperties;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.AbstractServerList;
|
||||
|
||||
/**
|
||||
* @author Josh Long
|
||||
*/
|
||||
public class CloudFoundryServerList extends AbstractServerList<CloudFoundryServer> {
|
||||
|
||||
private final CloudFoundryService cloudFoundryService;
|
||||
|
||||
private final CloudFoundryDiscoveryProperties properties;
|
||||
|
||||
private IClientConfig clientConfig;
|
||||
|
||||
private String serviceId;
|
||||
|
||||
CloudFoundryServerList(CloudFoundryService svc, CloudFoundryDiscoveryProperties properties) {
|
||||
CloudFoundryServerList(CloudFoundryService svc,
|
||||
CloudFoundryDiscoveryProperties properties) {
|
||||
this.cloudFoundryService = svc;
|
||||
this.properties = properties;
|
||||
}
|
||||
@@ -60,7 +64,7 @@ public class CloudFoundryServerList extends AbstractServerList<CloudFoundryServe
|
||||
private List<CloudFoundryServer> cloudFoundryServers() {
|
||||
Assert.notNull(this.clientConfig, "clientConfig may not be null");
|
||||
|
||||
RibbonProperties ribbon = RibbonProperties.from(clientConfig);
|
||||
RibbonProperties ribbon = RibbonProperties.from(this.clientConfig);
|
||||
|
||||
Boolean secure = ribbon.getSecure();
|
||||
Integer securePort = ribbon.getSecurePort();
|
||||
@@ -69,21 +73,23 @@ public class CloudFoundryServerList extends AbstractServerList<CloudFoundryServe
|
||||
final int port;
|
||||
if (secure != null && secure && securePort != null) {
|
||||
port = securePort;
|
||||
} else if (nonSecurePort != null) {
|
||||
}
|
||||
else if (nonSecurePort != null) {
|
||||
port = nonSecurePort;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
port = this.properties.getDefaultServerPort();
|
||||
}
|
||||
|
||||
return cloudFoundryService
|
||||
.getApplicationInstances(this.serviceId)
|
||||
.map(tpl -> new CloudFoundryServer(tpl.getT1().getName(), tpl.getT1().getUrls().get(0), port))
|
||||
.collectList()
|
||||
.blockOptional()
|
||||
.orElse(new ArrayList<>());
|
||||
return this.cloudFoundryService.getApplicationInstances(this.serviceId)
|
||||
.map(tpl -> new CloudFoundryServer(tpl.getT1().getName(),
|
||||
tpl.getT1().getUrls().get(0), port))
|
||||
.collectList().blockOptional().orElse(new ArrayList<>());
|
||||
}
|
||||
|
||||
/** for testing */ String getServiceId() {
|
||||
return serviceId;
|
||||
// for testing
|
||||
String getServiceId() {
|
||||
return this.serviceId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -26,9 +26,10 @@ import java.lang.annotation.Target;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* Convenience annotation for clients to enable Cloud Foundry discovery configuration (specifically).
|
||||
* Use this (optionally) in case you want discovery and know for sure that it is Cloud Foundry you want.
|
||||
* All it does is turn on discovery and let the auto-configuration find the Cloud Foundry classes.
|
||||
* Convenience annotation for clients to enable Cloud Foundry discovery configuration
|
||||
* (specifically). Use this (optionally) in case you want discovery and know for sure that
|
||||
* it is Cloud Foundry you want. All it does is turn on discovery and let the
|
||||
* auto-configuration find the Cloud Foundry classes.
|
||||
*
|
||||
* @author Josh Long
|
||||
*/
|
||||
@@ -38,4 +39,5 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
@Inherited
|
||||
@EnableDiscoveryClient
|
||||
public @interface EnableCloudFoundryClient {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.cloudfoundry.discovery;
|
||||
|
||||
import com.netflix.client.IClient;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
@@ -26,8 +28,11 @@ import org.springframework.cloud.netflix.ribbon.RibbonClients;
|
||||
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.netflix.client.IClient;
|
||||
|
||||
/**
|
||||
* Auto configuration for Ribbon.
|
||||
*
|
||||
* @author Josh Long
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties
|
||||
@ConditionalOnClass(IClient.class)
|
||||
@@ -36,4 +41,5 @@ import com.netflix.client.IClient;
|
||||
@AutoConfigureAfter(RibbonAutoConfiguration.class)
|
||||
@RibbonClients(defaultConfiguration = CloudFoundryRibbonClientConfiguration.class)
|
||||
public class RibbonCloudFoundryAutoConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.springframework.cloud.cloudfoundry.discovery.RibbonCloudFoundryAutoConfiguration
|
||||
|
||||
# Discovery Client Configuration
|
||||
org.springframework.cloud.client.discovery.EnableDiscoveryClient=\
|
||||
org.springframework.cloud.cloudfoundry.discovery.CloudFoundryDiscoveryClientConfiguration
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-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,7 +27,7 @@ import org.junit.runners.Suite.SuiteClasses;
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses({CloudFoundryServerListTest.class})
|
||||
@SuiteClasses({ CloudFoundryServerListTest.class })
|
||||
@Ignore
|
||||
public class AdhocTestSuite {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package org.springframework.cloud.cloudfoundry.discovery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.cloudfoundry.operations.CloudFoundryOperations;
|
||||
@@ -23,20 +26,17 @@ import org.cloudfoundry.operations.applications.ApplicationDetail;
|
||||
import org.cloudfoundry.operations.applications.ApplicationSummary;
|
||||
import org.cloudfoundry.operations.applications.Applications;
|
||||
import org.cloudfoundry.operations.applications.InstanceDetail;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.cloudfoundry.CloudFoundryService;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.util.function.Tuple2;
|
||||
import reactor.util.function.Tuples;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.cloudfoundry.CloudFoundryService;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
@@ -45,60 +45,53 @@ import static org.mockito.Mockito.mock;
|
||||
public class CloudFoundryDiscoveryClientTest {
|
||||
|
||||
private final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
private CloudFoundryDiscoveryClient cloudFoundryDiscoveryClient;
|
||||
|
||||
private String hiServiceServiceId = "hi-service";
|
||||
|
||||
private CloudFoundryOperations ops;
|
||||
|
||||
private CloudFoundryService svc;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.ops = mock(CloudFoundryOperations.class);
|
||||
this.svc = mock(CloudFoundryService.class);
|
||||
this.cloudFoundryDiscoveryClient = new CloudFoundryDiscoveryClient(this.ops, this.svc,
|
||||
new CloudFoundryDiscoveryProperties());
|
||||
this.cloudFoundryDiscoveryClient = new CloudFoundryDiscoveryClient(this.ops,
|
||||
this.svc, new CloudFoundryDiscoveryProperties());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServiceResolution() {
|
||||
Applications apps = mock(Applications.class);
|
||||
ApplicationSummary s = ApplicationSummary.builder()
|
||||
.id(UUID.randomUUID().toString())
|
||||
.instances(2)
|
||||
.memoryLimit(1024)
|
||||
.requestedState("requestedState")
|
||||
.diskQuota(1024)
|
||||
.name(this.hiServiceServiceId)
|
||||
.runningInstances(2)
|
||||
.build();
|
||||
.id(UUID.randomUUID().toString()).instances(2).memoryLimit(1024)
|
||||
.requestedState("requestedState").diskQuota(1024)
|
||||
.name(this.hiServiceServiceId).runningInstances(2).build();
|
||||
Mockito.when(apps.list()).thenReturn(Flux.just(s));
|
||||
Mockito.when(this.ops.applications()).thenReturn(apps);
|
||||
List<String> serviceNames = this.cloudFoundryDiscoveryClient.getServices();
|
||||
Assert.assertTrue("there should be one registered service.", serviceNames.contains(this.hiServiceServiceId));
|
||||
serviceNames.forEach(serviceName -> this.log.debug("\t discovered serviceName: " + serviceName));
|
||||
assertThat(serviceNames.contains(this.hiServiceServiceId))
|
||||
.as("there should be one registered service.").isTrue();
|
||||
serviceNames.forEach(serviceName -> this.log
|
||||
.debug("\t discovered serviceName: " + serviceName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInstances() {
|
||||
ApplicationDetail applicationDetail = ApplicationDetail
|
||||
.builder()
|
||||
.instances(2)
|
||||
.name("my-app")
|
||||
.stack("stack")
|
||||
.memoryLimit(1024)
|
||||
.id("id")
|
||||
.requestedState("requestedState")
|
||||
.runningInstances(2)
|
||||
.url("http://my-app.cfapps.io")
|
||||
.diskQuota(20)
|
||||
.build();
|
||||
InstanceDetail instanceDetail = InstanceDetail
|
||||
.builder()
|
||||
.index("0")
|
||||
.build();
|
||||
Tuple2<ApplicationDetail, InstanceDetail> tuple2 = Tuples.of(applicationDetail, instanceDetail);
|
||||
Mockito.when(svc.getApplicationInstances(this.hiServiceServiceId)).thenReturn(Flux.just(tuple2));
|
||||
ApplicationDetail applicationDetail = ApplicationDetail.builder().instances(2)
|
||||
.name("my-app").stack("stack").memoryLimit(1024).id("id")
|
||||
.requestedState("requestedState").runningInstances(2)
|
||||
.url("http://my-app.cfapps.io").diskQuota(20).build();
|
||||
InstanceDetail instanceDetail = InstanceDetail.builder().index("0").build();
|
||||
Tuple2<ApplicationDetail, InstanceDetail> tuple2 = Tuples.of(applicationDetail,
|
||||
instanceDetail);
|
||||
Mockito.when(this.svc.getApplicationInstances(this.hiServiceServiceId))
|
||||
.thenReturn(Flux.just(tuple2));
|
||||
List<ServiceInstance> instances = this.cloudFoundryDiscoveryClient
|
||||
.getInstances(this.hiServiceServiceId);
|
||||
assertEquals("Wrong instances: " + instances, 1, instances.size());
|
||||
assertThat(instances.size()).as("Wrong instances: " + instances).isEqualTo(1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-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,36 +18,35 @@ package org.springframework.cloud.cloudfoundry.discovery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.netflix.client.config.CommonClientConfigKey;
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import org.cloudfoundry.operations.applications.ApplicationDetail;
|
||||
import org.cloudfoundry.operations.applications.InstanceDetail;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.cloudfoundry.CloudFoundryService;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.util.function.Tuple2;
|
||||
import reactor.util.function.Tuples;
|
||||
|
||||
import com.netflix.client.config.CommonClientConfigKey;
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import org.springframework.cloud.cloudfoundry.CloudFoundryService;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.util.function.Tuple2;
|
||||
import reactor.util.function.Tuples;
|
||||
|
||||
/**
|
||||
* @author Josh Long
|
||||
*/
|
||||
public class CloudFoundryServerListTest {
|
||||
|
||||
private CloudFoundryServerList cloudFoundryServerList;
|
||||
|
||||
private String serviceId = "foo-service";
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
IClientConfig iClientConfig = IClientConfig.Builder.newBuilder(this.serviceId)
|
||||
.withSecure(true)
|
||||
.build();
|
||||
.withSecure(true).build();
|
||||
iClientConfig.set(CommonClientConfigKey.SecurePort, 443);
|
||||
|
||||
Tuple2<ApplicationDetail, InstanceDetail> tuple2 = getInstanceDetail();
|
||||
@@ -55,7 +54,8 @@ public class CloudFoundryServerListTest {
|
||||
CloudFoundryService cfs = mock(CloudFoundryService.class);
|
||||
when(cfs.getApplicationInstances(this.serviceId)).thenReturn(Flux.just(tuple2));
|
||||
|
||||
this.cloudFoundryServerList = new CloudFoundryServerList(cfs, new CloudFoundryDiscoveryProperties());
|
||||
this.cloudFoundryServerList = new CloudFoundryServerList(cfs,
|
||||
new CloudFoundryDiscoveryProperties());
|
||||
this.cloudFoundryServerList.initWithNiwsConfig(iClientConfig);
|
||||
}
|
||||
|
||||
@@ -85,8 +85,10 @@ public class CloudFoundryServerListTest {
|
||||
|
||||
@Test
|
||||
public void testListOfServers() {
|
||||
List<CloudFoundryServer> initialListOfServers = this.cloudFoundryServerList.getInitialListOfServers();
|
||||
List<CloudFoundryServer> updatedListOfServers = this.cloudFoundryServerList.getUpdatedListOfServers();
|
||||
List<CloudFoundryServer> initialListOfServers = this.cloudFoundryServerList
|
||||
.getInitialListOfServers();
|
||||
List<CloudFoundryServer> updatedListOfServers = this.cloudFoundryServerList
|
||||
.getUpdatedListOfServers();
|
||||
assertThat(initialListOfServers)
|
||||
.containsExactly(updatedListOfServers.toArray(new CloudFoundryServer[0]))
|
||||
.hasSize(1);
|
||||
@@ -105,7 +107,8 @@ public class CloudFoundryServerListTest {
|
||||
CloudFoundryService cfs = mock(CloudFoundryService.class);
|
||||
when(cfs.getApplicationInstances(this.serviceId)).thenReturn(Flux.just(tuple2));
|
||||
|
||||
CloudFoundryServerList serverList = new CloudFoundryServerList(cfs, new CloudFoundryDiscoveryProperties());
|
||||
CloudFoundryServerList serverList = new CloudFoundryServerList(cfs,
|
||||
new CloudFoundryDiscoveryProperties());
|
||||
serverList.initWithNiwsConfig(iClientConfig);
|
||||
|
||||
CloudFoundryServer server = serverList.getInitialListOfServers().get(0);
|
||||
|
||||
@@ -13,8 +13,8 @@ import org.springframework.web.bind.annotation.RestController
|
||||
@RestController
|
||||
class GreetingRestController {
|
||||
|
||||
@RequestMapping("/hi/{name}")
|
||||
def hi(@PathVariable String name) {
|
||||
[greeting: "Hello, " + name + "!"]
|
||||
}
|
||||
}
|
||||
@RequestMapping("/hi/{name}")
|
||||
def hi(@PathVariable String name) {
|
||||
[greeting: "Hello, " + name + "!"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?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">
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>
|
||||
|
||||
<artifactId>spring-cloud-cloudfoundry-sample</artifactId>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-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,6 +18,7 @@ package org.springframework.cloud.cloudfoundry.sample;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -26,22 +27,19 @@ import org.springframework.cloud.cloudfoundry.discovery.EnableCloudFoundryClient
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* This example uses the Spring Cloud {@code DiscoveryClient} abstraction to list all services
|
||||
* available to the application. It should deployed to a Cloud Foundry organization and space that
|
||||
* has other applications deployed to it.
|
||||
* This example uses the Spring Cloud {@code DiscoveryClient} abstraction to list all
|
||||
* services available to the application. It should deployed to a Cloud Foundry
|
||||
* organization and space that has other applications deployed to it.
|
||||
*
|
||||
* There is a sample file in the project root called {@code hi-service.groovy} which can be
|
||||
* deployed using the {@code spring} CLI and the {@code cf} CLI that works appropriately for
|
||||
* this example.
|
||||
* There is a sample file in the project root called {@code hi-service.groovy} which can
|
||||
* be deployed using the {@code spring} CLI and the {@code cf} CLI that works
|
||||
* appropriately for this example.
|
||||
*
|
||||
* Either modify this application's {@code application.yml} configuration file to provide credentials
|
||||
* and other information for the Cloud Foundry the app is deployed to, or set the following
|
||||
* environment variables on the application (using {@code cf set-env}):
|
||||
* Either modify this application's {@code application.yml} configuration file to provide
|
||||
* credentials and other information for the Cloud Foundry the app is deployed to, or set
|
||||
* the following environment variables on the application (using {@code cf set-env}):
|
||||
*
|
||||
* * {@code CF_USERNAME}
|
||||
* * {@code CF_PASSWORD}
|
||||
* * {@code CF_ORG}
|
||||
* * {@code CF_SPACE}
|
||||
* * {@code CF_USERNAME} * {@code CF_PASSWORD} * {@code CF_ORG} * {@code CF_SPACE}
|
||||
*
|
||||
* @author Josh Long
|
||||
* @author Spencer Gibb
|
||||
@@ -59,10 +57,11 @@ public class CloudFoundryApplication {
|
||||
@Bean
|
||||
CommandLineRunner demo(CloudFoundryDiscoveryClient discoveryClient) {
|
||||
Log log = LogFactory.getLog(getClass());
|
||||
return args ->
|
||||
discoveryClient.getServices().forEach(svc -> {
|
||||
log.info("service = " + svc);
|
||||
discoveryClient.getInstances(svc).forEach(si -> log.info("\tinstance = " + si));
|
||||
});
|
||||
return args -> discoveryClient.getServices().forEach(svc -> {
|
||||
log.info("service = " + svc);
|
||||
discoveryClient.getInstances(svc)
|
||||
.forEach(si -> log.info("\tinstance = " + si));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
spring:
|
||||
application:
|
||||
name: test-app
|
||||
cloud:
|
||||
cloudfoundry:
|
||||
username: ${CF_USERNAME:starbuxman@gmail.com}
|
||||
password: ${CF_PASSWORD:xxxx}
|
||||
org: ${CF_ORG:}
|
||||
space: ${CF_SPACE:}
|
||||
application:
|
||||
name: test-app
|
||||
cloud:
|
||||
cloudfoundry:
|
||||
username: ${CF_USERNAME:starbuxman@gmail.com}
|
||||
password: ${CF_PASSWORD:xxxx}
|
||||
org: ${CF_ORG:}
|
||||
space: ${CF_SPACE:}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -13,11 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.cloudfoundry.sample;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?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">
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>
|
||||
|
||||
<artifactId>spring-cloud-cloudfoundry-web</artifactId>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.cloudfoundry.environment;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.cloudfoundry.session;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
@@ -33,4 +34,4 @@ import org.springframework.context.annotation.Import;
|
||||
@Import(StickyFilterConfiguration.class)
|
||||
public @interface EnableStickyFilter {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.cloudfoundry.session;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -52,7 +53,8 @@ public class StickyFilterConfiguration {
|
||||
HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
if (!response.containsHeader("Set-Cookie")) {
|
||||
response.addCookie(new Cookie("JSESSIONID", cookie));
|
||||
response.addCookie(new Cookie("JSESSIONID",
|
||||
StickyFilterConfiguration.this.cookie));
|
||||
}
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
spring.cloud.cloudfoundry.web.cookie=${random}
|
||||
eureka.instance.metadata-map.cookie=${spring.cloud.cloudfoundry.web.cookie}
|
||||
eureka.instance.metadata-map.cookie=${spring.cloud.cloudfoundry.web.cookie}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -13,20 +13,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.cloudfoundry.environment;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.cloud.cloudfoundry.environment.VcapServiceCredentialsEnvironmentPostProcessor.STRING_OBJECT_MAP;
|
||||
|
||||
/**
|
||||
@@ -42,66 +43,85 @@ public class VcapServiceCredentialsEnvironmentPostProcessorTests {
|
||||
@Test
|
||||
public void noop() {
|
||||
this.listener.postProcessEnvironment(this.environment, new SpringApplication());
|
||||
Map<String, Object> properties = Binder.get(environment)
|
||||
.bind("security.oauth2", STRING_OBJECT_MAP).orElseGet(Collections::emptyMap);
|
||||
assertTrue(properties.isEmpty());
|
||||
Map<String, Object> properties = Binder.get(this.environment)
|
||||
.bind("security.oauth2", STRING_OBJECT_MAP)
|
||||
.orElseGet(Collections::emptyMap);
|
||||
assertThat(properties.isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addClientId() {
|
||||
TestPropertyValues.of("vcap.services.sso.credentials.clientId:foo").applyTo(this.environment);
|
||||
TestPropertyValues.of("vcap.services.sso.credentials.clientId:foo")
|
||||
.applyTo(this.environment);
|
||||
this.listener.postProcessEnvironment(this.environment, new SpringApplication());
|
||||
assertEquals("foo", this.environment
|
||||
.resolvePlaceholders("${security.oauth2.client.client-id}"));
|
||||
assertThat(this.environment
|
||||
.resolvePlaceholders("${security.oauth2.client.client-id}"))
|
||||
.isEqualTo("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addClientIdUnderscores() {
|
||||
TestPropertyValues.of("vcap.services.sso.credentials.client-id:foo").applyTo(this.environment);
|
||||
TestPropertyValues.of("vcap.services.sso.credentials.client-id:foo")
|
||||
.applyTo(this.environment);
|
||||
this.listener.postProcessEnvironment(this.environment, new SpringApplication());
|
||||
assertEquals("foo", this.environment
|
||||
.resolvePlaceholders("${security.oauth2.client.client-id}"));
|
||||
assertThat(this.environment
|
||||
.resolvePlaceholders("${security.oauth2.client.client-id}"))
|
||||
.isEqualTo("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addTokenUri() {
|
||||
TestPropertyValues.of( "vcap.services.sso.credentials.accessTokenUri:http://example.com").applyTo(this.environment);
|
||||
TestPropertyValues
|
||||
.of("vcap.services.sso.credentials.accessTokenUri:http://example.com")
|
||||
.applyTo(this.environment);
|
||||
this.listener.postProcessEnvironment(this.environment, new SpringApplication());
|
||||
assertEquals("http://example.com", this.environment
|
||||
.resolvePlaceholders("${security.oauth2.client.access-token-uri}"));
|
||||
assertThat(this.environment
|
||||
.resolvePlaceholders("${security.oauth2.client.access-token-uri}"))
|
||||
.isEqualTo("http://example.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addTokenUriAuthDomain() {
|
||||
TestPropertyValues.of("vcap.services.sso.credentials.auth-domain:http://example.com").applyTo(this.environment);
|
||||
TestPropertyValues
|
||||
.of("vcap.services.sso.credentials.auth-domain:http://example.com")
|
||||
.applyTo(this.environment);
|
||||
this.listener.postProcessEnvironment(this.environment, new SpringApplication());
|
||||
assertEquals("http://example.com/oauth/token", this.environment
|
||||
.resolvePlaceholders("${security.oauth2.client.access-token-uri}"));
|
||||
assertThat(this.environment
|
||||
.resolvePlaceholders("${security.oauth2.client.access-token-uri}"))
|
||||
.isEqualTo("http://example.com/oauth/token");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addUserInfoUri() {
|
||||
TestPropertyValues.of( "vcap.services.sso.credentials.userInfoUri:http://example.com").applyTo(this.environment);
|
||||
TestPropertyValues
|
||||
.of("vcap.services.sso.credentials.userInfoUri:http://example.com")
|
||||
.applyTo(this.environment);
|
||||
this.listener.postProcessEnvironment(this.environment, new SpringApplication());
|
||||
assertEquals("http://example.com", this.environment
|
||||
.resolvePlaceholders("${security.oauth2.resource.user-info-uri}"));
|
||||
assertThat(this.environment
|
||||
.resolvePlaceholders("${security.oauth2.resource.user-info-uri}"))
|
||||
.isEqualTo("http://example.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addServiceId() {
|
||||
TestPropertyValues.of("vcap.services.my.credentials.accessTokenUri:http://example.com",
|
||||
"security.oauth2.sso.serviceId:my").applyTo(this.environment);
|
||||
TestPropertyValues
|
||||
.of("vcap.services.my.credentials.accessTokenUri:http://example.com",
|
||||
"security.oauth2.sso.serviceId:my")
|
||||
.applyTo(this.environment);
|
||||
this.listener.postProcessEnvironment(this.environment, new SpringApplication());
|
||||
assertEquals("http://example.com", this.environment
|
||||
.resolvePlaceholders("${security.oauth2.client.access-token-uri}"));
|
||||
assertThat(this.environment
|
||||
.resolvePlaceholders("${security.oauth2.client.access-token-uri}"))
|
||||
.isEqualTo("http://example.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addJwtKeyUri() {
|
||||
TestPropertyValues.of("vcap.services.sso.credentials.keyUri:http://example.com").applyTo(this.environment);
|
||||
TestPropertyValues.of("vcap.services.sso.credentials.keyUri:http://example.com")
|
||||
.applyTo(this.environment);
|
||||
this.listener.postProcessEnvironment(this.environment, new SpringApplication());
|
||||
assertEquals("http://example.com", this.environment
|
||||
.resolvePlaceholders("${security.oauth2.resource.jwt.key-uri}"));
|
||||
assertThat(this.environment
|
||||
.resolvePlaceholders("${security.oauth2.resource.jwt.key-uri}"))
|
||||
.isEqualTo("http://example.com");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?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">
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>
|
||||
|
||||
@@ -1 +1 @@
|
||||
provides: spring-cloud-security
|
||||
provides: spring-cloud-security
|
||||
|
||||
Reference in New Issue
Block a user