DSL: Move Java DSL to the separate repo
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
Spring Integration Java DSL
|
||||
===============================
|
||||
|
||||
See the
|
||||
[Spring Integration Java DSL Reference](https://github.com/spring-projects/spring-integration-extensions/wiki/Spring-Integration-Java-DSL-Reference)
|
||||
for more info.
|
||||
The project is hosted on https://github.com/spring-projects/spring-integration-java-dsl
|
||||
@@ -1,253 +0,0 @@
|
||||
description = 'Spring Integration Java DSL'
|
||||
|
||||
apply plugin: 'java'
|
||||
apply from: "${rootProject.projectDir}/publish-maven.gradle"
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url 'http://repo.spring.io/plugins-release' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'org.springframework.build.gradle:spring-io-plugin:0.0.3.RELEASE'
|
||||
}
|
||||
}
|
||||
|
||||
group = 'org.springframework.integration'
|
||||
|
||||
repositories {
|
||||
if (version.endsWith('BUILD-SNAPSHOT') || project.hasProperty('platformVersion')) {
|
||||
maven { url 'http://repo.spring.io/libs-snapshot' }
|
||||
}
|
||||
maven { url 'http://repo.spring.io/libs-milestone' }
|
||||
}
|
||||
|
||||
if (project.hasProperty('platformVersion')) {
|
||||
apply plugin: 'spring-io'
|
||||
|
||||
dependencies {
|
||||
springIoVersions "io.spring.platform:platform-versions:${platformVersion}@properties"
|
||||
}
|
||||
}
|
||||
|
||||
compileJava {
|
||||
sourceCompatibility = 1.6
|
||||
targetCompatibility = 1.6
|
||||
}
|
||||
|
||||
compileTestJava {
|
||||
sourceCompatibility = 1.8
|
||||
}
|
||||
|
||||
ext {
|
||||
activeMqVersion = '5.10.0'
|
||||
apacheSshdVersion = '0.10.1'
|
||||
embedMongoVersion = '1.46.0'
|
||||
ftpServerVersion = '1.0.6'
|
||||
hsqldbVersion = '2.3.2'
|
||||
jacocoVersion = '0.7.1.201405082137'
|
||||
jmsApiVersion = '1.1-rev-1'
|
||||
mailVersion = '1.4.7'
|
||||
slf4jVersion = '1.7.7'
|
||||
springIntegrationVersion = '4.0.4.RELEASE'
|
||||
springBootVersion = '1.1.8.RELEASE'
|
||||
|
||||
linkHomepage = 'https://github.com/spring-projects/spring-integration-extensions'
|
||||
linkCi = 'https://build.spring.io/browse/INTEXT'
|
||||
linkIssue = 'https://jira.spring.io/browse/INTEXT'
|
||||
linkScmUrl = 'https://github.com/spring-projects/spring-integration-extensions'
|
||||
linkScmConnection = 'https://github.com/spring-projects/spring-integration-extensions.git'
|
||||
linkScmDevConnection = 'git@github.com:spring-projects/spring-integration-extensions.git'
|
||||
}
|
||||
|
||||
eclipse.project.natures += 'org.springframework.ide.eclipse.core.springnature'
|
||||
|
||||
// See http://www.gradle.org/docs/current/userguide/dependency_management.html#sub:configurations
|
||||
// and http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.ConfigurationContainer.html
|
||||
configurations {
|
||||
jacoco //Configuration Group used by Sonar to provide Code Coverage using JaCoCo
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.springframework.integration:spring-integration-core:$springIntegrationVersion"
|
||||
|
||||
['spring-integration-amqp'
|
||||
, 'spring-integration-event'
|
||||
, 'spring-integration-feed'
|
||||
, 'spring-integration-ftp'
|
||||
, 'spring-integration-gemfire'
|
||||
, 'spring-integration-http'
|
||||
, 'spring-integration-jdbc'
|
||||
, 'spring-integration-jms'
|
||||
, 'spring-integration-jmx'
|
||||
, 'spring-integration-jpa'
|
||||
, 'spring-integration-mail'
|
||||
, 'spring-integration-mongodb'
|
||||
, 'spring-integration-mqtt'
|
||||
, 'spring-integration-redis'
|
||||
, 'spring-integration-rmi'
|
||||
, 'spring-integration-sftp'
|
||||
, 'spring-integration-stream'
|
||||
, 'spring-integration-syslog'
|
||||
, 'spring-integration-twitter'
|
||||
, 'spring-integration-ws'
|
||||
, 'spring-integration-xml'
|
||||
, 'spring-integration-xmpp'].each {
|
||||
compile("org.springframework.integration:$it:$springIntegrationVersion", optional)
|
||||
}
|
||||
compile ("javax.jms:jms-api:$jmsApiVersion", provided)
|
||||
compile ("javax.mail:javax.mail-api:$mailVersion", provided)
|
||||
|
||||
testCompile "org.springframework.integration:spring-integration-test:$springIntegrationVersion"
|
||||
testCompile "de.flapdoodle.embed:de.flapdoodle.embed.mongo:$embedMongoVersion"
|
||||
testCompile "org.apache.ftpserver:ftpserver-core:$ftpServerVersion"
|
||||
testCompile "org.apache.sshd:sshd-core:$apacheSshdVersion"
|
||||
testCompile "org.springframework.boot:spring-boot-autoconfigure:$springBootVersion"
|
||||
|
||||
testRuntime "org.slf4j:slf4j-log4j12:$slf4jVersion"
|
||||
testRuntime("org.apache.activemq:activemq-broker:$activeMqVersion")
|
||||
testRuntime("org.apache.activemq:activemq-kahadb-store:$activeMqVersion") {
|
||||
exclude group: "org.springframework"
|
||||
}
|
||||
testRuntime "com.sun.mail:javax.mail:$mailVersion"
|
||||
testRuntime "com.sun.mail:smtp:$mailVersion"
|
||||
testRuntime "com.sun.mail:pop3:$mailVersion"
|
||||
testRuntime "com.sun.mail:imap:$mailVersion"
|
||||
testRuntime "org.hsqldb:hsqldb:$hsqldbVersion"
|
||||
|
||||
jacoco "org.jacoco:org.jacoco.agent:$jacocoVersion:runtime"
|
||||
}
|
||||
|
||||
// enable all compiler warnings; individual projects may customize further
|
||||
[compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:all,-options']
|
||||
|
||||
test {
|
||||
// suppress all console output during testing unless running `gradle -i`
|
||||
logging.captureStandardOutput(LogLevel.INFO)
|
||||
jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=*"
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
classifier = 'sources'
|
||||
from sourceSets.main.allJava
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar) {
|
||||
classifier = 'javadoc'
|
||||
from javadoc
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
archives javadocJar
|
||||
}
|
||||
|
||||
apply plugin: 'sonar-runner'
|
||||
|
||||
sonarRunner {
|
||||
sonarProperties {
|
||||
property "sonar.jacoco.reportPath", "${buildDir.name}/jacoco.exec"
|
||||
property "sonar.links.homepage", linkHomepage
|
||||
property "sonar.links.ci", linkCi
|
||||
property "sonar.links.issue", linkIssue
|
||||
property "sonar.links.scm", linkScmUrl
|
||||
property "sonar.links.scm_dev", linkScmDevConnection
|
||||
property "sonar.java.coveragePlugin", "jacoco"
|
||||
}
|
||||
}
|
||||
|
||||
task api(type: Javadoc) {
|
||||
group = 'Documentation'
|
||||
description = 'Generates the Javadoc API documentation.'
|
||||
title = "${rootProject.description} ${version} API"
|
||||
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
|
||||
options.author = true
|
||||
options.header = rootProject.description
|
||||
options.overview = 'src/api/overview.html'
|
||||
|
||||
source = sourceSets.main.allJava
|
||||
classpath = project.sourceSets.main.compileClasspath
|
||||
destinationDir = new File(buildDir, "api")
|
||||
}
|
||||
|
||||
task docsZip(type: Zip) {
|
||||
group = 'Distribution'
|
||||
classifier = 'docs'
|
||||
description = "Builds -${classifier} archive containing the api " +
|
||||
"for deployment at static.springframework.org/spring-integration/docs."
|
||||
|
||||
from(api) {
|
||||
into 'api'
|
||||
}
|
||||
}
|
||||
|
||||
task distZip(type: Zip, dependsOn: docsZip) {
|
||||
group = 'Distribution'
|
||||
classifier = 'dist'
|
||||
description = "Builds -${classifier} archive, containing all jars and docs, " +
|
||||
"suitable for community download page."
|
||||
|
||||
ext.baseDir = "${project.name}-${project.version}";
|
||||
|
||||
from('src/dist') {
|
||||
include 'license.txt'
|
||||
include 'notice.txt'
|
||||
into "${baseDir}"
|
||||
}
|
||||
|
||||
from(zipTree(docsZip.archivePath)) {
|
||||
into "${baseDir}/docs"
|
||||
}
|
||||
|
||||
into("${baseDir}/libs") {
|
||||
from project.jar
|
||||
from project.sourcesJar
|
||||
from project.javadocJar
|
||||
}
|
||||
}
|
||||
|
||||
// Create an optional "with dependencies" distribution.
|
||||
// Not published by default; only for use when building from source.
|
||||
task depsZip(type: Zip, dependsOn: distZip) { zipTask ->
|
||||
group = 'Distribution'
|
||||
classifier = 'dist-with-deps'
|
||||
description = "Builds -${classifier} archive, containing everything " +
|
||||
"in the -${distZip.classifier} archive plus all dependencies."
|
||||
|
||||
from zipTree(distZip.archivePath)
|
||||
|
||||
gradle.taskGraph.whenReady { taskGraph ->
|
||||
if (taskGraph.hasTask(":${zipTask.name}")) {
|
||||
def projectName = rootProject.name
|
||||
def artifacts = new HashSet()
|
||||
|
||||
rootProject.configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { artifact ->
|
||||
def dependency = artifact.moduleVersion.id
|
||||
if (!projectName.equals(dependency.name)) {
|
||||
artifacts << artifact.file
|
||||
}
|
||||
}
|
||||
|
||||
zipTask.from(artifacts) {
|
||||
into "${distZip.baseDir}/deps"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives distZip
|
||||
archives docsZip
|
||||
}
|
||||
|
||||
task dist(dependsOn: assemble) {
|
||||
group = 'Distribution'
|
||||
description = 'Builds -dist, -docs and distribution archives.'
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
description = 'Generates gradlew[.bat] scripts'
|
||||
gradleVersion = '1.12'
|
||||
distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
version=1.0.0.BUILD-SNAPSHOT
|
||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
#Wed Jul 23 18:56:31 EEST 2014
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
|
||||
164
spring-integration-java-dsl/gradlew
vendored
164
spring-integration-java-dsl/gradlew
vendored
@@ -1,164 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
90
spring-integration-java-dsl/gradlew.bat
vendored
90
spring-integration-java-dsl/gradlew.bat
vendored
@@ -1,90 +0,0 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,80 +0,0 @@
|
||||
apply plugin: 'maven'
|
||||
|
||||
ext.optionalDeps = []
|
||||
ext.providedDeps = []
|
||||
|
||||
ext.optional = { optionalDeps << it }
|
||||
ext.provided = { providedDeps << it }
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
customizePom(pom, project)
|
||||
}
|
||||
}
|
||||
|
||||
def customizePom(pom, gradleProject) {
|
||||
pom.whenConfigured { generatedPom ->
|
||||
// respect 'optional' and 'provided' dependencies
|
||||
gradleProject.optionalDeps.each { dep ->
|
||||
generatedPom.dependencies.find { it.artifactId == dep.name }?.optional = true
|
||||
}
|
||||
gradleProject.providedDeps.each { dep ->
|
||||
generatedPom.dependencies.find { it.artifactId == dep.name }?.scope = 'provided'
|
||||
}
|
||||
|
||||
// eliminate test-scoped dependencies (no need in maven central poms)
|
||||
generatedPom.dependencies.removeAll { dep ->
|
||||
dep.scope == 'test'
|
||||
}
|
||||
|
||||
// add all items necessary for maven central publication
|
||||
generatedPom.project {
|
||||
name = gradleProject.description
|
||||
description = gradleProject.description
|
||||
url = linkHomepage
|
||||
organization {
|
||||
name = 'SpringIO'
|
||||
url = 'http://spring.io'
|
||||
}
|
||||
licenses {
|
||||
license {
|
||||
name 'The Apache Software License, Version 2.0'
|
||||
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||
distribution 'repo'
|
||||
}
|
||||
}
|
||||
|
||||
scm {
|
||||
url = linkScmUrl
|
||||
connection = 'scm:git:' + linkScmConnection
|
||||
developerConnection = 'scm:git:' + linkScmDevConnection
|
||||
}
|
||||
|
||||
issueManagement {
|
||||
system = "Jira"
|
||||
url = linkIssue
|
||||
}
|
||||
|
||||
developers {
|
||||
developer {
|
||||
id = 'markfisher'
|
||||
name = 'Mark Fisher'
|
||||
email = 'mfisher@pivotal.io'
|
||||
roles = ["project founder and lead emeritus"]
|
||||
}
|
||||
developer {
|
||||
id = 'garyrussell'
|
||||
name = 'Gary Russell'
|
||||
email = 'grussell@pivotal.io'
|
||||
roles = ["project lead"]
|
||||
}
|
||||
developer {
|
||||
id = 'abilan'
|
||||
name = 'Artem Bilan'
|
||||
email = 'abilan@pivotal.io'
|
||||
roles = ["project lead"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
This document is the API specification for Spring Integration
|
||||
<hr/>
|
||||
<div id="overviewBody">
|
||||
<p>
|
||||
For further API reference and developer documentation, see the
|
||||
<a href="http://static.springsource.org/spring-integration/reference" target="_top">Spring
|
||||
Integration reference documentation</a>.
|
||||
That documentation contains more detailed, developer-targeted
|
||||
descriptions, with conceptual overviews, definitions of terms,
|
||||
workarounds, and working code examples.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If you are interested in commercial training, consultancy, and
|
||||
support for Spring Integration, please visit <a href="http://www.springsource.com" target="_top">
|
||||
http://www.springsource.com</a>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
201
spring-integration-java-dsl/src/dist/license.txt
vendored
201
spring-integration-java-dsl/src/dist/license.txt
vendored
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
21
spring-integration-java-dsl/src/dist/notice.txt
vendored
21
spring-integration-java-dsl/src/dist/notice.txt
vendored
@@ -1,21 +0,0 @@
|
||||
========================================================================
|
||||
== NOTICE file corresponding to section 4 d of the Apache License, ==
|
||||
== Version 2.0, in this case for the Spring Integration distribution. ==
|
||||
========================================================================
|
||||
|
||||
This product includes software developed by
|
||||
the Apache Software Foundation (http://www.apache.org).
|
||||
|
||||
The end-user documentation included with a redistribution, if any,
|
||||
must include the following acknowledgement:
|
||||
|
||||
"This product includes software developed by the Spring Framework
|
||||
Project (http://www.springframework.org)."
|
||||
|
||||
Alternatively, this acknowledgement may appear in the software itself,
|
||||
if and wherever such third-party acknowledgements normally appear.
|
||||
|
||||
The names "Spring", "Spring Framework", and "Spring Integration" must
|
||||
not be used to endorse or promote products derived from this software
|
||||
without prior written permission. For written permission, please contact
|
||||
enquiries@springsource.com.
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import org.springframework.integration.dsl.core.MessageHandlerSpec;
|
||||
import org.springframework.integration.router.AbstractMessageRouter;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class AbstractRouterSpec<S extends AbstractRouterSpec<S, R>, R extends AbstractMessageRouter>
|
||||
extends MessageHandlerSpec<S, R> {
|
||||
|
||||
AbstractRouterSpec(R router) {
|
||||
this.target = router;
|
||||
}
|
||||
|
||||
public S ignoreSendFailures(boolean ignoreSendFailures) {
|
||||
this.target.setIgnoreSendFailures(ignoreSendFailures);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S applySequence(boolean applySequence) {
|
||||
this.target.setApplySequence(applySequence);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected R doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.integration.dsl.amqp.Amqp;
|
||||
import org.springframework.integration.dsl.amqp.AmqpOutboundEndpointSpec;
|
||||
import org.springframework.integration.dsl.file.FileWritingMessageHandlerSpec;
|
||||
import org.springframework.integration.dsl.file.Files;
|
||||
import org.springframework.integration.dsl.ftp.Ftp;
|
||||
import org.springframework.integration.dsl.ftp.FtpMessageHandlerSpec;
|
||||
import org.springframework.integration.dsl.ftp.FtpOutboundGatewaySpec;
|
||||
import org.springframework.integration.dsl.jms.Jms;
|
||||
import org.springframework.integration.dsl.jms.JmsOutboundChannelAdapterSpec;
|
||||
import org.springframework.integration.dsl.jms.JmsOutboundGatewaySpec;
|
||||
import org.springframework.integration.dsl.mail.Mail;
|
||||
import org.springframework.integration.dsl.mail.MailSendingMessageHandlerSpec;
|
||||
import org.springframework.integration.dsl.sftp.Sftp;
|
||||
import org.springframework.integration.dsl.sftp.SftpMessageHandlerSpec;
|
||||
import org.springframework.integration.dsl.sftp.SftpOutboundGatewaySpec;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.file.remote.RemoteFileTemplate;
|
||||
import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway;
|
||||
import org.springframework.integration.file.remote.session.SessionFactory;
|
||||
import org.springframework.integration.file.support.FileExistsMode;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class Adapters {
|
||||
|
||||
public AmqpOutboundEndpointSpec amqp(AmqpTemplate amqpTemplate) {
|
||||
return Amqp.outboundAdapter(amqpTemplate);
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec amqpGateway(AmqpTemplate amqpTemplate) {
|
||||
return Amqp.outboundGateway(amqpTemplate);
|
||||
}
|
||||
|
||||
public FileWritingMessageHandlerSpec file(File destinationDirectory) {
|
||||
return Files.outboundAdapter(destinationDirectory);
|
||||
}
|
||||
|
||||
public FileWritingMessageHandlerSpec file(String directoryExpression) {
|
||||
return Files.outboundAdapter(directoryExpression);
|
||||
}
|
||||
|
||||
public <P> FileWritingMessageHandlerSpec file(Function<Message<P>, ?> directoryFunction) {
|
||||
return Files.outboundAdapter(directoryFunction);
|
||||
}
|
||||
|
||||
public FileWritingMessageHandlerSpec fileGateway(File destinationDirectory) {
|
||||
return Files.outboundGateway(destinationDirectory);
|
||||
}
|
||||
|
||||
public FileWritingMessageHandlerSpec fileGateway(String directoryExpression) {
|
||||
return Files.outboundGateway(directoryExpression);
|
||||
}
|
||||
|
||||
public <P> FileWritingMessageHandlerSpec fileGateway(Function<Message<P>, ?> directoryFunction) {
|
||||
return Files.outboundGateway(directoryFunction);
|
||||
}
|
||||
|
||||
public FtpMessageHandlerSpec ftp(SessionFactory<FTPFile> sessionFactory) {
|
||||
return Ftp.outboundAdapter(sessionFactory);
|
||||
}
|
||||
|
||||
public FtpMessageHandlerSpec ftp(SessionFactory<FTPFile> sessionFactory, FileExistsMode fileExistsMode) {
|
||||
return Ftp.outboundAdapter(sessionFactory, fileExistsMode);
|
||||
}
|
||||
|
||||
public FtpMessageHandlerSpec ftp(RemoteFileTemplate<FTPFile> remoteFileTemplate) {
|
||||
return Ftp.outboundAdapter(remoteFileTemplate);
|
||||
}
|
||||
|
||||
public FtpMessageHandlerSpec ftp(RemoteFileTemplate<FTPFile> remoteFileTemplate, FileExistsMode fileExistsMode) {
|
||||
return Ftp.outboundAdapter(remoteFileTemplate, fileExistsMode);
|
||||
}
|
||||
|
||||
public FtpOutboundGatewaySpec ftpGateway(SessionFactory<FTPFile> sessionFactory,
|
||||
AbstractRemoteFileOutboundGateway.Command command, String expression) {
|
||||
return Ftp.outboundGateway(sessionFactory, command, expression);
|
||||
}
|
||||
|
||||
public FtpOutboundGatewaySpec ftpGateway(SessionFactory<FTPFile> sessionFactory, String command,
|
||||
String expression) {
|
||||
return Ftp.outboundGateway(sessionFactory, command, expression);
|
||||
}
|
||||
|
||||
public SftpMessageHandlerSpec ftps(SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
|
||||
return Sftp.outboundAdapter(sessionFactory);
|
||||
}
|
||||
|
||||
public SftpMessageHandlerSpec sftp(SessionFactory<ChannelSftp.LsEntry> sessionFactory,
|
||||
FileExistsMode fileExistsMode) {
|
||||
return Sftp.outboundAdapter(sessionFactory, fileExistsMode);
|
||||
}
|
||||
|
||||
public SftpMessageHandlerSpec sftp(RemoteFileTemplate<ChannelSftp.LsEntry> remoteFileTemplate) {
|
||||
return Sftp.outboundAdapter(remoteFileTemplate);
|
||||
}
|
||||
|
||||
public SftpMessageHandlerSpec sftp(RemoteFileTemplate<ChannelSftp.LsEntry> remoteFileTemplate,
|
||||
FileExistsMode fileExistsMode) {
|
||||
return Sftp.outboundAdapter(remoteFileTemplate, fileExistsMode);
|
||||
}
|
||||
|
||||
public SftpOutboundGatewaySpec sftpGateway(SessionFactory<ChannelSftp.LsEntry> sessionFactory,
|
||||
AbstractRemoteFileOutboundGateway.Command command, String expression) {
|
||||
return Sftp.outboundGateway(sessionFactory, command, expression);
|
||||
}
|
||||
|
||||
public SftpOutboundGatewaySpec sftpGateway(SessionFactory<ChannelSftp.LsEntry> sessionFactory, String command,
|
||||
String expression) {
|
||||
return Sftp.outboundGateway(sessionFactory, command, expression);
|
||||
}
|
||||
|
||||
public JmsOutboundChannelAdapterSpec.JmsOutboundChannelSpecTemplateAware jms(ConnectionFactory connectionFactory) {
|
||||
return Jms.outboundAdapter(connectionFactory);
|
||||
}
|
||||
|
||||
public JmsOutboundChannelAdapterSpec<? extends JmsOutboundChannelAdapterSpec<?>> jms(JmsTemplate jmsTemplate) {
|
||||
return Jms.outboundAdapter(jmsTemplate);
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec jmsGateway(ConnectionFactory connectionFactory) {
|
||||
return Jms.outboundGateway(connectionFactory);
|
||||
}
|
||||
|
||||
public MailSendingMessageHandlerSpec mail(String host) {
|
||||
return Mail.outboundAdapter(host);
|
||||
}
|
||||
|
||||
Adapters() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import org.springframework.integration.aggregator.AggregatingMessageHandler;
|
||||
import org.springframework.integration.aggregator.DefaultAggregatingMessageGroupProcessor;
|
||||
import org.springframework.integration.aggregator.ExpressionEvaluatingMessageGroupProcessor;
|
||||
import org.springframework.integration.aggregator.MessageGroupProcessor;
|
||||
import org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class AggregatorSpec extends CorrelationHandlerSpec<AggregatorSpec, AggregatingMessageHandler> {
|
||||
|
||||
private MessageGroupProcessor outputProcessor = new DefaultAggregatingMessageGroupProcessor();
|
||||
|
||||
private boolean expireGroupsUponCompletion;
|
||||
|
||||
AggregatorSpec() {
|
||||
}
|
||||
|
||||
public AggregatorSpec processor(Object target, String methodName) {
|
||||
super.processor(target, methodName);
|
||||
return this.outputProcessor(methodName != null
|
||||
? new MethodInvokingMessageGroupProcessor(target, methodName)
|
||||
: new MethodInvokingMessageGroupProcessor(target));
|
||||
}
|
||||
|
||||
public AggregatorSpec outputExpression(String expression) {
|
||||
return this.outputProcessor(new ExpressionEvaluatingMessageGroupProcessor(expression));
|
||||
}
|
||||
|
||||
public AggregatorSpec outputProcessor(MessageGroupProcessor outputProcessor) {
|
||||
this.outputProcessor = outputProcessor;
|
||||
return _this();
|
||||
}
|
||||
|
||||
public AggregatorSpec expireGroupsUponCompletion(boolean expireGroupsUponCompletion) {
|
||||
this.expireGroupsUponCompletion = expireGroupsUponCompletion;
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregatingMessageHandler doGet() {
|
||||
AggregatingMessageHandler handler = new AggregatingMessageHandler(this.outputProcessor);
|
||||
handler.setExpireGroupsUponCompletion(this.expireGroupsUponCompletion);
|
||||
return this.configure(handler);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,198 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.integration.dsl.amqp.Amqp;
|
||||
import org.springframework.integration.dsl.amqp.AmqpMessageChannelSpec;
|
||||
import org.springframework.integration.dsl.amqp.AmqpPollableMessageChannelSpec;
|
||||
import org.springframework.integration.dsl.amqp.AmqpPublishSubscribeMessageChannelSpec;
|
||||
import org.springframework.integration.dsl.channel.DirectChannelSpec;
|
||||
import org.springframework.integration.dsl.channel.ExecutorChannelSpec;
|
||||
import org.springframework.integration.dsl.channel.MessageChannels;
|
||||
import org.springframework.integration.dsl.channel.PriorityChannelSpec;
|
||||
import org.springframework.integration.dsl.channel.PublishSubscribeChannelSpec;
|
||||
import org.springframework.integration.dsl.channel.QueueChannelSpec;
|
||||
import org.springframework.integration.dsl.channel.RendezvousChannelSpec;
|
||||
import org.springframework.integration.dsl.jms.Jms;
|
||||
import org.springframework.integration.dsl.jms.JmsMessageChannelSpec;
|
||||
import org.springframework.integration.dsl.jms.JmsPollableMessageChannelSpec;
|
||||
import org.springframework.integration.dsl.jms.JmsPublishSubscribeMessageChannelSpec;
|
||||
import org.springframework.integration.store.ChannelMessageStore;
|
||||
import org.springframework.integration.store.PriorityCapableChannelMessageStore;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class Channels {
|
||||
|
||||
public DirectChannelSpec direct() {
|
||||
return MessageChannels.direct();
|
||||
}
|
||||
|
||||
public DirectChannelSpec direct(String id) {
|
||||
return MessageChannels.direct(id);
|
||||
}
|
||||
|
||||
public QueueChannelSpec queue() {
|
||||
return MessageChannels.queue();
|
||||
}
|
||||
|
||||
public QueueChannelSpec queue(String id) {
|
||||
return MessageChannels.queue(id);
|
||||
}
|
||||
|
||||
public QueueChannelSpec queue(Integer capacity) {
|
||||
return MessageChannels.queue(capacity);
|
||||
}
|
||||
|
||||
public QueueChannelSpec queue(String id, Integer capacity) {
|
||||
return MessageChannels.queue(id, capacity);
|
||||
}
|
||||
|
||||
public QueueChannelSpec queue(Queue<Message<?>> queue) {
|
||||
return MessageChannels.queue(queue);
|
||||
}
|
||||
|
||||
public QueueChannelSpec queue(String id, Queue<Message<?>> queue) {
|
||||
return MessageChannels.queue(id, queue);
|
||||
}
|
||||
|
||||
public QueueChannelSpec.MessageStoreSpec queue(ChannelMessageStore messageGroupStore, Object groupId) {
|
||||
return MessageChannels.queue(messageGroupStore, groupId);
|
||||
}
|
||||
|
||||
public QueueChannelSpec.MessageStoreSpec queue(String id, ChannelMessageStore messageGroupStore, Object groupId) {
|
||||
return MessageChannels.queue(id, messageGroupStore, groupId);
|
||||
}
|
||||
|
||||
public PriorityChannelSpec priority() {
|
||||
return MessageChannels.priority();
|
||||
}
|
||||
|
||||
public PriorityChannelSpec priority(String id) {
|
||||
return MessageChannels.priority(id);
|
||||
}
|
||||
|
||||
public QueueChannelSpec.MessageStoreSpec priority(String id, PriorityCapableChannelMessageStore messageGroupStore,
|
||||
Object groupId) {
|
||||
return MessageChannels.priority(id, messageGroupStore, groupId);
|
||||
}
|
||||
|
||||
public QueueChannelSpec.MessageStoreSpec priority(PriorityCapableChannelMessageStore messageGroupStore,
|
||||
Object groupId) {
|
||||
return MessageChannels.priority(messageGroupStore, groupId);
|
||||
}
|
||||
|
||||
public RendezvousChannelSpec rendezvous() {
|
||||
return MessageChannels.rendezvous();
|
||||
}
|
||||
|
||||
public RendezvousChannelSpec rendezvous(String id) {
|
||||
return MessageChannels.rendezvous(id);
|
||||
}
|
||||
|
||||
public PublishSubscribeChannelSpec<? extends PublishSubscribeChannelSpec<?>> publishSubscribe() {
|
||||
return MessageChannels.publishSubscribe();
|
||||
}
|
||||
|
||||
public PublishSubscribeChannelSpec<? extends PublishSubscribeChannelSpec<?>> publishSubscribe(Executor executor) {
|
||||
return MessageChannels.publishSubscribe(executor);
|
||||
}
|
||||
|
||||
public PublishSubscribeChannelSpec<? extends PublishSubscribeChannelSpec<?>> publishSubscribe(String id,
|
||||
Executor executor) {
|
||||
return MessageChannels.publishSubscribe(id, executor);
|
||||
}
|
||||
|
||||
public PublishSubscribeChannelSpec<? extends PublishSubscribeChannelSpec<?>> publishSubscribe(String id) {
|
||||
return MessageChannels.publishSubscribe(id);
|
||||
}
|
||||
|
||||
public ExecutorChannelSpec executor(Executor executor) {
|
||||
return MessageChannels.executor(executor);
|
||||
}
|
||||
|
||||
public ExecutorChannelSpec executor(String id, Executor executor) {
|
||||
return MessageChannels.executor(id, executor);
|
||||
}
|
||||
|
||||
public AmqpPollableMessageChannelSpec<? extends AmqpPollableMessageChannelSpec<?>> amqpPollable(
|
||||
ConnectionFactory connectionFactory) {
|
||||
return Amqp.pollableChannel(connectionFactory);
|
||||
}
|
||||
|
||||
public AmqpPollableMessageChannelSpec<? extends AmqpPollableMessageChannelSpec<?>> amqpPollable(String id,
|
||||
ConnectionFactory connectionFactory) {
|
||||
return Amqp.pollableChannel(id, connectionFactory);
|
||||
}
|
||||
|
||||
public AmqpMessageChannelSpec<? extends AmqpMessageChannelSpec<?>> amqp(ConnectionFactory connectionFactory) {
|
||||
return Amqp.channel(connectionFactory);
|
||||
}
|
||||
|
||||
public AmqpMessageChannelSpec<? extends AmqpMessageChannelSpec<?>> amqp(String id,
|
||||
ConnectionFactory connectionFactory) {
|
||||
return Amqp.channel(id, connectionFactory);
|
||||
}
|
||||
|
||||
public static AmqpPublishSubscribeMessageChannelSpec amqpPublishSubscribe(ConnectionFactory connectionFactory) {
|
||||
return Amqp.publishSubscribeChannel(connectionFactory);
|
||||
}
|
||||
|
||||
public static AmqpPublishSubscribeMessageChannelSpec amqpPublishSubscribe(String id,
|
||||
ConnectionFactory connectionFactory) {
|
||||
return Amqp.publishSubscribeChannel(id, connectionFactory);
|
||||
}
|
||||
|
||||
public JmsPollableMessageChannelSpec<? extends JmsPollableMessageChannelSpec<?>> jmsPollable(
|
||||
javax.jms.ConnectionFactory connectionFactory) {
|
||||
return Jms.pollableChannel(connectionFactory);
|
||||
}
|
||||
|
||||
public JmsPollableMessageChannelSpec<? extends JmsPollableMessageChannelSpec<?>> jmsPollable(String id,
|
||||
javax.jms.ConnectionFactory connectionFactory) {
|
||||
return Jms.pollableChannel(id, connectionFactory);
|
||||
}
|
||||
|
||||
public JmsMessageChannelSpec<? extends JmsMessageChannelSpec<?>> jms(
|
||||
javax.jms.ConnectionFactory connectionFactory) {
|
||||
return Jms.channel(connectionFactory);
|
||||
}
|
||||
|
||||
public JmsMessageChannelSpec<? extends JmsMessageChannelSpec<?>> jms(String id,
|
||||
javax.jms.ConnectionFactory connectionFactory) {
|
||||
return Jms.channel(id, connectionFactory);
|
||||
}
|
||||
|
||||
public JmsPublishSubscribeMessageChannelSpec jmsPublishSubscribe(javax.jms.ConnectionFactory connectionFactory) {
|
||||
return Jms.publishSubscribeChannel(connectionFactory);
|
||||
}
|
||||
|
||||
public JmsPublishSubscribeMessageChannelSpec jmsPublishSubscribe(String id,
|
||||
javax.jms.ConnectionFactory connectionFactory) {
|
||||
return Jms.publishSubscribeChannel(id, connectionFactory);
|
||||
}
|
||||
|
||||
Channels() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler;
|
||||
import org.springframework.integration.aggregator.CorrelationStrategy;
|
||||
import org.springframework.integration.aggregator.ExpressionEvaluatingCorrelationStrategy;
|
||||
import org.springframework.integration.aggregator.ExpressionEvaluatingReleaseStrategy;
|
||||
import org.springframework.integration.aggregator.ReleaseStrategy;
|
||||
import org.springframework.integration.config.CorrelationStrategyFactoryBean;
|
||||
import org.springframework.integration.config.ReleaseStrategyFactoryBean;
|
||||
import org.springframework.integration.dsl.core.MessageHandlerSpec;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.dsl.support.FunctionExpression;
|
||||
import org.springframework.integration.expression.ValueExpression;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class
|
||||
CorrelationHandlerSpec<S extends CorrelationHandlerSpec<S, H>, H extends AbstractCorrelatingMessageHandler>
|
||||
extends MessageHandlerSpec<S, H> {
|
||||
|
||||
protected MessageGroupStore messageStore;
|
||||
|
||||
protected boolean sendPartialResultOnExpiry;
|
||||
|
||||
private long minimumTimeoutForEmptyGroups;
|
||||
|
||||
private Expression groupTimeoutExpression;
|
||||
|
||||
private TaskScheduler taskScheduler;
|
||||
|
||||
private MessageChannel discardChannel;
|
||||
|
||||
private String discardChannelName;
|
||||
|
||||
private CorrelationStrategy correlationStrategy;
|
||||
|
||||
private ReleaseStrategy releaseStrategy;
|
||||
|
||||
public S messageStore(MessageGroupStore messageStore) {
|
||||
this.messageStore = messageStore;
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S sendPartialResultOnExpiry(boolean sendPartialResultOnExpiry) {
|
||||
this.sendPartialResultOnExpiry = sendPartialResultOnExpiry;
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S minimumTimeoutForEmptyGroups(long minimumTimeoutForEmptyGroups) {
|
||||
this.minimumTimeoutForEmptyGroups = minimumTimeoutForEmptyGroups;
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S groupTimeout(long groupTimeout) {
|
||||
this.groupTimeoutExpression = new ValueExpression<Long>(groupTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S groupTimeoutExpression(String groupTimeoutExpression) {
|
||||
this.groupTimeoutExpression = PARSER.parseExpression(groupTimeoutExpression);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S groupTimeout(Function<MessageGroup, Long> groupTimeoutFunction) {
|
||||
this.groupTimeoutExpression = new FunctionExpression<MessageGroup>(groupTimeoutFunction);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S taskScheduler(TaskScheduler taskScheduler) {
|
||||
this.taskScheduler = taskScheduler;
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S discardChannel(MessageChannel discardChannel) {
|
||||
this.discardChannel = discardChannel;
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S discardChannel(String discardChannelName) {
|
||||
this.discardChannelName = discardChannelName;
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S processor(Object target, String methodName) {
|
||||
try {
|
||||
return correlationStrategy(new CorrelationStrategyFactoryBean(target, methodName).getObject())
|
||||
.releaseStrategy(new ReleaseStrategyFactoryBean(target, methodName).getObject());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public S correlationExpression(String correlationExpression) {
|
||||
return correlationStrategy(new ExpressionEvaluatingCorrelationStrategy(correlationExpression));
|
||||
}
|
||||
|
||||
public S correlationStrategy(Object target, String methodName) {
|
||||
try {
|
||||
return correlationStrategy(new CorrelationStrategyFactoryBean(target, methodName).getObject());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public S correlationStrategy(CorrelationStrategy correlationStrategy) {
|
||||
this.correlationStrategy = correlationStrategy;
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S releaseExpression(String releaseExpression) {
|
||||
return releaseStrategy(new ExpressionEvaluatingReleaseStrategy(releaseExpression));
|
||||
}
|
||||
|
||||
public S releaseStrategy(Object target, String methodName) {
|
||||
try {
|
||||
return releaseStrategy(new ReleaseStrategyFactoryBean(target, methodName).getObject());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public S releaseStrategy(ReleaseStrategy releaseStrategy) {
|
||||
this.releaseStrategy = releaseStrategy;
|
||||
return _this();
|
||||
}
|
||||
|
||||
protected H configure(H handler) {
|
||||
if (this.discardChannel != null) {
|
||||
handler.setDiscardChannel(this.discardChannel);
|
||||
}
|
||||
if (StringUtils.hasText(this.discardChannelName)) {
|
||||
handler.setDiscardChannelName(this.discardChannelName);
|
||||
}
|
||||
if (this.messageStore != null) {
|
||||
handler.setMessageStore(this.messageStore);
|
||||
}
|
||||
handler.setMinimumTimeoutForEmptyGroups(this.minimumTimeoutForEmptyGroups);
|
||||
handler.setGroupTimeoutExpression(this.groupTimeoutExpression);
|
||||
if (this.taskScheduler != null) {
|
||||
handler.setTaskScheduler(this.taskScheduler);
|
||||
}
|
||||
handler.setSendPartialResultOnExpiry(this.sendPartialResultOnExpiry);
|
||||
if (this.correlationStrategy != null) {
|
||||
handler.setCorrelationStrategy(this.correlationStrategy);
|
||||
}
|
||||
if (this.releaseStrategy != null) {
|
||||
handler.setReleaseStrategy(this.releaseStrategy);
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
CorrelationHandlerSpec() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
|
||||
import org.springframework.integration.dsl.core.ConsumerEndpointSpec;
|
||||
import org.springframework.integration.handler.DelayHandler;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public final class DelayerEndpointSpec extends ConsumerEndpointSpec<DelayerEndpointSpec, DelayHandler> {
|
||||
|
||||
private final List<Advice> delayedAdvice = new LinkedList<Advice>();
|
||||
|
||||
DelayerEndpointSpec(DelayHandler delayHandler) {
|
||||
super(delayHandler);
|
||||
this.target.getT2().setDelayedAdviceChain(this.delayedAdvice);
|
||||
}
|
||||
|
||||
public DelayerEndpointSpec defaultDelay(long defaultDelay) {
|
||||
this.target.getT2().setDefaultDelay(defaultDelay);
|
||||
return _this();
|
||||
}
|
||||
|
||||
|
||||
public DelayerEndpointSpec ignoreExpressionFailures(boolean ignoreExpressionFailures) {
|
||||
this.target.getT2().setIgnoreExpressionFailures(ignoreExpressionFailures);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public DelayerEndpointSpec messageStore(MessageGroupStore messageStore) {
|
||||
this.target.getT2().setMessageStore(messageStore);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public DelayerEndpointSpec delayedAdvice(Advice... advice) {
|
||||
this.delayedAdvice.addAll(Arrays.asList(advice));
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.dsl.support.MessageChannelReference;
|
||||
import org.springframework.integration.filter.ExpressionEvaluatingSelector;
|
||||
import org.springframework.integration.router.RecipientListRouter;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.core.DestinationResolutionException;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
class DslRecipientListRouter extends RecipientListRouter {
|
||||
|
||||
private final Map<String, String> expressionRecipientMap = new HashMap<String, String>();
|
||||
|
||||
private final Map<String, MessageSelector> selectorRecipientMap = new HashMap<String, MessageSelector>();
|
||||
|
||||
private final Map<MessageChannel, String> channelExpressionRecipientMap = new HashMap<MessageChannel, String>();
|
||||
|
||||
private final Map<MessageChannel, MessageSelector> channelSelectorRecipientMap =
|
||||
new HashMap<MessageChannel, MessageSelector>();
|
||||
|
||||
void add(String channelName, String expression) {
|
||||
this.expressionRecipientMap.put(channelName, expression);
|
||||
}
|
||||
|
||||
void add(String channelName, MessageSelector selector) {
|
||||
this.selectorRecipientMap.put(channelName, selector);
|
||||
}
|
||||
|
||||
void add(MessageChannel channel, String expression) {
|
||||
this.channelExpressionRecipientMap.put(channel, expression);
|
||||
}
|
||||
|
||||
void add(MessageChannel channel, MessageSelector selector) {
|
||||
this.channelSelectorRecipientMap.put(channel, selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit() throws Exception {
|
||||
for (Map.Entry<String, String> recipient : this.expressionRecipientMap.entrySet()) {
|
||||
ExpressionEvaluatingSelector selector = null;
|
||||
String expression = recipient.getValue();
|
||||
if (StringUtils.hasText(expression)) {
|
||||
selector = new ExpressionEvaluatingSelector(expression);
|
||||
selector.setBeanFactory(this.getBeanFactory());
|
||||
}
|
||||
this.selectorRecipientMap.put(recipient.getKey(), selector);
|
||||
}
|
||||
|
||||
for (Map.Entry<MessageChannel, String> recipient : this.channelExpressionRecipientMap.entrySet()) {
|
||||
ExpressionEvaluatingSelector selector = null;
|
||||
String expression = recipient.getValue();
|
||||
if (StringUtils.hasText(expression)) {
|
||||
selector = new ExpressionEvaluatingSelector(expression);
|
||||
selector.setBeanFactory(this.getBeanFactory());
|
||||
}
|
||||
this.channelSelectorRecipientMap.put(recipient.getKey(), selector);
|
||||
}
|
||||
|
||||
List<Recipient> recipients = new ArrayList<Recipient>(this.selectorRecipientMap.size()
|
||||
+ this.channelSelectorRecipientMap.size());
|
||||
|
||||
for (Map.Entry<String, MessageSelector> entry : selectorRecipientMap.entrySet()) {
|
||||
recipients.add(new DslRecipient(new MessageChannelReference(entry.getKey()), entry.getValue()));
|
||||
}
|
||||
|
||||
for (Map.Entry<MessageChannel, MessageSelector> entry : channelSelectorRecipientMap.entrySet()) {
|
||||
recipients.add(new Recipient(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
setRecipients(recipients);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
|
||||
class DslRecipient extends Recipient {
|
||||
|
||||
private volatile MessageChannel channel;
|
||||
|
||||
DslRecipient(MessageChannelReference channel, MessageSelector selector) {
|
||||
super(channel, selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageChannel getChannel() {
|
||||
if (this.channel == null) {
|
||||
synchronized (this) {
|
||||
if (this.channel == null) {
|
||||
this.channel = resolveChannelName((MessageChannelReference) super.getChannel());
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
private MessageChannel resolveChannelName(MessageChannelReference channelReference) {
|
||||
String channelName = channelReference.getName();
|
||||
try {
|
||||
return DslRecipientListRouter.this.getBeanFactory().getBean(channelName, MessageChannel.class);
|
||||
}
|
||||
catch (BeansException e) {
|
||||
throw new DestinationResolutionException("Failed to look up MessageChannel with name '"
|
||||
+ channelName + "' in the BeanFactory.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.dsl.core.MessageHandlerSpec;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.dsl.support.FunctionExpression;
|
||||
import org.springframework.integration.expression.ValueExpression;
|
||||
import org.springframework.integration.transformer.ContentEnricher;
|
||||
import org.springframework.integration.transformer.support.AbstractHeaderValueMessageProcessor;
|
||||
import org.springframework.integration.transformer.support.ExpressionEvaluatingHeaderValueMessageProcessor;
|
||||
import org.springframework.integration.transformer.support.HeaderValueMessageProcessor;
|
||||
import org.springframework.integration.transformer.support.StaticHeaderValueMessageProcessor;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Tim Ysewyn
|
||||
*/
|
||||
public class EnricherSpec extends MessageHandlerSpec<EnricherSpec, ContentEnricher> {
|
||||
|
||||
private final ContentEnricher enricher = new ContentEnricher();
|
||||
|
||||
private final Map<String, Expression> propertyExpressions = new HashMap<String, Expression>();
|
||||
|
||||
private final Map<String, HeaderValueMessageProcessor<?>> headerExpressions =
|
||||
new HashMap<String, HeaderValueMessageProcessor<?>>();
|
||||
|
||||
EnricherSpec() {
|
||||
}
|
||||
|
||||
public EnricherSpec requestChannel(MessageChannel requestChannel) {
|
||||
this.enricher.setRequestChannel(requestChannel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public EnricherSpec requestChannel(String requestChannel) {
|
||||
this.enricher.setRequestChannelName(requestChannel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public EnricherSpec replyChannel(MessageChannel replyChannel) {
|
||||
this.enricher.setReplyChannel(replyChannel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public EnricherSpec replyChannel(String replyChannel) {
|
||||
this.enricher.setReplyChannelName(replyChannel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public EnricherSpec requestTimeout(Long requestTimeout) {
|
||||
this.enricher.setRequestTimeout(requestTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public EnricherSpec replyTimeout(Long replyTimeout) {
|
||||
this.enricher.setReplyTimeout(replyTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public EnricherSpec requestPayloadExpression(String requestPayloadExpression) {
|
||||
this.enricher.setRequestPayloadExpression(PARSER.parseExpression(requestPayloadExpression));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public <P> EnricherSpec requestPayload(Function<Message<P>, ?> requestPayloadFunction) {
|
||||
this.enricher.setRequestPayloadExpression(new FunctionExpression<Message<P>>(requestPayloadFunction));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public EnricherSpec shouldClonePayload(boolean shouldClonePayload) {
|
||||
this.enricher.setShouldClonePayload(shouldClonePayload);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public <V> EnricherSpec property(String key, V value) {
|
||||
this.propertyExpressions.put(key, new ValueExpression<V>(value));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public EnricherSpec propertyExpression(String key, String expression) {
|
||||
Assert.notNull(key);
|
||||
this.propertyExpressions.put(key, PARSER.parseExpression(expression));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public <P> EnricherSpec propertyFunction(String key, Function<Message<P>, Object> function) {
|
||||
Assert.notNull(key);
|
||||
this.propertyExpressions.put(key, new FunctionExpression<Message<P>>(function));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public <V> EnricherSpec header(String name, V value) {
|
||||
return this.header(name, value, null);
|
||||
}
|
||||
|
||||
public <V> EnricherSpec header(String name, V value, Boolean overwrite) {
|
||||
AbstractHeaderValueMessageProcessor<V> headerValueMessageProcessor =
|
||||
new StaticHeaderValueMessageProcessor<V>(value);
|
||||
headerValueMessageProcessor.setOverwrite(overwrite);
|
||||
return header(name, headerValueMessageProcessor);
|
||||
}
|
||||
|
||||
public EnricherSpec headerExpression(String name, String expression) {
|
||||
return headerExpression(name, expression, null);
|
||||
}
|
||||
|
||||
public EnricherSpec headerExpression(String name, String expression, Boolean overwrite) {
|
||||
Assert.hasText(expression);
|
||||
return headerExpression(name, PARSER.parseExpression(expression), overwrite);
|
||||
}
|
||||
|
||||
public <P> EnricherSpec headerFunction(String name, Function<Message<P>, Object> function) {
|
||||
return headerFunction(name, function, null);
|
||||
}
|
||||
|
||||
public <P> EnricherSpec headerFunction(String name, Function<Message<P>, Object> function, Boolean overwrite) {
|
||||
Assert.notNull(function);
|
||||
return headerExpression(name, new FunctionExpression<Message<P>>(function), overwrite);
|
||||
}
|
||||
|
||||
private EnricherSpec headerExpression(String name, Expression expression, Boolean overwrite) {
|
||||
AbstractHeaderValueMessageProcessor<?> headerValueMessageProcessor =
|
||||
new ExpressionEvaluatingHeaderValueMessageProcessor<Object>(expression, null);
|
||||
headerValueMessageProcessor.setOverwrite(overwrite);
|
||||
return header(name, headerValueMessageProcessor);
|
||||
}
|
||||
|
||||
public <V> EnricherSpec header(String name, HeaderValueMessageProcessor<V> headerValueMessageProcessor) {
|
||||
Assert.hasText(name);
|
||||
this.headerExpressions.put(name, headerValueMessageProcessor);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ContentEnricher doGet() {
|
||||
if(!this.propertyExpressions.isEmpty()) {
|
||||
this.enricher.setPropertyExpressions(this.propertyExpressions);
|
||||
}
|
||||
if(!this.headerExpressions.isEmpty()) {
|
||||
this.enricher.setHeaderExpressions(this.headerExpressions);
|
||||
}
|
||||
return this.enricher;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.dsl.core.ComponentsRegistration;
|
||||
import org.springframework.integration.dsl.core.ConsumerEndpointSpec;
|
||||
import org.springframework.integration.filter.MessageFilter;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public final class FilterEndpointSpec extends ConsumerEndpointSpec<FilterEndpointSpec, MessageFilter>
|
||||
implements ComponentsRegistration {
|
||||
|
||||
private IntegrationFlow discardFlow;
|
||||
|
||||
FilterEndpointSpec(MessageFilter messageFilter) {
|
||||
super(messageFilter);
|
||||
}
|
||||
|
||||
public FilterEndpointSpec throwExceptionOnRejection(boolean throwExceptionOnRejection) {
|
||||
this.target.getT2().setThrowExceptionOnRejection(throwExceptionOnRejection);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FilterEndpointSpec discardChannel(MessageChannel discardChannel) {
|
||||
this.target.getT2().setDiscardChannel(discardChannel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FilterEndpointSpec discardChannel(String discardChannelName) {
|
||||
this.target.getT2().setDiscardChannelName(discardChannelName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FilterEndpointSpec discardFlow(IntegrationFlow discardFlow) {
|
||||
Assert.notNull(discardFlow);
|
||||
DirectChannel channel = new DirectChannel();
|
||||
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(channel);
|
||||
discardFlow.accept(flowBuilder);
|
||||
this.discardFlow = flowBuilder.get();
|
||||
return discardChannel(channel);
|
||||
}
|
||||
|
||||
public FilterEndpointSpec discardWithinAdvice(boolean discardWithinAdvice) {
|
||||
this.target.getT2().setDiscardWithinAdvice(discardWithinAdvice);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getComponentsToRegister() {
|
||||
if (this.discardFlow != null) {
|
||||
return Collections.<Object>singletonList(this.discardFlow);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import org.springframework.integration.dsl.core.ConsumerEndpointSpec;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public final class GatewayEndpointSpec extends ConsumerEndpointSpec<GatewayEndpointSpec, GatewayMessageHandler> {
|
||||
|
||||
GatewayEndpointSpec(MessageChannel requestChannel) {
|
||||
super(new GatewayMessageHandler());
|
||||
this.target.getT2().setRequestChannel(requestChannel);
|
||||
}
|
||||
|
||||
GatewayEndpointSpec(String requestChannel) {
|
||||
super(new GatewayMessageHandler());
|
||||
this.target.getT2().setRequestChannelName(requestChannel);
|
||||
}
|
||||
|
||||
public GatewayEndpointSpec replyChannel(MessageChannel replyChannel) {
|
||||
this.target.getT2().setReplyChannel(replyChannel);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GatewayEndpointSpec replyChannel(String replyChannel) {
|
||||
this.target.getT2().setReplyChannelName(replyChannel);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GatewayEndpointSpec errorChannel(MessageChannel errorChannel) {
|
||||
this.target.getT2().setErrorChannel(errorChannel);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GatewayEndpointSpec errorChannel(String errorChannel) {
|
||||
this.target.getT2().setErrorChannelName(errorChannel);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GatewayEndpointSpec requestTimeout(Long requestTimeout) {
|
||||
this.target.getT2().setRequestTimeout(requestTimeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GatewayEndpointSpec replyTimeout(Long replyTimeout) {
|
||||
this.target.getT2().setReplyTimeout(replyTimeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.integration.gateway.GatewayProxyFactoryBean;
|
||||
import org.springframework.integration.gateway.RequestReplyExchanger;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
class GatewayMessageHandler extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
private final GatewayProxyFactoryBean gatewayProxyFactoryBean;
|
||||
|
||||
private RequestReplyExchanger exchanger;
|
||||
|
||||
private String requestChannel;
|
||||
|
||||
private String replyChannel;
|
||||
|
||||
private String errorChannel;
|
||||
|
||||
GatewayMessageHandler() {
|
||||
this.gatewayProxyFactoryBean = new GatewayProxyFactoryBean();
|
||||
this.gatewayProxyFactoryBean.setServiceInterface(RequestReplyExchanger.class);
|
||||
}
|
||||
|
||||
void setRequestChannel(MessageChannel requestChannel) {
|
||||
this.gatewayProxyFactoryBean.setDefaultRequestChannel(requestChannel);
|
||||
}
|
||||
|
||||
void setRequestChannelName(String requestChannel) {
|
||||
this.requestChannel = requestChannel;
|
||||
}
|
||||
|
||||
public void setReplyChannel(MessageChannel replyChannel) {
|
||||
this.gatewayProxyFactoryBean.setDefaultReplyChannel(replyChannel);
|
||||
}
|
||||
|
||||
public void setReplyChannelName(String replyChannel) {
|
||||
this.replyChannel = replyChannel;
|
||||
}
|
||||
|
||||
public void setErrorChannel(MessageChannel errorChannel) {
|
||||
this.gatewayProxyFactoryBean.setErrorChannel(errorChannel);
|
||||
}
|
||||
|
||||
public void setErrorChannelName(String errorChannel) {
|
||||
this.errorChannel = errorChannel;
|
||||
}
|
||||
|
||||
public void setRequestTimeout(Long requestTimeout) {
|
||||
this.gatewayProxyFactoryBean.setDefaultRequestTimeout(requestTimeout);
|
||||
}
|
||||
|
||||
public void setReplyTimeout(Long replyTimeout) {
|
||||
this.gatewayProxyFactoryBean.setDefaultReplyTimeout(replyTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object handleRequestMessage(Message<?> requestMessage) {
|
||||
if (this.exchanger == null) {
|
||||
synchronized (this) {
|
||||
if (this.exchanger == null) {
|
||||
initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.exchanger.exchange(requestMessage);
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
BeanFactory beanFactory = getBeanFactory();
|
||||
|
||||
if (StringUtils.hasText(this.requestChannel)) {
|
||||
this.gatewayProxyFactoryBean.setDefaultRequestChannel(beanFactory.getBean(this.requestChannel,
|
||||
MessageChannel.class));
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(this.replyChannel)) {
|
||||
this.gatewayProxyFactoryBean.setDefaultReplyChannel(beanFactory.getBean(this.replyChannel,
|
||||
MessageChannel.class));
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(this.errorChannel)) {
|
||||
this.gatewayProxyFactoryBean.setErrorChannel(beanFactory.getBean(this.errorChannel,
|
||||
MessageChannel.class));
|
||||
}
|
||||
|
||||
if (beanFactory instanceof ConfigurableListableBeanFactory) {
|
||||
((ConfigurableListableBeanFactory) beanFactory).initializeBean(this.gatewayProxyFactoryBean, null);
|
||||
}
|
||||
try {
|
||||
this.exchanger = (RequestReplyExchanger) this.gatewayProxyFactoryBean.getObject();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new BeanCreationException("Can't instantiate the GatewayProxyFactoryBean: " + this, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import org.springframework.integration.dsl.core.ConsumerEndpointSpec;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public final class GenericEndpointSpec<H extends MessageHandler>
|
||||
extends ConsumerEndpointSpec<GenericEndpointSpec<H>, H> {
|
||||
|
||||
GenericEndpointSpec(H messageHandler) {
|
||||
super(messageHandler);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.dsl.core.IntegrationComponentSpec;
|
||||
import org.springframework.integration.dsl.support.BeanNameMessageProcessor;
|
||||
import org.springframework.integration.dsl.support.Consumer;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.dsl.support.FunctionExpression;
|
||||
import org.springframework.integration.dsl.support.MapBuilder;
|
||||
import org.springframework.integration.dsl.support.StringStringMapBuilder;
|
||||
import org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.transformer.HeaderEnricher;
|
||||
import org.springframework.integration.transformer.support.AbstractHeaderValueMessageProcessor;
|
||||
import org.springframework.integration.transformer.support.ExpressionEvaluatingHeaderValueMessageProcessor;
|
||||
import org.springframework.integration.transformer.support.HeaderValueMessageProcessor;
|
||||
import org.springframework.integration.transformer.support.StaticHeaderValueMessageProcessor;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class HeaderEnricherSpec extends IntegrationComponentSpec<HeaderEnricherSpec, HeaderEnricher> {
|
||||
|
||||
private final Map<String, HeaderValueMessageProcessor<?>> headerToAdd = new HashMap<String, HeaderValueMessageProcessor<?>>();
|
||||
|
||||
private final HeaderEnricher headerEnricher = new HeaderEnricher(headerToAdd);
|
||||
|
||||
HeaderEnricherSpec() {
|
||||
}
|
||||
|
||||
public HeaderEnricherSpec defaultOverwrite(boolean defaultOverwrite) {
|
||||
this.headerEnricher.setDefaultOverwrite(defaultOverwrite);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public HeaderEnricherSpec shouldSkipNulls(boolean shouldSkipNulls) {
|
||||
this.headerEnricher.setShouldSkipNulls(shouldSkipNulls);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public HeaderEnricherSpec messageProcessor(MessageProcessor<?> messageProcessor) {
|
||||
this.headerEnricher.setMessageProcessor(messageProcessor);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public HeaderEnricherSpec messageProcessor(String expression) {
|
||||
return messageProcessor(new ExpressionEvaluatingMessageProcessor<Object>(PARSER.parseExpression(expression)));
|
||||
}
|
||||
|
||||
public HeaderEnricherSpec messageProcessor(String beanName, String methodName) {
|
||||
return messageProcessor(new BeanNameMessageProcessor<Object>(beanName, methodName));
|
||||
}
|
||||
|
||||
public HeaderEnricherSpec headers(MapBuilder<?, String, Object> headers) {
|
||||
return headers(headers.get());
|
||||
}
|
||||
|
||||
public HeaderEnricherSpec headers(Map<String, Object> headers) {
|
||||
Assert.notNull(headers);
|
||||
for (Entry<String, Object> entry : headers.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof Expression) {
|
||||
header(name, new ExpressionEvaluatingHeaderValueMessageProcessor<Object>((Expression) value, null));
|
||||
}
|
||||
else {
|
||||
header(name, value);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public HeaderEnricherSpec headerExpressions(MapBuilder<?, String, String> headers) {
|
||||
Assert.notNull(headers);
|
||||
return headerExpressions(headers.get());
|
||||
}
|
||||
|
||||
public HeaderEnricherSpec headerExpressions(Consumer<StringStringMapBuilder> configurer) {
|
||||
Assert.notNull(configurer);
|
||||
StringStringMapBuilder builder = new StringStringMapBuilder();
|
||||
configurer.accept(builder);
|
||||
return headerExpressions(builder.get());
|
||||
}
|
||||
|
||||
public HeaderEnricherSpec headerExpressions(Map<String, String> headers) {
|
||||
Assert.notNull(headers);
|
||||
for (Entry<String, String> entry : headers.entrySet()) {
|
||||
header(entry.getKey(), new ExpressionEvaluatingHeaderValueMessageProcessor<Object>(entry.getValue(), null));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public <V> HeaderEnricherSpec header(String name, V value) {
|
||||
return header(name, value, null);
|
||||
}
|
||||
|
||||
public <V> HeaderEnricherSpec header(String name, V value, Boolean overwrite) {
|
||||
AbstractHeaderValueMessageProcessor<V> headerValueMessageProcessor =
|
||||
new StaticHeaderValueMessageProcessor<V>(value);
|
||||
headerValueMessageProcessor.setOverwrite(overwrite);
|
||||
return header(name, headerValueMessageProcessor);
|
||||
}
|
||||
|
||||
public HeaderEnricherSpec headerExpression(String name, String expression) {
|
||||
return headerExpression(name, expression, null);
|
||||
}
|
||||
|
||||
public HeaderEnricherSpec headerExpression(String name, String expression, Boolean overwrite) {
|
||||
Assert.hasText(expression);
|
||||
return headerExpression(name, PARSER.parseExpression(expression), overwrite);
|
||||
}
|
||||
|
||||
public <P> HeaderEnricherSpec headerFunction(String name, Function<Message<P>, Object> function) {
|
||||
return headerFunction(name, function, null);
|
||||
}
|
||||
|
||||
public <P> HeaderEnricherSpec headerFunction(String name, Function<Message<P>, Object> function,
|
||||
Boolean overwrite) {
|
||||
Assert.notNull(function);
|
||||
return headerExpression(name, new FunctionExpression<Message<P>>(function), overwrite);
|
||||
}
|
||||
|
||||
private HeaderEnricherSpec headerExpression(String name, Expression expression, Boolean overwrite) {
|
||||
AbstractHeaderValueMessageProcessor<?> headerValueMessageProcessor =
|
||||
new ExpressionEvaluatingHeaderValueMessageProcessor<Object>(expression, null);
|
||||
headerValueMessageProcessor.setOverwrite(overwrite);
|
||||
return header(name, headerValueMessageProcessor);
|
||||
}
|
||||
|
||||
public <V> HeaderEnricherSpec header(String name, HeaderValueMessageProcessor<V> headerValueMessageProcessor) {
|
||||
Assert.hasText(name);
|
||||
this.headerToAdd.put(name, headerValueMessageProcessor);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public <V> HeaderEnricherSpec headerChannelsToString() {
|
||||
return headerExpression("replyChannel",
|
||||
"@" + IntegrationContextUtils.INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME
|
||||
+ ".channelToChannelName(headers.replyChannel)",
|
||||
true)
|
||||
.headerExpression("errorChannel",
|
||||
"@" + IntegrationContextUtils.INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME
|
||||
+ ".channelToChannelName(headers.errorChannel)",
|
||||
true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HeaderEnricher doGet() {
|
||||
return this.headerEnricher;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import org.springframework.integration.dsl.support.Consumer;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public interface IntegrationFlow extends Consumer<IntegrationFlowDefinition<?>> {
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public final class IntegrationFlowBuilder extends IntegrationFlowDefinition<IntegrationFlowBuilder> {
|
||||
|
||||
@Override
|
||||
public StandardIntegrationFlow get() {
|
||||
return super.get();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,819 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler;
|
||||
import org.springframework.integration.aggregator.AggregatingMessageHandler;
|
||||
import org.springframework.integration.aggregator.ResequencingMessageHandler;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.FixedSubscriberChannel;
|
||||
import org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean;
|
||||
import org.springframework.integration.core.GenericSelector;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.dsl.channel.MessageChannelSpec;
|
||||
import org.springframework.integration.dsl.core.ComponentsRegistration;
|
||||
import org.springframework.integration.dsl.core.ConsumerEndpointSpec;
|
||||
import org.springframework.integration.dsl.core.MessageHandlerSpec;
|
||||
import org.springframework.integration.dsl.support.BeanNameMessageProcessor;
|
||||
import org.springframework.integration.dsl.support.Consumer;
|
||||
import org.springframework.integration.dsl.support.FixedSubscriberChannelPrototype;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.dsl.support.FunctionExpression;
|
||||
import org.springframework.integration.dsl.support.GenericHandler;
|
||||
import org.springframework.integration.dsl.support.MapBuilder;
|
||||
import org.springframework.integration.dsl.support.MessageChannelReference;
|
||||
import org.springframework.integration.expression.ControlBusMethodFilter;
|
||||
import org.springframework.integration.filter.ExpressionEvaluatingSelector;
|
||||
import org.springframework.integration.filter.MessageFilter;
|
||||
import org.springframework.integration.filter.MethodInvokingSelector;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.handler.BridgeHandler;
|
||||
import org.springframework.integration.handler.DelayHandler;
|
||||
import org.springframework.integration.handler.ExpressionCommandMessageProcessor;
|
||||
import org.springframework.integration.handler.ServiceActivatingHandler;
|
||||
import org.springframework.integration.router.AbstractMappingMessageRouter;
|
||||
import org.springframework.integration.router.AbstractMessageRouter;
|
||||
import org.springframework.integration.router.ExpressionEvaluatingRouter;
|
||||
import org.springframework.integration.router.MethodInvokingRouter;
|
||||
import org.springframework.integration.router.RecipientListRouter;
|
||||
import org.springframework.integration.splitter.AbstractMessageSplitter;
|
||||
import org.springframework.integration.splitter.DefaultMessageSplitter;
|
||||
import org.springframework.integration.splitter.ExpressionEvaluatingSplitter;
|
||||
import org.springframework.integration.splitter.MethodInvokingSplitter;
|
||||
import org.springframework.integration.store.MessageStore;
|
||||
import org.springframework.integration.transformer.ClaimCheckInTransformer;
|
||||
import org.springframework.integration.transformer.ClaimCheckOutTransformer;
|
||||
import org.springframework.integration.transformer.ContentEnricher;
|
||||
import org.springframework.integration.transformer.ExpressionEvaluatingTransformer;
|
||||
import org.springframework.integration.transformer.GenericTransformer;
|
||||
import org.springframework.integration.transformer.HeaderFilter;
|
||||
import org.springframework.integration.transformer.MessageTransformingHandler;
|
||||
import org.springframework.integration.transformer.MethodInvokingTransformer;
|
||||
import org.springframework.integration.transformer.Transformer;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinition<B>> {
|
||||
|
||||
private final static SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
protected final Set<Object> integrationComponents = new LinkedHashSet<Object>();
|
||||
|
||||
protected MessageChannel currentMessageChannel;
|
||||
|
||||
protected Object currentComponent;
|
||||
|
||||
IntegrationFlowDefinition() {
|
||||
}
|
||||
|
||||
B addComponent(Object component) {
|
||||
this.integrationComponents.add(component);
|
||||
return _this();
|
||||
}
|
||||
|
||||
B addComponents(Collection<Object> components) {
|
||||
if (components != null) {
|
||||
for (Object component : components) {
|
||||
this.integrationComponents.add(component);
|
||||
}
|
||||
}
|
||||
return _this();
|
||||
}
|
||||
|
||||
B currentComponent(Object component) {
|
||||
this.currentComponent = component;
|
||||
return _this();
|
||||
}
|
||||
|
||||
public B fixedSubscriberChannel() {
|
||||
return fixedSubscriberChannel(null);
|
||||
}
|
||||
|
||||
public B fixedSubscriberChannel(String messageChannelName) {
|
||||
return channel(new FixedSubscriberChannelPrototype(messageChannelName));
|
||||
}
|
||||
|
||||
public B channel(String messageChannelName) {
|
||||
return channel(new MessageChannelReference(messageChannelName));
|
||||
}
|
||||
|
||||
public B channel(Function<Channels, MessageChannelSpec<?, ?>> channels) {
|
||||
Assert.notNull(channels);
|
||||
return channel(channels.apply(new Channels()));
|
||||
}
|
||||
|
||||
public B channel(MessageChannelSpec<?, ?> messageChannelSpec) {
|
||||
Assert.notNull(messageChannelSpec);
|
||||
return channel(messageChannelSpec.get());
|
||||
}
|
||||
|
||||
public B channel(MessageChannel messageChannel) {
|
||||
Assert.notNull(messageChannel);
|
||||
if (this.currentMessageChannel != null) {
|
||||
this.register(new GenericEndpointSpec<BridgeHandler>(new BridgeHandler()), null);
|
||||
}
|
||||
this.currentMessageChannel = messageChannel;
|
||||
return registerOutputChannelIfCan(this.currentMessageChannel);
|
||||
}
|
||||
|
||||
public B publishSubscribeChannel(Consumer<PublishSubscribeSpec> publishSubscribeChannelConfigurer) {
|
||||
return publishSubscribeChannel(null, publishSubscribeChannelConfigurer);
|
||||
}
|
||||
|
||||
public B publishSubscribeChannel(Executor executor,
|
||||
Consumer<PublishSubscribeSpec> publishSubscribeChannelConfigurer) {
|
||||
Assert.notNull(publishSubscribeChannelConfigurer);
|
||||
PublishSubscribeSpec spec = new PublishSubscribeSpec(executor);
|
||||
publishSubscribeChannelConfigurer.accept(spec);
|
||||
return addComponents(spec.getComponentsToRegister()).channel(spec);
|
||||
}
|
||||
|
||||
public B controlBus() {
|
||||
return controlBus(null);
|
||||
}
|
||||
|
||||
public B controlBus(Consumer<GenericEndpointSpec<ServiceActivatingHandler>> endpointConfigurer) {
|
||||
return this.handle(new ServiceActivatingHandler(new ExpressionCommandMessageProcessor(
|
||||
new ControlBusMethodFilter())), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B transform(String expression) {
|
||||
Assert.hasText(expression);
|
||||
return this.transform(new ExpressionEvaluatingTransformer(PARSER.parseExpression(expression)));
|
||||
}
|
||||
|
||||
public <S, T> B transform(GenericTransformer<S, T> genericTransformer) {
|
||||
return this.transform(null, genericTransformer);
|
||||
}
|
||||
|
||||
public <P, T> B transform(Class<P> payloadType, GenericTransformer<P, T> genericTransformer) {
|
||||
return this.transform(payloadType, genericTransformer, null);
|
||||
}
|
||||
|
||||
public <S, T> B transform(GenericTransformer<S, T> genericTransformer,
|
||||
Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
|
||||
return this.transform(null, genericTransformer, endpointConfigurer);
|
||||
}
|
||||
|
||||
public <P, T> B transform(Class<P> payloadType, GenericTransformer<P, T> genericTransformer,
|
||||
Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
|
||||
Assert.notNull(genericTransformer);
|
||||
Transformer transformer = genericTransformer instanceof Transformer ? (Transformer) genericTransformer :
|
||||
(isLambda(genericTransformer)
|
||||
? new MethodInvokingTransformer(new LambdaMessageProcessor(genericTransformer, payloadType))
|
||||
: new MethodInvokingTransformer(genericTransformer));
|
||||
return addComponent(transformer)
|
||||
.handle(new MessageTransformingHandler(transformer), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B filter(String expression) {
|
||||
Assert.hasText(expression);
|
||||
return this.filter(new ExpressionEvaluatingSelector(PARSER.parseExpression(expression)));
|
||||
}
|
||||
|
||||
public <S> B filter(GenericSelector<S> genericSelector) {
|
||||
return this.filter(null, genericSelector);
|
||||
}
|
||||
|
||||
public <P> B filter(Class<P> payloadType, GenericSelector<P> genericSelector) {
|
||||
return this.filter(payloadType, genericSelector, null);
|
||||
}
|
||||
|
||||
public <P> B filter(GenericSelector<P> genericSelector, Consumer<FilterEndpointSpec> endpointConfigurer) {
|
||||
return filter(null, genericSelector, endpointConfigurer);
|
||||
}
|
||||
|
||||
public <P> B filter(Class<P> payloadType, GenericSelector<P> genericSelector,
|
||||
Consumer<FilterEndpointSpec> endpointConfigurer) {
|
||||
Assert.notNull(genericSelector);
|
||||
MessageSelector selector = genericSelector instanceof MessageSelector ? (MessageSelector) genericSelector :
|
||||
(isLambda(genericSelector)
|
||||
? new MethodInvokingSelector(new LambdaMessageProcessor(genericSelector, payloadType))
|
||||
: new MethodInvokingSelector(genericSelector));
|
||||
return this.register(new FilterEndpointSpec(new MessageFilter(selector)), endpointConfigurer);
|
||||
}
|
||||
|
||||
public <H extends MessageHandler> B handleWithAdapter(Function<Adapters, MessageHandlerSpec<?, H>> adapters) {
|
||||
return handleWithAdapter(adapters, null);
|
||||
}
|
||||
|
||||
public <H extends MessageHandler> B handleWithAdapter(Function<Adapters, MessageHandlerSpec<?, H>> adapters,
|
||||
Consumer<GenericEndpointSpec<H>> endpointConfigurer) {
|
||||
return handle(adapters.apply(new Adapters()), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B handle(MessageHandlerSpec<?, ? extends MessageHandler> messageHandlerSpec) {
|
||||
return handle(messageHandlerSpec, null);
|
||||
}
|
||||
|
||||
public B handle(MessageHandler messageHandler) {
|
||||
return this.handle(messageHandler, null);
|
||||
}
|
||||
|
||||
public B handle(String beanName, String methodName) {
|
||||
return this.handle(beanName, methodName, null);
|
||||
}
|
||||
|
||||
public B handle(String beanName, String methodName,
|
||||
Consumer<GenericEndpointSpec<ServiceActivatingHandler>> endpointConfigurer) {
|
||||
return this.handle(new ServiceActivatingHandler(new BeanNameMessageProcessor<Object>(beanName, methodName)),
|
||||
endpointConfigurer);
|
||||
}
|
||||
|
||||
public <P> B handle(GenericHandler<P> handler) {
|
||||
return handle(null, handler);
|
||||
}
|
||||
|
||||
public <P> B handle(GenericHandler<P> handler,
|
||||
Consumer<GenericEndpointSpec<ServiceActivatingHandler>> endpointConfigurer) {
|
||||
return this.handle(null, handler, endpointConfigurer);
|
||||
}
|
||||
|
||||
public <P> B handle(Class<P> payloadType, GenericHandler<P> handler) {
|
||||
return this.handle(payloadType, handler, null);
|
||||
}
|
||||
|
||||
public <P> B handle(Class<P> payloadType, GenericHandler<P> handler,
|
||||
Consumer<GenericEndpointSpec<ServiceActivatingHandler>> endpointConfigurer) {
|
||||
ServiceActivatingHandler serviceActivatingHandler = null;
|
||||
if (isLambda(handler)) {
|
||||
serviceActivatingHandler = new ServiceActivatingHandler(new LambdaMessageProcessor(handler, payloadType));
|
||||
}
|
||||
else {
|
||||
serviceActivatingHandler = new ServiceActivatingHandler(handler);
|
||||
}
|
||||
return this.handle(serviceActivatingHandler, endpointConfigurer);
|
||||
}
|
||||
|
||||
public <H extends MessageHandler> B handle(MessageHandlerSpec<?, H> messageHandlerSpec,
|
||||
Consumer<GenericEndpointSpec<H>> endpointConfigurer) {
|
||||
Assert.notNull(messageHandlerSpec);
|
||||
if (messageHandlerSpec instanceof ComponentsRegistration) {
|
||||
addComponents(((ComponentsRegistration) messageHandlerSpec).getComponentsToRegister());
|
||||
}
|
||||
return handle(messageHandlerSpec.get(), endpointConfigurer);
|
||||
}
|
||||
|
||||
public <H extends MessageHandler> B handle(H messageHandler, Consumer<GenericEndpointSpec<H>> endpointConfigurer) {
|
||||
Assert.notNull(messageHandler);
|
||||
return this.register(new GenericEndpointSpec<H>(messageHandler), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B bridge(Consumer<GenericEndpointSpec<BridgeHandler>> endpointConfigurer) {
|
||||
return this.register(new GenericEndpointSpec<BridgeHandler>(new BridgeHandler()), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B delay(String groupId) {
|
||||
return this.delay(groupId, (String) null);
|
||||
}
|
||||
|
||||
public B delay(String groupId, Consumer<DelayerEndpointSpec> endpointConfigurer) {
|
||||
return this.delay(groupId, (String) null, endpointConfigurer);
|
||||
}
|
||||
|
||||
public B delay(String groupId, String expression) {
|
||||
return this.delay(groupId, expression, null);
|
||||
}
|
||||
|
||||
public <P> B delay(String groupId, Function<Message<P>, Object> function) {
|
||||
return this.delay(groupId, function, null);
|
||||
}
|
||||
|
||||
public <P> B delay(String groupId, Function<Message<P>, Object> function,
|
||||
Consumer<DelayerEndpointSpec> endpointConfigurer) {
|
||||
Assert.notNull(function);
|
||||
return this.delay(groupId, new FunctionExpression<Message<P>>(function), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B delay(String groupId, String expression, Consumer<DelayerEndpointSpec> endpointConfigurer) {
|
||||
return delay(groupId,
|
||||
StringUtils.hasText(expression) ? PARSER.parseExpression(expression) : null,
|
||||
endpointConfigurer);
|
||||
}
|
||||
|
||||
private B delay(String groupId, Expression expression, Consumer<DelayerEndpointSpec> endpointConfigurer) {
|
||||
DelayHandler delayHandler = new DelayHandler(groupId);
|
||||
if (expression != null) {
|
||||
delayHandler.setDelayExpression(expression);
|
||||
}
|
||||
return this.register(new DelayerEndpointSpec(delayHandler), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B enrich(Consumer<EnricherSpec> enricherConfigurer) {
|
||||
return this.enrich(enricherConfigurer, null);
|
||||
}
|
||||
|
||||
public B enrich(Consumer<EnricherSpec> enricherConfigurer,
|
||||
Consumer<GenericEndpointSpec<ContentEnricher>> endpointConfigurer) {
|
||||
Assert.notNull(enricherConfigurer);
|
||||
EnricherSpec enricherSpec = new EnricherSpec();
|
||||
enricherConfigurer.accept(enricherSpec);
|
||||
return this.handle(enricherSpec.get(), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B enrichHeaders(MapBuilder<?, String, Object> headers) {
|
||||
return enrichHeaders(headers, null);
|
||||
}
|
||||
|
||||
public B enrichHeaders(MapBuilder<?, String, Object> headers,
|
||||
Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
|
||||
return enrichHeaders(headers.get(), endpointConfigurer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept a {@link Map} of values to be used for the
|
||||
* {@link org.springframework.messaging.Message} header enrichment.
|
||||
* {@code values} can apply an {@link org.springframework.expression.Expression}
|
||||
* to be evaluated against a request {@link org.springframework.messaging.Message}.
|
||||
* @param headers the Map of headers to enrich.
|
||||
* @return this.
|
||||
*/
|
||||
public B enrichHeaders(Map<String, Object> headers) {
|
||||
return enrichHeaders(headers, null);
|
||||
}
|
||||
|
||||
public B enrichHeaders(final Map<String, Object> headers,
|
||||
Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
|
||||
return enrichHeaders(new Consumer<HeaderEnricherSpec>() {
|
||||
|
||||
@Override
|
||||
public void accept(HeaderEnricherSpec spec) {
|
||||
spec.headers(headers);
|
||||
}
|
||||
|
||||
}, endpointConfigurer);
|
||||
}
|
||||
|
||||
public B enrichHeaders(Consumer<HeaderEnricherSpec> headerEnricherConfigurer) {
|
||||
return this.enrichHeaders(headerEnricherConfigurer, null);
|
||||
}
|
||||
|
||||
public B enrichHeaders(Consumer<HeaderEnricherSpec> headerEnricherConfigurer,
|
||||
Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
|
||||
Assert.notNull(headerEnricherConfigurer);
|
||||
HeaderEnricherSpec headerEnricherSpec = new HeaderEnricherSpec();
|
||||
headerEnricherConfigurer.accept(headerEnricherSpec);
|
||||
return transform(headerEnricherSpec.get(), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B split() {
|
||||
return this.split((Consumer<SplitterEndpointSpec<DefaultMessageSplitter>>) null);
|
||||
}
|
||||
|
||||
public B split(Consumer<SplitterEndpointSpec<DefaultMessageSplitter>> endpointConfigurer) {
|
||||
return this.split(new DefaultMessageSplitter(), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B split(String expression,
|
||||
Consumer<SplitterEndpointSpec<ExpressionEvaluatingSplitter>> endpointConfigurer) {
|
||||
return this.split(new ExpressionEvaluatingSplitter(PARSER.parseExpression(expression)), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B split(String beanName, String methodName) {
|
||||
return this.split(beanName, methodName, null);
|
||||
}
|
||||
|
||||
public B split(String beanName, String methodName,
|
||||
Consumer<SplitterEndpointSpec<MethodInvokingSplitter>> endpointConfigurer) {
|
||||
return this.split(new MethodInvokingSplitter(new BeanNameMessageProcessor<Object>(beanName, methodName)),
|
||||
endpointConfigurer);
|
||||
}
|
||||
|
||||
public <P> B split(Class<P> payloadType, Function<P, ?> splitter) {
|
||||
return split(payloadType, splitter, null);
|
||||
}
|
||||
|
||||
public <P> B split(Function<P, ?> splitter,
|
||||
Consumer<SplitterEndpointSpec<MethodInvokingSplitter>> endpointConfigurer) {
|
||||
return split(null, splitter, endpointConfigurer);
|
||||
}
|
||||
|
||||
public <P> B split(Class<P> payloadType, Function<P, ?> splitter,
|
||||
Consumer<SplitterEndpointSpec<MethodInvokingSplitter>> endpointConfigurer) {
|
||||
MethodInvokingSplitter split = isLambda(splitter)
|
||||
? new MethodInvokingSplitter(new LambdaMessageProcessor(splitter, payloadType))
|
||||
: new MethodInvokingSplitter(splitter);
|
||||
return this.split(split, endpointConfigurer);
|
||||
}
|
||||
|
||||
public <S extends AbstractMessageSplitter> B split(S splitter,
|
||||
Consumer<SplitterEndpointSpec<S>> endpointConfigurer) {
|
||||
Assert.notNull(splitter);
|
||||
return this.register(new SplitterEndpointSpec<S>(splitter), endpointConfigurer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the {@link HeaderFilter} to the current {@link StandardIntegrationFlow}.
|
||||
* @param headersToRemove the array of headers (or patterns)
|
||||
* to remove from {@link org.springframework.messaging.MessageHeaders}.
|
||||
* @return this {@link IntegrationFlowDefinition}.
|
||||
*/
|
||||
public B headerFilter(String... headersToRemove) {
|
||||
return this.headerFilter(new HeaderFilter(headersToRemove), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the {@link HeaderFilter} to the current {@link StandardIntegrationFlow}.
|
||||
* @param headersToRemove the comma separated headers (or patterns) to remove from
|
||||
* {@link org.springframework.messaging.MessageHeaders}.
|
||||
* @param patternMatch the {@code boolean} flag to indicate if {@code headersToRemove}
|
||||
* should be interpreted as patterns or direct header names.
|
||||
* @return this {@link IntegrationFlowDefinition}.
|
||||
*/
|
||||
public B headerFilter(String headersToRemove, boolean patternMatch) {
|
||||
HeaderFilter headerFilter = new HeaderFilter(StringUtils.delimitedListToStringArray(headersToRemove, ",", " "));
|
||||
headerFilter.setPatternMatch(patternMatch);
|
||||
return this.headerFilter(headerFilter, null);
|
||||
}
|
||||
|
||||
public B headerFilter(HeaderFilter headerFilter,
|
||||
Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
|
||||
return this.transform(headerFilter, endpointConfigurer);
|
||||
}
|
||||
|
||||
public B claimCheckIn(MessageStore messageStore) {
|
||||
return this.claimCheckIn(messageStore, null);
|
||||
}
|
||||
|
||||
public B claimCheckIn(MessageStore messageStore,
|
||||
Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
|
||||
return this.transform(new ClaimCheckInTransformer(messageStore), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B claimCheckOut(MessageStore messageStore) {
|
||||
return this.claimCheckOut(messageStore, false);
|
||||
}
|
||||
|
||||
public B claimCheckOut(MessageStore messageStore, boolean removeMessage) {
|
||||
return this.claimCheckOut(messageStore, removeMessage, null);
|
||||
}
|
||||
|
||||
public B claimCheckOut(MessageStore messageStore, boolean removeMessage,
|
||||
Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
|
||||
ClaimCheckOutTransformer claimCheckOutTransformer = new ClaimCheckOutTransformer(messageStore);
|
||||
claimCheckOutTransformer.setRemoveMessage(removeMessage);
|
||||
return this.transform(claimCheckOutTransformer, endpointConfigurer);
|
||||
}
|
||||
|
||||
public B resequence() {
|
||||
return this.resequence((Consumer<GenericEndpointSpec<ResequencingMessageHandler>>) null);
|
||||
}
|
||||
|
||||
public B resequence(Consumer<GenericEndpointSpec<ResequencingMessageHandler>> endpointConfigurer) {
|
||||
return this.handle(new ResequencerSpec().get(), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B resequence(Consumer<ResequencerSpec> resequencerConfigurer,
|
||||
Consumer<GenericEndpointSpec<ResequencingMessageHandler>> endpointConfigurer) {
|
||||
Assert.notNull(resequencerConfigurer);
|
||||
ResequencerSpec spec = new ResequencerSpec();
|
||||
resequencerConfigurer.accept(spec);
|
||||
return this.handle(spec.get(), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B aggregate() {
|
||||
return aggregate((Consumer<GenericEndpointSpec<AggregatingMessageHandler>>) null);
|
||||
}
|
||||
|
||||
public B
|
||||
aggregate(Consumer<GenericEndpointSpec<AggregatingMessageHandler>> endpointConfigurer) {
|
||||
return handle(new AggregatorSpec().get(), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B aggregate(Consumer<AggregatorSpec> aggregatorConfigurer,
|
||||
Consumer<GenericEndpointSpec<AggregatingMessageHandler>> endpointConfigurer) {
|
||||
Assert.notNull(aggregatorConfigurer);
|
||||
AggregatorSpec spec = new AggregatorSpec();
|
||||
aggregatorConfigurer.accept(spec);
|
||||
return this.handle(spec.get(), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B route(String beanName, String method) {
|
||||
return this.route(beanName, method, null);
|
||||
}
|
||||
|
||||
public B route(String beanName, String method, Consumer<RouterSpec<MethodInvokingRouter>> routerConfigurer) {
|
||||
return this.route(beanName, method, routerConfigurer, null);
|
||||
}
|
||||
|
||||
public B route(String beanName, String method, Consumer<RouterSpec<MethodInvokingRouter>> routerConfigurer,
|
||||
Consumer<GenericEndpointSpec<MethodInvokingRouter>> endpointConfigurer) {
|
||||
return this.route(new MethodInvokingRouter(new BeanNameMessageProcessor<Object>(beanName, method)),
|
||||
routerConfigurer, endpointConfigurer);
|
||||
}
|
||||
|
||||
public B route(String expression) {
|
||||
return this.route(expression, (Consumer<RouterSpec<ExpressionEvaluatingRouter>>) null);
|
||||
}
|
||||
|
||||
public B route(String expression, Consumer<RouterSpec<ExpressionEvaluatingRouter>> routerConfigurer) {
|
||||
return this.route(expression, routerConfigurer, null);
|
||||
}
|
||||
|
||||
public B route(String expression, Consumer<RouterSpec<ExpressionEvaluatingRouter>> routerConfigurer,
|
||||
Consumer<GenericEndpointSpec<ExpressionEvaluatingRouter>> endpointConfigurer) {
|
||||
return this.route(new ExpressionEvaluatingRouter(PARSER.parseExpression(expression)), routerConfigurer,
|
||||
endpointConfigurer);
|
||||
}
|
||||
|
||||
public <S, T> B route(Function<S, T> router) {
|
||||
return this.route(null, router);
|
||||
}
|
||||
|
||||
public <S, T> B route(Function<S, T> router, Consumer<RouterSpec<MethodInvokingRouter>> routerConfigurer) {
|
||||
return this.route(null, router, routerConfigurer);
|
||||
}
|
||||
|
||||
public <P, T> B route(Class<P> payloadType, Function<P, T> router) {
|
||||
return this.route(payloadType, router, null, null);
|
||||
}
|
||||
|
||||
public <P, T> B route(Class<P> payloadType, Function<P, T> router,
|
||||
Consumer<RouterSpec<MethodInvokingRouter>> routerConfigurer) {
|
||||
return this.route(payloadType, router, routerConfigurer, null);
|
||||
}
|
||||
|
||||
public <S, T> B route(Function<S, T> router, Consumer<RouterSpec<MethodInvokingRouter>> routerConfigurer,
|
||||
Consumer<GenericEndpointSpec<MethodInvokingRouter>> endpointConfigurer) {
|
||||
return route(null, router, routerConfigurer, endpointConfigurer);
|
||||
}
|
||||
|
||||
public <P, T> B route(Class<P> payloadType, Function<P, T> router,
|
||||
Consumer<RouterSpec<MethodInvokingRouter>> routerConfigurer,
|
||||
Consumer<GenericEndpointSpec<MethodInvokingRouter>> endpointConfigurer) {
|
||||
MethodInvokingRouter methodInvokingRouter = isLambda(router)
|
||||
? new MethodInvokingRouter(new LambdaMessageProcessor(router, payloadType))
|
||||
: new MethodInvokingRouter(router);
|
||||
return route(methodInvokingRouter, routerConfigurer, endpointConfigurer);
|
||||
}
|
||||
|
||||
public <R extends AbstractMappingMessageRouter> B route(R router, Consumer<RouterSpec<R>> routerConfigurer,
|
||||
Consumer<GenericEndpointSpec<R>> endpointConfigurer) {
|
||||
Collection<Object> componentsToRegister = null;
|
||||
if (routerConfigurer != null) {
|
||||
RouterSpec<R> routerSpec = new RouterSpec<R>(router);
|
||||
routerConfigurer.accept(routerSpec);
|
||||
componentsToRegister = routerSpec.getComponentsToRegister();
|
||||
}
|
||||
|
||||
route(router, endpointConfigurer);
|
||||
|
||||
final MessageChannel afterRouterChannel = new DirectChannel();
|
||||
boolean hasSubFlows = false;
|
||||
if (!CollectionUtils.isEmpty(componentsToRegister)) {
|
||||
for (Object component : componentsToRegister) {
|
||||
if (component instanceof IntegrationFlowDefinition) {
|
||||
hasSubFlows = true;
|
||||
IntegrationFlowDefinition<?> flowBuilder = (IntegrationFlowDefinition<?>) component;
|
||||
addComponent(flowBuilder.fixedSubscriberChannel()
|
||||
.bridge(new Consumer<GenericEndpointSpec<BridgeHandler>>() {
|
||||
|
||||
@Override
|
||||
public void accept(GenericEndpointSpec<BridgeHandler> bridge) {
|
||||
bridge.get().getT2().setOutputChannel(afterRouterChannel);
|
||||
}
|
||||
|
||||
})
|
||||
.get());
|
||||
}
|
||||
else {
|
||||
addComponent(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasSubFlows) {
|
||||
channel(afterRouterChannel);
|
||||
}
|
||||
return _this();
|
||||
}
|
||||
|
||||
public B routeToRecipients(Consumer<RecipientListRouterSpec> routerConfigurer) {
|
||||
return routeToRecipients(routerConfigurer, null);
|
||||
}
|
||||
|
||||
public B routeToRecipients(Consumer<RecipientListRouterSpec> routerConfigurer,
|
||||
Consumer<GenericEndpointSpec<RecipientListRouter>> endpointConfigurer) {
|
||||
Assert.notNull(routerConfigurer);
|
||||
RecipientListRouterSpec spec = new RecipientListRouterSpec();
|
||||
routerConfigurer.accept(spec);
|
||||
addComponents(spec.getComponentsToRegister());
|
||||
return route(spec.get(), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B route(AbstractMessageRouter router) {
|
||||
return route(router, null);
|
||||
}
|
||||
|
||||
public <R extends AbstractMessageRouter> B route(R router, Consumer<GenericEndpointSpec<R>> endpointConfigurer) {
|
||||
return handle(router, endpointConfigurer);
|
||||
}
|
||||
|
||||
public B gateway(String requestChannel) {
|
||||
return gateway(requestChannel, null);
|
||||
}
|
||||
|
||||
public B gateway(String requestChannel, Consumer<GatewayEndpointSpec> endpointConfigurer) {
|
||||
return register(new GatewayEndpointSpec(requestChannel), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B gateway(MessageChannel requestChannel) {
|
||||
return gateway(requestChannel, null);
|
||||
}
|
||||
|
||||
public B gateway(MessageChannel requestChannel, Consumer<GatewayEndpointSpec> endpointConfigurer) {
|
||||
return register(new GatewayEndpointSpec(requestChannel), endpointConfigurer);
|
||||
}
|
||||
|
||||
public B gateway(IntegrationFlow flow) {
|
||||
return gateway(flow, null);
|
||||
}
|
||||
|
||||
public B gateway(IntegrationFlow flow, Consumer<GatewayEndpointSpec> endpointConfigurer) {
|
||||
Assert.notNull(flow);
|
||||
final DirectChannel requestChannel = new DirectChannel();
|
||||
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(requestChannel);
|
||||
flow.accept(flowBuilder);
|
||||
addComponent(flowBuilder.get());
|
||||
return gateway(requestChannel, endpointConfigurer);
|
||||
}
|
||||
|
||||
private <S extends ConsumerEndpointSpec<S, ?>> B register(S endpointSpec, Consumer<S> endpointConfigurer) {
|
||||
if (endpointConfigurer != null) {
|
||||
endpointConfigurer.accept(endpointSpec);
|
||||
}
|
||||
if (endpointSpec instanceof ComponentsRegistration) {
|
||||
addComponents(((ComponentsRegistration) endpointSpec).getComponentsToRegister());
|
||||
}
|
||||
MessageChannel inputChannel = this.currentMessageChannel;
|
||||
this.currentMessageChannel = null;
|
||||
if (inputChannel == null) {
|
||||
inputChannel = new DirectChannel();
|
||||
this.registerOutputChannelIfCan(inputChannel);
|
||||
}
|
||||
|
||||
if (inputChannel instanceof MessageChannelReference) {
|
||||
endpointSpec.get().getT1().setInputChannelName(((MessageChannelReference) inputChannel).getName());
|
||||
}
|
||||
else {
|
||||
if (inputChannel instanceof FixedSubscriberChannelPrototype) {
|
||||
String beanName = ((FixedSubscriberChannelPrototype) inputChannel).getName();
|
||||
inputChannel = new FixedSubscriberChannel(endpointSpec.get().getT2());
|
||||
if (beanName != null) {
|
||||
((FixedSubscriberChannel) inputChannel).setBeanName(beanName);
|
||||
}
|
||||
this.registerOutputChannelIfCan(inputChannel);
|
||||
}
|
||||
endpointSpec.get().getT1().setInputChannel(inputChannel);
|
||||
}
|
||||
|
||||
return this.addComponent(endpointSpec).currentComponent(endpointSpec.get().getT2());
|
||||
}
|
||||
|
||||
private B registerOutputChannelIfCan(MessageChannel outputChannel) {
|
||||
if (!(outputChannel instanceof FixedSubscriberChannelPrototype)) {
|
||||
this.integrationComponents.add(outputChannel);
|
||||
if (this.currentComponent != null) {
|
||||
String channelName = null;
|
||||
if (outputChannel instanceof MessageChannelReference) {
|
||||
channelName = ((MessageChannelReference) outputChannel).getName();
|
||||
}
|
||||
|
||||
Object currentComponent = this.currentComponent;
|
||||
|
||||
if (AopUtils.isAopProxy(currentComponent)) {
|
||||
currentComponent = extractProxyTarget(currentComponent);
|
||||
}
|
||||
|
||||
if (currentComponent instanceof AbstractReplyProducingMessageHandler) {
|
||||
AbstractReplyProducingMessageHandler messageProducer =
|
||||
(AbstractReplyProducingMessageHandler) currentComponent;
|
||||
if (channelName != null) {
|
||||
messageProducer.setOutputChannelName(channelName);
|
||||
}
|
||||
else {
|
||||
messageProducer.setOutputChannel(outputChannel);
|
||||
}
|
||||
}
|
||||
else if (currentComponent instanceof SourcePollingChannelAdapterSpec) {
|
||||
SourcePollingChannelAdapterFactoryBean pollingChannelAdapterFactoryBean =
|
||||
((SourcePollingChannelAdapterSpec) currentComponent).get().getT1();
|
||||
if (channelName != null) {
|
||||
pollingChannelAdapterFactoryBean.setOutputChannelName(channelName);
|
||||
}
|
||||
else {
|
||||
pollingChannelAdapterFactoryBean.setOutputChannel(outputChannel);
|
||||
}
|
||||
}
|
||||
else if (currentComponent instanceof AbstractCorrelatingMessageHandler) {
|
||||
AbstractCorrelatingMessageHandler messageProducer =
|
||||
(AbstractCorrelatingMessageHandler) currentComponent;
|
||||
if (channelName != null) {
|
||||
messageProducer.setOutputChannelName(channelName);
|
||||
}
|
||||
else {
|
||||
messageProducer.setOutputChannel(outputChannel);
|
||||
}
|
||||
}
|
||||
else if (this.currentComponent instanceof AbstractMessageRouter) {
|
||||
AbstractMessageRouter router = (AbstractMessageRouter) this.currentComponent;
|
||||
if (channelName != null) {
|
||||
router.setDefaultOutputChannelName(channelName);
|
||||
}
|
||||
else {
|
||||
router.setDefaultOutputChannel(outputChannel);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new BeanCreationException("The 'currentComponent' (" + currentComponent +
|
||||
") is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'. " +
|
||||
"This is the end of the integration flow.");
|
||||
}
|
||||
this.currentComponent = null;
|
||||
}
|
||||
}
|
||||
return _this();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected final B _this() {
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
private static boolean isLambda(Object o) {
|
||||
Class<?> aClass = o.getClass();
|
||||
return aClass.isSynthetic() && !aClass.isAnonymousClass() && !aClass.isLocalClass();
|
||||
}
|
||||
|
||||
private static Object extractProxyTarget(Object target) {
|
||||
if (!(target instanceof Advised)) {
|
||||
return target;
|
||||
}
|
||||
Advised advised = (Advised) target;
|
||||
if (advised.getTargetSource() == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return extractProxyTarget(advised.getTargetSource().getTarget());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new BeanCreationException("Could not extract target", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected StandardIntegrationFlow get() {
|
||||
if (this.currentMessageChannel instanceof FixedSubscriberChannelPrototype) {
|
||||
throw new BeanCreationException("The 'currentMessageChannel' (" + this.currentMessageChannel +
|
||||
") is a prototype for FixedSubscriberChannel which can't be created without MessageHandler " +
|
||||
"constructor argument. That means that '.fixedSubscriberChannel()' can't be the last EIP-method " +
|
||||
"in the IntegrationFlow definition.");
|
||||
}
|
||||
|
||||
if (this.integrationComponents.size() == 1) {
|
||||
if (this.currentComponent != null) {
|
||||
if (this.currentComponent instanceof SourcePollingChannelAdapterSpec) {
|
||||
throw new BeanCreationException("The 'SourcePollingChannelAdapter' (" + this.currentComponent
|
||||
+ ") " + "must be configured with at least one 'MessageChanel' or 'MessageHandler'.");
|
||||
}
|
||||
}
|
||||
else if (this.currentMessageChannel != null) {
|
||||
throw new BeanCreationException("The 'IntegrationFlow' can't consist of only one 'MessageChannel'. " +
|
||||
"Add at lest '.bridge()' EIP-method before the end of flow.");
|
||||
}
|
||||
}
|
||||
return new StandardIntegrationFlow(this.integrationComponents);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,209 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.channel.MessageChannelSpec;
|
||||
import org.springframework.integration.dsl.core.ComponentsRegistration;
|
||||
import org.springframework.integration.dsl.core.MessageProducerSpec;
|
||||
import org.springframework.integration.dsl.core.MessageSourceSpec;
|
||||
import org.springframework.integration.dsl.core.MessagingGatewaySpec;
|
||||
import org.springframework.integration.dsl.support.Consumer;
|
||||
import org.springframework.integration.dsl.support.FixedSubscriberChannelPrototype;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.dsl.support.MessageChannelReference;
|
||||
import org.springframework.integration.endpoint.MessageProducerSupport;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The central factory for fluent {@link IntegrationFlowBuilder} API.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public final class IntegrationFlows {
|
||||
|
||||
/**
|
||||
* @param messageChannelName the name of existing {@link MessageChannel} bean.
|
||||
* The new {@link DirectChannel} bean will be created on context startup
|
||||
* if there is no bean with this name.
|
||||
* @return new {@link IntegrationFlowBuilder}
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(String messageChannelName) {
|
||||
return from(new MessageChannelReference(messageChannelName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param messageChannelName the name for {@link DirectChannel} or
|
||||
* {@link org.springframework.integration.channel.FixedSubscriberChannel}
|
||||
* to be created on context startup, not reference.
|
||||
* The {@link MessageChannel} depends on the {@code fixedSubscriber} boolean argument.
|
||||
* @param fixedSubscriber the boolean flag to determine if result {@link MessageChannel} should
|
||||
* be {@link DirectChannel}, if {@code false} or
|
||||
* {@link org.springframework.integration.channel.FixedSubscriberChannel}, if {@code true}.
|
||||
* @return new {@link IntegrationFlowBuilder}
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(String messageChannelName, boolean fixedSubscriber) {
|
||||
return fixedSubscriber
|
||||
? from(new FixedSubscriberChannelPrototype(messageChannelName))
|
||||
: from(messageChannelName);
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(ChannelsFunction channels) {
|
||||
Assert.notNull(channels);
|
||||
return from(channels.apply(new Channels()));
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessageChannelSpec<?, ?> messageChannelSpec) {
|
||||
Assert.notNull(messageChannelSpec);
|
||||
return from(messageChannelSpec.get());
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessageChannel messageChannel) {
|
||||
return new IntegrationFlowBuilder().channel(messageChannel);
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessageSourcesFunction sources) {
|
||||
return from(sources, null);
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessageSourcesFunction sources,
|
||||
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
|
||||
Assert.notNull(sources);
|
||||
return from(sources.apply(new MessageSources()), endpointConfigurer);
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessageSourceSpec<?, ? extends MessageSource<?>> messageSourceSpec) {
|
||||
return from(messageSourceSpec, null);
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessageSourceSpec<?, ? extends MessageSource<?>> messageSourceSpec,
|
||||
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
|
||||
Assert.notNull(messageSourceSpec);
|
||||
return from(messageSourceSpec.get(), endpointConfigurer, registerComponents(messageSourceSpec));
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessageSource<?> messageSource) {
|
||||
return from(messageSource, null);
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessageSource<?> messageSource,
|
||||
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
|
||||
return from(messageSource, endpointConfigurer, null);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder from(MessageSource<?> messageSource,
|
||||
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer,
|
||||
IntegrationFlowBuilder integrationFlowBuilder) {
|
||||
SourcePollingChannelAdapterSpec spec = new SourcePollingChannelAdapterSpec(messageSource);
|
||||
if (endpointConfigurer != null) {
|
||||
endpointConfigurer.accept(spec);
|
||||
}
|
||||
if (integrationFlowBuilder == null) {
|
||||
integrationFlowBuilder = new IntegrationFlowBuilder();
|
||||
}
|
||||
return integrationFlowBuilder.addComponent(spec)
|
||||
.currentComponent(spec);
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessageProducersFunction producers) {
|
||||
return from(producers.apply(new MessageProducers()));
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessageProducerSpec<?, ?> messageProducerSpec) {
|
||||
return from(messageProducerSpec.get(), registerComponents(messageProducerSpec));
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessageProducerSupport messageProducer) {
|
||||
return from(messageProducer, null);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder from(MessageProducerSupport messageProducer,
|
||||
IntegrationFlowBuilder integrationFlowBuilder) {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(messageProducer);
|
||||
MessageChannel outputChannel = (MessageChannel) dfa.getPropertyValue("outputChannel");
|
||||
if (outputChannel == null) {
|
||||
outputChannel = new DirectChannel();
|
||||
messageProducer.setOutputChannel(outputChannel);
|
||||
}
|
||||
if (integrationFlowBuilder == null) {
|
||||
integrationFlowBuilder = from(outputChannel);
|
||||
}
|
||||
else {
|
||||
integrationFlowBuilder.channel(outputChannel);
|
||||
}
|
||||
return integrationFlowBuilder.addComponent(messageProducer);
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessagingGatewaysFunction gateways) {
|
||||
return from(gateways.apply(new MessagingGateways()));
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessagingGatewaySpec<?, ?> inboundGatewaySpec) {
|
||||
return from(inboundGatewaySpec.get(), registerComponents(inboundGatewaySpec));
|
||||
}
|
||||
|
||||
public static IntegrationFlowBuilder from(MessagingGatewaySupport inboundGateway) {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(inboundGateway);
|
||||
MessageChannel outputChannel = (MessageChannel) dfa.getPropertyValue("requestChannel");
|
||||
if (outputChannel == null) {
|
||||
outputChannel = new DirectChannel();
|
||||
inboundGateway.setRequestChannel(outputChannel);
|
||||
}
|
||||
return from(outputChannel).addComponent(inboundGateway);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder from(MessagingGatewaySupport inboundGateway,
|
||||
IntegrationFlowBuilder integrationFlowBuilder) {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(inboundGateway);
|
||||
MessageChannel outputChannel = (MessageChannel) dfa.getPropertyValue("requestChannel");
|
||||
if (outputChannel == null) {
|
||||
outputChannel = new DirectChannel();
|
||||
inboundGateway.setRequestChannel(outputChannel);
|
||||
}
|
||||
if (integrationFlowBuilder == null) {
|
||||
integrationFlowBuilder = from(outputChannel);
|
||||
}
|
||||
else {
|
||||
integrationFlowBuilder.channel(outputChannel);
|
||||
}
|
||||
return integrationFlowBuilder.addComponent(inboundGateway);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder registerComponents(Object spec) {
|
||||
if (spec instanceof ComponentsRegistration) {
|
||||
return new IntegrationFlowBuilder()
|
||||
.addComponents(((ComponentsRegistration) spec).getComponentsToRegister());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private IntegrationFlows() {
|
||||
}
|
||||
|
||||
public interface ChannelsFunction extends Function<Channels, MessageChannelSpec<?, ?>> {}
|
||||
|
||||
public interface MessageSourcesFunction extends Function<MessageSources, MessageSourceSpec<?, ?>> {}
|
||||
|
||||
public interface MessageProducersFunction extends Function<MessageProducers, MessageProducerSpec<?, ?>> {}
|
||||
|
||||
public interface MessagingGatewaysFunction extends Function<MessagingGateways, MessagingGatewaySpec<?, ?>> {}
|
||||
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.support.utils.IntegrationUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
class LambdaMessageProcessor implements MessageProcessor<Object>, BeanFactoryAware {
|
||||
|
||||
private final Object target;
|
||||
|
||||
private final Method method;
|
||||
|
||||
private final TypeDescriptor payloadType;
|
||||
|
||||
private final Class<?>[] parameterTypes;
|
||||
|
||||
|
||||
private ConversionService conversionService;
|
||||
|
||||
public LambdaMessageProcessor(Object target, Class<?> payloadType) {
|
||||
Assert.notNull(target);
|
||||
this.target = target;
|
||||
final AtomicReference<Method> methodValue = new AtomicReference<Method>();
|
||||
ReflectionUtils.doWithMethods(target.getClass(), new ReflectionUtils.MethodCallback() {
|
||||
|
||||
@Override
|
||||
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
|
||||
methodValue.set(method);
|
||||
}
|
||||
|
||||
}, new ReflectionUtils.MethodFilter() {
|
||||
|
||||
@Override
|
||||
public boolean matches(Method method) {
|
||||
return !method.isBridge() && method.getDeclaringClass() != Object.class &&
|
||||
Modifier.isPublic(method.getModifiers()) && !Modifier.isStatic(method.getModifiers());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Assert.notNull(methodValue.get(), "LambdaMessageProcessor is applicable for inline or lambda " +
|
||||
"classes with single method - functional interfaces implementations.");
|
||||
|
||||
this.method = methodValue.get();
|
||||
this.method.setAccessible(true);
|
||||
this.parameterTypes = this.method.getParameterTypes();
|
||||
this.payloadType = TypeDescriptor.valueOf(payloadType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
ConversionService conversionService = IntegrationUtils.getConversionService(beanFactory);
|
||||
if (conversionService == null) {
|
||||
conversionService = new DefaultConversionService();
|
||||
}
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object processMessage(Message<?> message) {
|
||||
Object[] args = new Object[this.parameterTypes.length];
|
||||
for (int i = 0; i < this.parameterTypes.length; i++) {
|
||||
Class<?> parameterType = this.parameterTypes[i];
|
||||
if (Message.class.isAssignableFrom(parameterType)) {
|
||||
args[i] = message;
|
||||
}
|
||||
if (Map.class.isAssignableFrom(parameterType)) {
|
||||
if (message.getPayload() instanceof Map) {
|
||||
args[i] = message.getPayload();
|
||||
}
|
||||
else {
|
||||
args[i] = message.getHeaders();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.payloadType != null) {
|
||||
if (Message.class.isAssignableFrom(this.payloadType.getType())) {
|
||||
args[i] = message;
|
||||
}
|
||||
else {
|
||||
args[i] = this.conversionService.convert(message.getPayload(),
|
||||
TypeDescriptor.forObject(message.getPayload()), this.payloadType);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
args[i] = message.getPayload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return this.method.invoke(this.target, args);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new MessageHandlingException(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.integration.dsl.amqp.Amqp;
|
||||
import org.springframework.integration.dsl.amqp.AmqpInboundChannelAdapterSpec;
|
||||
import org.springframework.integration.dsl.file.Files;
|
||||
import org.springframework.integration.dsl.file.TailAdapterSpec;
|
||||
import org.springframework.integration.dsl.jms.Jms;
|
||||
import org.springframework.integration.dsl.jms.JmsMessageDrivenChannelAdapterSpec;
|
||||
import org.springframework.integration.dsl.mail.ImapIdleChannelAdapterSpec;
|
||||
import org.springframework.integration.dsl.mail.Mail;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class MessageProducers {
|
||||
|
||||
public AmqpInboundChannelAdapterSpec amqp(
|
||||
org.springframework.amqp.rabbit.connection.ConnectionFactory connectionFactory, String... queueNames) {
|
||||
return Amqp.inboundAdapter(connectionFactory, queueNames);
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec amqp(
|
||||
org.springframework.amqp.rabbit.connection.ConnectionFactory connectionFactory, Queue... queues) {
|
||||
return Amqp.inboundAdapter(connectionFactory, queues);
|
||||
}
|
||||
|
||||
public TailAdapterSpec tail(File file) {
|
||||
return Files.tailAdapter(file);
|
||||
}
|
||||
|
||||
public ImapIdleChannelAdapterSpec imap(String url) {
|
||||
return Mail.imapIdleAdapter(url);
|
||||
}
|
||||
|
||||
public JmsMessageDrivenChannelAdapterSpec<? extends JmsMessageDrivenChannelAdapterSpec<?>> jms(
|
||||
AbstractMessageListenerContainer listenerContainer) {
|
||||
return Jms.messageDriverChannelAdapter(listenerContainer);
|
||||
}
|
||||
|
||||
public JmsMessageDrivenChannelAdapterSpec<? extends JmsMessageDrivenChannelAdapterSpec<?>> jms(
|
||||
javax.jms.ConnectionFactory connectionFactory) {
|
||||
return Jms.messageDriverChannelAdapter(connectionFactory);
|
||||
}
|
||||
|
||||
public <C extends AbstractMessageListenerContainer>
|
||||
JmsMessageDrivenChannelAdapterSpec<? extends JmsMessageDrivenChannelAdapterSpec<?>> jms(
|
||||
javax.jms.ConnectionFactory connectionFactory,
|
||||
Class<C> containerClass) {
|
||||
return Jms.messageDriverChannelAdapter(connectionFactory, containerClass);
|
||||
}
|
||||
|
||||
MessageProducers() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
|
||||
import org.springframework.integration.dsl.file.FileInboundChannelAdapterSpec;
|
||||
import org.springframework.integration.dsl.file.Files;
|
||||
import org.springframework.integration.dsl.ftp.Ftp;
|
||||
import org.springframework.integration.dsl.ftp.FtpInboundChannelAdapterSpec;
|
||||
import org.springframework.integration.dsl.jms.Jms;
|
||||
import org.springframework.integration.dsl.jms.JmsInboundChannelAdapterSpec;
|
||||
import org.springframework.integration.dsl.mail.ImapMailInboundChannelAdapterSpec;
|
||||
import org.springframework.integration.dsl.mail.Mail;
|
||||
import org.springframework.integration.dsl.mail.Pop3MailInboundChannelAdapterSpec;
|
||||
import org.springframework.integration.dsl.sftp.Sftp;
|
||||
import org.springframework.integration.dsl.sftp.SftpInboundChannelAdapterSpec;
|
||||
import org.springframework.integration.file.remote.session.SessionFactory;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class MessageSources {
|
||||
|
||||
public FileInboundChannelAdapterSpec file(File directory) {
|
||||
return file(directory, null);
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec file(File directory, Comparator<File> receptionOrderComparator) {
|
||||
return Files.inboundAdapter(directory, receptionOrderComparator);
|
||||
}
|
||||
|
||||
public FtpInboundChannelAdapterSpec ftp(SessionFactory<FTPFile> sessionFactory) {
|
||||
return ftp(sessionFactory, null);
|
||||
}
|
||||
|
||||
public FtpInboundChannelAdapterSpec ftp(SessionFactory<FTPFile> sessionFactory,
|
||||
Comparator<File> receptionOrderComparator) {
|
||||
return Ftp.inboundAdapter(sessionFactory, receptionOrderComparator);
|
||||
}
|
||||
|
||||
public SftpInboundChannelAdapterSpec sftp(SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
|
||||
return sftp(sessionFactory, null);
|
||||
}
|
||||
|
||||
public SftpInboundChannelAdapterSpec sftp(SessionFactory<ChannelSftp.LsEntry> sessionFactory,
|
||||
Comparator<File> receptionOrderComparator) {
|
||||
return Sftp.inboundAdapter(sessionFactory, receptionOrderComparator);
|
||||
}
|
||||
|
||||
public JmsInboundChannelAdapterSpec<? extends JmsInboundChannelAdapterSpec<?>> jms(JmsTemplate jmsTemplate) {
|
||||
return Jms.inboundAdapter(jmsTemplate);
|
||||
}
|
||||
|
||||
public JmsInboundChannelAdapterSpec.JmsInboundChannelSpecTemplateAware jms(ConnectionFactory connectionFactory) {
|
||||
return Jms.inboundAdapter(connectionFactory);
|
||||
}
|
||||
|
||||
public ImapMailInboundChannelAdapterSpec imap() {
|
||||
return Mail.imapInboundAdapter();
|
||||
}
|
||||
|
||||
public ImapMailInboundChannelAdapterSpec imap(String url) {
|
||||
return Mail.imapInboundAdapter(url);
|
||||
}
|
||||
|
||||
public Pop3MailInboundChannelAdapterSpec pop3() {
|
||||
return Mail.pop3InboundAdapter();
|
||||
}
|
||||
|
||||
public Pop3MailInboundChannelAdapterSpec pop3(String url) {
|
||||
return Mail.pop3InboundAdapter(url);
|
||||
}
|
||||
|
||||
public Pop3MailInboundChannelAdapterSpec pop3(String host, String username, String password) {
|
||||
return pop3(host, -1, username, password);
|
||||
}
|
||||
|
||||
public Pop3MailInboundChannelAdapterSpec pop3(String host, int port, String username, String password) {
|
||||
return Mail.pop3InboundAdapter(host, port, username, password);
|
||||
}
|
||||
|
||||
MessageSources() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.integration.dsl.amqp.Amqp;
|
||||
import org.springframework.integration.dsl.amqp.AmqpInboundGatewaySpec;
|
||||
import org.springframework.integration.dsl.jms.Jms;
|
||||
import org.springframework.integration.dsl.jms.JmsInboundGatewaySpec;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.jms.listener.DefaultMessageListenerContainer;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class MessagingGateways {
|
||||
|
||||
public AmqpInboundGatewaySpec amqp(org.springframework.amqp.rabbit.connection.ConnectionFactory connectionFactory,
|
||||
String... queueNames) {
|
||||
return Amqp.inboundGateway(connectionFactory, queueNames);
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec amqp(org.springframework.amqp.rabbit.connection.ConnectionFactory connectionFactory,
|
||||
Queue... queues) {
|
||||
return Amqp.inboundGateway(connectionFactory, queues);
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec amqp(SimpleMessageListenerContainer listenerContainer) {
|
||||
return (AmqpInboundGatewaySpec) Amqp.inboundGateway(listenerContainer);
|
||||
}
|
||||
|
||||
public JmsInboundGatewaySpec.JmsInboundGatewayListenerContainerSpec<DefaultMessageListenerContainer> jms(
|
||||
javax.jms.ConnectionFactory connectionFactory) {
|
||||
return Jms.inboundGateway(connectionFactory);
|
||||
}
|
||||
|
||||
public <C extends AbstractMessageListenerContainer>
|
||||
JmsInboundGatewaySpec.JmsInboundGatewayListenerContainerSpec<C> jms(ConnectionFactory connectionFactory,
|
||||
Class<C> containerClass) {
|
||||
return Jms.inboundGateway(connectionFactory, containerClass);
|
||||
}
|
||||
|
||||
public JmsInboundGatewaySpec<? extends JmsInboundGatewaySpec<?>> jms(
|
||||
AbstractMessageListenerContainer listenerContainer) {
|
||||
return Jms.inboundGateway(listenerContainer);
|
||||
}
|
||||
|
||||
MessagingGateways() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.springframework.integration.dsl.channel.PublishSubscribeChannelSpec;
|
||||
import org.springframework.integration.dsl.core.ComponentsRegistration;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class PublishSubscribeSpec extends PublishSubscribeChannelSpec<PublishSubscribeSpec>
|
||||
implements ComponentsRegistration {
|
||||
|
||||
private final List<Object> subscriberFlows = new ArrayList<Object>();
|
||||
|
||||
PublishSubscribeSpec() {
|
||||
super();
|
||||
}
|
||||
|
||||
PublishSubscribeSpec(Executor executor) {
|
||||
super(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublishSubscribeSpec id(String id) {
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
public PublishSubscribeSpec subscribe(IntegrationFlow flow) {
|
||||
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(this.channel);
|
||||
flow.accept(flowBuilder);
|
||||
this.subscriberFlows.add(flowBuilder.get());
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getComponentsToRegister() {
|
||||
return this.subscriberFlows;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.dsl.core.ComponentsRegistration;
|
||||
import org.springframework.integration.router.RecipientListRouter;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRouterSpec, RecipientListRouter>
|
||||
implements ComponentsRegistration {
|
||||
|
||||
private final List<Object> subFlows = new ArrayList<Object>();
|
||||
|
||||
RecipientListRouterSpec() {
|
||||
super(new DslRecipientListRouter());
|
||||
}
|
||||
|
||||
public RecipientListRouterSpec recipient(String channelName, String expression) {
|
||||
Assert.hasText(channelName);
|
||||
((DslRecipientListRouter) this.target).add(channelName, expression);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public RecipientListRouterSpec recipient(String channelName, MessageSelector selector) {
|
||||
Assert.hasText(channelName);
|
||||
((DslRecipientListRouter) this.target).add(channelName, selector);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public RecipientListRouterSpec recipientFlow(MessageSelector selector, IntegrationFlow subFlow) {
|
||||
Assert.notNull(subFlow);
|
||||
DirectChannel channel = populateSubFlow(subFlow);
|
||||
((DslRecipientListRouter) this.target).add(channel, selector);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public RecipientListRouterSpec recipientFlow(String expression, IntegrationFlow subFlow) {
|
||||
Assert.notNull(subFlow);
|
||||
DirectChannel channel = populateSubFlow(subFlow);
|
||||
((DslRecipientListRouter) this.target).add(channel, expression);
|
||||
return _this();
|
||||
}
|
||||
|
||||
private DirectChannel populateSubFlow(IntegrationFlow subFlow) {
|
||||
DirectChannel channel = new DirectChannel();
|
||||
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(channel);
|
||||
subFlow.accept(flowBuilder);
|
||||
this.subFlows.add(flowBuilder.get());
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getComponentsToRegister() {
|
||||
return subFlows;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import org.springframework.integration.aggregator.ResequencingMessageGroupProcessor;
|
||||
import org.springframework.integration.aggregator.ResequencingMessageHandler;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class ResequencerSpec extends CorrelationHandlerSpec<ResequencerSpec, ResequencingMessageHandler> {
|
||||
|
||||
private final ResequencingMessageHandler resequencingMessageHandler =
|
||||
new ResequencingMessageHandler(new ResequencingMessageGroupProcessor());
|
||||
|
||||
ResequencerSpec() {
|
||||
}
|
||||
|
||||
public ResequencerSpec releasePartialSequences(boolean releasePartialSequences) {
|
||||
this.resequencingMessageHandler.setReleasePartialSequences(releasePartialSequences);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResequencingMessageHandler doGet() {
|
||||
return this.configure(this.resequencingMessageHandler);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.dsl.core.ComponentsRegistration;
|
||||
import org.springframework.integration.router.AbstractMappingMessageRouter;
|
||||
import org.springframework.integration.router.MappingMessageRouterManagement;
|
||||
import org.springframework.integration.support.context.NamedComponent;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public final class RouterSpec<R extends AbstractMappingMessageRouter> extends AbstractRouterSpec<RouterSpec<R>, R>
|
||||
implements ComponentsRegistration {
|
||||
|
||||
private final List<Object> subFlows = new ArrayList<Object>();
|
||||
|
||||
private String prefix;
|
||||
|
||||
private String suffix;
|
||||
|
||||
private RouterSubFlowMappingProvider mappingProvider;
|
||||
|
||||
RouterSpec(R router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
public RouterSpec<R> resolutionRequired(boolean resolutionRequired) {
|
||||
this.target.setResolutionRequired(resolutionRequired);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public RouterSpec<R> prefix(String prefix) {
|
||||
Assert.state(this.subFlows.isEmpty(), "The 'prefix'('suffix') and 'subFlowMapping' are mutually exclusive");
|
||||
this.prefix = prefix;
|
||||
this.target.setPrefix(prefix);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public RouterSpec<R> suffix(String suffix) {
|
||||
Assert.state(this.subFlows.isEmpty(), "The 'prefix'('suffix') and 'subFlowMapping' are mutually exclusive");
|
||||
this.suffix = suffix;
|
||||
this.target.setSuffix(suffix);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public RouterSpec<R> channelMapping(String key, String channelName) {
|
||||
Assert.hasText(key);
|
||||
Assert.hasText(channelName);
|
||||
this.target.setChannelMapping(key, channelName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public RouterSpec<R> subFlowMapping(String key, IntegrationFlow subFlow) {
|
||||
Assert.hasText(key);
|
||||
Assert.notNull(subFlow);
|
||||
Assert.state(!(StringUtils.hasText(this.prefix) || StringUtils.hasText(this.suffix)),
|
||||
"The 'prefix'('suffix') and 'subFlowMapping' are mutually exclusive");
|
||||
|
||||
DirectChannel channel = new DirectChannel();
|
||||
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(channel);
|
||||
subFlow.accept(flowBuilder);
|
||||
|
||||
this.subFlows.add(flowBuilder);
|
||||
|
||||
if (this.mappingProvider == null) {
|
||||
this.mappingProvider = new RouterSubFlowMappingProvider(this.target);
|
||||
}
|
||||
this.mappingProvider.addMapping(key, channel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getComponentsToRegister() {
|
||||
if (this.mappingProvider != null) {
|
||||
this.subFlows.add(this.mappingProvider);
|
||||
}
|
||||
return this.subFlows;
|
||||
}
|
||||
|
||||
private static class RouterSubFlowMappingProvider {
|
||||
|
||||
private final MappingMessageRouterManagement router;
|
||||
|
||||
private final Map<String, NamedComponent> mapping = new HashMap<String, NamedComponent>();
|
||||
|
||||
public RouterSubFlowMappingProvider(MappingMessageRouterManagement router) {
|
||||
this.router = router;
|
||||
}
|
||||
|
||||
void addMapping(String key, NamedComponent channel) {
|
||||
this.mapping.put(key, channel);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
for (Map.Entry<String, NamedComponent> entry : this.mapping.entrySet()) {
|
||||
this.router.setChannelMapping(entry.getKey(), entry.getValue().getComponentName());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.core.EndpointSpec;
|
||||
import org.springframework.integration.scheduling.PollerMetadata;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
|
||||
*/
|
||||
public final class SourcePollingChannelAdapterSpec extends
|
||||
EndpointSpec<SourcePollingChannelAdapterSpec, SourcePollingChannelAdapterFactoryBean, MessageSource<?>> {
|
||||
|
||||
SourcePollingChannelAdapterSpec(MessageSource<?> messageSource) {
|
||||
super(messageSource);
|
||||
this.target.getT1().setSource(messageSource);
|
||||
}
|
||||
|
||||
public SourcePollingChannelAdapterSpec phase(int phase) {
|
||||
this.target.getT1().setPhase(phase);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public SourcePollingChannelAdapterSpec autoStartup(boolean autoStartup) {
|
||||
this.target.getT1().setAutoStartup(autoStartup);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public SourcePollingChannelAdapterSpec poller(PollerMetadata pollerMetadata) {
|
||||
this.target.getT1().setPollerMetadata(pollerMetadata);
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import org.springframework.integration.dsl.core.ConsumerEndpointSpec;
|
||||
import org.springframework.integration.splitter.AbstractMessageSplitter;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public final class SplitterEndpointSpec<S extends AbstractMessageSplitter>
|
||||
extends ConsumerEndpointSpec<SplitterEndpointSpec<S>, S> {
|
||||
|
||||
SplitterEndpointSpec(S splitter) {
|
||||
super(splitter);
|
||||
}
|
||||
|
||||
public SplitterEndpointSpec<S> applySequence(boolean applySequence) {
|
||||
this.target.getT2().setApplySequence(applySequence);
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class StandardIntegrationFlow implements IntegrationFlow {
|
||||
|
||||
private final Set<Object> integrationComponents;
|
||||
|
||||
StandardIntegrationFlow(Set<Object> integrationComponents) {
|
||||
this.integrationComponents = integrationComponents;
|
||||
}
|
||||
|
||||
public Set<Object> getIntegrationComponents() {
|
||||
return integrationComponents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(IntegrationFlowDefinition<?> flow) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.amqp;
|
||||
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.integration.amqp.inbound.AmqpInboundChannelAdapter;
|
||||
import org.springframework.integration.amqp.inbound.AmqpInboundGateway;
|
||||
import org.springframework.integration.dsl.core.MessageProducerSpec;
|
||||
import org.springframework.integration.dsl.core.MessagingGatewaySpec;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class Amqp {
|
||||
|
||||
public static AmqpInboundGatewaySpec inboundGateway(ConnectionFactory connectionFactory, String... queueNames) {
|
||||
SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(connectionFactory);
|
||||
listenerContainer.setQueueNames(queueNames);
|
||||
return (AmqpInboundGatewaySpec) inboundGateway(listenerContainer);
|
||||
}
|
||||
|
||||
public static AmqpInboundGatewaySpec inboundGateway(ConnectionFactory connectionFactory, Queue... queues) {
|
||||
SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(connectionFactory);
|
||||
listenerContainer.setQueues(queues);
|
||||
return (AmqpInboundGatewaySpec) inboundGateway(listenerContainer);
|
||||
}
|
||||
|
||||
public static MessagingGatewaySpec<AmqpInboundGatewaySpec, AmqpInboundGateway> inboundGateway(
|
||||
SimpleMessageListenerContainer listenerContainer) {
|
||||
return new AmqpInboundGatewaySpec(listenerContainer);
|
||||
}
|
||||
|
||||
public static AmqpInboundChannelAdapterSpec inboundAdapter(ConnectionFactory connectionFactory,
|
||||
String... queueNames) {
|
||||
SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(connectionFactory);
|
||||
listenerContainer.setQueueNames(queueNames);
|
||||
return (AmqpInboundChannelAdapterSpec) inboundAdapter(listenerContainer);
|
||||
}
|
||||
|
||||
public static AmqpInboundChannelAdapterSpec inboundAdapter(ConnectionFactory connectionFactory, Queue... queues) {
|
||||
SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(connectionFactory);
|
||||
listenerContainer.setQueues(queues);
|
||||
return (AmqpInboundChannelAdapterSpec) inboundAdapter(listenerContainer);
|
||||
}
|
||||
|
||||
public static MessageProducerSpec<AmqpInboundChannelAdapterSpec, AmqpInboundChannelAdapter> inboundAdapter(
|
||||
SimpleMessageListenerContainer listenerContainer) {
|
||||
return new AmqpInboundChannelAdapterSpec(listenerContainer);
|
||||
}
|
||||
|
||||
public static AmqpOutboundEndpointSpec outboundAdapter(AmqpTemplate amqpTemplate) {
|
||||
return new AmqpOutboundEndpointSpec(amqpTemplate, false);
|
||||
}
|
||||
|
||||
public static AmqpOutboundEndpointSpec outboundGateway(AmqpTemplate amqpTemplate) {
|
||||
return new AmqpOutboundEndpointSpec(amqpTemplate, true);
|
||||
}
|
||||
|
||||
public static <S extends AmqpPollableMessageChannelSpec<S>> AmqpPollableMessageChannelSpec<S>
|
||||
pollableChannel(ConnectionFactory connectionFactory) {
|
||||
return pollableChannel(null, connectionFactory);
|
||||
}
|
||||
|
||||
public static <S extends AmqpPollableMessageChannelSpec<S>> AmqpPollableMessageChannelSpec<S> pollableChannel(
|
||||
String id, ConnectionFactory connectionFactory) {
|
||||
return new AmqpPollableMessageChannelSpec<S>(connectionFactory).id(id);
|
||||
}
|
||||
|
||||
public static <S extends AmqpMessageChannelSpec<S>> AmqpMessageChannelSpec<S> channel(
|
||||
ConnectionFactory connectionFactory) {
|
||||
return channel(null, connectionFactory);
|
||||
}
|
||||
|
||||
public static <S extends AmqpMessageChannelSpec<S>> AmqpMessageChannelSpec<S> channel(String id,
|
||||
ConnectionFactory connectionFactory) {
|
||||
return new AmqpMessageChannelSpec<S>(connectionFactory).id(id);
|
||||
}
|
||||
|
||||
public static AmqpPublishSubscribeMessageChannelSpec publishSubscribeChannel(ConnectionFactory connectionFactory) {
|
||||
return publishSubscribeChannel(null, connectionFactory);
|
||||
}
|
||||
|
||||
public static AmqpPublishSubscribeMessageChannelSpec publishSubscribeChannel(String id,
|
||||
ConnectionFactory connectionFactory) {
|
||||
return new AmqpPublishSubscribeMessageChannelSpec(connectionFactory).id(id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.amqp;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
|
||||
import org.springframework.amqp.core.AcknowledgeMode;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.integration.amqp.inbound.AmqpInboundChannelAdapter;
|
||||
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
|
||||
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
|
||||
import org.springframework.integration.dsl.core.MessageProducerSpec;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class AmqpInboundChannelAdapterSpec
|
||||
extends MessageProducerSpec<AmqpInboundChannelAdapterSpec, AmqpInboundChannelAdapter> {
|
||||
|
||||
private final SimpleMessageListenerContainer listenerContainer;
|
||||
|
||||
private final DefaultAmqpHeaderMapper headerMapper = new DefaultAmqpHeaderMapper();
|
||||
|
||||
public AmqpInboundChannelAdapterSpec(SimpleMessageListenerContainer listenerContainer) {
|
||||
super(new AmqpInboundChannelAdapter(listenerContainer));
|
||||
this.listenerContainer = listenerContainer;
|
||||
this.target.setHeaderMapper(headerMapper);
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec acknowledgeMode(AcknowledgeMode acknowledgeMode) {
|
||||
this.listenerContainer.setAcknowledgeMode(acknowledgeMode);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec addQueueNames(String... queueName) {
|
||||
this.listenerContainer.addQueueNames(queueName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec addQueues(Queue... queues) {
|
||||
this.listenerContainer.addQueues(queues);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec errorHandler(ErrorHandler errorHandler) {
|
||||
this.listenerContainer.setErrorHandler(errorHandler);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec channelTransacted(boolean transactional) {
|
||||
this.listenerContainer.setChannelTransacted(transactional);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec adviceChain(Advice... adviceChain) {
|
||||
this.listenerContainer.setAdviceChain(adviceChain);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec recoveryInterval(long recoveryInterval) {
|
||||
this.listenerContainer.setRecoveryInterval(recoveryInterval);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec concurrentConsumers(int concurrentConsumers) {
|
||||
this.listenerContainer.setConcurrentConsumers(concurrentConsumers);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec maxConcurrentConsumers(int maxConcurrentConsumers) {
|
||||
this.listenerContainer.setMaxConcurrentConsumers(maxConcurrentConsumers);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec exclusive(boolean exclusive) {
|
||||
this.listenerContainer.setExclusive(exclusive);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec startConsumerMinInterval(long startConsumerMinInterval) {
|
||||
this.listenerContainer.setStartConsumerMinInterval(startConsumerMinInterval);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec stopConsumerMinInterval(long stopConsumerMinInterval) {
|
||||
this.listenerContainer.setStopConsumerMinInterval(stopConsumerMinInterval);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec consecutiveActiveTrigger(int consecutiveActiveTrigger) {
|
||||
this.listenerContainer.setConsecutiveActiveTrigger(consecutiveActiveTrigger);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec consecutiveIdleTrigger(int consecutiveIdleTrigger) {
|
||||
this.listenerContainer.setConsecutiveIdleTrigger(consecutiveIdleTrigger);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec receiveTimeout(long receiveTimeout) {
|
||||
this.listenerContainer.setReceiveTimeout(receiveTimeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec shutdownTimeout(long shutdownTimeout) {
|
||||
this.listenerContainer.setShutdownTimeout(shutdownTimeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec taskExecutor(Executor taskExecutor) {
|
||||
this.listenerContainer.setTaskExecutor(taskExecutor);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec prefetchCount(int prefetchCount) {
|
||||
this.listenerContainer.setPrefetchCount(prefetchCount);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec txSize(int txSize) {
|
||||
this.listenerContainer.setTxSize(txSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec transactionManager(PlatformTransactionManager transactionManager) {
|
||||
this.listenerContainer.setTransactionManager(transactionManager);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec defaultRequeueRejected(boolean defaultRequeueRejected) {
|
||||
this.listenerContainer.setDefaultRequeueRejected(defaultRequeueRejected);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec messageConverter(MessageConverter messageConverter) {
|
||||
this.target.setMessageConverter(messageConverter);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec headerMapper(AmqpHeaderMapper headerMapper) {
|
||||
this.target.setHeaderMapper(headerMapper);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundChannelAdapterSpec mappedRequestHeaders(String... headers) {
|
||||
this.headerMapper.setRequestHeaderNames(headers);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.amqp;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
|
||||
import org.springframework.amqp.core.AcknowledgeMode;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.integration.amqp.inbound.AmqpInboundGateway;
|
||||
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
|
||||
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
|
||||
import org.springframework.integration.dsl.core.MessagingGatewaySpec;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class AmqpInboundGatewaySpec extends MessagingGatewaySpec<AmqpInboundGatewaySpec, AmqpInboundGateway> {
|
||||
|
||||
private final SimpleMessageListenerContainer listenerContainer;
|
||||
|
||||
private final DefaultAmqpHeaderMapper headerMapper = new DefaultAmqpHeaderMapper();
|
||||
|
||||
AmqpInboundGatewaySpec(SimpleMessageListenerContainer listenerContainer) {
|
||||
super(new AmqpInboundGateway(listenerContainer));
|
||||
this.listenerContainer = listenerContainer;
|
||||
this.target.setHeaderMapper(headerMapper);
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec acknowledgeMode(AcknowledgeMode acknowledgeMode) {
|
||||
this.listenerContainer.setAcknowledgeMode(acknowledgeMode);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec addQueueNames(String... queueName) {
|
||||
this.listenerContainer.addQueueNames(queueName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec addQueues(Queue... queues) {
|
||||
this.listenerContainer.addQueues(queues);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec errorHandler(ErrorHandler errorHandler) {
|
||||
this.listenerContainer.setErrorHandler(errorHandler);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec channelTransacted(boolean transactional) {
|
||||
this.listenerContainer.setChannelTransacted(transactional);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec adviceChain(Advice... adviceChain) {
|
||||
this.listenerContainer.setAdviceChain(adviceChain);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec recoveryInterval(long recoveryInterval) {
|
||||
this.listenerContainer.setRecoveryInterval(recoveryInterval);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec concurrentConsumers(int concurrentConsumers) {
|
||||
this.listenerContainer.setConcurrentConsumers(concurrentConsumers);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec maxConcurrentConsumers(int maxConcurrentConsumers) {
|
||||
this.listenerContainer.setMaxConcurrentConsumers(maxConcurrentConsumers);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec exclusive(boolean exclusive) {
|
||||
this.listenerContainer.setExclusive(exclusive);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec startConsumerMinInterval(long startConsumerMinInterval) {
|
||||
this.listenerContainer.setStartConsumerMinInterval(startConsumerMinInterval);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec stopConsumerMinInterval(long stopConsumerMinInterval) {
|
||||
this.listenerContainer.setStopConsumerMinInterval(stopConsumerMinInterval);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec consecutiveActiveTrigger(int consecutiveActiveTrigger) {
|
||||
this.listenerContainer.setConsecutiveActiveTrigger(consecutiveActiveTrigger);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec consecutiveIdleTrigger(int consecutiveIdleTrigger) {
|
||||
this.listenerContainer.setConsecutiveIdleTrigger(consecutiveIdleTrigger);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec receiveTimeout(long receiveTimeout) {
|
||||
this.listenerContainer.setReceiveTimeout(receiveTimeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec shutdownTimeout(long shutdownTimeout) {
|
||||
this.listenerContainer.setShutdownTimeout(shutdownTimeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec taskExecutor(Executor taskExecutor) {
|
||||
this.listenerContainer.setTaskExecutor(taskExecutor);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec prefetchCount(int prefetchCount) {
|
||||
this.listenerContainer.setPrefetchCount(prefetchCount);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec txSize(int txSize) {
|
||||
this.listenerContainer.setTxSize(txSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec transactionManager(PlatformTransactionManager transactionManager) {
|
||||
this.listenerContainer.setTransactionManager(transactionManager);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec defaultRequeueRejected(boolean defaultRequeueRejected) {
|
||||
this.listenerContainer.setDefaultRequeueRejected(defaultRequeueRejected);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec messageConverter(MessageConverter messageConverter) {
|
||||
this.target.setMessageConverter(messageConverter);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec headerMapper(AmqpHeaderMapper headerMapper) {
|
||||
this.target.setHeaderMapper(headerMapper);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec mappedRequestHeaders(String... headers) {
|
||||
this.headerMapper.setRequestHeaderNames(headers);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpInboundGatewaySpec mappedReplyHeaders(String... headers) {
|
||||
this.headerMapper.setReplyHeaderNames(headers);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.amqp;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
|
||||
import org.springframework.amqp.core.AcknowledgeMode;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.integration.amqp.channel.AbstractAmqpChannel;
|
||||
import org.springframework.integration.amqp.config.AmqpChannelFactoryBean;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.interceptor.TransactionAttribute;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class AmqpMessageChannelSpec<S extends AmqpMessageChannelSpec<S>> extends AmqpPollableMessageChannelSpec<S> {
|
||||
|
||||
private final List<Advice> adviceChain = new LinkedList<Advice>();
|
||||
|
||||
AmqpMessageChannelSpec(ConnectionFactory connectionFactory) {
|
||||
super(new AmqpChannelFactoryBean(true), connectionFactory);
|
||||
}
|
||||
|
||||
public S maxSubscribers(int maxSubscribers) {
|
||||
this.amqpChannelFactoryBean.setMaxSubscribers(maxSubscribers);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S acknowledgeMode(AcknowledgeMode acknowledgeMode) {
|
||||
this.amqpChannelFactoryBean.setAcknowledgeMode(acknowledgeMode);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S advice(Advice... advice) {
|
||||
this.adviceChain.addAll(Arrays.asList(advice));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S autoStartup(boolean autoStartup) {
|
||||
this.amqpChannelFactoryBean.setAutoStartup(autoStartup);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S concurrentConsumers(int concurrentConsumers) {
|
||||
this.amqpChannelFactoryBean.setConcurrentConsumers(concurrentConsumers);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S errorHandler(ErrorHandler errorHandler) {
|
||||
this.amqpChannelFactoryBean.setErrorHandler(errorHandler);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S exposeListenerChannel(boolean exposeListenerChannel) {
|
||||
this.amqpChannelFactoryBean.setExposeListenerChannel(exposeListenerChannel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S phase(int phase) {
|
||||
this.amqpChannelFactoryBean.setPhase(phase);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S prefetchCount(int prefetchCount) {
|
||||
this.amqpChannelFactoryBean.setPrefetchCount(prefetchCount);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S receiveTimeout(long receiveTimeout) {
|
||||
this.amqpChannelFactoryBean.setReceiveTimeout(receiveTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S recoveryInterval(long recoveryInterval) {
|
||||
this.amqpChannelFactoryBean.setRecoveryInterval(recoveryInterval);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S shutdownTimeout(long shutdownTimeout) {
|
||||
this.amqpChannelFactoryBean.setShutdownTimeout(shutdownTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S taskExecutor(Executor taskExecutor) {
|
||||
this.amqpChannelFactoryBean.setTaskExecutor(taskExecutor);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S transactionAttribute(TransactionAttribute transactionAttribute) {
|
||||
this.amqpChannelFactoryBean.setTransactionAttribute(transactionAttribute);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S transactionManager(PlatformTransactionManager transactionManager) {
|
||||
this.amqpChannelFactoryBean.setTransactionManager(transactionManager);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S txSize(int txSize) {
|
||||
this.amqpChannelFactoryBean.setTxSize(txSize);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractAmqpChannel doGet() {
|
||||
this.amqpChannelFactoryBean.setAdviceChain(this.adviceChain.toArray(new Advice[this.adviceChain.size()]));
|
||||
return super.doGet();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.amqp;
|
||||
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.amqp.core.MessageDeliveryMode;
|
||||
import org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint;
|
||||
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
|
||||
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
|
||||
import org.springframework.integration.dsl.core.MessageHandlerSpec;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class AmqpOutboundEndpointSpec extends MessageHandlerSpec<AmqpOutboundEndpointSpec, AmqpOutboundEndpoint> {
|
||||
|
||||
private final AmqpOutboundEndpoint endpoint;
|
||||
|
||||
private final boolean expectReply;
|
||||
|
||||
private final DefaultAmqpHeaderMapper headerMapper = new DefaultAmqpHeaderMapper();
|
||||
|
||||
AmqpOutboundEndpointSpec(AmqpTemplate amqpTemplate, boolean expectReply) {
|
||||
this.endpoint = new AmqpOutboundEndpoint(amqpTemplate);
|
||||
this.expectReply = expectReply;
|
||||
this.endpoint.setExpectReply(expectReply);
|
||||
if (expectReply) {
|
||||
this.endpoint.setRequiresReply(true);
|
||||
}
|
||||
this.endpoint.setHeaderMapper(this.headerMapper);
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec headerMapper(AmqpHeaderMapper headerMapper) {
|
||||
endpoint.setHeaderMapper(headerMapper);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec routingKey(String routingKey) {
|
||||
endpoint.setRoutingKey(routingKey);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec defaultDeliveryMode(MessageDeliveryMode defaultDeliveryMode) {
|
||||
endpoint.setDefaultDeliveryMode(defaultDeliveryMode);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec exchangeName(String exchangeName) {
|
||||
endpoint.setExchangeName(exchangeName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec routingKeyExpression(String routingKeyExpression) {
|
||||
endpoint.setRoutingKeyExpression(routingKeyExpression);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec returnChannel(MessageChannel returnChannel) {
|
||||
endpoint.setReturnChannel(returnChannel);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec confirmAckChannel(MessageChannel ackChannel) {
|
||||
endpoint.setConfirmAckChannel(ackChannel);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec exchangeNameExpression(String exchangeNameExpression) {
|
||||
endpoint.setExchangeNameExpression(exchangeNameExpression);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec confirmNackChannel(MessageChannel nackChannel) {
|
||||
endpoint.setConfirmNackChannel(nackChannel);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec confirmCorrelationExpression(String confirmCorrelationExpression) {
|
||||
endpoint.setConfirmCorrelationExpression(confirmCorrelationExpression);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec mappedRequestHeaders(String... headers) {
|
||||
this.headerMapper.setRequestHeaderNames(headers);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AmqpOutboundEndpointSpec mappedReplyHeaders(String... headers) {
|
||||
Assert.isTrue(expectReply, "'mappedReplyHeaders' can be applied on for gateway");
|
||||
this.headerMapper.setReplyHeaderNames(headers);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected AmqpOutboundEndpoint doGet() {
|
||||
return this.endpoint;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.amqp;
|
||||
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.support.MessagePropertiesConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.integration.amqp.channel.AbstractAmqpChannel;
|
||||
import org.springframework.integration.amqp.config.AmqpChannelFactoryBean;
|
||||
import org.springframework.integration.dsl.channel.MessageChannelSpec;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class AmqpPollableMessageChannelSpec<S extends AmqpPollableMessageChannelSpec<S>>
|
||||
extends MessageChannelSpec<S, AbstractAmqpChannel> {
|
||||
|
||||
protected final AmqpChannelFactoryBean amqpChannelFactoryBean;
|
||||
|
||||
AmqpPollableMessageChannelSpec(ConnectionFactory connectionFactory) {
|
||||
this(new AmqpChannelFactoryBean(false), connectionFactory);
|
||||
}
|
||||
|
||||
AmqpPollableMessageChannelSpec(AmqpChannelFactoryBean amqpChannelFactoryBean, ConnectionFactory connectionFactory) {
|
||||
this.amqpChannelFactoryBean = amqpChannelFactoryBean;
|
||||
this.amqpChannelFactoryBean.setConnectionFactory(connectionFactory);
|
||||
this.amqpChannelFactoryBean.setSingleton(false);
|
||||
this.amqpChannelFactoryBean.setPubSub(false);
|
||||
this.amqpChannelFactoryBean.setBeanFactory(new DefaultListableBeanFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected S id(String id) {
|
||||
this.amqpChannelFactoryBean.setBeanName(id);
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
public S queueName(String queueName) {
|
||||
if (this.id == null) {
|
||||
id(queueName + ".channel");
|
||||
}
|
||||
this.amqpChannelFactoryBean.setQueueName(queueName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S encoding(String encoding) {
|
||||
this.amqpChannelFactoryBean.setEncoding(encoding);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S amqpMessageConverter(MessageConverter messageConverter) {
|
||||
this.amqpChannelFactoryBean.setMessageConverter(messageConverter);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S channelTransacted(boolean channelTransacted) {
|
||||
this.amqpChannelFactoryBean.setChannelTransacted(channelTransacted);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S messagePropertiesConverter(MessagePropertiesConverter messagePropertiesConverter) {
|
||||
this.amqpChannelFactoryBean.setMessagePropertiesConverter(messagePropertiesConverter);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractAmqpChannel doGet() {
|
||||
Assert.notNull(this.id, "The 'id' or 'queueName' must be specified");
|
||||
try {
|
||||
this.channel = this.amqpChannelFactoryBean.getObject();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new BeanCreationException("Cannot create the AMQP MessageChannel", e);
|
||||
}
|
||||
return super.doGet();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.amqp;
|
||||
|
||||
import org.springframework.amqp.core.FanoutExchange;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class AmqpPublishSubscribeMessageChannelSpec
|
||||
extends AmqpMessageChannelSpec<AmqpPublishSubscribeMessageChannelSpec> {
|
||||
|
||||
AmqpPublishSubscribeMessageChannelSpec(ConnectionFactory connectionFactory) {
|
||||
super(connectionFactory);
|
||||
this.amqpChannelFactoryBean.setPubSub(true);
|
||||
}
|
||||
|
||||
public AmqpPublishSubscribeMessageChannelSpec exchange(FanoutExchange exchange) {
|
||||
this.amqpChannelFactoryBean.setExchange(exchange);
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Provides AMQP Components support for Spring Integration Java DSL.
|
||||
*/
|
||||
package org.springframework.integration.dsl.amqp;
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.channel;
|
||||
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class DirectChannelSpec extends LoadBalancingChannelSpec<DirectChannelSpec, DirectChannel> {
|
||||
|
||||
@Override
|
||||
protected DirectChannel doGet() {
|
||||
this.channel = new DirectChannel(this.loadBalancingStrategy);
|
||||
if (this.failover != null) {
|
||||
this.channel.setFailover(this.failover);
|
||||
}
|
||||
if (this.maxSubscribers != null) {
|
||||
this.channel.setMaxSubscribers(this.maxSubscribers);
|
||||
}
|
||||
return super.doGet();
|
||||
}
|
||||
|
||||
DirectChannelSpec() {
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.channel;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.springframework.integration.channel.ExecutorChannel;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class ExecutorChannelSpec extends LoadBalancingChannelSpec<ExecutorChannelSpec, ExecutorChannel> {
|
||||
|
||||
private final Executor executor;
|
||||
|
||||
ExecutorChannelSpec(Executor executor) {
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExecutorChannel doGet() {
|
||||
this.channel = new ExecutorChannel(this.executor, this.loadBalancingStrategy);
|
||||
if (this.failover != null) {
|
||||
this.channel.setFailover(this.failover);
|
||||
}
|
||||
if (this.maxSubscribers != null) {
|
||||
this.channel.setMaxSubscribers(this.maxSubscribers);
|
||||
}
|
||||
return super.doGet();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.channel;
|
||||
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.dispatcher.LoadBalancingStrategy;
|
||||
import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrategy;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class LoadBalancingChannelSpec<S extends MessageChannelSpec<S, C>, C extends AbstractMessageChannel>
|
||||
extends MessageChannelSpec<S, C> {
|
||||
|
||||
protected LoadBalancingStrategy loadBalancingStrategy = new RoundRobinLoadBalancingStrategy();
|
||||
|
||||
protected Boolean failover;
|
||||
|
||||
protected Integer maxSubscribers;
|
||||
|
||||
public S loadBalancer(LoadBalancingStrategy loadBalancingStrategy) {
|
||||
this.loadBalancingStrategy = loadBalancingStrategy;
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S failover(Boolean failover) {
|
||||
this.failover = failover;
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S maxSubscribers(Integer maxSubscribers) {
|
||||
this.maxSubscribers = maxSubscribers;
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.channel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.dsl.core.IntegrationComponentSpec;
|
||||
import org.springframework.messaging.converter.MessageConverter;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class MessageChannelSpec<S extends MessageChannelSpec<S, C>, C extends AbstractMessageChannel>
|
||||
extends IntegrationComponentSpec<S, C> {
|
||||
|
||||
protected C channel;
|
||||
|
||||
private final List<Class<?>> datatypes = new ArrayList<Class<?>>();
|
||||
|
||||
private final List<ChannelInterceptor> interceptors = new LinkedList<ChannelInterceptor>();
|
||||
|
||||
private MessageConverter messageConverter;
|
||||
|
||||
@Override
|
||||
protected S id(String id) {
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
public S datatype(Class<?>... datatypes) {
|
||||
Assert.noNullElements(datatypes);
|
||||
this.datatypes.addAll(Arrays.asList(datatypes));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S interceptor(ChannelInterceptor... interceptors) {
|
||||
Assert.noNullElements(interceptors);
|
||||
this.interceptors.addAll(Arrays.asList(interceptors));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S messageConverter(MessageConverter messageConverter) {
|
||||
this.messageConverter = messageConverter;
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected C doGet() {
|
||||
this.channel.setDatatypes(this.datatypes.toArray(new Class<?>[this.datatypes.size()]));
|
||||
this.channel.setBeanName(this.id);
|
||||
this.channel.setInterceptors(this.interceptors);
|
||||
this.channel.setMessageConverter(this.messageConverter);
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.channel;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.springframework.integration.store.ChannelMessageStore;
|
||||
import org.springframework.integration.store.PriorityCapableChannelMessageStore;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public final class MessageChannels {
|
||||
|
||||
public static DirectChannelSpec direct() {
|
||||
return new DirectChannelSpec();
|
||||
}
|
||||
|
||||
public static DirectChannelSpec direct(String id) {
|
||||
return direct().id(id);
|
||||
}
|
||||
|
||||
public static QueueChannelSpec queue() {
|
||||
return new QueueChannelSpec();
|
||||
}
|
||||
|
||||
public static QueueChannelSpec queue(String id) {
|
||||
return queue().id(id);
|
||||
}
|
||||
|
||||
public static QueueChannelSpec queue(Queue<Message<?>> queue) {
|
||||
return new QueueChannelSpec(queue);
|
||||
}
|
||||
|
||||
public static QueueChannelSpec queue(String id, Queue<Message<?>> queue) {
|
||||
return queue(queue).id(id);
|
||||
}
|
||||
|
||||
public static QueueChannelSpec queue(Integer capacity) {
|
||||
return new QueueChannelSpec(capacity);
|
||||
}
|
||||
|
||||
public static QueueChannelSpec queue(String id, Integer capacity) {
|
||||
return queue(capacity).id(id);
|
||||
}
|
||||
|
||||
public static QueueChannelSpec.MessageStoreSpec queue(ChannelMessageStore messageGroupStore, Object groupId) {
|
||||
return new QueueChannelSpec.MessageStoreSpec(messageGroupStore, groupId);
|
||||
}
|
||||
|
||||
public static QueueChannelSpec.MessageStoreSpec queue(String id, ChannelMessageStore messageGroupStore,
|
||||
Object groupId) {
|
||||
return queue(messageGroupStore, groupId).id(id);
|
||||
}
|
||||
|
||||
public static ExecutorChannelSpec executor(Executor executor) {
|
||||
return new ExecutorChannelSpec(executor);
|
||||
}
|
||||
|
||||
public static ExecutorChannelSpec executor(String id, Executor executor) {
|
||||
return executor(executor).id(id);
|
||||
}
|
||||
|
||||
public static RendezvousChannelSpec rendezvous() {
|
||||
return new RendezvousChannelSpec();
|
||||
}
|
||||
|
||||
public static RendezvousChannelSpec rendezvous(String id) {
|
||||
return rendezvous().id(id);
|
||||
}
|
||||
|
||||
public static PriorityChannelSpec priority() {
|
||||
return new PriorityChannelSpec();
|
||||
}
|
||||
|
||||
public static PriorityChannelSpec priority(String id) {
|
||||
return priority().id(id);
|
||||
}
|
||||
|
||||
public static QueueChannelSpec.MessageStoreSpec priority(PriorityCapableChannelMessageStore messageGroupStore,
|
||||
Object groupId) {
|
||||
return new QueueChannelSpec.MessageStoreSpec(messageGroupStore, groupId);
|
||||
}
|
||||
|
||||
public static QueueChannelSpec.MessageStoreSpec priority(String id,
|
||||
PriorityCapableChannelMessageStore messageGroupStore, Object groupId) {
|
||||
return queue(messageGroupStore, groupId).id(id);
|
||||
}
|
||||
|
||||
public static <S extends PublishSubscribeChannelSpec<S>> PublishSubscribeChannelSpec<S> publishSubscribe() {
|
||||
return new PublishSubscribeChannelSpec<S>();
|
||||
}
|
||||
|
||||
public static <S extends PublishSubscribeChannelSpec<S>> PublishSubscribeChannelSpec<S> publishSubscribe(
|
||||
String id) {
|
||||
return MessageChannels.<S>publishSubscribe().id(id);
|
||||
}
|
||||
|
||||
public static <S extends PublishSubscribeChannelSpec<S>> PublishSubscribeChannelSpec<S> publishSubscribe(
|
||||
Executor executor) {
|
||||
return new PublishSubscribeChannelSpec<S>(executor);
|
||||
}
|
||||
|
||||
public static <S extends PublishSubscribeChannelSpec<S>> PublishSubscribeChannelSpec<S> publishSubscribe(String id,
|
||||
Executor executor) {
|
||||
return MessageChannels.<S>publishSubscribe(executor).id(id);
|
||||
}
|
||||
|
||||
private MessageChannels() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.channel;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.springframework.integration.channel.PriorityChannel;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class PriorityChannelSpec extends MessageChannelSpec<PriorityChannelSpec, PriorityChannel> {
|
||||
|
||||
private int capacity;
|
||||
|
||||
Comparator<Message<?>> comparator;
|
||||
|
||||
public PriorityChannelSpec setCapacity(int capacity) {
|
||||
this.capacity = capacity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PriorityChannelSpec setComparator(Comparator<Message<?>> comparator) {
|
||||
this.comparator = comparator;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PriorityChannel doGet() {
|
||||
this.channel = new PriorityChannel(this.capacity, this.comparator);
|
||||
return super.doGet();
|
||||
}
|
||||
|
||||
|
||||
PriorityChannelSpec() {
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.channel;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.springframework.integration.channel.PublishSubscribeChannel;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class PublishSubscribeChannelSpec<S extends PublishSubscribeChannelSpec<S>>
|
||||
extends MessageChannelSpec<S, PublishSubscribeChannel> {
|
||||
|
||||
protected PublishSubscribeChannelSpec() {
|
||||
this.channel = new PublishSubscribeChannel();
|
||||
}
|
||||
|
||||
protected PublishSubscribeChannelSpec(Executor executor) {
|
||||
this.channel = new PublishSubscribeChannel(executor);
|
||||
}
|
||||
|
||||
public S errorHandler(ErrorHandler errorHandler) {
|
||||
this.channel.setErrorHandler(errorHandler);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S ignoreFailures(boolean ignoreFailures) {
|
||||
this.channel.setIgnoreFailures(ignoreFailures);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S applySequence(boolean applySequence) {
|
||||
this.channel.setApplySequence(applySequence);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S maxSubscribers(Integer maxSubscribers) {
|
||||
this.channel.setMaxSubscribers(maxSubscribers);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S minSubscribers(int minSubscribers) {
|
||||
this.channel.setMinSubscribers(minSubscribers);
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.channel;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.store.ChannelMessageStore;
|
||||
import org.springframework.integration.store.MessageGroupQueue;
|
||||
import org.springframework.integration.store.PriorityCapableChannelMessageStore;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class QueueChannelSpec extends MessageChannelSpec<QueueChannelSpec, QueueChannel> {
|
||||
|
||||
protected Queue<Message<?>> queue;
|
||||
|
||||
protected Integer capacity;
|
||||
|
||||
QueueChannelSpec() {
|
||||
}
|
||||
|
||||
QueueChannelSpec(Queue<Message<?>> queue) {
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
QueueChannelSpec(Integer capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QueueChannel doGet() {
|
||||
if (this.queue != null) {
|
||||
Constructor<?> queueConstructor =
|
||||
ClassUtils.getConstructorIfAvailable(QueueChannel.class, Queue.class);
|
||||
if (queueConstructor == null) {
|
||||
if (!(this.queue instanceof BlockingQueue)) {
|
||||
throw new IllegalArgumentException("The 'queue' must be an instance of BlockingQueue " +
|
||||
"for Spring Integration versions less than 4.1");
|
||||
}
|
||||
else {
|
||||
this.channel = new QueueChannel((BlockingQueue<Message<?>>) this.queue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
this.channel = (QueueChannel) queueConstructor.newInstance(this.queue);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.capacity != null) {
|
||||
this.channel = new QueueChannel(this.capacity);
|
||||
}
|
||||
else {
|
||||
this.channel = new QueueChannel();
|
||||
}
|
||||
return super.doGet();
|
||||
}
|
||||
|
||||
public static class MessageStoreSpec extends QueueChannelSpec {
|
||||
|
||||
private final ChannelMessageStore messageGroupStore;
|
||||
|
||||
private final Object groupId;
|
||||
|
||||
private Lock storeLock;
|
||||
|
||||
MessageStoreSpec(ChannelMessageStore messageGroupStore, Object groupId) {
|
||||
super();
|
||||
this.messageGroupStore = messageGroupStore;
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MessageStoreSpec id(String id) {
|
||||
return (MessageStoreSpec) super.id(id);
|
||||
}
|
||||
|
||||
|
||||
public MessageStoreSpec capacity(Integer capacity) {
|
||||
this.capacity = capacity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageStoreSpec storeLock(Lock storeLock) {
|
||||
this.storeLock = storeLock;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QueueChannel doGet() {
|
||||
if (this.capacity != null) {
|
||||
if (this.storeLock != null) {
|
||||
this.queue = new MessageGroupQueue(this.messageGroupStore, this.groupId, this.capacity,
|
||||
this.storeLock);
|
||||
}
|
||||
else {
|
||||
this.queue = new MessageGroupQueue(this.messageGroupStore, this.groupId, this.capacity);
|
||||
}
|
||||
}
|
||||
else if (this.storeLock != null) {
|
||||
this.queue = new MessageGroupQueue(this.messageGroupStore, this.groupId, this.storeLock);
|
||||
}
|
||||
else {
|
||||
this.queue = new MessageGroupQueue(this.messageGroupStore, this.groupId);
|
||||
}
|
||||
|
||||
((MessageGroupQueue) this.queue).setPriority(
|
||||
this.messageGroupStore instanceof PriorityCapableChannelMessageStore);
|
||||
|
||||
return super.doGet();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.channel;
|
||||
|
||||
import org.springframework.integration.channel.RendezvousChannel;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class RendezvousChannelSpec extends MessageChannelSpec<RendezvousChannelSpec, RendezvousChannel> {
|
||||
|
||||
RendezvousChannelSpec() {
|
||||
this.channel = new RendezvousChannel();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Contains MessageChannel Builders DSL.
|
||||
*/
|
||||
package org.springframework.integration.dsl.channel;
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.integration.config.IntegrationConfigurationInitializer;
|
||||
import org.springframework.integration.dsl.core.IntegrationComponentSpec;
|
||||
import org.springframework.integration.dsl.config.IntegrationFlowBeanPostProcessor;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The Java DSL Integration infrastructure {@code beanFactory} initializer.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class DslIntegrationConfigurationInitializer implements IntegrationConfigurationInitializer {
|
||||
|
||||
private static final String INTEGRATION_FLOW_BPP_BEAN_NAME = IntegrationFlowBeanPostProcessor
|
||||
.class.getName();
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
|
||||
Assert.isInstanceOf(BeanDefinitionRegistry.class, configurableListableBeanFactory,
|
||||
"To use Spring Integration Java DSL the 'beanFactory' has to be an instance of " +
|
||||
"'BeanDefinitionRegistry'. Consider using 'GenericApplicationContext' implementation."
|
||||
);
|
||||
|
||||
checkSpecBeans(configurableListableBeanFactory);
|
||||
|
||||
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) configurableListableBeanFactory;
|
||||
if (!registry.containsBeanDefinition(INTEGRATION_FLOW_BPP_BEAN_NAME)) {
|
||||
registry.registerBeanDefinition(INTEGRATION_FLOW_BPP_BEAN_NAME,
|
||||
new RootBeanDefinition(IntegrationFlowBeanPostProcessor.class));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSpecBeans(ConfigurableListableBeanFactory beanFactory) {
|
||||
List<String> specBeanNames = Arrays.asList(beanFactory.getBeanNamesForType(IntegrationComponentSpec.class,
|
||||
true, false));
|
||||
if (!specBeanNames.isEmpty()) {
|
||||
throw new BeanCreationException("'IntegrationComponentSpec' beans: '" + specBeanNames +
|
||||
"' must be populated to target objects via 'get()' method call. It is important for " +
|
||||
"@Autowired injections.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,223 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.config;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ApplicationEventMulticaster;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.FixedSubscriberChannel;
|
||||
import org.springframework.integration.config.ConsumerEndpointFactoryBean;
|
||||
import org.springframework.integration.config.IntegrationConfigUtils;
|
||||
import org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlowBuilder;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.SourcePollingChannelAdapterSpec;
|
||||
import org.springframework.integration.dsl.StandardIntegrationFlow;
|
||||
import org.springframework.integration.dsl.core.ConsumerEndpointSpec;
|
||||
import org.springframework.integration.dsl.support.MessageChannelReference;
|
||||
import org.springframework.integration.support.context.NamedComponent;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class IntegrationFlowBeanPostProcessor implements BeanPostProcessor, BeanFactoryAware {
|
||||
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
Assert.isInstanceOf(ConfigurableListableBeanFactory.class, beanFactory,
|
||||
"To use Spring Integration Java DSL the 'beanFactory' has to be an instance of " +
|
||||
"'ConfigurableListableBeanFactory'. Consider using 'GenericApplicationContext' implementation."
|
||||
);
|
||||
|
||||
this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof StandardIntegrationFlow) {
|
||||
return processStandardIntegrationFlow((StandardIntegrationFlow) bean, beanName);
|
||||
}
|
||||
else if (bean instanceof IntegrationFlow) {
|
||||
return processIntegrationFlowImpl((IntegrationFlow) bean, beanName);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
private Object processStandardIntegrationFlow(StandardIntegrationFlow flow,
|
||||
String beanName) {
|
||||
String flowNamePrefix = beanName + ".";
|
||||
int subFlowNameIndex = 0;
|
||||
int channelNameIndex = 0;
|
||||
for (Object component : flow.getIntegrationComponents()) {
|
||||
if (component instanceof ConsumerEndpointSpec) {
|
||||
ConsumerEndpointSpec<?, ?> endpointSpec = (ConsumerEndpointSpec<?, ?>) component;
|
||||
MessageHandler messageHandler = endpointSpec.get().getT2();
|
||||
ConsumerEndpointFactoryBean endpoint = endpointSpec.get().getT1();
|
||||
String id = endpointSpec.getId();
|
||||
|
||||
Collection<?> messageHandlers = this.beanFactory.getBeansOfType(MessageHandler.class, false,
|
||||
false).values();
|
||||
|
||||
if (!messageHandlers.contains(messageHandler)) {
|
||||
String handlerBeanName = generateBeanName(messageHandler);
|
||||
String[] handlerAlias = id != null
|
||||
? new String[] {id + IntegrationConfigUtils.HANDLER_ALIAS_SUFFIX}
|
||||
: null;
|
||||
|
||||
registerComponent(messageHandler, handlerBeanName);
|
||||
if (handlerAlias != null) {
|
||||
for (String alias : handlerAlias) {
|
||||
this.beanFactory.registerAlias(handlerBeanName, alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String endpointBeanName = id;
|
||||
if (endpointBeanName == null) {
|
||||
endpointBeanName = generateBeanName(endpoint);
|
||||
}
|
||||
registerComponent(endpoint, endpointBeanName);
|
||||
}
|
||||
else {
|
||||
//TODO workaround until SF will fix 'TypeDescriptor.forObject'
|
||||
if (component instanceof MessageChannel) {
|
||||
Collection<?> messageChannels =
|
||||
this.beanFactory.getBeansOfType(MessageChannel.class, false, false).values();
|
||||
if (!messageChannels.contains(component)) {
|
||||
if (component instanceof AbstractMessageChannel) {
|
||||
String channelBeanName = ((AbstractMessageChannel) component).getComponentName();
|
||||
if (channelBeanName == null) {
|
||||
channelBeanName = flowNamePrefix + "channel" +
|
||||
BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + channelNameIndex++;
|
||||
}
|
||||
registerComponent(component, channelBeanName);
|
||||
}
|
||||
else if (component instanceof MessageChannelReference) {
|
||||
String channelBeanName = ((MessageChannelReference) component).getName();
|
||||
if (!this.beanFactory.containsBean(channelBeanName)) {
|
||||
DirectChannel directChannel = new DirectChannel();
|
||||
registerComponent(directChannel, channelBeanName);
|
||||
}
|
||||
}
|
||||
else if (component instanceof FixedSubscriberChannel) {
|
||||
FixedSubscriberChannel fixedSubscriberChannel = (FixedSubscriberChannel) component;
|
||||
String channelBeanName = fixedSubscriberChannel.getComponentName();
|
||||
if ("Unnamed fixed subscriber channel".equals(channelBeanName)) {
|
||||
channelBeanName = flowNamePrefix + "channel" +
|
||||
BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + channelNameIndex++;
|
||||
}
|
||||
registerComponent(component, channelBeanName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (component instanceof SourcePollingChannelAdapterSpec) {
|
||||
SourcePollingChannelAdapterSpec spec = (SourcePollingChannelAdapterSpec) component;
|
||||
SourcePollingChannelAdapterFactoryBean pollingChannelAdapterFactoryBean = spec.get().getT1();
|
||||
String id = spec.getId();
|
||||
if (!StringUtils.hasText(id)) {
|
||||
id = generateBeanName(pollingChannelAdapterFactoryBean);
|
||||
}
|
||||
registerComponent(pollingChannelAdapterFactoryBean, id);
|
||||
|
||||
MessageSource<?> messageSource = spec.get().getT2();
|
||||
if (!this.beanFactory
|
||||
.getBeansOfType(MessageSource.class, false, false)
|
||||
.values()
|
||||
.contains(messageSource)) {
|
||||
String messageSourceId = id + ".source";
|
||||
if (messageSource instanceof NamedComponent
|
||||
&& ((NamedComponent) messageSource).getComponentName() != null) {
|
||||
messageSourceId = ((NamedComponent) messageSource).getComponentName();
|
||||
}
|
||||
registerComponent(messageSource, messageSourceId);
|
||||
}
|
||||
}
|
||||
else if (component instanceof StandardIntegrationFlow) {
|
||||
String subFlowBeanName = flowNamePrefix + "subFlow" +
|
||||
BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + subFlowNameIndex++;
|
||||
registerComponent(component, subFlowBeanName);
|
||||
}
|
||||
else if (!this.beanFactory
|
||||
.getBeansOfType(AopUtils.getTargetClass(component), false, false)
|
||||
.values()
|
||||
.contains(component)) {
|
||||
registerComponent(component, generateBeanName(component));
|
||||
if (ApplicationListener.class.isAssignableFrom(
|
||||
AopUtils.getTargetClass(component))
|
||||
&& this.beanFactory.containsBean(
|
||||
AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
|
||||
ApplicationEventMulticaster multicaster =
|
||||
(ApplicationEventMulticaster) this.beanFactory.getBean(
|
||||
AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME);
|
||||
multicaster.addApplicationListener((ApplicationListener<?>) component);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return flow;
|
||||
}
|
||||
|
||||
private Object processIntegrationFlowImpl(IntegrationFlow flow, String beanName) {
|
||||
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(beanName + ".input");
|
||||
flow.accept(flowBuilder);
|
||||
return processStandardIntegrationFlow(flowBuilder.get(), beanName);
|
||||
}
|
||||
|
||||
private void registerComponent(Object component, String beanName) {
|
||||
this.beanFactory.registerSingleton(beanName, component);
|
||||
this.beanFactory.initializeBean(component, beanName);
|
||||
}
|
||||
|
||||
private String generateBeanName(Object instance) {
|
||||
if (instance instanceof NamedComponent && ((NamedComponent) instance).getComponentName() != null) {
|
||||
return ((NamedComponent) instance).getComponentName();
|
||||
}
|
||||
String generatedBeanName = instance.getClass().getName();
|
||||
String id = instance.getClass().getName();
|
||||
int counter = -1;
|
||||
while (counter == -1 || this.beanFactory.containsBean(id)) {
|
||||
counter++;
|
||||
id = generatedBeanName + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + counter;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Provides config classes of the Spring Integration Java DSL.
|
||||
*/
|
||||
package org.springframework.integration.dsl.config;
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.core;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public interface ComponentsRegistration {
|
||||
|
||||
Collection<Object> getComponentsToRegister();
|
||||
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
|
||||
import org.springframework.integration.config.ConsumerEndpointFactoryBean;
|
||||
import org.springframework.integration.handler.AbstractMessageHandler;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.scheduling.PollerMetadata;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class ConsumerEndpointSpec<S extends ConsumerEndpointSpec<S, H>, H extends MessageHandler>
|
||||
extends EndpointSpec<S, ConsumerEndpointFactoryBean, H> {
|
||||
|
||||
private final List<Advice> adviceChain = new LinkedList<Advice>();
|
||||
|
||||
protected ConsumerEndpointSpec(H messageHandler) {
|
||||
super(messageHandler);
|
||||
this.target.getT1().setHandler(messageHandler);
|
||||
if (messageHandler instanceof AbstractReplyProducingMessageHandler) {
|
||||
((AbstractReplyProducingMessageHandler) messageHandler).setAdviceChain(this.adviceChain);
|
||||
}
|
||||
else {
|
||||
this.target.getT1().setAdviceChain(this.adviceChain);
|
||||
}
|
||||
}
|
||||
|
||||
public S phase(int phase) {
|
||||
this.target.getT1().setPhase(phase);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S autoStartup(boolean autoStartup) {
|
||||
this.target.getT1().setAutoStartup(autoStartup);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S poller(PollerMetadata pollerMetadata) {
|
||||
this.target.getT1().setPollerMetadata(pollerMetadata);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S advice(Advice... advice) {
|
||||
this.adviceChain.addAll(Arrays.asList(advice));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S requiresReply(boolean requiresReply) {
|
||||
H handler = this.target.getT2();
|
||||
if (handler instanceof AbstractReplyProducingMessageHandler) {
|
||||
((AbstractReplyProducingMessageHandler) handler).setRequiresReply(requiresReply);
|
||||
}
|
||||
else {
|
||||
logger.warn("'requiresReply' can be applied only for AbstractReplyProducingMessageHandler");
|
||||
}
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S sendTimeout(long sendTimeout) {
|
||||
H handler = this.target.getT2();
|
||||
if (handler instanceof AbstractReplyProducingMessageHandler) {
|
||||
((AbstractReplyProducingMessageHandler) handler).setSendTimeout(sendTimeout);
|
||||
}
|
||||
else {
|
||||
logger.warn("'sendTimeout' can be applied only for AbstractReplyProducingMessageHandler");
|
||||
}
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S order(int order) {
|
||||
H handler = this.target.getT2();
|
||||
if (handler instanceof AbstractMessageHandler) {
|
||||
((AbstractMessageHandler) handler).setOrder(order);
|
||||
}
|
||||
else {
|
||||
logger.warn("'order' can be applied only for AbstractMessageHandler");
|
||||
}
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.core;
|
||||
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.dsl.support.tuple.Tuple2;
|
||||
import org.springframework.integration.dsl.support.tuple.Tuples;
|
||||
import org.springframework.integration.scheduling.PollerMetadata;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
|
||||
*/
|
||||
public abstract class EndpointSpec<S extends EndpointSpec<S, F, H>, F extends BeanNameAware, H>
|
||||
extends IntegrationComponentSpec<S, Tuple2<F, H>> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected EndpointSpec(H handler) {
|
||||
Assert.notNull(handler);
|
||||
try {
|
||||
Class<?> fClass = ResolvableType.forClass(this.getClass()).as(EndpointSpec.class).resolveGenerics()[1];
|
||||
F endpointFactoryBean = (F) fClass.newInstance();
|
||||
this.target = Tuples.of(endpointFactoryBean, handler);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public S id(String id) {
|
||||
this.target.getT1().setBeanName(id);
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
public abstract S phase(int phase);
|
||||
|
||||
public abstract S autoStartup(boolean autoStartup);
|
||||
|
||||
public abstract S poller(PollerMetadata pollerMetadata);
|
||||
|
||||
public S poller(Function<PollerFactory, PollerSpec> pollers) {
|
||||
return poller(pollers.apply(new PollerFactory()));
|
||||
}
|
||||
|
||||
public S poller(PollerSpec pollerMetadataSpec) {
|
||||
return this.poller(pollerMetadataSpec.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final Tuple2<F, H> doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.core;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
|
||||
/**
|
||||
* The common Builder abstraction.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class IntegrationComponentSpec<S extends IntegrationComponentSpec<S, T>, T> {
|
||||
|
||||
protected final static SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
protected volatile T target;
|
||||
|
||||
protected String id;
|
||||
|
||||
protected S id(String id) {
|
||||
this.id = id;
|
||||
return _this();
|
||||
}
|
||||
|
||||
public final String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public final T get() {
|
||||
if (this.target == null) {
|
||||
this.target = this.doGet();
|
||||
}
|
||||
return this.target;
|
||||
}
|
||||
|
||||
protected abstract T doGet();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected final S _this() {
|
||||
return (S) this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.core;
|
||||
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class MessageHandlerSpec<S extends MessageHandlerSpec<S, H>, H extends MessageHandler>
|
||||
extends IntegrationComponentSpec<S, H> {
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.core;
|
||||
|
||||
import org.springframework.integration.endpoint.MessageProducerSupport;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class MessageProducerSpec<S extends MessageProducerSpec<S, P>, P extends MessageProducerSupport>
|
||||
extends IntegrationComponentSpec<S, P> {
|
||||
|
||||
public MessageProducerSpec(P producer) {
|
||||
this.target = producer;
|
||||
}
|
||||
|
||||
public S id(String id) {
|
||||
this.target.setBeanName(id);
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
public S phase(int phase) {
|
||||
this.target.setPhase(phase);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S autoStartup(boolean autoStartup) {
|
||||
this.target.setAutoStartup(autoStartup);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S outputChannel(MessageChannel outputChannel) {
|
||||
target.setOutputChannel(outputChannel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S errorChannel(MessageChannel errorChannel) {
|
||||
target.setErrorChannel(errorChannel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected P doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.core;
|
||||
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class MessageSourceSpec<S extends MessageSourceSpec<S, H>, H extends MessageSource<?>>
|
||||
extends IntegrationComponentSpec<S, H> {
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.core;
|
||||
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.integration.mapping.InboundMessageMapper;
|
||||
import org.springframework.integration.mapping.OutboundMessageMapper;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class MessagingGatewaySpec<S extends MessagingGatewaySpec<S, G>, G extends MessagingGatewaySupport>
|
||||
extends IntegrationComponentSpec<S, G> {
|
||||
|
||||
public MessagingGatewaySpec(G gateway) {
|
||||
this.target = gateway;
|
||||
}
|
||||
|
||||
public S id(String id) {
|
||||
this.target.setBeanName(id);
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
public S phase(int phase) {
|
||||
this.target.setPhase(phase);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S autoStartup(boolean autoStartup) {
|
||||
this.target.setAutoStartup(autoStartup);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S replyChannel(MessageChannel replyChannel) {
|
||||
this.target.setReplyChannel(replyChannel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S requestChannel(MessageChannel requestChannel) {
|
||||
target.setRequestChannel(requestChannel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S errorChannel(MessageChannel errorChannel) {
|
||||
target.setErrorChannel(errorChannel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S requestTimeout(long requestTimeout) {
|
||||
target.setRequestTimeout(requestTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S replyTimeout(long replyTimeout) {
|
||||
target.setReplyTimeout(replyTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S requestMapper(InboundMessageMapper<?> requestMapper) {
|
||||
target.setRequestMapper(requestMapper);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S replyMapper(OutboundMessageMapper<?> replyMapper) {
|
||||
target.setReplyMapper(replyMapper);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final G doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.core;
|
||||
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.scheduling.Trigger;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class PollerFactory {
|
||||
|
||||
public PollerSpec trigger(Trigger trigger) {
|
||||
return Pollers.trigger(trigger);
|
||||
}
|
||||
|
||||
public PollerSpec cron(String cronExpression) {
|
||||
return Pollers.cron(cronExpression);
|
||||
}
|
||||
|
||||
public PollerSpec cron(String cronExpression, TimeZone timeZone) {
|
||||
return Pollers.cron(cronExpression, timeZone);
|
||||
}
|
||||
|
||||
public PollerSpec fixedRate(long period) {
|
||||
return Pollers.fixedRate(period);
|
||||
}
|
||||
|
||||
public PollerSpec fixedRate(long period, TimeUnit timeUnit) {
|
||||
return Pollers.fixedRate(period, timeUnit);
|
||||
}
|
||||
|
||||
public PollerSpec fixedRate(long period, long initialDelay) {
|
||||
return Pollers.fixedRate(period, initialDelay);
|
||||
}
|
||||
|
||||
public PollerSpec fixedDelay(long period, TimeUnit timeUnit, long initialDelay) {
|
||||
return Pollers.fixedDelay(period, timeUnit, initialDelay);
|
||||
}
|
||||
|
||||
public PollerSpec fixedRate(long period, TimeUnit timeUnit, long initialDelay) {
|
||||
return Pollers.fixedRate(period, timeUnit, initialDelay);
|
||||
}
|
||||
|
||||
public PollerSpec fixedDelay(long period, TimeUnit timeUnit) {
|
||||
return Pollers.fixedDelay(period, timeUnit);
|
||||
}
|
||||
|
||||
public PollerSpec fixedDelay(long period, long initialDelay) {
|
||||
return Pollers.fixedDelay(period, initialDelay);
|
||||
}
|
||||
|
||||
public PollerSpec fixedDelay(long period) {
|
||||
return Pollers.fixedDelay(period);
|
||||
}
|
||||
|
||||
PollerFactory() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
|
||||
import org.springframework.integration.scheduling.PollerMetadata;
|
||||
import org.springframework.integration.transaction.TransactionSynchronizationFactory;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource;
|
||||
import org.springframework.transaction.interceptor.TransactionInterceptor;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
|
||||
*/
|
||||
public final class PollerSpec extends IntegrationComponentSpec<PollerSpec, PollerMetadata> {
|
||||
|
||||
private final PollerMetadata pollerMetadata = new PollerMetadata();
|
||||
|
||||
private final List<Advice> adviceChain = new LinkedList<Advice>();
|
||||
|
||||
PollerSpec(Trigger trigger) {
|
||||
this.pollerMetadata.setTrigger(trigger);
|
||||
}
|
||||
|
||||
public PollerSpec transactionSynchronizationFactory(
|
||||
TransactionSynchronizationFactory transactionSynchronizationFactory) {
|
||||
pollerMetadata.setTransactionSynchronizationFactory(transactionSynchronizationFactory);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PollerSpec errorHandler(ErrorHandler errorHandler) {
|
||||
pollerMetadata.setErrorHandler(errorHandler);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PollerSpec maxMessagesPerPoll(long maxMessagesPerPoll) {
|
||||
pollerMetadata.setMaxMessagesPerPoll(maxMessagesPerPoll);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PollerSpec receiveTimeout(long receiveTimeout) {
|
||||
pollerMetadata.setReceiveTimeout(receiveTimeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PollerSpec advice(Advice... advice) {
|
||||
this.adviceChain.addAll(Arrays.asList(advice));
|
||||
return this;
|
||||
}
|
||||
|
||||
public PollerSpec transactional(PlatformTransactionManager transactionManager) {
|
||||
return this.advice(new TransactionInterceptor(transactionManager, new MatchAlwaysTransactionAttributeSource()));
|
||||
}
|
||||
|
||||
public PollerSpec taskExecutor(Executor taskExecutor) {
|
||||
pollerMetadata.setTaskExecutor(taskExecutor);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PollerSpec sendTimeout(long sendTimeout) {
|
||||
pollerMetadata.setSendTimeout(sendTimeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PollerMetadata doGet() {
|
||||
pollerMetadata.setAdviceChain(this.adviceChain);
|
||||
return this.pollerMetadata;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.core;
|
||||
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.scheduling.support.CronTrigger;
|
||||
import org.springframework.scheduling.support.PeriodicTrigger;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public final class Pollers {
|
||||
|
||||
public static PollerSpec trigger(Trigger trigger) {
|
||||
return new PollerSpec(trigger);
|
||||
}
|
||||
|
||||
public static PollerSpec fixedRate(long period) {
|
||||
return fixedRate(period, null);
|
||||
}
|
||||
|
||||
public static PollerSpec fixedRate(long period, TimeUnit timeUnit) {
|
||||
return fixedRate(period, timeUnit, 0);
|
||||
}
|
||||
public static PollerSpec fixedRate(long period, long initialDelay) {
|
||||
return periodicTrigger(period, null, true, initialDelay);
|
||||
}
|
||||
|
||||
public static PollerSpec fixedRate(long period, TimeUnit timeUnit, long initialDelay) {
|
||||
return periodicTrigger(period, timeUnit, true, initialDelay);
|
||||
}
|
||||
|
||||
public static PollerSpec fixedDelay(long period) {
|
||||
return fixedDelay(period, null);
|
||||
}
|
||||
|
||||
public static PollerSpec fixedDelay(long period, TimeUnit timeUnit) {
|
||||
return fixedDelay(period, timeUnit, 0);
|
||||
}
|
||||
|
||||
public static PollerSpec fixedDelay(long period, long initialDelay) {
|
||||
return periodicTrigger(period, null, false, initialDelay);
|
||||
}
|
||||
|
||||
public static PollerSpec fixedDelay(long period, TimeUnit timeUnit, long initialDelay) {
|
||||
return periodicTrigger(period, timeUnit, false, initialDelay);
|
||||
}
|
||||
|
||||
private static PollerSpec periodicTrigger(long period, TimeUnit timeUnit, boolean fixedRate, long initialDelay) {
|
||||
PeriodicTrigger periodicTrigger = new PeriodicTrigger(period, timeUnit);
|
||||
periodicTrigger.setFixedRate(fixedRate);
|
||||
periodicTrigger.setInitialDelay(initialDelay);
|
||||
return new PollerSpec(periodicTrigger);
|
||||
}
|
||||
|
||||
public static PollerSpec cron(String cronExpression) {
|
||||
return cron(cronExpression, TimeZone.getDefault());
|
||||
}
|
||||
|
||||
public static PollerSpec cron(String cronExpression, TimeZone timeZone) {
|
||||
return new PollerSpec(new CronTrigger(cronExpression, timeZone));
|
||||
}
|
||||
|
||||
private Pollers() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Provides core classes of the Spring Integration Java DSL.
|
||||
*/
|
||||
package org.springframework.integration.dsl.core;
|
||||
@@ -1,138 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.springframework.integration.dsl.core.MessageSourceSpec;
|
||||
import org.springframework.integration.file.DirectoryScanner;
|
||||
import org.springframework.integration.file.FileLocker;
|
||||
import org.springframework.integration.file.FileReadingMessageSource;
|
||||
import org.springframework.integration.file.filters.AcceptAllFileListFilter;
|
||||
import org.springframework.integration.file.filters.AcceptOnceFileListFilter;
|
||||
import org.springframework.integration.file.filters.CompositeFileListFilter;
|
||||
import org.springframework.integration.file.filters.FileListFilter;
|
||||
import org.springframework.integration.file.filters.RegexPatternFileListFilter;
|
||||
import org.springframework.integration.file.filters.SimplePatternFileListFilter;
|
||||
import org.springframework.integration.file.locking.NioFileLocker;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class FileInboundChannelAdapterSpec
|
||||
extends MessageSourceSpec<FileInboundChannelAdapterSpec, FileReadingMessageSource> {
|
||||
|
||||
private FileListFilter<File> filter;
|
||||
|
||||
private FileLocker locker;
|
||||
|
||||
FileInboundChannelAdapterSpec() {
|
||||
this.target = new FileReadingMessageSource();
|
||||
}
|
||||
|
||||
FileInboundChannelAdapterSpec(Comparator<File> receptionOrderComparator) {
|
||||
this.target = new FileReadingMessageSource(receptionOrderComparator);
|
||||
}
|
||||
|
||||
FileInboundChannelAdapterSpec directory(File directory) {
|
||||
this.target.setDirectory(directory);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec scanner(DirectoryScanner scanner) {
|
||||
this.target.setScanner(scanner);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec autoCreateDirectory(boolean autoCreateDirectory) {
|
||||
this.target.setAutoCreateDirectory(autoCreateDirectory);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec filter(FileListFilter<File> filter) {
|
||||
return filter(filter, false);
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec filter(FileListFilter<File> filter, boolean preventDuplicates) {
|
||||
Assert.isNull(this.filter,
|
||||
"The 'filter' (" + this.filter + ") is already configured for the FileReadingMessageSource");
|
||||
FileListFilter<File> targetFilter = filter;
|
||||
if (preventDuplicates) {
|
||||
targetFilter = createCompositeWithAcceptOnceFilter(filter);
|
||||
}
|
||||
this.filter = targetFilter;
|
||||
this.target.setFilter(targetFilter);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec preventDuplicatesFilter(boolean preventDuplicates) {
|
||||
if (preventDuplicates) {
|
||||
return filter(new AcceptOnceFileListFilter<File>(), false);
|
||||
}
|
||||
else {
|
||||
return filter(new AcceptAllFileListFilter<File>(), false);
|
||||
}
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec patternFilter(String pattern) {
|
||||
return patternFilter(pattern, true);
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec patternFilter(String pattern, boolean preventDuplicates) {
|
||||
return filter(new SimplePatternFileListFilter(pattern), preventDuplicates);
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec regexFilter(String regex) {
|
||||
return regexFilter(regex, true);
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec regexFilter(String regex, boolean preventDuplicates) {
|
||||
return filter(new RegexPatternFileListFilter(regex), preventDuplicates);
|
||||
}
|
||||
|
||||
private CompositeFileListFilter<File> createCompositeWithAcceptOnceFilter(FileListFilter<File> otherFilter) {
|
||||
CompositeFileListFilter<File> compositeFilter = new CompositeFileListFilter<File>();
|
||||
compositeFilter.addFilter(new AcceptOnceFileListFilter<File>());
|
||||
compositeFilter.addFilter(otherFilter);
|
||||
return compositeFilter;
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec locker(FileLocker locker) {
|
||||
Assert.isNull(this.locker,
|
||||
"The 'locker' (" + this.locker + ") is already configured for the FileReadingMessageSource");
|
||||
this.locker = locker;
|
||||
this.target.setLocker(locker);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec nioLocker() {
|
||||
return locker(new NioFileLocker());
|
||||
}
|
||||
|
||||
public FileInboundChannelAdapterSpec scanEachPoll(boolean scanEachPoll) {
|
||||
this.target.setScanEachPoll(scanEachPoll);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FileReadingMessageSource doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.file;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.integration.dsl.core.ComponentsRegistration;
|
||||
import org.springframework.integration.dsl.core.MessageHandlerSpec;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.dsl.support.FunctionExpression;
|
||||
import org.springframework.integration.file.DefaultFileNameGenerator;
|
||||
import org.springframework.integration.file.FileNameGenerator;
|
||||
import org.springframework.integration.file.remote.RemoteFileTemplate;
|
||||
import org.springframework.integration.file.remote.handler.FileTransferringMessageHandler;
|
||||
import org.springframework.integration.file.remote.session.SessionFactory;
|
||||
import org.springframework.integration.file.support.FileExistsMode;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class FileTransferringMessageHandlerSpec<F, S extends FileTransferringMessageHandlerSpec<F, S>>
|
||||
extends MessageHandlerSpec<S, FileTransferringMessageHandler<F>>
|
||||
implements ComponentsRegistration {
|
||||
|
||||
private FileNameGenerator fileNameGenerator;
|
||||
|
||||
private DefaultFileNameGenerator defaultFileNameGenerator;
|
||||
|
||||
protected FileTransferringMessageHandlerSpec(SessionFactory<F> sessionFactory) {
|
||||
this.target = new FileTransferringMessageHandler<F>(sessionFactory);
|
||||
}
|
||||
|
||||
protected FileTransferringMessageHandlerSpec(RemoteFileTemplate<F> remoteFileTemplate) {
|
||||
this.target = new FileTransferringMessageHandler<F>(remoteFileTemplate);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected FileTransferringMessageHandlerSpec(RemoteFileTemplate<F> remoteFileTemplate,
|
||||
FileExistsMode fileExistsMode) {
|
||||
Constructor<?> fileExistsModeConstructor =
|
||||
ClassUtils.getConstructorIfAvailable(FileTransferringMessageHandler.class, RemoteFileTemplate.class,
|
||||
FileExistsMode.class);
|
||||
if (fileExistsModeConstructor == null) {
|
||||
logger.warn("The 'FileExistsMode' constructor argument for the 'FileTransferringMessageHandler' is " +
|
||||
"available since Spring Integration 4.1. Will be ignored for previous versions.");
|
||||
this.target = new FileTransferringMessageHandler<F>(remoteFileTemplate);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
this.target =
|
||||
(FileTransferringMessageHandler<F>) fileExistsModeConstructor.newInstance(remoteFileTemplate,
|
||||
fileExistsMode);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public S autoCreateDirectory(boolean autoCreateDirectory) {
|
||||
this.target.setAutoCreateDirectory(autoCreateDirectory);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S remoteFileSeparator(String remoteFileSeparator) {
|
||||
this.target.setRemoteFileSeparator(remoteFileSeparator);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S remoteDirectory(String remoteDirectory) {
|
||||
this.target.setRemoteDirectoryExpression(new LiteralExpression(remoteDirectory));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S remoteDirectoryExpression(String remoteDirectoryExpression) {
|
||||
this.target.setRemoteDirectoryExpression(PARSER.parseExpression(remoteDirectoryExpression));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public <P> S remoteDirectory(Function<Message<P>, String> remoteDirectoryFunction) {
|
||||
this.target.setRemoteDirectoryExpression(new FunctionExpression<Message<P>>(remoteDirectoryFunction));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S temporaryRemoteDirectory(String temporaryRemoteDirectory) {
|
||||
this.target.setTemporaryRemoteDirectoryExpression(new LiteralExpression(temporaryRemoteDirectory));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S temporaryRemoteDirectoryExpression(String temporaryRemoteDirectoryExpression) {
|
||||
this.target.setTemporaryRemoteDirectoryExpression(PARSER.parseExpression(temporaryRemoteDirectoryExpression));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public <P> S temporaryRemoteDirectory(Function<Message<P>, String> temporaryRemoteDirectoryFunction) {
|
||||
this.target.setTemporaryRemoteDirectoryExpression(
|
||||
new FunctionExpression<Message<P>>(temporaryRemoteDirectoryFunction));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S useTemporaryFileName(boolean useTemporaryFileName) {
|
||||
this.target.setUseTemporaryFileName(useTemporaryFileName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S fileNameGenerator(FileNameGenerator fileNameGenerator) {
|
||||
this.fileNameGenerator = fileNameGenerator;
|
||||
this.target.setFileNameGenerator(fileNameGenerator);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S fileNameExpression(String fileNameGeneratorExpression) {
|
||||
Assert.isNull(this.fileNameGenerator,
|
||||
"'fileNameGenerator' and 'fileNameGeneratorExpression' are mutually exclusive.");
|
||||
this.defaultFileNameGenerator = new DefaultFileNameGenerator();
|
||||
this.defaultFileNameGenerator.setExpression(fileNameGeneratorExpression);
|
||||
return fileNameGenerator(this.defaultFileNameGenerator);
|
||||
}
|
||||
|
||||
public S charset(String charset) {
|
||||
this.target.setCharset(charset);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S charset(Charset charset) {
|
||||
this.target.setCharset(charset.name());
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S temporaryFileSuffix(String temporaryFileSuffix) {
|
||||
this.target.setTemporaryFileSuffix(temporaryFileSuffix);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getComponentsToRegister() {
|
||||
if (this.defaultFileNameGenerator != null) {
|
||||
return Collections.<Object>singletonList(this.defaultFileNameGenerator);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FileTransferringMessageHandler<F> doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.integration.dsl.core.ComponentsRegistration;
|
||||
import org.springframework.integration.dsl.core.MessageHandlerSpec;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.dsl.support.FunctionExpression;
|
||||
import org.springframework.integration.file.DefaultFileNameGenerator;
|
||||
import org.springframework.integration.file.FileNameGenerator;
|
||||
import org.springframework.integration.file.FileWritingMessageHandler;
|
||||
import org.springframework.integration.file.support.FileExistsMode;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class FileWritingMessageHandlerSpec
|
||||
extends MessageHandlerSpec<FileWritingMessageHandlerSpec, FileWritingMessageHandler>
|
||||
implements ComponentsRegistration {
|
||||
|
||||
private FileNameGenerator fileNameGenerator;
|
||||
|
||||
private DefaultFileNameGenerator defaultFileNameGenerator;
|
||||
|
||||
FileWritingMessageHandlerSpec(File destinationDirectory) {
|
||||
this.target = new FileWritingMessageHandler(destinationDirectory);
|
||||
}
|
||||
|
||||
FileWritingMessageHandlerSpec(String directoryExpression) {
|
||||
this.target = new FileWritingMessageHandler(PARSER.parseExpression(directoryExpression));
|
||||
}
|
||||
|
||||
<P> FileWritingMessageHandlerSpec(Function<Message<P>, ?> directoryFunction) {
|
||||
this.target = new FileWritingMessageHandler(new FunctionExpression<Message<P>>(directoryFunction));
|
||||
}
|
||||
|
||||
FileWritingMessageHandlerSpec expectReply(boolean expectReply) {
|
||||
this.target.setExpectReply(expectReply);
|
||||
if (expectReply) {
|
||||
this.target.setRequiresReply(true);
|
||||
}
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FileWritingMessageHandlerSpec autoCreateDirectory(boolean autoCreateDirectory) {
|
||||
this.target.setAutoCreateDirectory(autoCreateDirectory);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FileWritingMessageHandlerSpec temporaryFileSuffix(String temporaryFileSuffix) {
|
||||
this.target.setTemporaryFileSuffix(temporaryFileSuffix);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FileWritingMessageHandlerSpec fileExistsMode(FileExistsMode fileExistsMode) {
|
||||
this.target.setFileExistsMode(fileExistsMode);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FileWritingMessageHandlerSpec fileNameGenerator(FileNameGenerator fileNameGenerator) {
|
||||
this.fileNameGenerator = fileNameGenerator;
|
||||
this.target.setFileNameGenerator(fileNameGenerator);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FileWritingMessageHandlerSpec fileNameExpression(String fileNameExpression) {
|
||||
Assert.isNull(this.fileNameGenerator,
|
||||
"'fileNameGenerator' and 'fileNameGeneratorExpression' are mutually exclusive.");
|
||||
this.defaultFileNameGenerator = new DefaultFileNameGenerator();
|
||||
this.defaultFileNameGenerator.setExpression(fileNameExpression);
|
||||
return fileNameGenerator(this.defaultFileNameGenerator);
|
||||
}
|
||||
|
||||
|
||||
public FileWritingMessageHandlerSpec deleteSourceFiles(boolean deleteSourceFiles) {
|
||||
this.target.setDeleteSourceFiles(deleteSourceFiles);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public FileWritingMessageHandlerSpec charset(String charset) {
|
||||
this.target.setCharset(charset);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getComponentsToRegister() {
|
||||
if (this.defaultFileNameGenerator != null) {
|
||||
return Collections.<Object>singletonList(this.defaultFileNameGenerator);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FileWritingMessageHandler doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class Files {
|
||||
|
||||
public static FileInboundChannelAdapterSpec inboundAdapter(File directory) {
|
||||
return inboundAdapter(directory, null);
|
||||
}
|
||||
|
||||
public static FileInboundChannelAdapterSpec inboundAdapter(File directory,
|
||||
Comparator<File> receptionOrderComparator) {
|
||||
return new FileInboundChannelAdapterSpec(receptionOrderComparator).directory(directory);
|
||||
}
|
||||
|
||||
public static FileWritingMessageHandlerSpec outboundAdapter(File destinationDirectory) {
|
||||
return new FileWritingMessageHandlerSpec(destinationDirectory).expectReply(false);
|
||||
}
|
||||
|
||||
public static FileWritingMessageHandlerSpec outboundAdapter(String directoryExpression) {
|
||||
return new FileWritingMessageHandlerSpec(directoryExpression).expectReply(false);
|
||||
}
|
||||
|
||||
public static <P> FileWritingMessageHandlerSpec outboundAdapter(Function<Message<P>, ?> directoryFunction) {
|
||||
return new FileWritingMessageHandlerSpec(directoryFunction).expectReply(false);
|
||||
}
|
||||
|
||||
public static FileWritingMessageHandlerSpec outboundGateway(File destinationDirectory) {
|
||||
return new FileWritingMessageHandlerSpec(destinationDirectory).expectReply(true);
|
||||
}
|
||||
|
||||
public static FileWritingMessageHandlerSpec outboundGateway(String directoryExpression) {
|
||||
return new FileWritingMessageHandlerSpec(directoryExpression).expectReply(true);
|
||||
}
|
||||
|
||||
public static <P> FileWritingMessageHandlerSpec outboundGateway(Function<Message<P>, ?> directoryFunction) {
|
||||
return new FileWritingMessageHandlerSpec(directoryFunction).expectReply(true);
|
||||
}
|
||||
|
||||
public static TailAdapterSpec tailAdapter(File file) {
|
||||
return new TailAdapterSpec().file(file);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.integration.dsl.core.ComponentsRegistration;
|
||||
import org.springframework.integration.dsl.core.MessageSourceSpec;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.dsl.support.FunctionExpression;
|
||||
import org.springframework.integration.file.filters.FileListFilter;
|
||||
import org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer;
|
||||
import org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class RemoteFileInboundChannelAdapterSpec<F, S extends RemoteFileInboundChannelAdapterSpec<F, S, MS>,
|
||||
MS extends AbstractInboundFileSynchronizingMessageSource<F>>
|
||||
extends MessageSourceSpec<S, MS> implements ComponentsRegistration {
|
||||
|
||||
protected final AbstractInboundFileSynchronizer<F> synchronizer;
|
||||
|
||||
private FileListFilter<F> filter;
|
||||
|
||||
protected RemoteFileInboundChannelAdapterSpec(AbstractInboundFileSynchronizer<F> synchronizer) {
|
||||
this.synchronizer = synchronizer;
|
||||
}
|
||||
|
||||
public S autoCreateLocalDirectory(boolean autoCreateLocalDirectory) {
|
||||
this.target.setAutoCreateLocalDirectory(autoCreateLocalDirectory);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S localDirectory(File localDirectory) {
|
||||
this.target.setLocalDirectory(localDirectory);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S localFilter(FileListFilter<File> localFileListFilter) {
|
||||
this.target.setLocalFilter(localFileListFilter);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S remoteFileSeparator(String remoteFileSeparator) {
|
||||
this.synchronizer.setRemoteFileSeparator(remoteFileSeparator);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S localFilenameExpression(String localFilenameExpression) {
|
||||
this.synchronizer.setLocalFilenameGeneratorExpression(PARSER.parseExpression(localFilenameExpression));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S localFilename(Function<String, String> localFilenameFunction) {
|
||||
this.synchronizer.setLocalFilenameGeneratorExpression(new FunctionExpression<String>(localFilenameFunction));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S temporaryFileSuffix(String temporaryFileSuffix) {
|
||||
this.synchronizer.setTemporaryFileSuffix(temporaryFileSuffix);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S remoteDirectory(String remoteDirectory) {
|
||||
this.synchronizer.setRemoteDirectory(remoteDirectory);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S filter(FileListFilter<F> filter) {
|
||||
Assert.isNull(this.filter,
|
||||
"The 'filter' (" + this.filter + ") is already configured for the: " + this);
|
||||
this.filter = filter;
|
||||
this.synchronizer.setFilter(filter);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public abstract S patternFilter(String pattern);
|
||||
|
||||
public abstract S regexFilter(String regex);
|
||||
|
||||
public S deleteRemoteFiles(boolean deleteRemoteFiles) {
|
||||
this.synchronizer.setDeleteRemoteFiles(deleteRemoteFiles);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S preserveTimestamp(boolean preserveTimestamp) {
|
||||
this.synchronizer.setPreserveTimestamp(preserveTimestamp);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Object> getComponentsToRegister() {
|
||||
return Collections.<Object>singletonList(this.synchronizer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MS doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.file;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.springframework.integration.dsl.core.MessageHandlerSpec;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.dsl.support.FunctionExpression;
|
||||
import org.springframework.integration.file.filters.FileListFilter;
|
||||
import org.springframework.integration.file.filters.RegexPatternFileListFilter;
|
||||
import org.springframework.integration.file.filters.SimplePatternFileListFilter;
|
||||
import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class RemoteFileOutboundGatewaySpec<F, S extends RemoteFileOutboundGatewaySpec<F, S>>
|
||||
extends MessageHandlerSpec<S, AbstractRemoteFileOutboundGateway<F>> {
|
||||
|
||||
private FileListFilter<F> filter;
|
||||
|
||||
private FileListFilter<File> mputFilter;
|
||||
|
||||
protected RemoteFileOutboundGatewaySpec(AbstractRemoteFileOutboundGateway<F> outboundGateway) {
|
||||
this.target = outboundGateway;
|
||||
this.target.setRequiresReply(true);
|
||||
}
|
||||
|
||||
public S options(String options) {
|
||||
this.target.setOptions(options);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S options(AbstractRemoteFileOutboundGateway.Option... options) {
|
||||
Assert.noNullElements(options);
|
||||
StringBuilder optionsString = new StringBuilder();
|
||||
for (AbstractRemoteFileOutboundGateway.Option option : options) {
|
||||
optionsString.append(option.getOption()).append(" ");
|
||||
}
|
||||
this.target.setOptions(optionsString.toString());
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S remoteFileSeparator(String remoteFileSeparator) {
|
||||
this.target.setRemoteFileSeparator(remoteFileSeparator);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S localDirectory(File localDirectory) {
|
||||
this.target.setLocalDirectory(localDirectory);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S localDirectoryExpression(String localDirectoryExpression) {
|
||||
this.target.setLocalDirectoryExpression(PARSER.parseExpression(localDirectoryExpression));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public <P> S localDirectory(Function<Message<P>, String> localDirectoryFunction) {
|
||||
this.target.setLocalDirectoryExpression(new FunctionExpression<Message<P>>(localDirectoryFunction));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S autoCreateLocalDirectory(boolean autoCreateLocalDirectory) {
|
||||
this.target.setAutoCreateLocalDirectory(autoCreateLocalDirectory);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S temporaryFileSuffix(String temporaryFileSuffix) {
|
||||
this.target.setTemporaryFileSuffix(temporaryFileSuffix);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S filter(FileListFilter<F> filter) {
|
||||
Assert.isNull(this.filter,
|
||||
"The 'filter' (" + this.filter + ") is already configured for the: " + this);
|
||||
this.filter = filter;
|
||||
this.target.setFilter(filter);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public abstract S patternFileNameFilter(String pattern);
|
||||
|
||||
public abstract S regexFileNameFilter(String regex);
|
||||
|
||||
public S mputFilter(FileListFilter<File> filter) {
|
||||
Assert.isNull(this.mputFilter,
|
||||
"The 'filter' (" + this.mputFilter + ") is already configured for the: " + this);
|
||||
this.mputFilter = filter;
|
||||
this.target.setMputFilter(filter);
|
||||
return _this();
|
||||
}
|
||||
|
||||
|
||||
public S patternMputFilter(String pattern) {
|
||||
return mputFilter(new SimplePatternFileListFilter(pattern));
|
||||
}
|
||||
|
||||
public S regexMpuFilter(String regex) {
|
||||
return mputFilter(new RegexPatternFileListFilter(regex));
|
||||
}
|
||||
|
||||
|
||||
public S renameExpression(String expression) {
|
||||
this.target.setRenameExpression(expression);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S localFilenameExpression(String localFilenameExpression) {
|
||||
this.target.setLocalFilenameGeneratorExpression(PARSER.parseExpression(localFilenameExpression));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public <P> S localFilename(Function<Message<P>, String> localFilenameFunction) {
|
||||
this.target.setLocalFilenameGeneratorExpression(new FunctionExpression<Message<P>>(localFilenameFunction));
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractRemoteFileOutboundGateway<F> doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.file;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.integration.channel.NullChannel;
|
||||
import org.springframework.integration.dsl.core.MessageProducerSpec;
|
||||
import org.springframework.integration.file.config.FileTailInboundChannelAdapterFactoryBean;
|
||||
import org.springframework.integration.file.tail.FileTailingMessageProducerSupport;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class TailAdapterSpec extends MessageProducerSpec<TailAdapterSpec, FileTailingMessageProducerSupport> {
|
||||
|
||||
private final FileTailInboundChannelAdapterFactoryBean factoryBean = new FileTailInboundChannelAdapterFactoryBean();
|
||||
|
||||
private MessageChannel outputChannel;
|
||||
|
||||
private MessageChannel errorChannel;
|
||||
|
||||
TailAdapterSpec() {
|
||||
super(null);
|
||||
this.factoryBean.setBeanFactory(new DefaultListableBeanFactory());
|
||||
}
|
||||
|
||||
TailAdapterSpec file(File file) {
|
||||
Assert.notNull(file);
|
||||
this.factoryBean.setFile(file);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public TailAdapterSpec nativeOptions(String nativeOptions) {
|
||||
this.factoryBean.setNativeOptions(nativeOptions);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public TailAdapterSpec taskExecutor(TaskExecutor taskExecutor) {
|
||||
this.factoryBean.setTaskExecutor(taskExecutor);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public TailAdapterSpec taskScheduler(TaskScheduler taskScheduler) {
|
||||
this.factoryBean.setTaskScheduler(taskScheduler);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public TailAdapterSpec delay(long delay) {
|
||||
this.factoryBean.setDelay(delay);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public TailAdapterSpec fileDelay(long fileDelay) {
|
||||
this.factoryBean.setFileDelay(fileDelay);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public TailAdapterSpec end(boolean end) {
|
||||
this.factoryBean.setEnd(end);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public TailAdapterSpec reopen(boolean reopen) {
|
||||
this.factoryBean.setReopen(reopen);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TailAdapterSpec id(String id) {
|
||||
this.factoryBean.setBeanName(id);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TailAdapterSpec phase(int phase) {
|
||||
this.factoryBean.setPhase(phase);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TailAdapterSpec autoStartup(boolean autoStartup) {
|
||||
this.factoryBean.setAutoStartup(autoStartup);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TailAdapterSpec outputChannel(MessageChannel outputChannel) {
|
||||
this.outputChannel = outputChannel;
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TailAdapterSpec errorChannel(MessageChannel errorChannel) {
|
||||
this.errorChannel = errorChannel;
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FileTailingMessageProducerSupport doGet() {
|
||||
if (this.outputChannel == null) {
|
||||
this.factoryBean.setOutputChannel(new NullChannel());
|
||||
}
|
||||
FileTailingMessageProducerSupport tailingMessageProducerSupport = null;
|
||||
try {
|
||||
this.factoryBean.afterPropertiesSet();
|
||||
tailingMessageProducerSupport = this.factoryBean.getObject();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
if (this.errorChannel != null) {
|
||||
tailingMessageProducerSupport.setErrorChannel(this.errorChannel);
|
||||
}
|
||||
tailingMessageProducerSupport.setOutputChannel(this.outputChannel);
|
||||
return tailingMessageProducerSupport;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Provides File Components support for Spring Integration Java DSL.
|
||||
*/
|
||||
package org.springframework.integration.dsl.file;
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.ftp;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
|
||||
import org.springframework.integration.file.remote.RemoteFileTemplate;
|
||||
import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway;
|
||||
import org.springframework.integration.file.remote.session.SessionFactory;
|
||||
import org.springframework.integration.file.support.FileExistsMode;
|
||||
import org.springframework.integration.ftp.gateway.FtpOutboundGateway;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class Ftp {
|
||||
|
||||
public static FtpInboundChannelAdapterSpec inboundAdapter(SessionFactory<FTPFile> sessionFactory) {
|
||||
return inboundAdapter(sessionFactory, null);
|
||||
}
|
||||
|
||||
public static FtpInboundChannelAdapterSpec inboundAdapter(SessionFactory<FTPFile> sessionFactory,
|
||||
Comparator<File> receptionOrderComparator) {
|
||||
return new FtpInboundChannelAdapterSpec(sessionFactory, receptionOrderComparator);
|
||||
}
|
||||
|
||||
public static FtpMessageHandlerSpec outboundAdapter(SessionFactory<FTPFile> sessionFactory) {
|
||||
return new FtpMessageHandlerSpec(sessionFactory);
|
||||
}
|
||||
|
||||
public static FtpMessageHandlerSpec outboundAdapter(SessionFactory<FTPFile> sessionFactory,
|
||||
FileExistsMode fileExistsMode) {
|
||||
return outboundAdapter(new RemoteFileTemplate<FTPFile>(sessionFactory), fileExistsMode);
|
||||
}
|
||||
|
||||
public static FtpMessageHandlerSpec outboundAdapter(RemoteFileTemplate<FTPFile> remoteFileTemplate) {
|
||||
return new FtpMessageHandlerSpec(remoteFileTemplate);
|
||||
}
|
||||
|
||||
public static FtpMessageHandlerSpec outboundAdapter(RemoteFileTemplate<FTPFile> remoteFileTemplate,
|
||||
FileExistsMode fileExistsMode) {
|
||||
return new FtpMessageHandlerSpec(remoteFileTemplate, fileExistsMode);
|
||||
}
|
||||
|
||||
public static FtpOutboundGatewaySpec outboundGateway(SessionFactory<FTPFile> sessionFactory,
|
||||
AbstractRemoteFileOutboundGateway.Command command, String expression) {
|
||||
return outboundGateway(sessionFactory, command.getCommand(), expression);
|
||||
}
|
||||
|
||||
public static FtpOutboundGatewaySpec outboundGateway(SessionFactory<FTPFile> sessionFactory,
|
||||
String command, String expression) {
|
||||
return new FtpOutboundGatewaySpec(new FtpOutboundGateway(sessionFactory, command, expression));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.ftp;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
|
||||
import org.springframework.integration.dsl.file.RemoteFileInboundChannelAdapterSpec;
|
||||
import org.springframework.integration.file.remote.session.SessionFactory;
|
||||
import org.springframework.integration.ftp.filters.FtpRegexPatternFileListFilter;
|
||||
import org.springframework.integration.ftp.filters.FtpSimplePatternFileListFilter;
|
||||
import org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer;
|
||||
import org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizingMessageSource;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class FtpInboundChannelAdapterSpec
|
||||
extends RemoteFileInboundChannelAdapterSpec<FTPFile, FtpInboundChannelAdapterSpec,
|
||||
FtpInboundFileSynchronizingMessageSource> {
|
||||
|
||||
FtpInboundChannelAdapterSpec(SessionFactory<FTPFile> sessionFactory, Comparator<File> comparator) {
|
||||
super(new FtpInboundFileSynchronizer(sessionFactory));
|
||||
this.target = new FtpInboundFileSynchronizingMessageSource(this.synchronizer, comparator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FtpInboundChannelAdapterSpec patternFilter(String pattern) {
|
||||
return filter(new FtpSimplePatternFileListFilter(pattern));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FtpInboundChannelAdapterSpec regexFilter(String regex) {
|
||||
return filter(new FtpRegexPatternFileListFilter(regex));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.ftp;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
|
||||
import org.springframework.integration.dsl.file.FileTransferringMessageHandlerSpec;
|
||||
import org.springframework.integration.file.remote.RemoteFileTemplate;
|
||||
import org.springframework.integration.file.remote.session.SessionFactory;
|
||||
import org.springframework.integration.file.support.FileExistsMode;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class FtpMessageHandlerSpec extends FileTransferringMessageHandlerSpec<FTPFile, FtpMessageHandlerSpec> {
|
||||
|
||||
FtpMessageHandlerSpec(SessionFactory<FTPFile> sessionFactory) {
|
||||
super(sessionFactory);
|
||||
}
|
||||
|
||||
FtpMessageHandlerSpec(RemoteFileTemplate<FTPFile> remoteFileTemplate) {
|
||||
super(remoteFileTemplate);
|
||||
}
|
||||
|
||||
FtpMessageHandlerSpec(RemoteFileTemplate<FTPFile> remoteFileTemplate, FileExistsMode fileExistsMode) {
|
||||
super(remoteFileTemplate, fileExistsMode);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.ftp;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
|
||||
import org.springframework.integration.dsl.file.RemoteFileOutboundGatewaySpec;
|
||||
import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway;
|
||||
import org.springframework.integration.ftp.filters.FtpRegexPatternFileListFilter;
|
||||
import org.springframework.integration.ftp.filters.FtpSimplePatternFileListFilter;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class FtpOutboundGatewaySpec extends RemoteFileOutboundGatewaySpec<FTPFile, FtpOutboundGatewaySpec> {
|
||||
|
||||
FtpOutboundGatewaySpec(AbstractRemoteFileOutboundGateway<FTPFile> outboundGateway) {
|
||||
super(outboundGateway);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FtpOutboundGatewaySpec patternFileNameFilter(String pattern) {
|
||||
return filter(new FtpSimplePatternFileListFilter(pattern));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FtpOutboundGatewaySpec regexFileNameFilter(String regex) {
|
||||
return filter(new FtpRegexPatternFileListFilter(regex));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Provides FTP Components support for Spring Integration Java DSL.
|
||||
*/
|
||||
package org.springframework.integration.dsl.ftp;
|
||||
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.jms.listener.DefaultMessageListenerContainer;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class Jms {
|
||||
|
||||
public static <S extends JmsPollableMessageChannelSpec<S>> JmsPollableMessageChannelSpec<S>
|
||||
pollableChannel(ConnectionFactory connectionFactory) {
|
||||
return pollableChannel(null, connectionFactory);
|
||||
}
|
||||
|
||||
public static
|
||||
<S extends JmsPollableMessageChannelSpec<S>> JmsPollableMessageChannelSpec<S> pollableChannel(String id,
|
||||
ConnectionFactory connectionFactory) {
|
||||
return new JmsPollableMessageChannelSpec<S>(connectionFactory).id(id);
|
||||
}
|
||||
|
||||
public static
|
||||
<S extends JmsMessageChannelSpec<S>> JmsMessageChannelSpec<S> channel(ConnectionFactory connectionFactory) {
|
||||
return channel(null, connectionFactory);
|
||||
}
|
||||
|
||||
public static <S extends JmsMessageChannelSpec<S>> JmsMessageChannelSpec<S> channel(String id,
|
||||
ConnectionFactory connectionFactory) {
|
||||
return new JmsMessageChannelSpec<S>(connectionFactory).id(id);
|
||||
}
|
||||
|
||||
public static JmsPublishSubscribeMessageChannelSpec publishSubscribeChannel(ConnectionFactory connectionFactory) {
|
||||
return publishSubscribeChannel(null, connectionFactory);
|
||||
}
|
||||
|
||||
public static JmsPublishSubscribeMessageChannelSpec publishSubscribeChannel(String id,
|
||||
ConnectionFactory connectionFactory) {
|
||||
return new JmsPublishSubscribeMessageChannelSpec(connectionFactory).id(id);
|
||||
}
|
||||
|
||||
public static <S extends JmsOutboundChannelAdapterSpec<S>> JmsOutboundChannelAdapterSpec<S>
|
||||
outboundAdapter(JmsTemplate jmsTemplate) {
|
||||
return new JmsOutboundChannelAdapterSpec<S>(jmsTemplate);
|
||||
}
|
||||
|
||||
public static JmsOutboundChannelAdapterSpec.JmsOutboundChannelSpecTemplateAware
|
||||
outboundAdapter(ConnectionFactory connectionFactory) {
|
||||
return new JmsOutboundChannelAdapterSpec.JmsOutboundChannelSpecTemplateAware(connectionFactory);
|
||||
}
|
||||
|
||||
public static <S extends JmsInboundChannelAdapterSpec<S>> JmsInboundChannelAdapterSpec<S>
|
||||
inboundAdapter(JmsTemplate jmsTemplate) {
|
||||
return new JmsInboundChannelAdapterSpec<S>(jmsTemplate);
|
||||
}
|
||||
|
||||
public static JmsInboundChannelAdapterSpec.JmsInboundChannelSpecTemplateAware
|
||||
inboundAdapter(ConnectionFactory connectionFactory) {
|
||||
return new JmsInboundChannelAdapterSpec.JmsInboundChannelSpecTemplateAware(connectionFactory);
|
||||
}
|
||||
|
||||
public static JmsOutboundGatewaySpec outboundGateway(ConnectionFactory connectionFactory) {
|
||||
return new JmsOutboundGatewaySpec(connectionFactory);
|
||||
}
|
||||
|
||||
public static <S extends JmsInboundGatewaySpec<S>> JmsInboundGatewaySpec<S>
|
||||
inboundGateway(AbstractMessageListenerContainer listenerContainer) {
|
||||
return new JmsInboundGatewaySpec<S>(listenerContainer);
|
||||
}
|
||||
|
||||
public static JmsInboundGatewaySpec.JmsInboundGatewayListenerContainerSpec<DefaultMessageListenerContainer>
|
||||
inboundGateway(ConnectionFactory connectionFactory) {
|
||||
return inboundGateway(connectionFactory, DefaultMessageListenerContainer.class);
|
||||
}
|
||||
|
||||
public static <C extends AbstractMessageListenerContainer>
|
||||
JmsInboundGatewaySpec.JmsInboundGatewayListenerContainerSpec<C> inboundGateway(ConnectionFactory connectionFactory,
|
||||
Class<C> containerClass) {
|
||||
try {
|
||||
JmsListenerContainerSpec<C> spec = new JmsListenerContainerSpec<C>(containerClass)
|
||||
.connectionFactory(connectionFactory);
|
||||
return new JmsInboundGatewaySpec.JmsInboundGatewayListenerContainerSpec<C>(spec);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <S extends JmsMessageDrivenChannelAdapterSpec<S>> JmsMessageDrivenChannelAdapterSpec<S>
|
||||
messageDriverChannelAdapter(AbstractMessageListenerContainer listenerContainer) {
|
||||
return new JmsMessageDrivenChannelAdapterSpec<S>(listenerContainer);
|
||||
}
|
||||
|
||||
public static
|
||||
JmsMessageDrivenChannelAdapterSpec.JmsMessageDrivenChannelAdapterListenerContainerSpec<DefaultMessageListenerContainer>
|
||||
messageDriverChannelAdapter(ConnectionFactory connectionFactory) {
|
||||
return messageDriverChannelAdapter(connectionFactory, DefaultMessageListenerContainer.class);
|
||||
}
|
||||
|
||||
public static <C extends AbstractMessageListenerContainer>
|
||||
JmsMessageDrivenChannelAdapterSpec.JmsMessageDrivenChannelAdapterListenerContainerSpec<C>
|
||||
messageDriverChannelAdapter(ConnectionFactory connectionFactory, Class<C> containerClass) {
|
||||
try {
|
||||
JmsListenerContainerSpec<C> spec = new JmsListenerContainerSpec<C>(containerClass)
|
||||
.connectionFactory(connectionFactory);
|
||||
return new JmsMessageDrivenChannelAdapterSpec.JmsMessageDrivenChannelAdapterListenerContainerSpec<C>(spec);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
||||
import org.springframework.integration.dsl.core.IntegrationComponentSpec;
|
||||
import org.springframework.jms.support.destination.DestinationResolver;
|
||||
import org.springframework.jms.support.destination.JmsDestinationAccessor;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class
|
||||
JmsDestinationAccessorSpec<S extends JmsDestinationAccessorSpec<S, A>, A extends JmsDestinationAccessor>
|
||||
extends IntegrationComponentSpec<S, A> {
|
||||
|
||||
protected JmsDestinationAccessorSpec(A accessor) {
|
||||
this.target = accessor;
|
||||
}
|
||||
|
||||
S connectionFactory(ConnectionFactory connectionFactory) {
|
||||
this.target.setConnectionFactory(connectionFactory);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S destinationResolver(DestinationResolver destinationResolver) {
|
||||
this.target.setDestinationResolver(destinationResolver);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S pubSubDomain(boolean pubSubDomain) {
|
||||
target.setPubSubDomain(pubSubDomain);
|
||||
return _this();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sessionAcknowledgeMode the acknowledgement mode constant
|
||||
* @return the current {@link org.springframework.integration.dsl.channel.MessageChannelSpec}
|
||||
* @see javax.jms.Session#AUTO_ACKNOWLEDGE etc.
|
||||
*/
|
||||
public S sessionAcknowledgeMode(int sessionAcknowledgeMode) {
|
||||
this.target.setSessionAcknowledgeMode(sessionAcknowledgeMode);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S sessionAcknowledgeModeName(String constantName) {
|
||||
target.setSessionAcknowledgeModeName(constantName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S sessionTransacted(boolean sessionTransacted) {
|
||||
this.target.setSessionTransacted(sessionTransacted);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected A doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.Destination;
|
||||
|
||||
import org.springframework.integration.dsl.core.MessageSourceSpec;
|
||||
import org.springframework.integration.dsl.support.Consumer;
|
||||
import org.springframework.integration.jms.JmsDestinationPollingSource;
|
||||
import org.springframework.integration.jms.JmsHeaderMapper;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JmsInboundChannelAdapterSpec<S extends JmsInboundChannelAdapterSpec<S>>
|
||||
extends MessageSourceSpec<S, JmsDestinationPollingSource> {
|
||||
|
||||
final JmsTemplateSpec jmsTemplateSpec = new JmsTemplateSpec();
|
||||
|
||||
JmsInboundChannelAdapterSpec(JmsTemplate jmsTemplate) {
|
||||
this.target = new JmsDestinationPollingSource(jmsTemplate);
|
||||
}
|
||||
|
||||
private JmsInboundChannelAdapterSpec(ConnectionFactory connectionFactory) {
|
||||
this.target = new JmsDestinationPollingSource(this.jmsTemplateSpec.connectionFactory(connectionFactory).get());
|
||||
}
|
||||
|
||||
public S messageSelector(String messageSelector) {
|
||||
this.target.setMessageSelector(messageSelector);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S headerMapper(JmsHeaderMapper headerMapper) {
|
||||
this.target.setHeaderMapper(headerMapper);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S destination(Destination destination) {
|
||||
this.target.setDestination(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S destination(String destination) {
|
||||
this.target.setDestinationName(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JmsDestinationPollingSource doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static class JmsInboundChannelSpecTemplateAware extends
|
||||
JmsInboundChannelAdapterSpec<JmsInboundChannelSpecTemplateAware> {
|
||||
|
||||
JmsInboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) {
|
||||
super(connectionFactory);
|
||||
}
|
||||
|
||||
public JmsInboundChannelSpecTemplateAware configureJmsTemplate(Consumer<JmsTemplateSpec> configurer) {
|
||||
Assert.notNull(configurer);
|
||||
configurer.accept(this.jmsTemplateSpec);
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.integration.context.OrderlyShutdownCapable;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.integration.jms.ChannelPublishingJmsMessageListener;
|
||||
import org.springframework.integration.jms.JmsMessageDrivenEndpoint;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JmsInboundGateway extends MessagingGatewaySupport implements
|
||||
DisposableBean, OrderlyShutdownCapable {
|
||||
|
||||
private final JmsMessageDrivenEndpoint endpoint;
|
||||
|
||||
private final ChannelPublishingJmsMessageListener listener;
|
||||
|
||||
public JmsInboundGateway(AbstractMessageListenerContainer listenerContainer,
|
||||
ChannelPublishingJmsMessageListener listener) {
|
||||
this.endpoint = new JmsMessageDrivenEndpoint(listenerContainer, listener);
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRequestChannel(MessageChannel requestChannel) {
|
||||
this.listener.setRequestChannel(requestChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyChannel(MessageChannel replyChannel) {
|
||||
this.listener.setReplyChannel(replyChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrorChannel(MessageChannel errorChannel) {
|
||||
this.listener.setErrorChannel(errorChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRequestTimeout(long requestTimeout) {
|
||||
this.listener.setRequestTimeout(requestTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTimeout(long replyTimeout) {
|
||||
this.listener.setReplyTimeout(replyTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShouldTrack(boolean shouldTrack) {
|
||||
this.listener.setShouldTrack(shouldTrack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "jms:inbound-gateway";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComponentName(String componentName) {
|
||||
super.setComponentName(componentName);
|
||||
this.endpoint.setComponentName(getComponentName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
super.setApplicationContext(applicationContext);
|
||||
this.endpoint.setApplicationContext(applicationContext);
|
||||
this.endpoint.setBeanFactory(applicationContext);
|
||||
this.listener.setBeanFactory(applicationContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() throws Exception {
|
||||
this.endpoint.afterPropertiesSet();
|
||||
}
|
||||
|
||||
ChannelPublishingJmsMessageListener getListener() {
|
||||
return this.listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() {
|
||||
this.endpoint.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() {
|
||||
this.endpoint.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
this.endpoint.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int beforeShutdown() {
|
||||
return this.endpoint.beforeShutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int afterShutdown() {
|
||||
return this.endpoint.afterShutdown();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import javax.jms.Destination;
|
||||
|
||||
import org.springframework.integration.dsl.core.MessagingGatewaySpec;
|
||||
import org.springframework.integration.dsl.support.Consumer;
|
||||
import org.springframework.integration.jms.ChannelPublishingJmsMessageListener;
|
||||
import org.springframework.integration.jms.JmsHeaderMapper;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
import org.springframework.jms.support.destination.DestinationResolver;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JmsInboundGatewaySpec<S extends JmsInboundGatewaySpec<S>>
|
||||
extends MessagingGatewaySpec<S, JmsInboundGateway> {
|
||||
|
||||
JmsInboundGatewaySpec(AbstractMessageListenerContainer listenerContainer) {
|
||||
super(new JmsInboundGateway(listenerContainer, new ChannelPublishingJmsMessageListener()));
|
||||
this.target.getListener().setExpectReply(true);
|
||||
}
|
||||
|
||||
public S defaultReplyDestination(Destination defaultReplyDestination) {
|
||||
this.target.getListener().setDefaultReplyDestination(defaultReplyDestination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S defaultReplyQueueName(String destinationName) {
|
||||
this.target.getListener().setDefaultReplyQueueName(destinationName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S defaultReplyTopicName(String destinationName) {
|
||||
this.target.getListener().setDefaultReplyTopicName(destinationName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S replyTimeToLive(long replyTimeToLive) {
|
||||
this.target.getListener().setReplyTimeToLive(replyTimeToLive);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S replyPriority(int replyPriority) {
|
||||
this.target.getListener().setReplyPriority(replyPriority);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S replyDeliveryPersistent(boolean replyDeliveryPersistent) {
|
||||
this.target.getListener().setReplyDeliveryPersistent(replyDeliveryPersistent);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S correlationKey(String correlationKey) {
|
||||
this.target.getListener().setCorrelationKey(correlationKey);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S explicitQosEnabledForReplies(boolean explicitQosEnabledForReplies) {
|
||||
this.target.getListener().setExplicitQosEnabledForReplies(explicitQosEnabledForReplies);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S destinationResolver(DestinationResolver destinationResolver) {
|
||||
this.target.getListener().setDestinationResolver(destinationResolver);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S jmsMessageConverter(MessageConverter messageConverter) {
|
||||
this.target.getListener().setMessageConverter(messageConverter);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S setHeaderMapper(JmsHeaderMapper headerMapper) {
|
||||
this.target.getListener().setHeaderMapper(headerMapper);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S extractRequestPayload(boolean extractRequestPayload) {
|
||||
this.target.getListener().setExtractRequestPayload(extractRequestPayload);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S extractReplyPayload(boolean extractReplyPayload) {
|
||||
this.target.getListener().setExtractReplyPayload(extractReplyPayload);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public static class JmsInboundGatewayListenerContainerSpec<C extends AbstractMessageListenerContainer> extends
|
||||
JmsInboundGatewaySpec<JmsInboundGatewayListenerContainerSpec<C>> {
|
||||
|
||||
private final JmsListenerContainerSpec<C> spec;
|
||||
|
||||
JmsInboundGatewayListenerContainerSpec(JmsListenerContainerSpec<C> spec) {
|
||||
super(spec.get());
|
||||
this.spec = spec;
|
||||
this.spec.get().setAutoStartup(false);
|
||||
}
|
||||
|
||||
public JmsInboundGatewayListenerContainerSpec<C> destination(Destination destination) {
|
||||
spec.destination(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsInboundGatewayListenerContainerSpec<C> destination(String destinationName) {
|
||||
spec.destination(destinationName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsInboundGatewayListenerContainerSpec<C> configureListenerContainer(
|
||||
Consumer<JmsListenerContainerSpec<C>> configurer) {
|
||||
Assert.notNull(configurer);
|
||||
configurer.accept(this.spec);
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import javax.jms.Destination;
|
||||
import javax.jms.ExceptionListener;
|
||||
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JmsListenerContainerSpec<C extends AbstractMessageListenerContainer>
|
||||
extends JmsDestinationAccessorSpec<JmsListenerContainerSpec<C>, C> {
|
||||
|
||||
JmsListenerContainerSpec(Class<C> aClass) throws Exception {
|
||||
super(aClass.newInstance());
|
||||
}
|
||||
|
||||
JmsListenerContainerSpec<C> destination(Destination destination) {
|
||||
target.setDestination(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
JmsListenerContainerSpec<C> destination(String destinationName) {
|
||||
target.setDestinationName(destinationName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsListenerContainerSpec<C> messageSelector(String messageSelector) {
|
||||
target.setMessageSelector(messageSelector);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsListenerContainerSpec<C> subscriptionDurable(boolean subscriptionDurable) {
|
||||
target.setSubscriptionDurable(subscriptionDurable);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsListenerContainerSpec<C> durableSubscriptionName(String durableSubscriptionName) {
|
||||
target.setDurableSubscriptionName(durableSubscriptionName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsListenerContainerSpec<C> exceptionListener(ExceptionListener exceptionListener) {
|
||||
target.setExceptionListener(exceptionListener);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsListenerContainerSpec<C> errorHandler(ErrorHandler errorHandler) {
|
||||
target.setErrorHandler(errorHandler);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsListenerContainerSpec<C> exposeListenerSession(boolean exposeListenerSession) {
|
||||
target.setExposeListenerSession(exposeListenerSession);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsListenerContainerSpec<C> acceptMessagesWhileStopping(boolean acceptMessagesWhileStopping) {
|
||||
target.setAcceptMessagesWhileStopping(acceptMessagesWhileStopping);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsListenerContainerSpec<C> clientId(String clientId) {
|
||||
target.setClientId(clientId);
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.integration.jms.AbstractJmsChannel;
|
||||
import org.springframework.integration.jms.config.JmsChannelFactoryBean;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.jms.listener.DefaultMessageListenerContainer;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JmsMessageChannelSpec<S extends JmsMessageChannelSpec<S>> extends JmsPollableMessageChannelSpec<S> {
|
||||
|
||||
private Integer cacheLevel;
|
||||
|
||||
JmsMessageChannelSpec(ConnectionFactory connectionFactory) {
|
||||
super(new JmsChannelFactoryBean(true), connectionFactory);
|
||||
}
|
||||
|
||||
public S containerType(Class<? extends AbstractMessageListenerContainer> containerType) {
|
||||
this.jmsChannelFactoryBean.setContainerType(containerType);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S concurrentConsumers(int concurrentConsumers) {
|
||||
this.jmsChannelFactoryBean.setConcurrentConsumers(concurrentConsumers);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S maxSubscribers(int maxSubscribers) {
|
||||
this.jmsChannelFactoryBean.setMaxSubscribers(maxSubscribers);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S autoStartup(boolean autoStartup) {
|
||||
this.jmsChannelFactoryBean.setAutoStartup(autoStartup);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S phase(int phase) {
|
||||
this.jmsChannelFactoryBean.setPhase(phase);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S errorHandler(ErrorHandler errorHandler) {
|
||||
this.jmsChannelFactoryBean.setErrorHandler(errorHandler);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S exposeListenerSession(boolean exposeListenerSession) {
|
||||
this.jmsChannelFactoryBean.setExposeListenerSession(exposeListenerSession);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S acceptMessagesWhileStopping(boolean acceptMessagesWhileStopping) {
|
||||
this.jmsChannelFactoryBean.setAcceptMessagesWhileStopping(acceptMessagesWhileStopping);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S idleTaskExecutionLimit(int idleTaskExecutionLimit) {
|
||||
this.jmsChannelFactoryBean.setIdleTaskExecutionLimit(idleTaskExecutionLimit);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S maxMessagesPerTask(int maxMessagesPerTask) {
|
||||
this.jmsChannelFactoryBean.setMaxMessagesPerTask(maxMessagesPerTask);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S recoveryInterval(long recoveryInterval) {
|
||||
this.jmsChannelFactoryBean.setRecoveryInterval(recoveryInterval);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S taskExecutor(Executor taskExecutor) {
|
||||
this.jmsChannelFactoryBean.setTaskExecutor(taskExecutor);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S transactionManager(PlatformTransactionManager transactionManager) {
|
||||
this.jmsChannelFactoryBean.setTransactionManager(transactionManager);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S transactionName(String transactionName) {
|
||||
this.jmsChannelFactoryBean.setTransactionName(transactionName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S transactionTimeout(int transactionTimeout) {
|
||||
this.jmsChannelFactoryBean.setTransactionTimeout(transactionTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cacheLevel the value for {@code DefaultMessageListenerContainer.cacheLevel}
|
||||
* @return the current {@link org.springframework.integration.dsl.channel.MessageChannelSpec}
|
||||
* @see org.springframework.jms.listener.DefaultMessageListenerContainer#CACHE_AUTO etc.
|
||||
*/
|
||||
public S cacheLevel(Integer cacheLevel) {
|
||||
this.cacheLevel = cacheLevel;
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractJmsChannel doGet() {
|
||||
AbstractJmsChannel jmsChannel = super.doGet();
|
||||
if (this.cacheLevel != null) {
|
||||
//TODO till INT-3435
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(jmsChannel);
|
||||
Object container = dfa.getPropertyValue("container");
|
||||
if (container instanceof DefaultMessageListenerContainer) {
|
||||
((DefaultMessageListenerContainer) container).setCacheLevel(this.cacheLevel);
|
||||
}
|
||||
|
||||
}
|
||||
return jmsChannel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.integration.context.OrderlyShutdownCapable;
|
||||
import org.springframework.integration.endpoint.MessageProducerSupport;
|
||||
import org.springframework.integration.jms.ChannelPublishingJmsMessageListener;
|
||||
import org.springframework.integration.jms.JmsMessageDrivenEndpoint;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JmsMessageDrivenChannelAdapter extends MessageProducerSupport implements
|
||||
DisposableBean, OrderlyShutdownCapable {
|
||||
|
||||
private final JmsMessageDrivenEndpoint endpoint;
|
||||
|
||||
private final ChannelPublishingJmsMessageListener listener;
|
||||
|
||||
public JmsMessageDrivenChannelAdapter(AbstractMessageListenerContainer listenerContainer,
|
||||
ChannelPublishingJmsMessageListener listener) {
|
||||
this.endpoint = new JmsMessageDrivenEndpoint(listenerContainer, listener);
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutputChannel(MessageChannel requestChannel) {
|
||||
this.listener.setRequestChannel(requestChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrorChannel(MessageChannel errorChannel) {
|
||||
this.listener.setErrorChannel(errorChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSendTimeout(long requestTimeout) {
|
||||
this.listener.setRequestTimeout(requestTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShouldTrack(boolean shouldTrack) {
|
||||
this.listener.setShouldTrack(shouldTrack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "jms:message-driven-channel-adapter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComponentName(String componentName) {
|
||||
super.setComponentName(componentName);
|
||||
this.endpoint.setComponentName(getComponentName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
super.setApplicationContext(applicationContext);
|
||||
this.endpoint.setApplicationContext(applicationContext);
|
||||
this.endpoint.setBeanFactory(applicationContext);
|
||||
this.listener.setBeanFactory(applicationContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() {
|
||||
this.endpoint.afterPropertiesSet();
|
||||
}
|
||||
|
||||
ChannelPublishingJmsMessageListener getListener() {
|
||||
return this.listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() {
|
||||
this.endpoint.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() {
|
||||
this.endpoint.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
this.endpoint.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int beforeShutdown() {
|
||||
return this.endpoint.beforeShutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int afterShutdown() {
|
||||
return this.endpoint.afterShutdown();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import javax.jms.Destination;
|
||||
|
||||
import org.springframework.integration.dsl.core.MessageProducerSpec;
|
||||
import org.springframework.integration.dsl.support.Consumer;
|
||||
import org.springframework.integration.jms.ChannelPublishingJmsMessageListener;
|
||||
import org.springframework.integration.jms.JmsHeaderMapper;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JmsMessageDrivenChannelAdapterSpec<S extends JmsMessageDrivenChannelAdapterSpec<S>>
|
||||
extends MessageProducerSpec<S, JmsMessageDrivenChannelAdapter> {
|
||||
|
||||
JmsMessageDrivenChannelAdapterSpec(AbstractMessageListenerContainer listenerContainer) {
|
||||
super(new JmsMessageDrivenChannelAdapter(listenerContainer, new ChannelPublishingJmsMessageListener()));
|
||||
this.target.getListener().setExpectReply(false);
|
||||
}
|
||||
|
||||
public S jmsMessageConverter(MessageConverter messageConverter) {
|
||||
this.target.getListener().setMessageConverter(messageConverter);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S setHeaderMapper(JmsHeaderMapper headerMapper) {
|
||||
this.target.getListener().setHeaderMapper(headerMapper);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S extractPayload(boolean extractRequestPayload) {
|
||||
this.target.getListener().setExtractRequestPayload(extractRequestPayload);
|
||||
return _this();
|
||||
}
|
||||
|
||||
|
||||
public static class
|
||||
JmsMessageDrivenChannelAdapterListenerContainerSpec<C extends AbstractMessageListenerContainer> extends
|
||||
JmsMessageDrivenChannelAdapterSpec<JmsMessageDrivenChannelAdapterListenerContainerSpec<C>> {
|
||||
|
||||
private final JmsListenerContainerSpec<C> spec;
|
||||
|
||||
JmsMessageDrivenChannelAdapterListenerContainerSpec(JmsListenerContainerSpec<C> spec) {
|
||||
super(spec.get());
|
||||
this.spec = spec;
|
||||
this.spec.get().setAutoStartup(false);
|
||||
}
|
||||
|
||||
public JmsMessageDrivenChannelAdapterListenerContainerSpec<C> destination(Destination destination) {
|
||||
spec.destination(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsMessageDrivenChannelAdapterListenerContainerSpec<C> destination(String destinationName) {
|
||||
spec.destination(destinationName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsMessageDrivenChannelAdapterListenerContainerSpec<C> configureListenerContainer(
|
||||
Consumer<JmsListenerContainerSpec<C>> configurer) {
|
||||
Assert.notNull(configurer);
|
||||
configurer.accept(this.spec);
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.Destination;
|
||||
|
||||
import org.springframework.integration.dsl.core.MessageHandlerSpec;
|
||||
import org.springframework.integration.dsl.support.Consumer;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.dsl.support.FunctionExpression;
|
||||
import org.springframework.integration.jms.JmsHeaderMapper;
|
||||
import org.springframework.integration.jms.JmsSendingMessageHandler;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JmsOutboundChannelAdapterSpec<S extends JmsOutboundChannelAdapterSpec<S>>
|
||||
extends MessageHandlerSpec<S, JmsSendingMessageHandler> {
|
||||
|
||||
protected final JmsTemplateSpec jmsTemplateSpec = new JmsTemplateSpec();
|
||||
|
||||
JmsOutboundChannelAdapterSpec(JmsTemplate jmsTemplate) {
|
||||
this.target = new JmsSendingMessageHandler(jmsTemplate);
|
||||
}
|
||||
|
||||
private JmsOutboundChannelAdapterSpec(ConnectionFactory connectionFactory) {
|
||||
this.target = new JmsSendingMessageHandler(this.jmsTemplateSpec.connectionFactory(connectionFactory).get());
|
||||
}
|
||||
|
||||
public S extractPayload(boolean extractPayload) {
|
||||
this.target.setExtractPayload(extractPayload);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S headerMapper(JmsHeaderMapper headerMapper) {
|
||||
this.target.setHeaderMapper(headerMapper);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S destination(Destination destination) {
|
||||
this.target.setDestination(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S destination(String destination) {
|
||||
this.target.setDestinationName(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S destinationExpression(String destination) {
|
||||
this.target.setDestinationExpression(PARSER.parseExpression(destination));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public <P> S destination(Function<Message<P>, ?> destinationFunction) {
|
||||
this.target.setDestinationExpression(new FunctionExpression<Message<P>>(destinationFunction));
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JmsSendingMessageHandler doGet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class JmsOutboundChannelSpecTemplateAware extends
|
||||
JmsOutboundChannelAdapterSpec<JmsOutboundChannelSpecTemplateAware> {
|
||||
|
||||
JmsOutboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) {
|
||||
super(connectionFactory);
|
||||
}
|
||||
|
||||
public JmsOutboundChannelSpecTemplateAware configureJmsTemplate(Consumer<JmsTemplateSpec> configurer) {
|
||||
Assert.notNull(configurer);
|
||||
configurer.accept(this.jmsTemplateSpec);
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,240 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.Destination;
|
||||
|
||||
import org.springframework.integration.dsl.core.IntegrationComponentSpec;
|
||||
import org.springframework.integration.dsl.core.MessageHandlerSpec;
|
||||
import org.springframework.integration.dsl.support.Consumer;
|
||||
import org.springframework.integration.dsl.support.Function;
|
||||
import org.springframework.integration.dsl.support.FunctionExpression;
|
||||
import org.springframework.integration.jms.JmsHeaderMapper;
|
||||
import org.springframework.integration.jms.JmsOutboundGateway;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
import org.springframework.jms.support.destination.DestinationResolver;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JmsOutboundGatewaySpec extends MessageHandlerSpec<JmsOutboundGatewaySpec, JmsOutboundGateway> {
|
||||
|
||||
JmsOutboundGatewaySpec(ConnectionFactory connectionFactory) {
|
||||
this.target = new JmsOutboundGateway();
|
||||
this.target.setConnectionFactory(connectionFactory);
|
||||
this.target.setRequiresReply(true);
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec extractRequestPayload(boolean extractPayload) {
|
||||
this.target.setExtractRequestPayload(extractPayload);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec extractReplyPayload(boolean extractPayload) {
|
||||
this.target.setExtractReplyPayload(extractPayload);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec headerMapper(JmsHeaderMapper headerMapper) {
|
||||
this.target.setHeaderMapper(headerMapper);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec requestDestination(Destination destination) {
|
||||
this.target.setRequestDestination(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec requestDestination(String destination) {
|
||||
this.target.setRequestDestinationName(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec requestDestinationExpression(String destination) {
|
||||
this.target.setRequestDestinationExpression(PARSER.parseExpression(destination));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public <P> JmsOutboundGatewaySpec requestDestination(Function<Message<P>, ?> destinationFunction) {
|
||||
this.target.setRequestDestinationExpression(new FunctionExpression<Message<P>>(destinationFunction));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec replyDestination(Destination destination) {
|
||||
this.target.setReplyDestination(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec replyDestination(String destination) {
|
||||
this.target.setReplyDestinationName(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec replyDestinationExpression(String destination) {
|
||||
this.target.setReplyDestinationExpression(PARSER.parseExpression(destination));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public <P> JmsOutboundGatewaySpec replyDestination(Function<Message<P>, ?> destinationFunction) {
|
||||
this.target.setReplyDestinationExpression(new FunctionExpression<Message<P>>(destinationFunction));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec destinationResolver(DestinationResolver destinationResolver) {
|
||||
this.target.setDestinationResolver(destinationResolver);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec jmsMessageConverter(MessageConverter messageConverter) {
|
||||
this.target.setMessageConverter(messageConverter);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec correlationKey(String correlationKey) {
|
||||
this.target.setCorrelationKey(correlationKey);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec requestPubSubDomain(boolean pubSubDomain) {
|
||||
this.target.setRequestPubSubDomain(pubSubDomain);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec replyPubSubDomain(boolean pubSubDomain) {
|
||||
this.target.setReplyPubSubDomain(pubSubDomain);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec deliveryPersistent(boolean deliveryPersistent) {
|
||||
this.target.setDeliveryPersistent(deliveryPersistent);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec priority(int priority) {
|
||||
this.target.setPriority(priority);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec timeToLive(long timeToLive) {
|
||||
this.target.setTimeToLive(timeToLive);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec receiveTimeout(long receiveTimeout) {
|
||||
this.target.setReceiveTimeout(receiveTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec explicitQosEnabled(boolean explicitQosEnabled) {
|
||||
this.target.setExplicitQosEnabled(explicitQosEnabled);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec replyContainer() {
|
||||
this.target.setReplyContainerProperties(new JmsOutboundGateway.ReplyContainerProperties());
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsOutboundGatewaySpec replyContainer(Consumer<ReplyContainerSpec> configurer) {
|
||||
Assert.notNull(configurer);
|
||||
ReplyContainerSpec spec = new ReplyContainerSpec();
|
||||
configurer.accept(spec);
|
||||
this.target.setReplyContainerProperties(spec.get());
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JmsOutboundGateway doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
public class ReplyContainerSpec
|
||||
extends IntegrationComponentSpec<ReplyContainerSpec, JmsOutboundGateway.ReplyContainerProperties> {
|
||||
|
||||
ReplyContainerSpec() {
|
||||
this.target = new JmsOutboundGateway.ReplyContainerProperties();
|
||||
}
|
||||
|
||||
public ReplyContainerSpec sessionTransacted(Boolean sessionTransacted) {
|
||||
this.target.setSessionTransacted(sessionTransacted);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public ReplyContainerSpec sessionAcknowledgeMode(Integer sessionAcknowledgeMode) {
|
||||
this.target.setSessionAcknowledgeMode(sessionAcknowledgeMode);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public ReplyContainerSpec receiveTimeout(Long receiveTimeout) {
|
||||
this.target.setReceiveTimeout(receiveTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public ReplyContainerSpec recoveryInterval(Long recoveryInterval) {
|
||||
this.target.setRecoveryInterval(recoveryInterval);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public ReplyContainerSpec cacheLevel(Integer cacheLevel) {
|
||||
this.target.setCacheLevel(cacheLevel);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public ReplyContainerSpec concurrentConsumers(Integer concurrentConsumers) {
|
||||
this.target.setConcurrentConsumers(concurrentConsumers);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public ReplyContainerSpec maxConcurrentConsumers(Integer maxConcurrentConsumers) {
|
||||
this.target.setMaxConcurrentConsumers(maxConcurrentConsumers);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public ReplyContainerSpec maxMessagesPerTask(Integer maxMessagesPerTask) {
|
||||
this.target.setMaxMessagesPerTask(maxMessagesPerTask);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public ReplyContainerSpec idleConsumerLimit(Integer idleConsumerLimit) {
|
||||
this.target.setIdleConsumerLimit(idleConsumerLimit);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public ReplyContainerSpec idleTaskExecutionLimit(Integer idleTaskExecutionLimit) {
|
||||
this.target.setIdleTaskExecutionLimit(idleTaskExecutionLimit);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public ReplyContainerSpec taskExecutor(Executor taskExecutor) {
|
||||
this.target.setTaskExecutor(taskExecutor);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JmsOutboundGateway.ReplyContainerProperties doGet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.Destination;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.integration.dsl.channel.MessageChannelSpec;
|
||||
import org.springframework.integration.jms.AbstractJmsChannel;
|
||||
import org.springframework.integration.jms.config.JmsChannelFactoryBean;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
import org.springframework.jms.support.destination.DestinationResolver;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JmsPollableMessageChannelSpec<S extends JmsPollableMessageChannelSpec<S>>
|
||||
extends MessageChannelSpec<S, AbstractJmsChannel> {
|
||||
|
||||
protected final JmsChannelFactoryBean jmsChannelFactoryBean;
|
||||
|
||||
JmsPollableMessageChannelSpec(ConnectionFactory connectionFactory) {
|
||||
this(new JmsChannelFactoryBean(false), connectionFactory);
|
||||
}
|
||||
|
||||
JmsPollableMessageChannelSpec(JmsChannelFactoryBean jmsChannelFactoryBean, ConnectionFactory connectionFactory) {
|
||||
this.jmsChannelFactoryBean = jmsChannelFactoryBean;
|
||||
this.jmsChannelFactoryBean.setConnectionFactory(connectionFactory);
|
||||
this.jmsChannelFactoryBean.setSingleton(false);
|
||||
this.jmsChannelFactoryBean.setBeanFactory(new DefaultListableBeanFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected S id(String id) {
|
||||
this.jmsChannelFactoryBean.setBeanName(id);
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
public S destination(String destination) {
|
||||
this.jmsChannelFactoryBean.setDestinationName(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S destinationResolver(DestinationResolver destinationResolver) {
|
||||
this.jmsChannelFactoryBean.setDestinationResolver(destinationResolver);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S destination(Destination destination) {
|
||||
this.jmsChannelFactoryBean.setDestination(destination);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S messageSelector(String messageSelector) {
|
||||
this.jmsChannelFactoryBean.setMessageSelector(messageSelector);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S jmsMessageConverter(MessageConverter messageConverter) {
|
||||
this.jmsChannelFactoryBean.setMessageConverter(messageConverter);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S deliveryPersistent(boolean deliveryPersistent) {
|
||||
this.jmsChannelFactoryBean.setDeliveryPersistent(deliveryPersistent);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S explicitQosEnabled(boolean explicitQosEnabled) {
|
||||
this.jmsChannelFactoryBean.setExplicitQosEnabled(explicitQosEnabled);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S messageIdEnabled(boolean messageIdEnabled) {
|
||||
this.jmsChannelFactoryBean.setMessageIdEnabled(messageIdEnabled);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S messageTimestampEnabled(boolean messageTimestampEnabled) {
|
||||
this.jmsChannelFactoryBean.setMessageTimestampEnabled(messageTimestampEnabled);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S priority(int priority) {
|
||||
this.jmsChannelFactoryBean.setPriority(priority);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S timeToLive(long timeToLive) {
|
||||
this.jmsChannelFactoryBean.setTimeToLive(timeToLive);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S receiveTimeout(long receiveTimeout) {
|
||||
this.jmsChannelFactoryBean.setReceiveTimeout(receiveTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sessionAcknowledgeMode the acknowledgement mode constant
|
||||
* @return the current {@link MessageChannelSpec}
|
||||
* @see javax.jms.Session#AUTO_ACKNOWLEDGE etc.
|
||||
*/
|
||||
public S sessionAcknowledgeMode(int sessionAcknowledgeMode) {
|
||||
this.jmsChannelFactoryBean.setSessionAcknowledgeMode(sessionAcknowledgeMode);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S sessionTransacted(boolean sessionTransacted) {
|
||||
this.jmsChannelFactoryBean.setSessionTransacted(sessionTransacted);
|
||||
return _this();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractJmsChannel doGet() {
|
||||
try {
|
||||
this.channel = this.jmsChannelFactoryBean.getObject();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new BeanCreationException("Cannot create the JMS MessageChannel", e);
|
||||
}
|
||||
return super.doGet();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JmsPublishSubscribeMessageChannelSpec
|
||||
extends JmsMessageChannelSpec<JmsPublishSubscribeMessageChannelSpec> {
|
||||
|
||||
JmsPublishSubscribeMessageChannelSpec(ConnectionFactory connectionFactory) {
|
||||
super(connectionFactory);
|
||||
this.jmsChannelFactoryBean.setPubSubDomain(true);
|
||||
}
|
||||
|
||||
public JmsPublishSubscribeMessageChannelSpec subscriptionDurable(boolean durable) {
|
||||
this.jmsChannelFactoryBean.setSubscriptionDurable(durable);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsPublishSubscribeMessageChannelSpec durableSubscriptionName(String durableSubscriptionName) {
|
||||
this.jmsChannelFactoryBean.setDurableSubscriptionName(durableSubscriptionName);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsPublishSubscribeMessageChannelSpec clientId(String clientId) {
|
||||
this.jmsChannelFactoryBean.setClientId(clientId);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsPublishSubscribeMessageChannelSpec pubSubNoLocal(boolean pubSubNoLocal) {
|
||||
this.jmsChannelFactoryBean.setPubSubNoLocal(pubSubNoLocal);
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.dsl.jms;
|
||||
|
||||
import org.springframework.integration.jms.DynamicJmsTemplate;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JmsTemplateSpec extends JmsDestinationAccessorSpec<JmsTemplateSpec, DynamicJmsTemplate> {
|
||||
|
||||
JmsTemplateSpec() {
|
||||
super(new DynamicJmsTemplate());
|
||||
}
|
||||
|
||||
public JmsTemplateSpec jmsMessageConverter(MessageConverter messageConverter) {
|
||||
this.target.setMessageConverter(messageConverter);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsTemplateSpec deliveryPersistent(boolean deliveryPersistent) {
|
||||
this.target.setDeliveryPersistent(deliveryPersistent);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsTemplateSpec explicitQosEnabled(boolean explicitQosEnabled) {
|
||||
this.target.setExplicitQosEnabled(explicitQosEnabled);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsTemplateSpec priority(int priority) {
|
||||
this.target.setPriority(priority);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsTemplateSpec timeToLive(long timeToLive) {
|
||||
this.target.setTimeToLive(timeToLive);
|
||||
return _this();
|
||||
}
|
||||
|
||||
public JmsTemplateSpec receiveTimeout(long receiveTimeout) {
|
||||
this.target.setReceiveTimeout(receiveTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Provides JMS Components support for Spring Integration Java DSL.
|
||||
*/
|
||||
package org.springframework.integration.dsl.jms;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user