diff --git a/spring-integration-java-dsl/README.md b/spring-integration-java-dsl/README.md index 8897b4d..2c2b023 100644 --- a/spring-integration-java-dsl/README.md +++ b/spring-integration-java-dsl/README.md @@ -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 \ No newline at end of file diff --git a/spring-integration-java-dsl/build.gradle b/spring-integration-java-dsl/build.gradle deleted file mode 100644 index 82bc98a..0000000 --- a/spring-integration-java-dsl/build.gradle +++ /dev/null @@ -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" -} diff --git a/spring-integration-java-dsl/gradle.properties b/spring-integration-java-dsl/gradle.properties deleted file mode 100644 index bebfcbc..0000000 --- a/spring-integration-java-dsl/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -version=1.0.0.BUILD-SNAPSHOT diff --git a/spring-integration-java-dsl/gradle/wrapper/gradle-wrapper.jar b/spring-integration-java-dsl/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 3c7abdf..0000000 Binary files a/spring-integration-java-dsl/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/spring-integration-java-dsl/gradle/wrapper/gradle-wrapper.properties b/spring-integration-java-dsl/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ba6ee38..0000000 --- a/spring-integration-java-dsl/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -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 diff --git a/spring-integration-java-dsl/gradlew b/spring-integration-java-dsl/gradlew deleted file mode 100755 index 91a7e26..0000000 --- a/spring-integration-java-dsl/gradlew +++ /dev/null @@ -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 "$@" diff --git a/spring-integration-java-dsl/gradlew.bat b/spring-integration-java-dsl/gradlew.bat deleted file mode 100644 index 8a0b282..0000000 --- a/spring-integration-java-dsl/gradlew.bat +++ /dev/null @@ -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 diff --git a/spring-integration-java-dsl/publish-maven.gradle b/spring-integration-java-dsl/publish-maven.gradle deleted file mode 100644 index c6c6f35..0000000 --- a/spring-integration-java-dsl/publish-maven.gradle +++ /dev/null @@ -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"] - } - } - } - } -} diff --git a/spring-integration-java-dsl/src/api/overview.html b/spring-integration-java-dsl/src/api/overview.html deleted file mode 100644 index fb0198b..0000000 --- a/spring-integration-java-dsl/src/api/overview.html +++ /dev/null @@ -1,22 +0,0 @@ - - -This document is the API specification for Spring Integration -
-
-

- For further API reference and developer documentation, see the - Spring - Integration reference documentation. - That documentation contains more detailed, developer-targeted - descriptions, with conceptual overviews, definitions of terms, - workarounds, and working code examples. -

- -

- If you are interested in commercial training, consultancy, and - support for Spring Integration, please visit - http://www.springsource.com -

-
- - diff --git a/spring-integration-java-dsl/src/dist/license.txt b/spring-integration-java-dsl/src/dist/license.txt deleted file mode 100644 index 261eeb9..0000000 --- a/spring-integration-java-dsl/src/dist/license.txt +++ /dev/null @@ -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. diff --git a/spring-integration-java-dsl/src/dist/notice.txt b/spring-integration-java-dsl/src/dist/notice.txt deleted file mode 100644 index f62045a..0000000 --- a/spring-integration-java-dsl/src/dist/notice.txt +++ /dev/null @@ -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. diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/AbstractRouterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/AbstractRouterSpec.java deleted file mode 100644 index 4530924..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/AbstractRouterSpec.java +++ /dev/null @@ -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, R extends AbstractMessageRouter> - extends MessageHandlerSpec { - - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/Adapters.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/Adapters.java deleted file mode 100644 index c88f9a9..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/Adapters.java +++ /dev/null @@ -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

FileWritingMessageHandlerSpec file(Function, ?> directoryFunction) { - return Files.outboundAdapter(directoryFunction); - } - - public FileWritingMessageHandlerSpec fileGateway(File destinationDirectory) { - return Files.outboundGateway(destinationDirectory); - } - - public FileWritingMessageHandlerSpec fileGateway(String directoryExpression) { - return Files.outboundGateway(directoryExpression); - } - - public

FileWritingMessageHandlerSpec fileGateway(Function, ?> directoryFunction) { - return Files.outboundGateway(directoryFunction); - } - - public FtpMessageHandlerSpec ftp(SessionFactory sessionFactory) { - return Ftp.outboundAdapter(sessionFactory); - } - - public FtpMessageHandlerSpec ftp(SessionFactory sessionFactory, FileExistsMode fileExistsMode) { - return Ftp.outboundAdapter(sessionFactory, fileExistsMode); - } - - public FtpMessageHandlerSpec ftp(RemoteFileTemplate remoteFileTemplate) { - return Ftp.outboundAdapter(remoteFileTemplate); - } - - public FtpMessageHandlerSpec ftp(RemoteFileTemplate remoteFileTemplate, FileExistsMode fileExistsMode) { - return Ftp.outboundAdapter(remoteFileTemplate, fileExistsMode); - } - - public FtpOutboundGatewaySpec ftpGateway(SessionFactory sessionFactory, - AbstractRemoteFileOutboundGateway.Command command, String expression) { - return Ftp.outboundGateway(sessionFactory, command, expression); - } - - public FtpOutboundGatewaySpec ftpGateway(SessionFactory sessionFactory, String command, - String expression) { - return Ftp.outboundGateway(sessionFactory, command, expression); - } - - public SftpMessageHandlerSpec ftps(SessionFactory sessionFactory) { - return Sftp.outboundAdapter(sessionFactory); - } - - public SftpMessageHandlerSpec sftp(SessionFactory sessionFactory, - FileExistsMode fileExistsMode) { - return Sftp.outboundAdapter(sessionFactory, fileExistsMode); - } - - public SftpMessageHandlerSpec sftp(RemoteFileTemplate remoteFileTemplate) { - return Sftp.outboundAdapter(remoteFileTemplate); - } - - public SftpMessageHandlerSpec sftp(RemoteFileTemplate remoteFileTemplate, - FileExistsMode fileExistsMode) { - return Sftp.outboundAdapter(remoteFileTemplate, fileExistsMode); - } - - public SftpOutboundGatewaySpec sftpGateway(SessionFactory sessionFactory, - AbstractRemoteFileOutboundGateway.Command command, String expression) { - return Sftp.outboundGateway(sessionFactory, command, expression); - } - - public SftpOutboundGatewaySpec sftpGateway(SessionFactory sessionFactory, String command, - String expression) { - return Sftp.outboundGateway(sessionFactory, command, expression); - } - - public JmsOutboundChannelAdapterSpec.JmsOutboundChannelSpecTemplateAware jms(ConnectionFactory connectionFactory) { - return Jms.outboundAdapter(connectionFactory); - } - - public 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() { - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/AggregatorSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/AggregatorSpec.java deleted file mode 100644 index d23963d..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/AggregatorSpec.java +++ /dev/null @@ -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 { - - 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); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/Channels.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/Channels.java deleted file mode 100644 index a5c1f25..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/Channels.java +++ /dev/null @@ -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> queue) { - return MessageChannels.queue(queue); - } - - public QueueChannelSpec queue(String id, Queue> 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> publishSubscribe() { - return MessageChannels.publishSubscribe(); - } - - public PublishSubscribeChannelSpec> publishSubscribe(Executor executor) { - return MessageChannels.publishSubscribe(executor); - } - - public PublishSubscribeChannelSpec> publishSubscribe(String id, - Executor executor) { - return MessageChannels.publishSubscribe(id, executor); - } - - public 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> amqpPollable( - ConnectionFactory connectionFactory) { - return Amqp.pollableChannel(connectionFactory); - } - - public AmqpPollableMessageChannelSpec> amqpPollable(String id, - ConnectionFactory connectionFactory) { - return Amqp.pollableChannel(id, connectionFactory); - } - - public AmqpMessageChannelSpec> amqp(ConnectionFactory connectionFactory) { - return Amqp.channel(connectionFactory); - } - - public 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> jmsPollable( - javax.jms.ConnectionFactory connectionFactory) { - return Jms.pollableChannel(connectionFactory); - } - - public JmsPollableMessageChannelSpec> jmsPollable(String id, - javax.jms.ConnectionFactory connectionFactory) { - return Jms.pollableChannel(id, connectionFactory); - } - - public JmsMessageChannelSpec> jms( - javax.jms.ConnectionFactory connectionFactory) { - return Jms.channel(connectionFactory); - } - - public 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() { - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/CorrelationHandlerSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/CorrelationHandlerSpec.java deleted file mode 100644 index 065a0a7..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/CorrelationHandlerSpec.java +++ /dev/null @@ -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, H extends AbstractCorrelatingMessageHandler> - extends MessageHandlerSpec { - - 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(groupTimeout); - return _this(); - } - - public S groupTimeoutExpression(String groupTimeoutExpression) { - this.groupTimeoutExpression = PARSER.parseExpression(groupTimeoutExpression); - return _this(); - } - - public S groupTimeout(Function groupTimeoutFunction) { - this.groupTimeoutExpression = new FunctionExpression(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() { - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/DelayerEndpointSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/DelayerEndpointSpec.java deleted file mode 100644 index 4eef421..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/DelayerEndpointSpec.java +++ /dev/null @@ -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 { - - private final List delayedAdvice = new LinkedList(); - - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/DslRecipientListRouter.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/DslRecipientListRouter.java deleted file mode 100644 index de77e15..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/DslRecipientListRouter.java +++ /dev/null @@ -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 expressionRecipientMap = new HashMap(); - - private final Map selectorRecipientMap = new HashMap(); - - private final Map channelExpressionRecipientMap = new HashMap(); - - private final Map channelSelectorRecipientMap = - new HashMap(); - - 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 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 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 recipients = new ArrayList(this.selectorRecipientMap.size() - + this.channelSelectorRecipientMap.size()); - - for (Map.Entry entry : selectorRecipientMap.entrySet()) { - recipients.add(new DslRecipient(new MessageChannelReference(entry.getKey()), entry.getValue())); - } - - for (Map.Entry 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."); - } - } - - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/EnricherSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/EnricherSpec.java deleted file mode 100644 index ce0a622..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/EnricherSpec.java +++ /dev/null @@ -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 { - - private final ContentEnricher enricher = new ContentEnricher(); - - private final Map propertyExpressions = new HashMap(); - - private final Map> headerExpressions = - new HashMap>(); - - 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

EnricherSpec requestPayload(Function, ?> requestPayloadFunction) { - this.enricher.setRequestPayloadExpression(new FunctionExpression>(requestPayloadFunction)); - return _this(); - } - - public EnricherSpec shouldClonePayload(boolean shouldClonePayload) { - this.enricher.setShouldClonePayload(shouldClonePayload); - return _this(); - } - - public EnricherSpec property(String key, V value) { - this.propertyExpressions.put(key, new ValueExpression(value)); - return _this(); - } - - public EnricherSpec propertyExpression(String key, String expression) { - Assert.notNull(key); - this.propertyExpressions.put(key, PARSER.parseExpression(expression)); - return _this(); - } - - public

EnricherSpec propertyFunction(String key, Function, Object> function) { - Assert.notNull(key); - this.propertyExpressions.put(key, new FunctionExpression>(function)); - return _this(); - } - - public EnricherSpec header(String name, V value) { - return this.header(name, value, null); - } - - public EnricherSpec header(String name, V value, Boolean overwrite) { - AbstractHeaderValueMessageProcessor headerValueMessageProcessor = - new StaticHeaderValueMessageProcessor(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

EnricherSpec headerFunction(String name, Function, Object> function) { - return headerFunction(name, function, null); - } - - public

EnricherSpec headerFunction(String name, Function, Object> function, Boolean overwrite) { - Assert.notNull(function); - return headerExpression(name, new FunctionExpression>(function), overwrite); - } - - private EnricherSpec headerExpression(String name, Expression expression, Boolean overwrite) { - AbstractHeaderValueMessageProcessor headerValueMessageProcessor = - new ExpressionEvaluatingHeaderValueMessageProcessor(expression, null); - headerValueMessageProcessor.setOverwrite(overwrite); - return header(name, headerValueMessageProcessor); - } - - public EnricherSpec header(String name, HeaderValueMessageProcessor 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; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/FilterEndpointSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/FilterEndpointSpec.java deleted file mode 100644 index 7ed1d1f..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/FilterEndpointSpec.java +++ /dev/null @@ -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 - 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 getComponentsToRegister() { - if (this.discardFlow != null) { - return Collections.singletonList(this.discardFlow); - } - return null; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/GatewayEndpointSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/GatewayEndpointSpec.java deleted file mode 100644 index 7c3a149..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/GatewayEndpointSpec.java +++ /dev/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(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; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/GatewayMessageHandler.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/GatewayMessageHandler.java deleted file mode 100644 index 06e5852..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/GatewayMessageHandler.java +++ /dev/null @@ -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); - } - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/GenericEndpointSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/GenericEndpointSpec.java deleted file mode 100644 index ec6b388..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/GenericEndpointSpec.java +++ /dev/null @@ -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 - extends ConsumerEndpointSpec, H> { - - GenericEndpointSpec(H messageHandler) { - super(messageHandler); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/HeaderEnricherSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/HeaderEnricherSpec.java deleted file mode 100644 index 08a0d71..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/HeaderEnricherSpec.java +++ /dev/null @@ -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 { - - private final Map> headerToAdd = new HashMap>(); - - 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(PARSER.parseExpression(expression))); - } - - public HeaderEnricherSpec messageProcessor(String beanName, String methodName) { - return messageProcessor(new BeanNameMessageProcessor(beanName, methodName)); - } - - public HeaderEnricherSpec headers(MapBuilder headers) { - return headers(headers.get()); - } - - public HeaderEnricherSpec headers(Map headers) { - Assert.notNull(headers); - for (Entry entry : headers.entrySet()) { - String name = entry.getKey(); - Object value = entry.getValue(); - if (value instanceof Expression) { - header(name, new ExpressionEvaluatingHeaderValueMessageProcessor((Expression) value, null)); - } - else { - header(name, value); - } - } - return this; - } - - public HeaderEnricherSpec headerExpressions(MapBuilder headers) { - Assert.notNull(headers); - return headerExpressions(headers.get()); - } - - public HeaderEnricherSpec headerExpressions(Consumer configurer) { - Assert.notNull(configurer); - StringStringMapBuilder builder = new StringStringMapBuilder(); - configurer.accept(builder); - return headerExpressions(builder.get()); - } - - public HeaderEnricherSpec headerExpressions(Map headers) { - Assert.notNull(headers); - for (Entry entry : headers.entrySet()) { - header(entry.getKey(), new ExpressionEvaluatingHeaderValueMessageProcessor(entry.getValue(), null)); - } - return this; - } - - public HeaderEnricherSpec header(String name, V value) { - return header(name, value, null); - } - - public HeaderEnricherSpec header(String name, V value, Boolean overwrite) { - AbstractHeaderValueMessageProcessor headerValueMessageProcessor = - new StaticHeaderValueMessageProcessor(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

HeaderEnricherSpec headerFunction(String name, Function, Object> function) { - return headerFunction(name, function, null); - } - - public

HeaderEnricherSpec headerFunction(String name, Function, Object> function, - Boolean overwrite) { - Assert.notNull(function); - return headerExpression(name, new FunctionExpression>(function), overwrite); - } - - private HeaderEnricherSpec headerExpression(String name, Expression expression, Boolean overwrite) { - AbstractHeaderValueMessageProcessor headerValueMessageProcessor = - new ExpressionEvaluatingHeaderValueMessageProcessor(expression, null); - headerValueMessageProcessor.setOverwrite(overwrite); - return header(name, headerValueMessageProcessor); - } - - public HeaderEnricherSpec header(String name, HeaderValueMessageProcessor headerValueMessageProcessor) { - Assert.hasText(name); - this.headerToAdd.put(name, headerValueMessageProcessor); - return _this(); - } - - public 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; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/IntegrationFlow.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/IntegrationFlow.java deleted file mode 100644 index 81d6bcd..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/IntegrationFlow.java +++ /dev/null @@ -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> { -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/IntegrationFlowBuilder.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/IntegrationFlowBuilder.java deleted file mode 100644 index 1383336..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/IntegrationFlowBuilder.java +++ /dev/null @@ -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 { - - @Override - public StandardIntegrationFlow get() { - return super.get(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java deleted file mode 100644 index f1bfeb5..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java +++ /dev/null @@ -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> { - - private final static SpelExpressionParser PARSER = new SpelExpressionParser(); - - protected final Set integrationComponents = new LinkedHashSet(); - - protected MessageChannel currentMessageChannel; - - protected Object currentComponent; - - IntegrationFlowDefinition() { - } - - B addComponent(Object component) { - this.integrationComponents.add(component); - return _this(); - } - - B addComponents(Collection 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) { - 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(new BridgeHandler()), null); - } - this.currentMessageChannel = messageChannel; - return registerOutputChannelIfCan(this.currentMessageChannel); - } - - public B publishSubscribeChannel(Consumer publishSubscribeChannelConfigurer) { - return publishSubscribeChannel(null, publishSubscribeChannelConfigurer); - } - - public B publishSubscribeChannel(Executor executor, - Consumer 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> 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 B transform(GenericTransformer genericTransformer) { - return this.transform(null, genericTransformer); - } - - public B transform(Class

payloadType, GenericTransformer genericTransformer) { - return this.transform(payloadType, genericTransformer, null); - } - - public B transform(GenericTransformer genericTransformer, - Consumer> endpointConfigurer) { - return this.transform(null, genericTransformer, endpointConfigurer); - } - - public B transform(Class

payloadType, GenericTransformer genericTransformer, - Consumer> 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 B filter(GenericSelector genericSelector) { - return this.filter(null, genericSelector); - } - - public

B filter(Class

payloadType, GenericSelector

genericSelector) { - return this.filter(payloadType, genericSelector, null); - } - - public

B filter(GenericSelector

genericSelector, Consumer endpointConfigurer) { - return filter(null, genericSelector, endpointConfigurer); - } - - public

B filter(Class

payloadType, GenericSelector

genericSelector, - Consumer 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 B handleWithAdapter(Function> adapters) { - return handleWithAdapter(adapters, null); - } - - public B handleWithAdapter(Function> adapters, - Consumer> endpointConfigurer) { - return handle(adapters.apply(new Adapters()), endpointConfigurer); - } - - public B handle(MessageHandlerSpec 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> endpointConfigurer) { - return this.handle(new ServiceActivatingHandler(new BeanNameMessageProcessor(beanName, methodName)), - endpointConfigurer); - } - - public

B handle(GenericHandler

handler) { - return handle(null, handler); - } - - public

B handle(GenericHandler

handler, - Consumer> endpointConfigurer) { - return this.handle(null, handler, endpointConfigurer); - } - - public

B handle(Class

payloadType, GenericHandler

handler) { - return this.handle(payloadType, handler, null); - } - - public

B handle(Class

payloadType, GenericHandler

handler, - Consumer> 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 B handle(MessageHandlerSpec messageHandlerSpec, - Consumer> endpointConfigurer) { - Assert.notNull(messageHandlerSpec); - if (messageHandlerSpec instanceof ComponentsRegistration) { - addComponents(((ComponentsRegistration) messageHandlerSpec).getComponentsToRegister()); - } - return handle(messageHandlerSpec.get(), endpointConfigurer); - } - - public B handle(H messageHandler, Consumer> endpointConfigurer) { - Assert.notNull(messageHandler); - return this.register(new GenericEndpointSpec(messageHandler), endpointConfigurer); - } - - public B bridge(Consumer> endpointConfigurer) { - return this.register(new GenericEndpointSpec(new BridgeHandler()), endpointConfigurer); - } - - public B delay(String groupId) { - return this.delay(groupId, (String) null); - } - - public B delay(String groupId, Consumer endpointConfigurer) { - return this.delay(groupId, (String) null, endpointConfigurer); - } - - public B delay(String groupId, String expression) { - return this.delay(groupId, expression, null); - } - - public

B delay(String groupId, Function, Object> function) { - return this.delay(groupId, function, null); - } - - public

B delay(String groupId, Function, Object> function, - Consumer endpointConfigurer) { - Assert.notNull(function); - return this.delay(groupId, new FunctionExpression>(function), endpointConfigurer); - } - - public B delay(String groupId, String expression, Consumer endpointConfigurer) { - return delay(groupId, - StringUtils.hasText(expression) ? PARSER.parseExpression(expression) : null, - endpointConfigurer); - } - - private B delay(String groupId, Expression expression, Consumer endpointConfigurer) { - DelayHandler delayHandler = new DelayHandler(groupId); - if (expression != null) { - delayHandler.setDelayExpression(expression); - } - return this.register(new DelayerEndpointSpec(delayHandler), endpointConfigurer); - } - - public B enrich(Consumer enricherConfigurer) { - return this.enrich(enricherConfigurer, null); - } - - public B enrich(Consumer enricherConfigurer, - Consumer> endpointConfigurer) { - Assert.notNull(enricherConfigurer); - EnricherSpec enricherSpec = new EnricherSpec(); - enricherConfigurer.accept(enricherSpec); - return this.handle(enricherSpec.get(), endpointConfigurer); - } - - public B enrichHeaders(MapBuilder headers) { - return enrichHeaders(headers, null); - } - - public B enrichHeaders(MapBuilder headers, - Consumer> 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 headers) { - return enrichHeaders(headers, null); - } - - public B enrichHeaders(final Map headers, - Consumer> endpointConfigurer) { - return enrichHeaders(new Consumer() { - - @Override - public void accept(HeaderEnricherSpec spec) { - spec.headers(headers); - } - - }, endpointConfigurer); - } - - public B enrichHeaders(Consumer headerEnricherConfigurer) { - return this.enrichHeaders(headerEnricherConfigurer, null); - } - - public B enrichHeaders(Consumer headerEnricherConfigurer, - Consumer> endpointConfigurer) { - Assert.notNull(headerEnricherConfigurer); - HeaderEnricherSpec headerEnricherSpec = new HeaderEnricherSpec(); - headerEnricherConfigurer.accept(headerEnricherSpec); - return transform(headerEnricherSpec.get(), endpointConfigurer); - } - - public B split() { - return this.split((Consumer>) null); - } - - public B split(Consumer> endpointConfigurer) { - return this.split(new DefaultMessageSplitter(), endpointConfigurer); - } - - public B split(String expression, - Consumer> 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> endpointConfigurer) { - return this.split(new MethodInvokingSplitter(new BeanNameMessageProcessor(beanName, methodName)), - endpointConfigurer); - } - - public

B split(Class

payloadType, Function splitter) { - return split(payloadType, splitter, null); - } - - public

B split(Function splitter, - Consumer> endpointConfigurer) { - return split(null, splitter, endpointConfigurer); - } - - public

B split(Class

payloadType, Function splitter, - Consumer> endpointConfigurer) { - MethodInvokingSplitter split = isLambda(splitter) - ? new MethodInvokingSplitter(new LambdaMessageProcessor(splitter, payloadType)) - : new MethodInvokingSplitter(splitter); - return this.split(split, endpointConfigurer); - } - - public B split(S splitter, - Consumer> endpointConfigurer) { - Assert.notNull(splitter); - return this.register(new SplitterEndpointSpec(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> endpointConfigurer) { - return this.transform(headerFilter, endpointConfigurer); - } - - public B claimCheckIn(MessageStore messageStore) { - return this.claimCheckIn(messageStore, null); - } - - public B claimCheckIn(MessageStore messageStore, - Consumer> 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> endpointConfigurer) { - ClaimCheckOutTransformer claimCheckOutTransformer = new ClaimCheckOutTransformer(messageStore); - claimCheckOutTransformer.setRemoveMessage(removeMessage); - return this.transform(claimCheckOutTransformer, endpointConfigurer); - } - - public B resequence() { - return this.resequence((Consumer>) null); - } - - public B resequence(Consumer> endpointConfigurer) { - return this.handle(new ResequencerSpec().get(), endpointConfigurer); - } - - public B resequence(Consumer resequencerConfigurer, - Consumer> endpointConfigurer) { - Assert.notNull(resequencerConfigurer); - ResequencerSpec spec = new ResequencerSpec(); - resequencerConfigurer.accept(spec); - return this.handle(spec.get(), endpointConfigurer); - } - - public B aggregate() { - return aggregate((Consumer>) null); - } - - public B - aggregate(Consumer> endpointConfigurer) { - return handle(new AggregatorSpec().get(), endpointConfigurer); - } - - public B aggregate(Consumer aggregatorConfigurer, - Consumer> 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> routerConfigurer) { - return this.route(beanName, method, routerConfigurer, null); - } - - public B route(String beanName, String method, Consumer> routerConfigurer, - Consumer> endpointConfigurer) { - return this.route(new MethodInvokingRouter(new BeanNameMessageProcessor(beanName, method)), - routerConfigurer, endpointConfigurer); - } - - public B route(String expression) { - return this.route(expression, (Consumer>) null); - } - - public B route(String expression, Consumer> routerConfigurer) { - return this.route(expression, routerConfigurer, null); - } - - public B route(String expression, Consumer> routerConfigurer, - Consumer> endpointConfigurer) { - return this.route(new ExpressionEvaluatingRouter(PARSER.parseExpression(expression)), routerConfigurer, - endpointConfigurer); - } - - public B route(Function router) { - return this.route(null, router); - } - - public B route(Function router, Consumer> routerConfigurer) { - return this.route(null, router, routerConfigurer); - } - - public B route(Class

payloadType, Function router) { - return this.route(payloadType, router, null, null); - } - - public B route(Class

payloadType, Function router, - Consumer> routerConfigurer) { - return this.route(payloadType, router, routerConfigurer, null); - } - - public B route(Function router, Consumer> routerConfigurer, - Consumer> endpointConfigurer) { - return route(null, router, routerConfigurer, endpointConfigurer); - } - - public B route(Class

payloadType, Function router, - Consumer> routerConfigurer, - Consumer> endpointConfigurer) { - MethodInvokingRouter methodInvokingRouter = isLambda(router) - ? new MethodInvokingRouter(new LambdaMessageProcessor(router, payloadType)) - : new MethodInvokingRouter(router); - return route(methodInvokingRouter, routerConfigurer, endpointConfigurer); - } - - public B route(R router, Consumer> routerConfigurer, - Consumer> endpointConfigurer) { - Collection componentsToRegister = null; - if (routerConfigurer != null) { - RouterSpec routerSpec = new RouterSpec(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>() { - - @Override - public void accept(GenericEndpointSpec bridge) { - bridge.get().getT2().setOutputChannel(afterRouterChannel); - } - - }) - .get()); - } - else { - addComponent(component); - } - } - } - if (hasSubFlows) { - channel(afterRouterChannel); - } - return _this(); - } - - public B routeToRecipients(Consumer routerConfigurer) { - return routeToRecipients(routerConfigurer, null); - } - - public B routeToRecipients(Consumer routerConfigurer, - Consumer> 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 B route(R router, Consumer> endpointConfigurer) { - return handle(router, endpointConfigurer); - } - - public B gateway(String requestChannel) { - return gateway(requestChannel, null); - } - - public B gateway(String requestChannel, Consumer endpointConfigurer) { - return register(new GatewayEndpointSpec(requestChannel), endpointConfigurer); - } - - public B gateway(MessageChannel requestChannel) { - return gateway(requestChannel, null); - } - - public B gateway(MessageChannel requestChannel, Consumer endpointConfigurer) { - return register(new GatewayEndpointSpec(requestChannel), endpointConfigurer); - } - - public B gateway(IntegrationFlow flow) { - return gateway(flow, null); - } - - public B gateway(IntegrationFlow flow, Consumer 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 > B register(S endpointSpec, Consumer 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); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/IntegrationFlows.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/IntegrationFlows.java deleted file mode 100644 index 11eec72..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/IntegrationFlows.java +++ /dev/null @@ -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 endpointConfigurer) { - Assert.notNull(sources); - return from(sources.apply(new MessageSources()), endpointConfigurer); - } - - public static IntegrationFlowBuilder from(MessageSourceSpec> messageSourceSpec) { - return from(messageSourceSpec, null); - } - - public static IntegrationFlowBuilder from(MessageSourceSpec> messageSourceSpec, - Consumer 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 endpointConfigurer) { - return from(messageSource, endpointConfigurer, null); - } - - private static IntegrationFlowBuilder from(MessageSource messageSource, - Consumer 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> {} - - public interface MessageSourcesFunction extends Function> {} - - public interface MessageProducersFunction extends Function> {} - - public interface MessagingGatewaysFunction extends Function> {} - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/LambdaMessageProcessor.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/LambdaMessageProcessor.java deleted file mode 100644 index b8e9a97..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/LambdaMessageProcessor.java +++ /dev/null @@ -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, 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 methodValue = new AtomicReference(); - 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); - } - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/MessageProducers.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/MessageProducers.java deleted file mode 100644 index 3d8d2e6..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/MessageProducers.java +++ /dev/null @@ -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> jms( - AbstractMessageListenerContainer listenerContainer) { - return Jms.messageDriverChannelAdapter(listenerContainer); - } - - public JmsMessageDrivenChannelAdapterSpec> jms( - javax.jms.ConnectionFactory connectionFactory) { - return Jms.messageDriverChannelAdapter(connectionFactory); - } - - public - JmsMessageDrivenChannelAdapterSpec> jms( - javax.jms.ConnectionFactory connectionFactory, - Class containerClass) { - return Jms.messageDriverChannelAdapter(connectionFactory, containerClass); - } - - MessageProducers() { - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/MessageSources.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/MessageSources.java deleted file mode 100644 index f625e6c..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/MessageSources.java +++ /dev/null @@ -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 receptionOrderComparator) { - return Files.inboundAdapter(directory, receptionOrderComparator); - } - - public FtpInboundChannelAdapterSpec ftp(SessionFactory sessionFactory) { - return ftp(sessionFactory, null); - } - - public FtpInboundChannelAdapterSpec ftp(SessionFactory sessionFactory, - Comparator receptionOrderComparator) { - return Ftp.inboundAdapter(sessionFactory, receptionOrderComparator); - } - - public SftpInboundChannelAdapterSpec sftp(SessionFactory sessionFactory) { - return sftp(sessionFactory, null); - } - - public SftpInboundChannelAdapterSpec sftp(SessionFactory sessionFactory, - Comparator receptionOrderComparator) { - return Sftp.inboundAdapter(sessionFactory, receptionOrderComparator); - } - - public 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() { - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/MessagingGateways.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/MessagingGateways.java deleted file mode 100644 index 4827a70..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/MessagingGateways.java +++ /dev/null @@ -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 jms( - javax.jms.ConnectionFactory connectionFactory) { - return Jms.inboundGateway(connectionFactory); - } - - public - JmsInboundGatewaySpec.JmsInboundGatewayListenerContainerSpec jms(ConnectionFactory connectionFactory, - Class containerClass) { - return Jms.inboundGateway(connectionFactory, containerClass); - } - - public JmsInboundGatewaySpec> jms( - AbstractMessageListenerContainer listenerContainer) { - return Jms.inboundGateway(listenerContainer); - } - - MessagingGateways() { - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/PublishSubscribeSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/PublishSubscribeSpec.java deleted file mode 100644 index 1647ca1..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/PublishSubscribeSpec.java +++ /dev/null @@ -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 - implements ComponentsRegistration { - - private final List subscriberFlows = new ArrayList(); - - 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 getComponentsToRegister() { - return this.subscriberFlows; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/RecipientListRouterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/RecipientListRouterSpec.java deleted file mode 100644 index a437e8d..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/RecipientListRouterSpec.java +++ /dev/null @@ -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 - implements ComponentsRegistration { - - private final List subFlows = new ArrayList(); - - 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 getComponentsToRegister() { - return subFlows; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ResequencerSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ResequencerSpec.java deleted file mode 100644 index 2863095..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ResequencerSpec.java +++ /dev/null @@ -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 { - - 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); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/RouterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/RouterSpec.java deleted file mode 100644 index b642934..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/RouterSpec.java +++ /dev/null @@ -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 extends AbstractRouterSpec, R> - implements ComponentsRegistration { - - private final List subFlows = new ArrayList(); - - private String prefix; - - private String suffix; - - private RouterSubFlowMappingProvider mappingProvider; - - RouterSpec(R router) { - super(router); - } - - public RouterSpec resolutionRequired(boolean resolutionRequired) { - this.target.setResolutionRequired(resolutionRequired); - return _this(); - } - - public RouterSpec 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 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 channelMapping(String key, String channelName) { - Assert.hasText(key); - Assert.hasText(channelName); - this.target.setChannelMapping(key, channelName); - return _this(); - } - - public RouterSpec 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 getComponentsToRegister() { - if (this.mappingProvider != null) { - this.subFlows.add(this.mappingProvider); - } - return this.subFlows; - } - - private static class RouterSubFlowMappingProvider { - - private final MappingMessageRouterManagement router; - - private final Map mapping = new HashMap(); - - 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 entry : this.mapping.entrySet()) { - this.router.setChannelMapping(entry.getKey(), entry.getValue().getComponentName()); - - } - } - - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/SourcePollingChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/SourcePollingChannelAdapterSpec.java deleted file mode 100644 index 530ff45..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/SourcePollingChannelAdapterSpec.java +++ /dev/null @@ -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(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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/SplitterEndpointSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/SplitterEndpointSpec.java deleted file mode 100644 index 76e9550..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/SplitterEndpointSpec.java +++ /dev/null @@ -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 - extends ConsumerEndpointSpec, S> { - - SplitterEndpointSpec(S splitter) { - super(splitter); - } - - public SplitterEndpointSpec applySequence(boolean applySequence) { - this.target.getT2().setApplySequence(applySequence); - return _this(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/StandardIntegrationFlow.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/StandardIntegrationFlow.java deleted file mode 100644 index 3ff1dce..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/StandardIntegrationFlow.java +++ /dev/null @@ -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 integrationComponents; - - StandardIntegrationFlow(Set integrationComponents) { - this.integrationComponents = integrationComponents; - } - - public Set getIntegrationComponents() { - return integrationComponents; - } - - @Override - public void accept(IntegrationFlowDefinition flow) { - throw new UnsupportedOperationException(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/Amqp.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/Amqp.java deleted file mode 100644 index 0bbd4d4..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/Amqp.java +++ /dev/null @@ -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 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 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 > AmqpPollableMessageChannelSpec - pollableChannel(ConnectionFactory connectionFactory) { - return pollableChannel(null, connectionFactory); - } - - public static > AmqpPollableMessageChannelSpec pollableChannel( - String id, ConnectionFactory connectionFactory) { - return new AmqpPollableMessageChannelSpec(connectionFactory).id(id); - } - - public static > AmqpMessageChannelSpec channel( - ConnectionFactory connectionFactory) { - return channel(null, connectionFactory); - } - - public static > AmqpMessageChannelSpec channel(String id, - ConnectionFactory connectionFactory) { - return new AmqpMessageChannelSpec(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); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpInboundChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpInboundChannelAdapterSpec.java deleted file mode 100644 index 56bdeb7..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpInboundChannelAdapterSpec.java +++ /dev/null @@ -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 { - - 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; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpInboundGatewaySpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpInboundGatewaySpec.java deleted file mode 100644 index 37faa02..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpInboundGatewaySpec.java +++ /dev/null @@ -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 { - - 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; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpMessageChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpMessageChannelSpec.java deleted file mode 100644 index ca09599..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpMessageChannelSpec.java +++ /dev/null @@ -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> extends AmqpPollableMessageChannelSpec { - - private final List adviceChain = new LinkedList(); - - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpOutboundEndpointSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpOutboundEndpointSpec.java deleted file mode 100644 index ffd2872..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpOutboundEndpointSpec.java +++ /dev/null @@ -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 { - - 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; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpPollableMessageChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpPollableMessageChannelSpec.java deleted file mode 100644 index 791fb05..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpPollableMessageChannelSpec.java +++ /dev/null @@ -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> - extends MessageChannelSpec { - - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpPublishSubscribeMessageChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpPublishSubscribeMessageChannelSpec.java deleted file mode 100644 index b1e4d4b..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/AmqpPublishSubscribeMessageChannelSpec.java +++ /dev/null @@ -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(ConnectionFactory connectionFactory) { - super(connectionFactory); - this.amqpChannelFactoryBean.setPubSub(true); - } - - public AmqpPublishSubscribeMessageChannelSpec exchange(FanoutExchange exchange) { - this.amqpChannelFactoryBean.setExchange(exchange); - return _this(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/package-info.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/package-info.java deleted file mode 100644 index ed0d7b6..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/amqp/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides AMQP Components support for Spring Integration Java DSL. - */ -package org.springframework.integration.dsl.amqp; diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/DirectChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/DirectChannelSpec.java deleted file mode 100644 index 15dc281..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/DirectChannelSpec.java +++ /dev/null @@ -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 { - - @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() { - } -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/ExecutorChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/ExecutorChannelSpec.java deleted file mode 100644 index d217bbf..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/ExecutorChannelSpec.java +++ /dev/null @@ -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 { - - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/LoadBalancingChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/LoadBalancingChannelSpec.java deleted file mode 100644 index 2c35fc2..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/LoadBalancingChannelSpec.java +++ /dev/null @@ -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, C extends AbstractMessageChannel> - extends MessageChannelSpec { - - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/MessageChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/MessageChannelSpec.java deleted file mode 100644 index e29e6c0..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/MessageChannelSpec.java +++ /dev/null @@ -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, C extends AbstractMessageChannel> - extends IntegrationComponentSpec { - - protected C channel; - - private final List> datatypes = new ArrayList>(); - - private final List interceptors = new LinkedList(); - - 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; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/MessageChannels.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/MessageChannels.java deleted file mode 100644 index aa9679a..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/MessageChannels.java +++ /dev/null @@ -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> queue) { - return new QueueChannelSpec(queue); - } - - public static QueueChannelSpec queue(String id, Queue> 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 > PublishSubscribeChannelSpec publishSubscribe() { - return new PublishSubscribeChannelSpec(); - } - - public static > PublishSubscribeChannelSpec publishSubscribe( - String id) { - return MessageChannels.publishSubscribe().id(id); - } - - public static > PublishSubscribeChannelSpec publishSubscribe( - Executor executor) { - return new PublishSubscribeChannelSpec(executor); - } - - public static > PublishSubscribeChannelSpec publishSubscribe(String id, - Executor executor) { - return MessageChannels.publishSubscribe(executor).id(id); - } - - private MessageChannels() { - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/PriorityChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/PriorityChannelSpec.java deleted file mode 100644 index 4ea9c17..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/PriorityChannelSpec.java +++ /dev/null @@ -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 { - - private int capacity; - - Comparator> comparator; - - public PriorityChannelSpec setCapacity(int capacity) { - this.capacity = capacity; - return this; - } - - public PriorityChannelSpec setComparator(Comparator> comparator) { - this.comparator = comparator; - return this; - } - - @Override - protected PriorityChannel doGet() { - this.channel = new PriorityChannel(this.capacity, this.comparator); - return super.doGet(); - } - - - PriorityChannelSpec() { - } -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/PublishSubscribeChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/PublishSubscribeChannelSpec.java deleted file mode 100644 index 2cdbae9..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/PublishSubscribeChannelSpec.java +++ /dev/null @@ -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> - extends MessageChannelSpec { - - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/QueueChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/QueueChannelSpec.java deleted file mode 100644 index 6c58d09..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/QueueChannelSpec.java +++ /dev/null @@ -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 { - - protected Queue> queue; - - protected Integer capacity; - - QueueChannelSpec() { - } - - QueueChannelSpec(Queue> 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>) 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(); - } - - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/RendezvousChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/RendezvousChannelSpec.java deleted file mode 100644 index d922a86..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/RendezvousChannelSpec.java +++ /dev/null @@ -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() { - this.channel = new RendezvousChannel(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/package-info.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/package-info.java deleted file mode 100644 index 4ed59bd..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/channel/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Contains MessageChannel Builders DSL. - */ -package org.springframework.integration.dsl.channel; diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/config/DslIntegrationConfigurationInitializer.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/config/DslIntegrationConfigurationInitializer.java deleted file mode 100644 index 96caf6f..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/config/DslIntegrationConfigurationInitializer.java +++ /dev/null @@ -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 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."); - } - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/config/IntegrationFlowBeanPostProcessor.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/config/IntegrationFlowBeanPostProcessor.java deleted file mode 100644 index 28ee19b..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/config/IntegrationFlowBeanPostProcessor.java +++ /dev/null @@ -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; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/config/package-info.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/config/package-info.java deleted file mode 100644 index 6a30f88..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/config/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides config classes of the Spring Integration Java DSL. - */ -package org.springframework.integration.dsl.config; diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/ComponentsRegistration.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/ComponentsRegistration.java deleted file mode 100644 index 7db8656..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/ComponentsRegistration.java +++ /dev/null @@ -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 getComponentsToRegister(); - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/ConsumerEndpointSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/ConsumerEndpointSpec.java deleted file mode 100644 index e35a1d4..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/ConsumerEndpointSpec.java +++ /dev/null @@ -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, H extends MessageHandler> - extends EndpointSpec { - - private final List adviceChain = new LinkedList(); - - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/EndpointSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/EndpointSpec.java deleted file mode 100644 index e1b0f06..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/EndpointSpec.java +++ /dev/null @@ -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, F extends BeanNameAware, H> - extends IntegrationComponentSpec> { - - @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 pollers) { - return poller(pollers.apply(new PollerFactory())); - } - - public S poller(PollerSpec pollerMetadataSpec) { - return this.poller(pollerMetadataSpec.get()); - } - - @Override - protected final Tuple2 doGet() { - throw new UnsupportedOperationException(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/IntegrationComponentSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/IntegrationComponentSpec.java deleted file mode 100644 index ce2769a..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/IntegrationComponentSpec.java +++ /dev/null @@ -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, 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; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/MessageHandlerSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/MessageHandlerSpec.java deleted file mode 100644 index 59a0c99..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/MessageHandlerSpec.java +++ /dev/null @@ -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, H extends MessageHandler> - extends IntegrationComponentSpec { -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/MessageProducerSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/MessageProducerSpec.java deleted file mode 100644 index f1db9cb..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/MessageProducerSpec.java +++ /dev/null @@ -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, P extends MessageProducerSupport> - extends IntegrationComponentSpec { - - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/MessageSourceSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/MessageSourceSpec.java deleted file mode 100644 index f8d7841..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/MessageSourceSpec.java +++ /dev/null @@ -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, H extends MessageSource> - extends IntegrationComponentSpec { -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/MessagingGatewaySpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/MessagingGatewaySpec.java deleted file mode 100644 index 762ae96..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/MessagingGatewaySpec.java +++ /dev/null @@ -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, G extends MessagingGatewaySupport> - extends IntegrationComponentSpec { - - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/PollerFactory.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/PollerFactory.java deleted file mode 100644 index 204812f..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/PollerFactory.java +++ /dev/null @@ -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() { - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/PollerSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/PollerSpec.java deleted file mode 100644 index ea7a346..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/PollerSpec.java +++ /dev/null @@ -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 { - - private final PollerMetadata pollerMetadata = new PollerMetadata(); - - private final List adviceChain = new LinkedList(); - - 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; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/Pollers.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/Pollers.java deleted file mode 100644 index 8a2e14a..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/Pollers.java +++ /dev/null @@ -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() { - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/package-info.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/package-info.java deleted file mode 100644 index 4fd70bd..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides core classes of the Spring Integration Java DSL. - */ -package org.springframework.integration.dsl.core; diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/FileInboundChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/FileInboundChannelAdapterSpec.java deleted file mode 100644 index 51b4718..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/FileInboundChannelAdapterSpec.java +++ /dev/null @@ -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 { - - private FileListFilter filter; - - private FileLocker locker; - - FileInboundChannelAdapterSpec() { - this.target = new FileReadingMessageSource(); - } - - FileInboundChannelAdapterSpec(Comparator 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 filter) { - return filter(filter, false); - } - - public FileInboundChannelAdapterSpec filter(FileListFilter filter, boolean preventDuplicates) { - Assert.isNull(this.filter, - "The 'filter' (" + this.filter + ") is already configured for the FileReadingMessageSource"); - FileListFilter 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(), false); - } - else { - return filter(new AcceptAllFileListFilter(), 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 createCompositeWithAcceptOnceFilter(FileListFilter otherFilter) { - CompositeFileListFilter compositeFilter = new CompositeFileListFilter(); - compositeFilter.addFilter(new AcceptOnceFileListFilter()); - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/FileTransferringMessageHandlerSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/FileTransferringMessageHandlerSpec.java deleted file mode 100644 index 90984f5..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/FileTransferringMessageHandlerSpec.java +++ /dev/null @@ -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> - extends MessageHandlerSpec> - implements ComponentsRegistration { - - private FileNameGenerator fileNameGenerator; - - private DefaultFileNameGenerator defaultFileNameGenerator; - - protected FileTransferringMessageHandlerSpec(SessionFactory sessionFactory) { - this.target = new FileTransferringMessageHandler(sessionFactory); - } - - protected FileTransferringMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate) { - this.target = new FileTransferringMessageHandler(remoteFileTemplate); - } - - @SuppressWarnings("unchecked") - protected FileTransferringMessageHandlerSpec(RemoteFileTemplate 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(remoteFileTemplate); - } - else { - try { - this.target = - (FileTransferringMessageHandler) 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

S remoteDirectory(Function, String> remoteDirectoryFunction) { - this.target.setRemoteDirectoryExpression(new FunctionExpression>(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

S temporaryRemoteDirectory(Function, String> temporaryRemoteDirectoryFunction) { - this.target.setTemporaryRemoteDirectoryExpression( - new FunctionExpression>(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 getComponentsToRegister() { - if (this.defaultFileNameGenerator != null) { - return Collections.singletonList(this.defaultFileNameGenerator); - } - return null; - } - - @Override - protected FileTransferringMessageHandler doGet() { - throw new UnsupportedOperationException(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/FileWritingMessageHandlerSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/FileWritingMessageHandlerSpec.java deleted file mode 100644 index 5213f70..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/FileWritingMessageHandlerSpec.java +++ /dev/null @@ -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 - 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)); - } - -

FileWritingMessageHandlerSpec(Function, ?> directoryFunction) { - this.target = new FileWritingMessageHandler(new FunctionExpression>(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 getComponentsToRegister() { - if (this.defaultFileNameGenerator != null) { - return Collections.singletonList(this.defaultFileNameGenerator); - } - return null; - } - - @Override - protected FileWritingMessageHandler doGet() { - throw new UnsupportedOperationException(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/Files.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/Files.java deleted file mode 100644 index 6dfac9a..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/Files.java +++ /dev/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.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 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

FileWritingMessageHandlerSpec outboundAdapter(Function, ?> 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

FileWritingMessageHandlerSpec outboundGateway(Function, ?> directoryFunction) { - return new FileWritingMessageHandlerSpec(directoryFunction).expectReply(true); - } - - public static TailAdapterSpec tailAdapter(File file) { - return new TailAdapterSpec().file(file); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/RemoteFileInboundChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/RemoteFileInboundChannelAdapterSpec.java deleted file mode 100644 index 1324c63..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/RemoteFileInboundChannelAdapterSpec.java +++ /dev/null @@ -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, - MS extends AbstractInboundFileSynchronizingMessageSource> - extends MessageSourceSpec implements ComponentsRegistration { - - protected final AbstractInboundFileSynchronizer synchronizer; - - private FileListFilter filter; - - protected RemoteFileInboundChannelAdapterSpec(AbstractInboundFileSynchronizer 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 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 localFilenameFunction) { - this.synchronizer.setLocalFilenameGeneratorExpression(new FunctionExpression(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 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 getComponentsToRegister() { - return Collections.singletonList(this.synchronizer); - } - - @Override - protected MS doGet() { - throw new UnsupportedOperationException(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/RemoteFileOutboundGatewaySpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/RemoteFileOutboundGatewaySpec.java deleted file mode 100644 index 0d05859..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/RemoteFileOutboundGatewaySpec.java +++ /dev/null @@ -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> - extends MessageHandlerSpec> { - - private FileListFilter filter; - - private FileListFilter mputFilter; - - protected RemoteFileOutboundGatewaySpec(AbstractRemoteFileOutboundGateway 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

S localDirectory(Function, String> localDirectoryFunction) { - this.target.setLocalDirectoryExpression(new FunctionExpression>(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 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 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

S localFilename(Function, String> localFilenameFunction) { - this.target.setLocalFilenameGeneratorExpression(new FunctionExpression>(localFilenameFunction)); - return _this(); - } - - @Override - protected AbstractRemoteFileOutboundGateway doGet() { - throw new UnsupportedOperationException(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/TailAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/TailAdapterSpec.java deleted file mode 100644 index c83b900..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/TailAdapterSpec.java +++ /dev/null @@ -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 { - - 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; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/package-info.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/package-info.java deleted file mode 100644 index 0294723..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/file/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides File Components support for Spring Integration Java DSL. - */ -package org.springframework.integration.dsl.file; diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/Ftp.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/Ftp.java deleted file mode 100644 index 1c278df..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/Ftp.java +++ /dev/null @@ -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 sessionFactory) { - return inboundAdapter(sessionFactory, null); - } - - public static FtpInboundChannelAdapterSpec inboundAdapter(SessionFactory sessionFactory, - Comparator receptionOrderComparator) { - return new FtpInboundChannelAdapterSpec(sessionFactory, receptionOrderComparator); - } - - public static FtpMessageHandlerSpec outboundAdapter(SessionFactory sessionFactory) { - return new FtpMessageHandlerSpec(sessionFactory); - } - - public static FtpMessageHandlerSpec outboundAdapter(SessionFactory sessionFactory, - FileExistsMode fileExistsMode) { - return outboundAdapter(new RemoteFileTemplate(sessionFactory), fileExistsMode); - } - - public static FtpMessageHandlerSpec outboundAdapter(RemoteFileTemplate remoteFileTemplate) { - return new FtpMessageHandlerSpec(remoteFileTemplate); - } - - public static FtpMessageHandlerSpec outboundAdapter(RemoteFileTemplate remoteFileTemplate, - FileExistsMode fileExistsMode) { - return new FtpMessageHandlerSpec(remoteFileTemplate, fileExistsMode); - } - - public static FtpOutboundGatewaySpec outboundGateway(SessionFactory sessionFactory, - AbstractRemoteFileOutboundGateway.Command command, String expression) { - return outboundGateway(sessionFactory, command.getCommand(), expression); - } - - public static FtpOutboundGatewaySpec outboundGateway(SessionFactory sessionFactory, - String command, String expression) { - return new FtpOutboundGatewaySpec(new FtpOutboundGateway(sessionFactory, command, expression)); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/FtpInboundChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/FtpInboundChannelAdapterSpec.java deleted file mode 100644 index b4c10dd..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/FtpInboundChannelAdapterSpec.java +++ /dev/null @@ -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 { - - FtpInboundChannelAdapterSpec(SessionFactory sessionFactory, Comparator 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)); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/FtpMessageHandlerSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/FtpMessageHandlerSpec.java deleted file mode 100644 index 7e301f1..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/FtpMessageHandlerSpec.java +++ /dev/null @@ -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 { - - FtpMessageHandlerSpec(SessionFactory sessionFactory) { - super(sessionFactory); - } - - FtpMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate) { - super(remoteFileTemplate); - } - - FtpMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate, FileExistsMode fileExistsMode) { - super(remoteFileTemplate, fileExistsMode); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/FtpOutboundGatewaySpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/FtpOutboundGatewaySpec.java deleted file mode 100644 index 578dca8..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/FtpOutboundGatewaySpec.java +++ /dev/null @@ -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 { - - FtpOutboundGatewaySpec(AbstractRemoteFileOutboundGateway 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)); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/package-info.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/package-info.java deleted file mode 100644 index 8eba86f..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/ftp/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides FTP Components support for Spring Integration Java DSL. - */ -package org.springframework.integration.dsl.ftp; diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/Jms.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/Jms.java deleted file mode 100644 index 3841e74..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/Jms.java +++ /dev/null @@ -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 > JmsPollableMessageChannelSpec - pollableChannel(ConnectionFactory connectionFactory) { - return pollableChannel(null, connectionFactory); - } - - public static - > JmsPollableMessageChannelSpec pollableChannel(String id, - ConnectionFactory connectionFactory) { - return new JmsPollableMessageChannelSpec(connectionFactory).id(id); - } - - public static - > JmsMessageChannelSpec channel(ConnectionFactory connectionFactory) { - return channel(null, connectionFactory); - } - - public static > JmsMessageChannelSpec channel(String id, - ConnectionFactory connectionFactory) { - return new JmsMessageChannelSpec(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 > JmsOutboundChannelAdapterSpec - outboundAdapter(JmsTemplate jmsTemplate) { - return new JmsOutboundChannelAdapterSpec(jmsTemplate); - } - - public static JmsOutboundChannelAdapterSpec.JmsOutboundChannelSpecTemplateAware - outboundAdapter(ConnectionFactory connectionFactory) { - return new JmsOutboundChannelAdapterSpec.JmsOutboundChannelSpecTemplateAware(connectionFactory); - } - - public static > JmsInboundChannelAdapterSpec - inboundAdapter(JmsTemplate jmsTemplate) { - return new JmsInboundChannelAdapterSpec(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 > JmsInboundGatewaySpec - inboundGateway(AbstractMessageListenerContainer listenerContainer) { - return new JmsInboundGatewaySpec(listenerContainer); - } - - public static JmsInboundGatewaySpec.JmsInboundGatewayListenerContainerSpec - inboundGateway(ConnectionFactory connectionFactory) { - return inboundGateway(connectionFactory, DefaultMessageListenerContainer.class); - } - - public static - JmsInboundGatewaySpec.JmsInboundGatewayListenerContainerSpec inboundGateway(ConnectionFactory connectionFactory, - Class containerClass) { - try { - JmsListenerContainerSpec spec = new JmsListenerContainerSpec(containerClass) - .connectionFactory(connectionFactory); - return new JmsInboundGatewaySpec.JmsInboundGatewayListenerContainerSpec(spec); - } - catch (Exception e) { - throw new IllegalStateException(e); - } - } - - public static > JmsMessageDrivenChannelAdapterSpec - messageDriverChannelAdapter(AbstractMessageListenerContainer listenerContainer) { - return new JmsMessageDrivenChannelAdapterSpec(listenerContainer); - } - - public static - JmsMessageDrivenChannelAdapterSpec.JmsMessageDrivenChannelAdapterListenerContainerSpec - messageDriverChannelAdapter(ConnectionFactory connectionFactory) { - return messageDriverChannelAdapter(connectionFactory, DefaultMessageListenerContainer.class); - } - - public static - JmsMessageDrivenChannelAdapterSpec.JmsMessageDrivenChannelAdapterListenerContainerSpec - messageDriverChannelAdapter(ConnectionFactory connectionFactory, Class containerClass) { - try { - JmsListenerContainerSpec spec = new JmsListenerContainerSpec(containerClass) - .connectionFactory(connectionFactory); - return new JmsMessageDrivenChannelAdapterSpec.JmsMessageDrivenChannelAdapterListenerContainerSpec(spec); - } - catch (Exception e) { - throw new IllegalStateException(e); - } - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsDestinationAccessorSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsDestinationAccessorSpec.java deleted file mode 100644 index b592c0e..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsDestinationAccessorSpec.java +++ /dev/null @@ -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, A extends JmsDestinationAccessor> - extends IntegrationComponentSpec { - - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsInboundChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsInboundChannelAdapterSpec.java deleted file mode 100644 index c56e10a..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsInboundChannelAdapterSpec.java +++ /dev/null @@ -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> - extends MessageSourceSpec { - - 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(ConnectionFactory connectionFactory) { - super(connectionFactory); - } - - public JmsInboundChannelSpecTemplateAware configureJmsTemplate(Consumer configurer) { - Assert.notNull(configurer); - configurer.accept(this.jmsTemplateSpec); - return _this(); - } - - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsInboundGateway.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsInboundGateway.java deleted file mode 100644 index 89efa1e..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsInboundGateway.java +++ /dev/null @@ -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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsInboundGatewaySpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsInboundGatewaySpec.java deleted file mode 100644 index 2f15757..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsInboundGatewaySpec.java +++ /dev/null @@ -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> - extends MessagingGatewaySpec { - - 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 extends - JmsInboundGatewaySpec> { - - private final JmsListenerContainerSpec spec; - - JmsInboundGatewayListenerContainerSpec(JmsListenerContainerSpec spec) { - super(spec.get()); - this.spec = spec; - this.spec.get().setAutoStartup(false); - } - - public JmsInboundGatewayListenerContainerSpec destination(Destination destination) { - spec.destination(destination); - return _this(); - } - - public JmsInboundGatewayListenerContainerSpec destination(String destinationName) { - spec.destination(destinationName); - return _this(); - } - - public JmsInboundGatewayListenerContainerSpec configureListenerContainer( - Consumer> configurer) { - Assert.notNull(configurer); - configurer.accept(this.spec); - return _this(); - } - - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsListenerContainerSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsListenerContainerSpec.java deleted file mode 100644 index b74f0cb..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsListenerContainerSpec.java +++ /dev/null @@ -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 - extends JmsDestinationAccessorSpec, C> { - - JmsListenerContainerSpec(Class aClass) throws Exception { - super(aClass.newInstance()); - } - - JmsListenerContainerSpec destination(Destination destination) { - target.setDestination(destination); - return _this(); - } - - JmsListenerContainerSpec destination(String destinationName) { - target.setDestinationName(destinationName); - return _this(); - } - - public JmsListenerContainerSpec messageSelector(String messageSelector) { - target.setMessageSelector(messageSelector); - return _this(); - } - - public JmsListenerContainerSpec subscriptionDurable(boolean subscriptionDurable) { - target.setSubscriptionDurable(subscriptionDurable); - return _this(); - } - - public JmsListenerContainerSpec durableSubscriptionName(String durableSubscriptionName) { - target.setDurableSubscriptionName(durableSubscriptionName); - return _this(); - } - - public JmsListenerContainerSpec exceptionListener(ExceptionListener exceptionListener) { - target.setExceptionListener(exceptionListener); - return _this(); - } - - public JmsListenerContainerSpec errorHandler(ErrorHandler errorHandler) { - target.setErrorHandler(errorHandler); - return _this(); - } - - public JmsListenerContainerSpec exposeListenerSession(boolean exposeListenerSession) { - target.setExposeListenerSession(exposeListenerSession); - return _this(); - } - - public JmsListenerContainerSpec acceptMessagesWhileStopping(boolean acceptMessagesWhileStopping) { - target.setAcceptMessagesWhileStopping(acceptMessagesWhileStopping); - return _this(); - } - - public JmsListenerContainerSpec clientId(String clientId) { - target.setClientId(clientId); - return _this(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsMessageChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsMessageChannelSpec.java deleted file mode 100644 index 798919d..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsMessageChannelSpec.java +++ /dev/null @@ -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> extends JmsPollableMessageChannelSpec { - - private Integer cacheLevel; - - JmsMessageChannelSpec(ConnectionFactory connectionFactory) { - super(new JmsChannelFactoryBean(true), connectionFactory); - } - - public S containerType(Class 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; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsMessageDrivenChannelAdapter.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsMessageDrivenChannelAdapter.java deleted file mode 100644 index 1efcae7..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsMessageDrivenChannelAdapter.java +++ /dev/null @@ -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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsMessageDrivenChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsMessageDrivenChannelAdapterSpec.java deleted file mode 100644 index b52c039..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsMessageDrivenChannelAdapterSpec.java +++ /dev/null @@ -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> - extends MessageProducerSpec { - - 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 extends - JmsMessageDrivenChannelAdapterSpec> { - - private final JmsListenerContainerSpec spec; - - JmsMessageDrivenChannelAdapterListenerContainerSpec(JmsListenerContainerSpec spec) { - super(spec.get()); - this.spec = spec; - this.spec.get().setAutoStartup(false); - } - - public JmsMessageDrivenChannelAdapterListenerContainerSpec destination(Destination destination) { - spec.destination(destination); - return _this(); - } - - public JmsMessageDrivenChannelAdapterListenerContainerSpec destination(String destinationName) { - spec.destination(destinationName); - return _this(); - } - - public JmsMessageDrivenChannelAdapterListenerContainerSpec configureListenerContainer( - Consumer> configurer) { - Assert.notNull(configurer); - configurer.accept(this.spec); - return _this(); - } - - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsOutboundChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsOutboundChannelAdapterSpec.java deleted file mode 100644 index caf2418..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsOutboundChannelAdapterSpec.java +++ /dev/null @@ -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> - extends MessageHandlerSpec { - - 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

S destination(Function, ?> destinationFunction) { - this.target.setDestinationExpression(new FunctionExpression>(destinationFunction)); - return _this(); - } - - @Override - protected JmsSendingMessageHandler doGet() { - return null; - } - - public static class JmsOutboundChannelSpecTemplateAware extends - JmsOutboundChannelAdapterSpec { - - JmsOutboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) { - super(connectionFactory); - } - - public JmsOutboundChannelSpecTemplateAware configureJmsTemplate(Consumer configurer) { - Assert.notNull(configurer); - configurer.accept(this.jmsTemplateSpec); - return _this(); - } - - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsOutboundGatewaySpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsOutboundGatewaySpec.java deleted file mode 100644 index 1030349..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsOutboundGatewaySpec.java +++ /dev/null @@ -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(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

JmsOutboundGatewaySpec requestDestination(Function, ?> destinationFunction) { - this.target.setRequestDestinationExpression(new FunctionExpression>(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

JmsOutboundGatewaySpec replyDestination(Function, ?> destinationFunction) { - this.target.setReplyDestinationExpression(new FunctionExpression>(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 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() { - 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(); - } - - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsPollableMessageChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsPollableMessageChannelSpec.java deleted file mode 100644 index bdae1e5..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsPollableMessageChannelSpec.java +++ /dev/null @@ -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> - extends MessageChannelSpec { - - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsPublishSubscribeMessageChannelSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsPublishSubscribeMessageChannelSpec.java deleted file mode 100644 index fef4fcf..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsPublishSubscribeMessageChannelSpec.java +++ /dev/null @@ -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(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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsTemplateSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsTemplateSpec.java deleted file mode 100644 index f2220c4..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/JmsTemplateSpec.java +++ /dev/null @@ -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() { - 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(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/package-info.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/package-info.java deleted file mode 100644 index 07bf0a6..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/jms/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides JMS Components support for Spring Integration Java DSL. - */ -package org.springframework.integration.dsl.jms; diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/ImapIdleChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/ImapIdleChannelAdapterSpec.java deleted file mode 100644 index 9bab06f..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/ImapIdleChannelAdapterSpec.java +++ /dev/null @@ -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.mail; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Properties; -import java.util.concurrent.Executor; - -import javax.mail.Authenticator; -import javax.mail.Session; -import javax.mail.internet.MimeMessage; - -import org.aopalliance.aop.Advice; - -import org.springframework.integration.dsl.core.ComponentsRegistration; -import org.springframework.integration.dsl.core.MessageProducerSpec; -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.PropertiesBuilder; -import org.springframework.integration.mail.ImapIdleChannelAdapter; -import org.springframework.integration.mail.ImapMailReceiver; -import org.springframework.integration.mail.SearchTermStrategy; -import org.springframework.integration.transaction.TransactionSynchronizationFactory; - -/** - * @author Gary Russell - * @author Artem Bilan - */ -public class ImapIdleChannelAdapterSpec - extends MessageProducerSpec - implements ComponentsRegistration { - - private final ImapMailReceiver receiver; - - ImapIdleChannelAdapterSpec(ImapMailReceiver receiver) { - super(new ImapIdleChannelAdapter(receiver)); - this.receiver = receiver; - } - - public ImapIdleChannelAdapterSpec selectorExpression(String selectorExpression) { - this.receiver.setSelectorExpression(PARSER.parseExpression(selectorExpression)); - return this; - } - - public ImapIdleChannelAdapterSpec selector(Function selectorFunction) { - this.receiver.setSelectorExpression(new FunctionExpression(selectorFunction)); - return this; - } - - public ImapIdleChannelAdapterSpec session(Session session) { - this.receiver.setSession(session); - return this; - } - - public ImapIdleChannelAdapterSpec javaMailProperties(Properties javaMailProperties) { - this.receiver.setJavaMailProperties(javaMailProperties); - return this; - } - - public ImapIdleChannelAdapterSpec javaMailProperties(Consumer configurer) { - PropertiesBuilder properties = new PropertiesBuilder(); - configurer.accept(properties); - return javaMailProperties(properties.get()); - } - - public ImapIdleChannelAdapterSpec javaMailAuthenticator(Authenticator javaMailAuthenticator) { - this.receiver.setJavaMailAuthenticator(javaMailAuthenticator); - return this; - } - - public ImapIdleChannelAdapterSpec maxFetchSize(int maxFetchSize) { - this.receiver.setMaxFetchSize(maxFetchSize); - return this; - } - - public ImapIdleChannelAdapterSpec shouldDeleteMessages(boolean shouldDeleteMessages) { - this.receiver.setShouldDeleteMessages(shouldDeleteMessages); - return this; - } - - public ImapIdleChannelAdapterSpec searchTermStrategy(SearchTermStrategy searchTermStrategy) { - this.receiver.setSearchTermStrategy(searchTermStrategy); - return this; - } - - public ImapIdleChannelAdapterSpec shouldMarkMessagesAsRead(boolean shouldMarkMessagesAsRead) { - this.receiver.setShouldMarkMessagesAsRead(shouldMarkMessagesAsRead); - return this; - } - - public ImapIdleChannelAdapterSpec - transactionSynchronizationFactory(TransactionSynchronizationFactory transactionSynchronizationFactory) { - this.target.setTransactionSynchronizationFactory(transactionSynchronizationFactory); - return this; - } - - public ImapIdleChannelAdapterSpec adviceChain(Advice... adviceChain) { - this.target.setAdviceChain(Arrays.asList(adviceChain)); - return this; - } - - public ImapIdleChannelAdapterSpec sendingTaskExecutor(Executor sendingTaskExecutor) { - this.target.setSendingTaskExecutor(sendingTaskExecutor); - return this; - } - - public ImapIdleChannelAdapterSpec shouldReconnectAutomatically(boolean shouldReconnectAutomatically) { - this.target.setShouldReconnectAutomatically(shouldReconnectAutomatically); - return this; - } - - @Override - public Collection getComponentsToRegister() { - return Collections.singletonList(this.receiver); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/ImapMailInboundChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/ImapMailInboundChannelAdapterSpec.java deleted file mode 100644 index e53358f..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/ImapMailInboundChannelAdapterSpec.java +++ /dev/null @@ -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.mail; - -import org.springframework.integration.mail.ImapMailReceiver; -import org.springframework.integration.mail.SearchTermStrategy; - -/** - * @author Gary Russell - * - */ -public class ImapMailInboundChannelAdapterSpec - extends MailInboundChannelAdapterSpec { - - ImapMailInboundChannelAdapterSpec() { - this.receiver = new ImapMailReceiver(); - } - - ImapMailInboundChannelAdapterSpec(String url) { - this.receiver = new ImapMailReceiver(url); - } - - public ImapMailInboundChannelAdapterSpec searchTermStrategy(SearchTermStrategy searchTermStrategy) { - this.receiver.setSearchTermStrategy(searchTermStrategy); - return this; - } - - public ImapMailInboundChannelAdapterSpec shouldMarkMessagesAsRead(boolean shouldMarkMessagesAsRead) { - this.receiver.setShouldMarkMessagesAsRead(shouldMarkMessagesAsRead); - return this; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/Mail.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/Mail.java deleted file mode 100644 index 0cbd37b..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/Mail.java +++ /dev/null @@ -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.mail; - -import org.springframework.integration.mail.ImapMailReceiver; - -/** - * @author Gary Russell - * @author Artem Bilan - */ -public class Mail { - - public static MailSendingMessageHandlerSpec outboundAdapter(String host) { - return new MailSendingMessageHandlerSpec(host); - } - - public static Pop3MailInboundChannelAdapterSpec pop3InboundAdapter() { - return new Pop3MailInboundChannelAdapterSpec(); - } - - public static Pop3MailInboundChannelAdapterSpec pop3InboundAdapter(String url) { - return new Pop3MailInboundChannelAdapterSpec(url); - } - - public static Pop3MailInboundChannelAdapterSpec pop3InboundAdapter(String host, String username, String password) { - return pop3InboundAdapter(host, -1, username, password); - } - - public static Pop3MailInboundChannelAdapterSpec pop3InboundAdapter(String host, int port, String username, - String password) { - return new Pop3MailInboundChannelAdapterSpec(host, port, username, password); - } - - public static ImapMailInboundChannelAdapterSpec imapInboundAdapter() { - return new ImapMailInboundChannelAdapterSpec(); - } - - public static ImapMailInboundChannelAdapterSpec imapInboundAdapter(String url) { - return new ImapMailInboundChannelAdapterSpec(url); - } - - public static ImapIdleChannelAdapterSpec imapIdleAdapter() { - return imapIdleAdapter(new ImapMailReceiver()); - } - - public static ImapIdleChannelAdapterSpec imapIdleAdapter(String url) { - return imapIdleAdapter(new ImapMailReceiver(url)); - } - - public static MailHeadersBuilder headers() { - return new MailHeadersBuilder(); - } - - private static ImapIdleChannelAdapterSpec imapIdleAdapter(ImapMailReceiver imapMailReceiver) { - return new ImapIdleChannelAdapterSpec(imapMailReceiver); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/MailHeadersBuilder.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/MailHeadersBuilder.java deleted file mode 100644 index 4a7ec82..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/MailHeadersBuilder.java +++ /dev/null @@ -1,151 +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.mail; - -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.mail.MailHeaders; -import org.springframework.messaging.Message; - -/** - * @author Artem Bilan - * @author Gary Russell - */ -public class MailHeadersBuilder extends MapBuilder { - - public MailHeadersBuilder subject(String subject) { - return put(MailHeaders.SUBJECT, subject); - } - - public MailHeadersBuilder subjectExpression(String subject) { - return putExpression(MailHeaders.SUBJECT, subject); - } - - public

MailHeadersBuilder subjectFunction(Function, String> subject) { - return put(MailHeaders.SUBJECT, new FunctionExpression>(subject)); - } - - public MailHeadersBuilder to(String... to) { - return put(MailHeaders.TO, to); - } - - public MailHeadersBuilder toExpression(String to) { - return putExpression(MailHeaders.TO, to); - } - - public

MailHeadersBuilder toFunction(Function, String[]> to) { - return put(MailHeaders.TO, new FunctionExpression>(to)); - } - - public MailHeadersBuilder cc(String... cc) { - return put(MailHeaders.CC, cc); - } - - public MailHeadersBuilder ccExpression(String cc) { - return putExpression(MailHeaders.CC, cc); - } - - public

MailHeadersBuilder ccFunction(Function, String[]> cc) { - return put(MailHeaders.CC, new FunctionExpression>(cc)); - } - - public MailHeadersBuilder bcc(String... bcc) { - return put(MailHeaders.BCC, bcc); - } - - public MailHeadersBuilder bccExpression(String bcc) { - return putExpression(MailHeaders.BCC, bcc); - } - - public

MailHeadersBuilder bccFunction(Function, String[]> bcc) { - return put(MailHeaders.BCC, new FunctionExpression>(bcc)); - } - - public MailHeadersBuilder from(String from) { - return put(MailHeaders.FROM, from); - } - - public MailHeadersBuilder fromExpression(String from) { - return putExpression(MailHeaders.FROM, from); - } - - public

MailHeadersBuilder fromFunction(Function, String> from) { - return put(MailHeaders.FROM, new FunctionExpression>(from)); - } - - public MailHeadersBuilder replyTo(String replyTo) { - return put(MailHeaders.REPLY_TO, replyTo); - } - - public MailHeadersBuilder replyToExpression(String replyTo) { - return putExpression(MailHeaders.REPLY_TO, replyTo); - } - - public

MailHeadersBuilder replyToFunction(Function, String> replyTo) { - return put(MailHeaders.REPLY_TO, new FunctionExpression>(replyTo)); - } - - /** - * @param multipartMode header value - * @return this - * @see org.springframework.mail.javamail.MimeMessageHelper - */ - public MailHeadersBuilder multipartMode(int multipartMode) { - return put(MailHeaders.MULTIPART_MODE, multipartMode); - } - - public MailHeadersBuilder multipartModeExpression(String multipartMode) { - return putExpression(MailHeaders.MULTIPART_MODE, multipartMode); - } - - public

MailHeadersBuilder multipartModeFunction(Function, Integer> multipartMode) { - return put(MailHeaders.MULTIPART_MODE, new FunctionExpression>(multipartMode)); - } - - public MailHeadersBuilder attachmentFilename(String attachmentFilename) { - return put(MailHeaders.ATTACHMENT_FILENAME, attachmentFilename); - } - - public MailHeadersBuilder attachmentFilenameExpression(String attachmentFilename) { - return putExpression(MailHeaders.ATTACHMENT_FILENAME, attachmentFilename); - } - - public

MailHeadersBuilder attachmentFilenameFunction(Function, String> attachmentFilename) { - return put(MailHeaders.ATTACHMENT_FILENAME, new FunctionExpression>(attachmentFilename)); - } - - public MailHeadersBuilder contentType(String contentType) { - return put(MailHeaders.CONTENT_TYPE, contentType); - } - - public MailHeadersBuilder contentTypeExpression(String contentType) { - return putExpression(MailHeaders.CONTENT_TYPE, contentType); - } - - public

MailHeadersBuilder contentTypeFunction(Function, String> contentType) { - return put(MailHeaders.CONTENT_TYPE, new FunctionExpression>(contentType)); - } - - private MailHeadersBuilder putExpression(String key, String expression) { - return put(key, PARSER.parseExpression(expression)); - } - - MailHeadersBuilder() { - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/MailInboundChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/MailInboundChannelAdapterSpec.java deleted file mode 100644 index bb0c7c4..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/MailInboundChannelAdapterSpec.java +++ /dev/null @@ -1,97 +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.mail; - -import java.util.Collection; -import java.util.Collections; -import java.util.Properties; - -import javax.mail.Authenticator; -import javax.mail.Session; -import javax.mail.internet.MimeMessage; - -import org.springframework.integration.dsl.core.ComponentsRegistration; -import org.springframework.integration.dsl.core.MessageSourceSpec; -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.PropertiesBuilder; -import org.springframework.integration.mail.AbstractMailReceiver; -import org.springframework.integration.mail.MailReceivingMessageSource; - -/** - * @author Gary Russell - * @author Artem Bilan - */ -public abstract class MailInboundChannelAdapterSpec, - R extends AbstractMailReceiver> - extends MessageSourceSpec - implements ComponentsRegistration { - - protected volatile R receiver; - - public S selectorExpression(String selectorExpression) { - this.receiver.setSelectorExpression(PARSER.parseExpression(selectorExpression)); - return _this(); - } - - public S selector(Function selectorFunction) { - this.receiver.setSelectorExpression(new FunctionExpression(selectorFunction)); - return _this(); - } - - public S session(Session session) { - this.receiver.setSession(session); - return _this(); - } - - public S javaMailProperties(Properties javaMailProperties) { - this.receiver.setJavaMailProperties(javaMailProperties); - return _this(); - } - - public S javaMailProperties(Consumer configurer) { - PropertiesBuilder properties = new PropertiesBuilder(); - configurer.accept(properties); - return javaMailProperties(properties.get()); - } - - public S javaMailAuthenticator(Authenticator javaMailAuthenticator) { - this.receiver.setJavaMailAuthenticator(javaMailAuthenticator); - return _this(); - } - - public S maxFetchSize(int maxFetchSize) { - this.receiver.setMaxFetchSize(maxFetchSize); - return _this(); - } - - public S shouldDeleteMessages(boolean shouldDeleteMessages) { - this.receiver.setShouldDeleteMessages(shouldDeleteMessages); - return _this(); - } - - @Override - public Collection getComponentsToRegister() { - return Collections.singletonList(this.receiver); - } - - @Override - public MailReceivingMessageSource doGet() { - return new MailReceivingMessageSource(this.receiver); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/MailSendingMessageHandlerSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/MailSendingMessageHandlerSpec.java deleted file mode 100644 index 6762b65..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/MailSendingMessageHandlerSpec.java +++ /dev/null @@ -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.mail; - -import java.util.Properties; - -import javax.activation.FileTypeMap; - -import org.springframework.integration.dsl.core.MessageHandlerSpec; -import org.springframework.integration.dsl.support.Consumer; -import org.springframework.integration.dsl.support.PropertiesBuilder; -import org.springframework.integration.mail.MailSendingMessageHandler; -import org.springframework.mail.javamail.JavaMailSenderImpl; - -/** - * @author Gary Russell - * @author Artem Bilan - */ -public class MailSendingMessageHandlerSpec - extends MessageHandlerSpec { - - private final JavaMailSenderImpl sender = new JavaMailSenderImpl(); - - MailSendingMessageHandlerSpec (String host) { - this.sender.setHost(host); - this.target = new MailSendingMessageHandler(this.sender); - } - - public MailSendingMessageHandlerSpec javaMailProperties(Properties javaMailProperties) { - this.sender.setJavaMailProperties(javaMailProperties); - return this; - } - - public MailSendingMessageHandlerSpec javaMailProperties(Consumer propertiesConfigurer) { - PropertiesBuilder properties = new PropertiesBuilder(); - propertiesConfigurer.accept(properties); - return javaMailProperties(properties.get()); - } - - public MailSendingMessageHandlerSpec protocol(String protocol) { - this.sender.setProtocol(protocol); - return this; - } - - public MailSendingMessageHandlerSpec port(int port) { - this.sender.setPort(port); - return this; - } - - public MailSendingMessageHandlerSpec credentials(String username, String password) { - this.sender.setUsername(username); - this.sender.setPassword(password); - return this; - } - - public MailSendingMessageHandlerSpec defaultEncoding(String defaultEncoding) { - this.sender.setDefaultEncoding(defaultEncoding); - return this; - } - - public MailSendingMessageHandlerSpec defaultFileTypeMap(FileTypeMap defaultFileTypeMap) { - this.sender.setDefaultFileTypeMap(defaultFileTypeMap); - return this; - } - - @Override - protected MailSendingMessageHandler doGet() { - throw new UnsupportedOperationException(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/Pop3MailInboundChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/Pop3MailInboundChannelAdapterSpec.java deleted file mode 100644 index 62e5fbb..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/Pop3MailInboundChannelAdapterSpec.java +++ /dev/null @@ -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.mail; - -import org.springframework.integration.mail.Pop3MailReceiver; - -/** - * @author Gary Russell - * - */ -public class Pop3MailInboundChannelAdapterSpec - extends MailInboundChannelAdapterSpec { - - Pop3MailInboundChannelAdapterSpec() { - this.receiver = new Pop3MailReceiver(); - } - - Pop3MailInboundChannelAdapterSpec(String url) { - this.receiver = new Pop3MailReceiver(url); - } - - Pop3MailInboundChannelAdapterSpec(String host, String username, String password) { - this.receiver = new Pop3MailReceiver(host, username, password); - } - - Pop3MailInboundChannelAdapterSpec(String host, int port, String username, String password) { - this.receiver = new Pop3MailReceiver(host, port, username, password); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/package-info.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/package-info.java deleted file mode 100644 index dd43519..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/mail/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides Mail Components support for Spring Integration Java DSL. - */ -package org.springframework.integration.dsl.mail; diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/package-info.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/package-info.java deleted file mode 100644 index bcf137d..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Root package of the Spring Integration Java DSL. - */ -package org.springframework.integration.dsl; diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/Sftp.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/Sftp.java deleted file mode 100644 index 9bab536..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/Sftp.java +++ /dev/null @@ -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.sftp; - -import java.io.File; -import java.util.Comparator; - -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.sftp.gateway.SftpOutboundGateway; - -import com.jcraft.jsch.ChannelSftp; - -/** - * @author Artem Bilan - */ -public abstract class Sftp { - - public static SftpInboundChannelAdapterSpec inboundAdapter(SessionFactory sessionFactory) { - return inboundAdapter(sessionFactory, null); - } - - public static SftpInboundChannelAdapterSpec inboundAdapter(SessionFactory sessionFactory, - Comparator receptionOrderComparator) { - return new SftpInboundChannelAdapterSpec(sessionFactory, receptionOrderComparator); - } - - public static SftpMessageHandlerSpec outboundAdapter(SessionFactory sessionFactory) { - return new SftpMessageHandlerSpec(sessionFactory); - } - - public static SftpMessageHandlerSpec outboundAdapter(SessionFactory sessionFactory, - FileExistsMode fileExistsMode) { - return outboundAdapter(new RemoteFileTemplate(sessionFactory), fileExistsMode); - } - - public static SftpMessageHandlerSpec outboundAdapter(RemoteFileTemplate remoteFileTemplate) { - return new SftpMessageHandlerSpec(remoteFileTemplate); - } - - public static SftpMessageHandlerSpec outboundAdapter(RemoteFileTemplate remoteFileTemplate, - FileExistsMode fileExistsMode) { - return new SftpMessageHandlerSpec(remoteFileTemplate, fileExistsMode); - } - - public static SftpOutboundGatewaySpec outboundGateway(SessionFactory sessionFactory, - AbstractRemoteFileOutboundGateway.Command command, String expression) { - return outboundGateway(sessionFactory, command.getCommand(), expression); - } - - public static SftpOutboundGatewaySpec outboundGateway(SessionFactory sessionFactory, - String command, String expression) { - return new SftpOutboundGatewaySpec(new SftpOutboundGateway(sessionFactory, command, expression)); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/SftpInboundChannelAdapterSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/SftpInboundChannelAdapterSpec.java deleted file mode 100644 index ecac1b0..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/SftpInboundChannelAdapterSpec.java +++ /dev/null @@ -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.sftp; - -import java.io.File; -import java.util.Comparator; - -import com.jcraft.jsch.ChannelSftp; - -import org.springframework.integration.dsl.file.RemoteFileInboundChannelAdapterSpec; -import org.springframework.integration.file.remote.session.SessionFactory; -import org.springframework.integration.sftp.filters.SftpRegexPatternFileListFilter; -import org.springframework.integration.sftp.filters.SftpSimplePatternFileListFilter; -import org.springframework.integration.sftp.inbound.SftpInboundFileSynchronizer; -import org.springframework.integration.sftp.inbound.SftpInboundFileSynchronizingMessageSource; - -/** - * @author Artem Bilan - */ -public class SftpInboundChannelAdapterSpec - extends RemoteFileInboundChannelAdapterSpec { - - SftpInboundChannelAdapterSpec(SessionFactory sessionFactory, Comparator comparator) { - super(new SftpInboundFileSynchronizer(sessionFactory)); - this.target = new SftpInboundFileSynchronizingMessageSource(this.synchronizer, comparator); - } - - @Override - public SftpInboundChannelAdapterSpec patternFilter(String pattern) { - return filter(new SftpSimplePatternFileListFilter(pattern)); - } - - @Override - public SftpInboundChannelAdapterSpec regexFilter(String regex) { - return filter(new SftpRegexPatternFileListFilter(regex)); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/SftpMessageHandlerSpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/SftpMessageHandlerSpec.java deleted file mode 100644 index 69a203c..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/SftpMessageHandlerSpec.java +++ /dev/null @@ -1,44 +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.sftp; - -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; - -import com.jcraft.jsch.ChannelSftp; - -/** - * @author Artem Bilan - */ -public class SftpMessageHandlerSpec - extends FileTransferringMessageHandlerSpec { - - SftpMessageHandlerSpec(SessionFactory sessionFactory) { - super(sessionFactory); - } - - SftpMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate) { - super(remoteFileTemplate); - } - - SftpMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate, FileExistsMode fileExistsMode) { - super(remoteFileTemplate, fileExistsMode); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/SftpOutboundGatewaySpec.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/SftpOutboundGatewaySpec.java deleted file mode 100644 index baba636..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/SftpOutboundGatewaySpec.java +++ /dev/null @@ -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.sftp; - -import org.springframework.integration.dsl.file.RemoteFileOutboundGatewaySpec; -import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway; -import org.springframework.integration.sftp.filters.SftpRegexPatternFileListFilter; -import org.springframework.integration.sftp.filters.SftpSimplePatternFileListFilter; - -import com.jcraft.jsch.ChannelSftp; - -/** - * @author Artem Bilan - */ -public class SftpOutboundGatewaySpec - extends RemoteFileOutboundGatewaySpec { - - - SftpOutboundGatewaySpec(AbstractRemoteFileOutboundGateway outboundGateway) { - super(outboundGateway); - } - - @Override - public SftpOutboundGatewaySpec patternFileNameFilter(String pattern) { - return filter(new SftpSimplePatternFileListFilter(pattern)); - } - - @Override - public SftpOutboundGatewaySpec regexFileNameFilter(String regex) { - return filter(new SftpRegexPatternFileListFilter(regex)); - } -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/package-info.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/package-info.java deleted file mode 100644 index b8cff3d..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/sftp/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides SFTP Components support for Spring Integration Java DSL. - */ -package org.springframework.integration.dsl.sftp; diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/BeanNameMessageProcessor.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/BeanNameMessageProcessor.java deleted file mode 100644 index eab72ff..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/BeanNameMessageProcessor.java +++ /dev/null @@ -1,55 +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.support; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.integration.handler.MessageProcessor; -import org.springframework.integration.handler.MethodInvokingMessageProcessor; -import org.springframework.messaging.Message; -import org.springframework.util.Assert; - -/** - * @author Artem Bilan - */ -public class BeanNameMessageProcessor implements MessageProcessor, BeanFactoryAware { - - private final String object; - - private final String methodName; - - private MessageProcessor delegate; - - public BeanNameMessageProcessor(String object, String methodName) { - this.object = object; - this.methodName = methodName; - } - - @Override - public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - Assert.notNull(beanFactory); - Object target = beanFactory.getBean(object); - this.delegate = new MethodInvokingMessageProcessor(target, this.methodName); - } - - @Override - public T processMessage(Message message) { - return this.delegate.processMessage(message); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/Consumer.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/Consumer.java deleted file mode 100644 index be8719e..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/Consumer.java +++ /dev/null @@ -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.support; - -/** - * Implementations accept a given value and perform work on the argument. - * - *

This is a copy of Java 8 {@code Consumer} interface. - * - * @param the type of values to accept - * - * @author Jon Brisbin - * @author Stephane Maldini - */ -public interface Consumer { - - /** - * Execute the logic of the action, accepting the given parameter. - * @param t The parameter to pass to the consumer. - */ - void accept(T t); - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/FixedSubscriberChannelPrototype.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/FixedSubscriberChannelPrototype.java deleted file mode 100644 index cef6258..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/FixedSubscriberChannelPrototype.java +++ /dev/null @@ -1,59 +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.support; - -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; - -/** - * @author Artem Bilan - */ -public class FixedSubscriberChannelPrototype implements MessageChannel { - - private final String name; - - public FixedSubscriberChannelPrototype() { - this(null); - } - - public FixedSubscriberChannelPrototype(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - - @Override - public boolean send(Message message) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean send(Message message, long timeout) { - throw new UnsupportedOperationException(); - } - - @Override - public String toString() { - return "FixedSubscriberChannelPrototype{" + - "name='" + name + '\'' + - '}'; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/Function.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/Function.java deleted file mode 100644 index 64f841d..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/Function.java +++ /dev/null @@ -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.support; - -/** - * Implementations of this class perform work on the given parameter - * and return a result of an optionally different type. - * - *

This is a copy of Java 8 {@code Function} interface. - * - * @param The type of the input to the apply operation - * @param The type of the result of the apply operation - * - * @author Jon Brisbin - * @author Stephane Maldini - */ -public interface Function { - - /** - * Execute the logic of the action, accepting the given parameter. - * @param t The parameter to pass to the action. - * @return result - */ - R apply(T t); - -} - diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/FunctionExpression.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/FunctionExpression.java deleted file mode 100644 index d88b509..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/FunctionExpression.java +++ /dev/null @@ -1,177 +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.support; - -import org.springframework.core.convert.TypeDescriptor; -import org.springframework.expression.EvaluationContext; -import org.springframework.expression.EvaluationException; -import org.springframework.expression.Expression; -import org.springframework.expression.TypedValue; -import org.springframework.expression.common.ExpressionUtils; -import org.springframework.expression.spel.support.StandardEvaluationContext; - -/** - * An {@link Expression} that simply invokes {@link Function#apply(Object)} on its - * provided {@link Function}. - *

- * This is a powerful alternative to the SpEL, when Java 8 and its Lambda support is in use. - *

- * If the target component has support for an {@link Expression} property, - * a {@link FunctionExpression} can be specified instead of a - * {@link org.springframework.expression.spel.standard.SpelExpression} - * as an alternative to evaluate the value from the Lambda, rather than runtime SpEL resolution. - *

- * The {@link FunctionExpression} is 'read-only', hence only {@link #getValue} operations - * are allowed. - * Any {@link #setValue} operations and {@link #getValueType} related operations - * throw {@link EvaluationException}. - * - * @author Artem Bilan - */ -public class FunctionExpression implements Expression { - - private final Function function; - - private final EvaluationContext defaultContext = new StandardEvaluationContext(); - - private final EvaluationException readOnlyException; - - public FunctionExpression(Function function) { - this.function = function; - this.readOnlyException = new EvaluationException(getExpressionString(), - "FunctionExpression is a 'read only' Expression implementation"); - } - - @Override - public Object getValue() throws EvaluationException { - return this.function.apply(null); - } - - @Override - @SuppressWarnings("unchecked") - public Object getValue(Object rootObject) throws EvaluationException { - return this.function.apply((S) rootObject); - } - - @Override - public T getValue(Class desiredResultType) throws EvaluationException { - return getValue(this.defaultContext, desiredResultType); - } - - @Override - public T getValue(Object rootObject, Class desiredResultType) throws EvaluationException { - return getValue(this.defaultContext, rootObject, desiredResultType); - } - - @Override - public Object getValue(EvaluationContext context) throws EvaluationException { - return getValue(); - } - - @Override - public Object getValue(EvaluationContext context, Object rootObject) throws EvaluationException { - return getValue(rootObject); - } - - @Override - public T getValue(EvaluationContext context, Class desiredResultType) throws EvaluationException { - return ExpressionUtils.convertTypedValue(context, new TypedValue(getValue()), desiredResultType); - } - - @Override - public T getValue(EvaluationContext context, Object rootObject, Class desiredResultType) - throws EvaluationException { - return ExpressionUtils.convertTypedValue(context, new TypedValue(getValue(rootObject)), desiredResultType); - } - - @Override - public Class getValueType() throws EvaluationException { - throw this.readOnlyException; - } - - @Override - public Class getValueType(Object rootObject) throws EvaluationException { - throw this.readOnlyException; - } - - @Override - public Class getValueType(EvaluationContext context) throws EvaluationException { - throw this.readOnlyException; - } - - @Override - public Class getValueType(EvaluationContext context, Object rootObject) throws EvaluationException { - throw this.readOnlyException; - } - - @Override - public TypeDescriptor getValueTypeDescriptor() throws EvaluationException { - throw this.readOnlyException; - } - - @Override - public TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException { - throw this.readOnlyException; - } - - @Override - public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException { - throw this.readOnlyException; - } - - @Override - public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject) - throws EvaluationException { - throw this.readOnlyException; - } - - @Override - public void setValue(EvaluationContext context, Object value) throws EvaluationException { - throw this.readOnlyException; - } - - @Override - public void setValue(Object rootObject, Object value) throws EvaluationException { - throw this.readOnlyException; - } - - @Override - public void setValue(EvaluationContext context, Object rootObject, Object value) throws EvaluationException { - throw this.readOnlyException; - } - - @Override - public boolean isWritable(EvaluationContext context) throws EvaluationException { - return false; - } - - @Override - public boolean isWritable(EvaluationContext context, Object rootObject) throws EvaluationException { - return false; - } - - @Override - public boolean isWritable(Object rootObject) throws EvaluationException { - return false; - } - - @Override - public String getExpressionString() { - return this.function.toString(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/GenericHandler.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/GenericHandler.java deleted file mode 100644 index 5bf275e..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/GenericHandler.java +++ /dev/null @@ -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.support; - -import java.util.Map; - -/** - * @author Artem Bilan - */ -public interface GenericHandler

{ - - Object handle(P payload, Map headers); - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/MapBuilder.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/MapBuilder.java deleted file mode 100644 index 981b0e9..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/MapBuilder.java +++ /dev/null @@ -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.support; - -import java.util.HashMap; -import java.util.Map; - -import org.springframework.expression.spel.standard.SpelExpressionParser; - -/** - * @author Artem Bilan - */ -public class MapBuilder, K, V> { - - protected final static SpelExpressionParser PARSER = new SpelExpressionParser(); - - private final Map map = new HashMap(); - - public B put(K key, V value) { - this.map.put(key, value); - return _this(); - } - - public Map get() { - return this.map; - } - - @SuppressWarnings("unchecked") - protected final B _this() { - return (B) this; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/MessageChannelReference.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/MessageChannelReference.java deleted file mode 100644 index 99b95bf..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/MessageChannelReference.java +++ /dev/null @@ -1,49 +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.support; - -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.util.Assert; - -/** - * @author Artem Bilan - */ -public class MessageChannelReference implements MessageChannel { - - private final String name; - - public MessageChannelReference(String name) { - Assert.notNull(name); - this.name = name; - } - - public String getName() { - return name; - } - - @Override - public boolean send(Message message) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean send(Message message, long timeout) { - throw new UnsupportedOperationException(); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/PropertiesBuilder.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/PropertiesBuilder.java deleted file mode 100644 index 17eb6e2..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/PropertiesBuilder.java +++ /dev/null @@ -1,39 +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.support; - -import java.util.Properties; - - -/** - * @author Gary Russell - * @author Artem Bilan - * - */ -public class PropertiesBuilder { - - private final Properties properties = new Properties(); - - public PropertiesBuilder put(Object key, Object value) { - properties.put(key, value); - return this; - } - - public Properties get() { - return this.properties; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/StringStringMapBuilder.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/StringStringMapBuilder.java deleted file mode 100644 index b2bd375..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/StringStringMapBuilder.java +++ /dev/null @@ -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.support; - -/** - * A map builder creating a map with String keys and values. - * - * @author Gary Russell - * - */ -public class StringStringMapBuilder extends MapBuilder { - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/Transformers.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/Transformers.java deleted file mode 100644 index 5225d2b..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/Transformers.java +++ /dev/null @@ -1,339 +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.support; - -import java.util.HashMap; -import java.util.Map; - -import javax.xml.parsers.ParserConfigurationException; - -import org.springframework.core.convert.converter.Converter; -import org.springframework.core.io.Resource; -import org.springframework.core.serializer.Deserializer; -import org.springframework.core.serializer.Serializer; -import org.springframework.expression.Expression; -import org.springframework.integration.dsl.support.tuple.Tuple2; -import org.springframework.integration.file.transformer.FileToByteArrayTransformer; -import org.springframework.integration.file.transformer.FileToStringTransformer; -import org.springframework.integration.json.JsonToObjectTransformer; -import org.springframework.integration.json.ObjectToJsonTransformer; -import org.springframework.integration.mail.transformer.MailToStringTransformer; -import org.springframework.integration.support.json.JsonObjectMapper; -import org.springframework.integration.transformer.MapToObjectTransformer; -import org.springframework.integration.transformer.ObjectToMapTransformer; -import org.springframework.integration.transformer.ObjectToStringTransformer; -import org.springframework.integration.transformer.PayloadDeserializingTransformer; -import org.springframework.integration.transformer.PayloadSerializingTransformer; -import org.springframework.integration.transformer.PayloadTypeConvertingTransformer; -import org.springframework.integration.transformer.SyslogToMapTransformer; -import org.springframework.integration.xml.result.ResultFactory; -import org.springframework.integration.xml.source.SourceFactory; -import org.springframework.integration.xml.transformer.MarshallingTransformer; -import org.springframework.integration.xml.transformer.ResultTransformer; -import org.springframework.integration.xml.transformer.SourceCreatingTransformer; -import org.springframework.integration.xml.transformer.UnmarshallingTransformer; -import org.springframework.integration.xml.transformer.XPathTransformer; -import org.springframework.integration.xml.transformer.XsltPayloadTransformer; -import org.springframework.integration.xml.xpath.XPathEvaluationType; -import org.springframework.oxm.Marshaller; -import org.springframework.oxm.Unmarshaller; -import org.springframework.util.Assert; -import org.springframework.xml.xpath.NodeMapper; - -/** - * @author Artem Bilan - */ -public abstract class Transformers { - - public static ObjectToStringTransformer objectToString() { - return objectToString(null); - } - - public static ObjectToStringTransformer objectToString(String charset) { - return charset != null ? new ObjectToStringTransformer(charset) : new ObjectToStringTransformer(); - } - - public static ObjectToMapTransformer toMap() { - return new ObjectToMapTransformer(); - } - - public static ObjectToMapTransformer toMap(boolean shouldFlattenKeys) { - ObjectToMapTransformer transformer = new ObjectToMapTransformer(); - transformer.setShouldFlattenKeys(shouldFlattenKeys); - return transformer; - } - - public static MapToObjectTransformer fromMap(Class targetClass) { - return new MapToObjectTransformer(targetClass); - } - - public static MapToObjectTransformer fromMap(String beanName) { - return new MapToObjectTransformer(beanName); - } - - public static ObjectToJsonTransformer toJson() { - return toJson(null, null, null); - } - - public static ObjectToJsonTransformer toJson(JsonObjectMapper jsonObjectMapper) { - return toJson(jsonObjectMapper, null, null); - } - - public static ObjectToJsonTransformer toJson(JsonObjectMapper jsonObjectMapper, - ObjectToJsonTransformer.ResultType resultType) { - return toJson(jsonObjectMapper, resultType, null); - } - - public static ObjectToJsonTransformer toJson(String contentType) { - return toJson(null, null, contentType); - } - - public static ObjectToJsonTransformer toJson(JsonObjectMapper jsonObjectMapper, String contentType) { - return toJson(jsonObjectMapper, null, contentType); - } - - public static ObjectToJsonTransformer toJson(ObjectToJsonTransformer.ResultType resultType, String contentType) { - return toJson(null, resultType, contentType); - } - - public static ObjectToJsonTransformer toJson(JsonObjectMapper jsonObjectMapper, - ObjectToJsonTransformer.ResultType resultType, String contentType) { - ObjectToJsonTransformer transformer; - if (jsonObjectMapper != null) { - if (resultType != null) { - transformer = new ObjectToJsonTransformer(jsonObjectMapper, resultType); - } - else { - transformer = new ObjectToJsonTransformer(jsonObjectMapper); - } - } - else if (resultType != null) { - transformer = new ObjectToJsonTransformer(resultType); - } - else { - transformer = new ObjectToJsonTransformer(); - } - if (contentType != null) { - transformer.setContentType(contentType); - } - return transformer; - } - - public static JsonToObjectTransformer fromJson() { - return fromJson(null, null); - } - - public static JsonToObjectTransformer fromJson(Class targetClass) { - return fromJson(targetClass, null); - } - - public static JsonToObjectTransformer fromJson(JsonObjectMapper jsonObjectMapper) { - return fromJson(null, jsonObjectMapper); - } - - public static JsonToObjectTransformer fromJson(Class targetClass, JsonObjectMapper jsonObjectMapper) { - return new JsonToObjectTransformer(targetClass, jsonObjectMapper); - } - - public static PayloadSerializingTransformer serializer() { - return serializer(null); - } - - public static PayloadSerializingTransformer serializer(Serializer serializer) { - PayloadSerializingTransformer transformer = new PayloadSerializingTransformer(); - if (serializer != null) { - transformer.setSerializer(serializer); - } - return transformer; - } - - public static PayloadDeserializingTransformer deserializer() { - return deserializer(null); - } - - public static PayloadDeserializingTransformer deserializer(Deserializer deserializer) { - PayloadDeserializingTransformer transformer = new PayloadDeserializingTransformer(); - if (deserializer != null) { - transformer.setDeserializer(deserializer); - } - return transformer; - } - - public static PayloadTypeConvertingTransformer converter(Converter converter) { - Assert.notNull(converter, "The Converter is required for the PayloadTypeConvertingTransformer"); - PayloadTypeConvertingTransformer transformer = new PayloadTypeConvertingTransformer(); - transformer.setConverter(converter); - return transformer; - } - - public static SyslogToMapTransformer syslogToMap() { - return new SyslogToMapTransformer(); - } - - public static MailToStringTransformer fromMail() { - return fromMail(null); - } - - public static MailToStringTransformer fromMail(String charset) { - MailToStringTransformer transformer = new MailToStringTransformer(); - if (charset != null) { - transformer.setCharset(charset); - } - return transformer; - } - - public static FileToStringTransformer fileToString() { - return fileToString(null); - } - - public static FileToStringTransformer fileToString(String charset) { - FileToStringTransformer transformer = new FileToStringTransformer(); - if (charset != null) { - transformer.setCharset(charset); - } - return transformer; - } - - public static FileToByteArrayTransformer fileToByteArray() { - return new FileToByteArrayTransformer(); - } - - public static MarshallingTransformer marshaller(Marshaller marshaller) { - return marshaller(marshaller, null, null, null); - } - - public static MarshallingTransformer marshaller(Marshaller marshaller, ResultTransformer resultTransformer) { - return marshaller(marshaller, resultTransformer, null); - } - - public static MarshallingTransformer marshaller(Marshaller marshaller, ResultFactory resultFactory) { - return marshaller(marshaller, null, resultFactory); - } - - public static MarshallingTransformer marshaller(Marshaller marshaller, boolean extractPayload) { - return marshaller(marshaller, null, null, extractPayload); - } - - public static MarshallingTransformer marshaller(Marshaller marshaller,ResultFactory resultFactory, - boolean extractPayload) { - return marshaller(marshaller, null, resultFactory, extractPayload); - } - - public static MarshallingTransformer marshaller(Marshaller marshaller, ResultTransformer resultTransformer, - boolean extractPayload) { - return marshaller(marshaller, resultTransformer, null, extractPayload); - } - - - public static MarshallingTransformer marshaller(Marshaller marshaller, ResultTransformer resultTransformer, - ResultFactory resultFactory) { - return marshaller(marshaller, resultTransformer, resultFactory, null); - } - - public static MarshallingTransformer marshaller(Marshaller marshaller, ResultTransformer resultTransformer, - ResultFactory resultFactory, boolean extractPayload) { - return marshaller(marshaller, resultTransformer, resultFactory, Boolean.valueOf(extractPayload)); - } - - private static MarshallingTransformer marshaller(Marshaller marshaller, ResultTransformer resultTransformer, - ResultFactory resultFactory, Boolean extractPayload) { - try { - MarshallingTransformer transformer = new MarshallingTransformer(marshaller, resultTransformer); - if (resultFactory != null) { - transformer.setResultFactory(resultFactory); - } - if (extractPayload != null) { - transformer.setExtractPayload(extractPayload); - } - return transformer; - } - catch (ParserConfigurationException e) { - throw new IllegalStateException(e); - } - } - - public static UnmarshallingTransformer unmarshaller(Unmarshaller unmarshaller) { - return unmarshaller(unmarshaller, null); - } - - public static UnmarshallingTransformer unmarshaller(Unmarshaller unmarshaller, SourceFactory sourceFactory) { - return unmarshaller(unmarshaller, sourceFactory, false); - } - - public static UnmarshallingTransformer unmarshaller(Unmarshaller unmarshaller, - boolean alwaysUseSourceFactory) { - return unmarshaller(unmarshaller, null, alwaysUseSourceFactory); - } - - public static UnmarshallingTransformer unmarshaller(Unmarshaller unmarshaller, SourceFactory sourceFactory, - boolean alwaysUseSourceFactory) { - UnmarshallingTransformer transformer = new UnmarshallingTransformer(unmarshaller); - if(sourceFactory != null) { - transformer.setSourceFactory(sourceFactory); - } - transformer.setAlwaysUseSourceFactory(alwaysUseSourceFactory); - - return transformer; - } - - public static SourceCreatingTransformer xmlSource() { - return xmlSource(null); - } - - public static SourceCreatingTransformer xmlSource(SourceFactory sourceFactory) { - return sourceFactory != null ? new SourceCreatingTransformer(sourceFactory) : new SourceCreatingTransformer(); - } - - public static XPathTransformer xpath(String xpathExpression) { - return xpath(xpathExpression, null, null); - } - - public static XPathTransformer xpath(String xpathExpression, XPathEvaluationType xpathEvaluationType) { - return xpath(xpathExpression, xpathEvaluationType, null); - } - - public static XPathTransformer xpath(String xpathExpression, NodeMapper nodeMapper) { - return xpath(xpathExpression, null, nodeMapper); - } - - public static XPathTransformer xpath(String xpathExpression, XPathEvaluationType xpathEvaluationType, - NodeMapper nodeMapper) { - XPathTransformer transformer = new XPathTransformer(xpathExpression); - if (xpathEvaluationType != null) { - transformer.setEvaluationType(xpathEvaluationType); - } - if (nodeMapper != null) { - transformer.setNodeMapper(nodeMapper); - } - return transformer; - } - - @SuppressWarnings("unchecked") - public static XsltPayloadTransformer xslt(Resource xsltTemplate, - Tuple2... xslParameterMappings) { - XsltPayloadTransformer transformer = new XsltPayloadTransformer(xsltTemplate); - if (xslParameterMappings != null) { - Map params = new HashMap(xslParameterMappings.length); - for (Tuple2 mapping : xslParameterMappings) { - params.put(mapping.getT1(), mapping.getT2()); - } - transformer.setXslParameterMappings(params); - } - return transformer; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/package-info.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/package-info.java deleted file mode 100644 index 1affe13..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides various support classes used across Spring Integration Java DSL Components. - */ -package org.springframework.integration.dsl.support; diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/Tuple.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/Tuple.java deleted file mode 100644 index 716d046..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/Tuple.java +++ /dev/null @@ -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.support.tuple; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; - -import org.springframework.util.Assert; - -/** - * A {@literal Tuple} is an immutable {@link java.util.Collection} of objects, - * each of which can be of an arbitrary type. - * - * @author Jon Brisbin - * @author Stephane Maldini - */ -@SuppressWarnings({"rawtypes"}) -public class Tuple implements Iterable, Serializable { - - private static final long serialVersionUID = 8777121214502020842L; - - protected final Object[] entries; - - protected final int size; - - /** - * Creates a new {@code Tuple} that holds the given {@code values}. - * - * @param values The values to hold - */ - public Tuple(Collection values) { - Assert.notEmpty(values); - this.entries = values.toArray(); - this.size = entries.length; - } - - /** - * Creates a new {@code Tuple} that holds the given {@code values}. - * - * @param values The values to hold - */ - public Tuple(Object... values) { - this.entries = Arrays.copyOf(values, values.length); - this.size = values.length; - } - - - /** - * Get the object at the given index. - * - * @param index The index of the object to retrieve. Starts at 0. - * @return The object. Might be {@literal null}. - */ - public Object get(int index) { - return (size > 0 && size > index ? entries[index] : null); - } - - /** - * Turn this {@literal Tuple} into a plain Object array. - * - * @return A new Object array. - */ - public Object[] toArray() { - return entries; - } - - /** - * Return the number of elements in this {@literal Tuple}. - * - * @return The size of this {@literal Tuple}. - */ - public int size() { - return size; - } - - @Override - public Iterator iterator() { - return Arrays.asList(entries).iterator(); - } - - - @Override - public int hashCode() { - if (this.size == 0) { - return 0; - } - else if (this.size == 1) { - return this.entries[0].hashCode(); - } - else { - int hashCode = 1; - for (Object entry : this.entries) { - hashCode = hashCode ^ entry.hashCode(); - } - return hashCode; - } - } - - @Override - public boolean equals(Object o) { - if (o == null) return false; - - if (!(o instanceof Tuple)) return false; - - Tuple cast = (Tuple) o; - - if (this.size != cast.size) return false; - - for (int i = 0; i < this.size; i++) { - if (!this.entries[i].equals(cast.entries[i])) { - return false; - } - } - return true; - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/Tuple1.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/Tuple1.java deleted file mode 100644 index 66166ba..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/Tuple1.java +++ /dev/null @@ -1,44 +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.support.tuple; - -/** - * A tuple that holds a single value - * - * @param The type held by this tuple - * - * @author Jon Brisbin - */ -public class Tuple1 extends Tuple { - - private static final long serialVersionUID = -1467756857377152573L; - - Tuple1(Object... values) { - super(values); - } - - /** - * Type-safe way to get the first object of this {@link Tuple}. - * - * @return The first object, cast to the correct type. - */ - @SuppressWarnings("unchecked") - public T1 getT1() { - return (T1) get(0); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/Tuple2.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/Tuple2.java deleted file mode 100644 index 1098936..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/Tuple2.java +++ /dev/null @@ -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.support.tuple; - -/** - * A tuple that holds two values - * - * @param The type of the first value held by this tuple - * @param The type of the second value held by this tuple - * - * @author Jon Brisbin - */ -public class Tuple2 extends Tuple1 { - - private static final long serialVersionUID = -565933838909569191L; - - Tuple2(Object... values) { - super(values); - } - - /** - * Type-safe way to get the second object of this {@link Tuple}. - * - * @return The second object, cast to the correct type. - */ - @SuppressWarnings("unchecked") - public T2 getT2() { - return (T2) get(1); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/Tuples.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/Tuples.java deleted file mode 100644 index 7a81c79..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/Tuples.java +++ /dev/null @@ -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.support.tuple; - -/** - * @author Artem Bilan - */ -public abstract class Tuples { - /** - * Create a {@link Tuple1} with the given object. - * - * @param t1 The first value in the tuple. - * @param The type of the first value. - * @return The new {@link Tuple1}. - */ - public static Tuple1 of(T1 t1) { - return new Tuple1(t1); - } - - /** - * Create a {@link Tuple2} with the given objects. - * - * @param t1 The first value in the tuple. - * @param t2 The second value in the tuple. - * @param The type of the first value. - * @param The type of the second value. - * @return The new {@link Tuple2}. - */ - public static Tuple2 of(T1 t1, T2 t2) { - return new Tuple2(t1, t2); - } - -} diff --git a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/package-info.java b/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/package-info.java deleted file mode 100644 index 65ad5a2..0000000 --- a/spring-integration-java-dsl/src/main/java/org/springframework/integration/dsl/support/tuple/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Tuples provide a type-safe way to specify multiple parameters. - */ -package org.springframework.integration.dsl.support.tuple; diff --git a/spring-integration-java-dsl/src/main/resources/META-INF/spring.factories b/spring-integration-java-dsl/src/main/resources/META-INF/spring.factories deleted file mode 100644 index d11f830..0000000 --- a/spring-integration-java-dsl/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.integration.config.IntegrationConfigurationInitializer=\ -org.springframework.integration.dsl.config.DslIntegrationConfigurationInitializer diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/amqp/AmqpTests.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/amqp/AmqpTests.java deleted file mode 100644 index cc08ff4..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/amqp/AmqpTests.java +++ /dev/null @@ -1,177 +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.test.amqp; - -import static org.hamcrest.Matchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.amqp.core.AmqpTemplate; -import org.springframework.amqp.core.AnonymousQueue; -import org.springframework.amqp.core.Queue; -import org.springframework.amqp.rabbit.connection.ConnectionFactory; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; -import org.springframework.integration.dsl.MessageProducers; -import org.springframework.integration.dsl.amqp.Amqp; -import org.springframework.integration.handler.ReplyRequiredException; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.PollableChannel; -import org.springframework.messaging.support.GenericMessage; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Artem Bilan - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class AmqpTests { - - @Autowired - private AmqpTemplate amqpTemplate; - - @Autowired - @Qualifier("queue") - private Queue amqpQueue; - - @Autowired - @Qualifier("amqpOutboundInput") - private MessageChannel amqpOutboundInput; - @Autowired - @Qualifier("amqpReplyChannel.channel") - private PollableChannel amqpReplyChannel; - - @Autowired - @Qualifier("amqpOutboundGatewayFlow.input") - private MessageChannel amqpOutboundGatewayFlowInput; - - @Test - public void testAmqpInboundGatewayFlow() throws Exception { - Object result = this.amqpTemplate.convertSendAndReceive(this.amqpQueue.getName(), "world"); - assertEquals("HELLO WORLD", result); - } - - @Test - public void testAmqpOutboundFlow() throws Exception { - this.amqpOutboundInput.send(MessageBuilder.withPayload("hello through the amqp") - .setHeader("routingKey", "foo") - .build()); - Message receive = null; - int i = 0; - do { - receive = this.amqpReplyChannel.receive(); - if (receive != null) { - break; - } - Thread.sleep(100); - i++; - } while (i < 10); - - assertNotNull(receive); - assertEquals("HELLO THROUGH THE AMQP", receive.getPayload()); - } - - @Test - public void testAmqpOutboundGatewayRequiresReply() { - try { - this.amqpOutboundGatewayFlowInput.send(new GenericMessage<>("foo")); - fail("ReplyRequiredException expected"); - } - catch (Exception e) { - assertThat(e, instanceOf(ReplyRequiredException.class)); - } - } - - @Configuration - @EnableAutoConfiguration - public static class ContextConfiguration { - - @Autowired - private ConnectionFactory rabbitConnectionFactory; - - @Bean - public RabbitTemplate rabbitTemplate() { - RabbitTemplate rabbitTemplate = new RabbitTemplate(this.rabbitConnectionFactory); - rabbitTemplate.setReplyTimeout(1000); - return rabbitTemplate; - } - - @Bean - public Queue queue() { - return new AnonymousQueue(); - } - - @Bean - public IntegrationFlow amqpFlow() { - return IntegrationFlows.from(Amqp.inboundGateway(this.rabbitConnectionFactory, queue())) - .transform("hello "::concat) - .transform(String.class, String::toUpperCase) - .get(); - } - - @Bean - public IntegrationFlow amqpOutboundFlow() { - return IntegrationFlows.from(Amqp.channel("amqpOutboundInput", this.rabbitConnectionFactory)) - .handle(Amqp.outboundAdapter(rabbitTemplate()).routingKeyExpression("headers.routingKey")) - .get(); - } - - @Bean - public Queue fooQueue() { - return new Queue("foo"); - } - - @Bean - public Queue amqpReplyChannel() { - return new Queue("amqpReplyChannel"); - } - - @Bean - public IntegrationFlow amqpInboundFlow() { - return IntegrationFlows.from((MessageProducers p) -> p.amqp(this.rabbitConnectionFactory, fooQueue())) - .transform(String.class, String::toUpperCase) - .channel(Amqp.pollableChannel(this.rabbitConnectionFactory) - .queueName("amqpReplyChannel") - .channelTransacted(true)) - .get(); - } - - @Bean - public IntegrationFlow amqpOutboundGatewayFlow() { - return f -> f.handleWithAdapter(a -> a.amqpGateway(rabbitTemplate()).routingKey("bar")); - } - - } - -} diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/event/EventTests.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/event/EventTests.java deleted file mode 100644 index 750021b..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/event/EventTests.java +++ /dev/null @@ -1,121 +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.test.event; - -import static org.hamcrest.Matchers.instanceOf; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationEvent; -import org.springframework.context.ApplicationListener; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.integration.channel.QueueChannel; -import org.springframework.integration.config.EnableIntegration; -import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; -import org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer; -import org.springframework.messaging.Message; -import org.springframework.messaging.PollableChannel; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Artem Bilan - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class EventTests { - - @Autowired - private ApplicationContext applicationContext; - - @Autowired - private PollableChannel resultsChannel; - - @Test - public void testRawApplicationEventListeningMessageProducer() { - this.applicationContext.publishEvent(new TestApplicationEvent1()); - Message receive = this.resultsChannel.receive(10000); - assertNotNull(receive); - assertThat(receive.getPayload(), instanceOf(TestApplicationEvent1.class)); - - this.applicationContext.publishEvent(new TestApplicationEvent2()); - receive = this.resultsChannel.receive(10000); - assertNotNull(receive); - assertThat(receive.getPayload(), instanceOf(TestApplicationEvent2.class)); - } - - @Configuration - @EnableIntegration - public static class ContextConfiguration { - - - @Bean - @SuppressWarnings("unchecked") - public ApplicationListener applicationListener() { - ApplicationEventListeningMessageProducer producer = new ApplicationEventListeningMessageProducer(); - producer.setEventTypes(TestApplicationEvent1.class); - producer.setOutputChannel(resultsChannel()); - return producer; - } - - - @Bean - public PollableChannel resultsChannel() { - return new QueueChannel(); - } - - @Bean - @SuppressWarnings("unchecked") - public IntegrationFlow eventProducerFlow() { - ApplicationEventListeningMessageProducer producer = new ApplicationEventListeningMessageProducer(); - producer.setEventTypes(TestApplicationEvent2.class); - - return IntegrationFlows.from(producer) - .channel(resultsChannel()) - .get(); - } - - } - - @SuppressWarnings("serial") - private static class TestApplicationEvent1 extends ApplicationEvent { - - public TestApplicationEvent1() { - super("TestApplicationEvent1"); - } - - } - - @SuppressWarnings("serial") - private static class TestApplicationEvent2 extends ApplicationEvent { - - public TestApplicationEvent2() { - super("TestApplicationEvent2"); - } - - } - -} diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/file/FileTests.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/file/FileTests.java deleted file mode 100644 index c48d6b3..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/file/FileTests.java +++ /dev/null @@ -1,261 +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.test.file; - -import static org.hamcrest.Matchers.endsWith; -import static org.hamcrest.Matchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.aop.TargetSource; -import org.springframework.aop.framework.Advised; -import org.springframework.beans.DirectFieldAccessor; -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.integration.annotation.IntegrationComponentScan; -import org.springframework.integration.annotation.MessagingGateway; -import org.springframework.integration.config.EnableIntegration; -import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; -import org.springframework.integration.dsl.MessageProducers; -import org.springframework.integration.dsl.channel.MessageChannels; -import org.springframework.integration.dsl.core.Pollers; -import org.springframework.integration.dsl.support.Transformers; -import org.springframework.integration.file.DefaultFileNameGenerator; -import org.springframework.integration.file.FileHeaders; -import org.springframework.integration.file.FileWritingMessageHandler; -import org.springframework.integration.file.tail.ApacheCommonsFileTailingMessageProducer; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.integration.test.util.TestUtils; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.MessageHandler; -import org.springframework.messaging.MessageHandlingException; -import org.springframework.messaging.PollableChannel; -import org.springframework.messaging.support.GenericMessage; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.util.StreamUtils; - -/** - * @author Artem Bilan - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class FileTests { - - private static final File tmpDir = new File(System.getProperty("java.io.tmpdir")); - - @Autowired - private ListableBeanFactory beanFactory; - - @Autowired - private ControlBusGateway controlBus; - - @Autowired - @Qualifier("fileFlow1Input") - private MessageChannel fileFlow1Input; - - @Autowired - @Qualifier("fileWriting.handler") - private MessageHandler fileWritingMessageHandler; - - @Autowired - @Qualifier("tailChannel") - private PollableChannel tailChannel; - - @Autowired - private ApacheCommonsFileTailingMessageProducer tailer; - - @Autowired - @Qualifier("fileReadingResultChannel") - private PollableChannel fileReadingResultChannel; - - @Autowired - @Qualifier("fileWritingInput") - private MessageChannel fileWritingInput; - - @Autowired - @Qualifier("fileWritingResultChannel") - private PollableChannel fileWritingResultChannel; - - @Test - public void testFileHandler() throws Exception { - Message message = MessageBuilder.withPayload("foo").setHeader(FileHeaders.FILENAME, "foo").build(); - try { - this.fileFlow1Input.send(message); - fail("NullPointerException expected"); - } - catch (Exception e) { - assertThat(e, instanceOf(MessageHandlingException.class)); - assertThat(e.getCause(), instanceOf(NullPointerException.class)); - } - DefaultFileNameGenerator fileNameGenerator = new DefaultFileNameGenerator(); - fileNameGenerator.setBeanFactory(this.beanFactory); - Object targetFileWritingMessageHandler = this.fileWritingMessageHandler; - if (this.fileWritingMessageHandler instanceof Advised) { - TargetSource targetSource = ((Advised) this.fileWritingMessageHandler).getTargetSource(); - if (targetSource != null) { - targetFileWritingMessageHandler = targetSource.getTarget(); - } - } - DirectFieldAccessor dfa = new DirectFieldAccessor(targetFileWritingMessageHandler); - dfa.setPropertyValue("fileNameGenerator", fileNameGenerator); - this.fileFlow1Input.send(message); - - assertTrue(new File(tmpDir, "foo").exists()); - } - - @Test - public void testMessageProducerFlow() throws Exception { - FileOutputStream file = new FileOutputStream(new File(tmpDir, "TailTest")); - for (int i = 0; i < 50; i++) { - file.write((i + "\n").getBytes()); - } - this.tailer.start(); - for (int i = 0; i < 50; i++) { - Message message = this.tailChannel.receive(5000); - assertNotNull(message); - assertEquals("hello " + i, message.getPayload()); - } - assertNull(this.tailChannel.receive(1)); - - this.controlBus.send("@tailer.stop()"); - file.close(); - } - - - @Test - public void testFileReadingFlow() throws Exception { - List evens = new ArrayList<>(25); - for (int i = 0; i < 50; i++) { - boolean even = i % 2 == 0; - String extension = even ? ".sitest" : ".foofile"; - if (even) { - evens.add(i); - } - FileOutputStream file = new FileOutputStream(new File(tmpDir, i + extension)); - file.write(("" + i).getBytes()); - file.flush(); - file.close(); - } - - Message message = fileReadingResultChannel.receive(10000); - assertNotNull(message); - Object payload = message.getPayload(); - assertThat(payload, instanceOf(List.class)); - @SuppressWarnings("unchecked") - List result = (List) payload; - assertEquals(25, result.size()); - result.forEach(s -> assertTrue(evens.contains(Integer.parseInt(s)))); - } - - @Test - public void testFileWritingFlow() throws Exception { - String payload = "Spring Integration"; - this.fileWritingInput.send(new GenericMessage<>(payload)); - Message receive = this.fileWritingResultChannel.receive(1000); - assertNotNull(receive); - assertThat(receive.getPayload(), instanceOf(File.class)); - File resultFile = (File) receive.getPayload(); - assertThat(resultFile.getAbsolutePath(), - endsWith(TestUtils.applySystemFileSeparator("fileWritingFlow/foo.sitest"))); - String fileContent = StreamUtils.copyToString(new FileInputStream(resultFile), Charset.defaultCharset()); - assertEquals(payload, fileContent); - } - - @MessagingGateway(defaultRequestChannel = "controlBus.input") - private static interface ControlBusGateway { - - void send(String command); - - } - - @Configuration - @EnableIntegration - @IntegrationComponentScan - public static class ContextConfiguration { - - @Bean - public IntegrationFlow controlBus() { - return f -> f.controlBus(); - } - - @Bean - public IntegrationFlow fileFlow1() { - return IntegrationFlows.from("fileFlow1Input") - .handleWithAdapter(h -> h.file(tmpDir).fileNameGenerator(message -> null) - , c -> c.id("fileWriting")) - .get(); - } - - @Bean - public IntegrationFlow tailFlow() { - return IntegrationFlows.from((MessageProducers p) -> p.tail(new File(tmpDir, "TailTest")) - .delay(500) - .end(false) - .id("tailer") - .autoStartup(false)) - .transform("hello "::concat) - .channel(MessageChannels.queue("tailChannel")) - .get(); - } - - @Bean - public IntegrationFlow fileReadingFlow() { - return IntegrationFlows - .from(s -> s.file(tmpDir).patternFilter("*.sitest"), - e -> e.poller(Pollers.fixedDelay(100))) - .transform(Transformers.fileToString()) - .aggregate(a -> a.correlationExpression("1") - .releaseStrategy(g -> g.size() == 25), null) - .channel(MessageChannels.queue("fileReadingResultChannel")) - .get(); - } - - @Bean - public IntegrationFlow fileWritingFlow() { - return IntegrationFlows.from("fileWritingInput") - .enrichHeaders(h -> h.header(FileHeaders.FILENAME, "foo.sitest") - .header("directory", new File(tmpDir, "fileWritingFlow"))) - .handleWithAdapter(a -> a.fileGateway(m -> m.getHeaders().get("directory"))) - .channel(MessageChannels.queue("fileWritingResultChannel")) - .get(); - } - - } - -} diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/flows/IntegrationFlowTests.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/flows/IntegrationFlowTests.java deleted file mode 100644 index 7b89955..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/flows/IntegrationFlowTests.java +++ /dev/null @@ -1,1400 +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.test.flows; - -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.instanceOf; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; - -import org.aopalliance.aop.Advice; -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; -import org.hamcrest.Matchers; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.BeanCreationException; -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.ApplicationListener; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.DependsOn; -import org.springframework.integration.IntegrationMessageHeaderAccessor; -import org.springframework.integration.MessageDispatchingException; -import org.springframework.integration.MessageRejectedException; -import org.springframework.integration.annotation.Header; -import org.springframework.integration.annotation.IntegrationComponentScan; -import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.MessagingGateway; -import org.springframework.integration.annotation.ServiceActivator; -import org.springframework.integration.channel.FixedSubscriberChannel; -import org.springframework.integration.channel.QueueChannel; -import org.springframework.integration.config.EnableIntegration; -import org.springframework.integration.context.IntegrationContextUtils; -import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; -import org.springframework.integration.dsl.channel.DirectChannelSpec; -import org.springframework.integration.dsl.channel.MessageChannels; -import org.springframework.integration.dsl.core.Pollers; -import org.springframework.integration.event.core.MessagingEvent; -import org.springframework.integration.event.outbound.ApplicationEventPublishingMessageHandler; -import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; -import org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice; -import org.springframework.integration.router.MethodInvokingRouter; -import org.springframework.integration.scheduling.PollerMetadata; -import org.springframework.integration.store.MessageStore; -import org.springframework.integration.store.SimpleMessageStore; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.integration.support.MutableMessageBuilder; -import org.springframework.integration.transformer.PayloadDeserializingTransformer; -import org.springframework.integration.transformer.PayloadSerializingTransformer; -import org.springframework.integration.xml.transformer.support.XPathExpressionEvaluatingHeaderValueMessageProcessor; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.MessageDeliveryException; -import org.springframework.messaging.MessageHandler; -import org.springframework.messaging.MessageHeaders; -import org.springframework.messaging.MessagingException; -import org.springframework.messaging.PollableChannel; -import org.springframework.messaging.SubscribableChannel; -import org.springframework.messaging.core.DestinationResolutionException; -import org.springframework.messaging.support.ErrorMessage; -import org.springframework.messaging.support.GenericMessage; -import org.springframework.scheduling.TaskScheduler; -import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Artem Bilan - * @author Tim Ysewyn - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class IntegrationFlowTests { - - @Autowired - private ListableBeanFactory beanFactory; - - @Autowired - private ControlBusGateway controlBus; - - @Autowired - @Qualifier("inputChannel") - private MessageChannel inputChannel; - - @Autowired - @Qualifier("discardChannel") - private PollableChannel discardChannel; - - @Autowired - @Qualifier("foo") - private SubscribableChannel foo; - - @Autowired - @Qualifier("successChannel") - private PollableChannel successChannel; - - @Autowired - @Qualifier("flow3Input") - private MessageChannel flow3Input; - - @Autowired - private AtomicReference eventHolder; - - @Autowired - @Qualifier("bridgeFlowInput") - private PollableChannel bridgeFlowInput; - - @Autowired - @Qualifier("bridgeFlowOutput") - private PollableChannel bridgeFlowOutput; - - @Autowired - @Qualifier("bridgeFlow2Input") - private MessageChannel bridgeFlow2Input; - - @Autowired - @Qualifier("bridgeFlow2Output") - private PollableChannel bridgeFlow2Output; - - @Autowired - @Qualifier("methodInvokingInput") - private MessageChannel methodInvokingInput; - - @Autowired - @Qualifier("delayedAdvice") - private DelayedAdvice delayedAdvice; - - @Autowired - @Qualifier("enricherInput") - private FixedSubscriberChannel enricherInput; - - @Autowired - @Qualifier("enricherInput2") - private FixedSubscriberChannel enricherInput2; - - @Autowired - @Qualifier("enricherInput3") - private FixedSubscriberChannel enricherInput3; - - @Autowired - @Qualifier("splitResequenceFlow.input") - private MessageChannel splitInput; - - @Autowired - @Qualifier("xpathHeaderEnricherInput") - private MessageChannel xpathHeaderEnricherInput; - - @Autowired - @Qualifier("splitAggregateInput") - private MessageChannel splitAggregateInput; - - @Autowired - @Qualifier("routerInput") - private MessageChannel routerInput; - - @Autowired - @Qualifier("oddChannel") - private PollableChannel oddChannel; - - @Autowired - @Qualifier("evenChannel") - private PollableChannel evenChannel; - - @Autowired - @Qualifier("routerMethodInput") - private MessageChannel routerMethodInput; - - @Autowired - @Qualifier("foo-channel") - private PollableChannel fooChannel; - - @Autowired - @Qualifier("bar-channel") - private PollableChannel barChannel; - - @Autowired - @Qualifier("routerMethod2Input") - private MessageChannel routerMethod2Input; - - @Autowired - @Qualifier("routeMethodInvocationFlow3.input") - private MessageChannel routerMethod3Input; - - @Autowired - @Qualifier("routerMultiInput") - private MessageChannel routerMultiInput; - - @Autowired - @Qualifier("recipientListInput") - private MessageChannel recipientListInput; - - @Autowired - @Qualifier("recipientListSubFlow1Result") - private PollableChannel recipientListSubFlow1Result; - - @Autowired - @Qualifier("recipientListSubFlow2Result") - private PollableChannel recipientListSubFlow2Result; - - @Autowired - @Qualifier("defaultOutputChannel") - private PollableChannel defaultOutputChannel; - - @Autowired - private MessageStore messageStore; - - @Autowired - @Qualifier("claimCheckInput") - private MessageChannel claimCheckInput; - - @Autowired - @Qualifier("lamdasInput") - private MessageChannel lamdasInput; - - @Autowired - @Qualifier("gatewayInput") - private MessageChannel gatewayInput; - - @Autowired - @Qualifier("gatewayError") - private PollableChannel gatewayError; - - @Test - public void testDirectFlow() { - assertTrue(this.beanFactory.containsBean("filter")); - assertTrue(this.beanFactory.containsBean("filter.handler")); - QueueChannel replyChannel = new QueueChannel(); - Message message = MessageBuilder.withPayload("100").setReplyChannel(replyChannel).build(); - try { - this.inputChannel.send(message); - fail("Expected MessageDispatchingException"); - } - catch (Exception e) { - assertThat(e, instanceOf(MessageDeliveryException.class)); - assertThat(e.getCause(), instanceOf(MessageDispatchingException.class)); - assertThat(e.getMessage(), containsString("Dispatcher has no subscribers")); - } - this.controlBus.send("@payloadSerializingTransformer.start()"); - - final AtomicBoolean used = new AtomicBoolean(); - - this.foo.subscribe(m -> used.set(true)); - - this.inputChannel.send(message); - Message reply = replyChannel.receive(5000); - assertNotNull(reply); - assertEquals(200, reply.getPayload()); - - Message successMessage = this.successChannel.receive(5000); - assertNotNull(successMessage); - assertEquals(100, successMessage.getPayload()); - - assertTrue(used.get()); - - this.inputChannel.send(new GenericMessage(1000)); - Message discarded = this.discardChannel.receive(5000); - assertNotNull(discarded); - assertEquals("Discarded: 1000", discarded.getPayload()); - } - - @Test - public void testHandle() { - assertNull(this.eventHolder.get()); - this.flow3Input.send(new GenericMessage<>("2")); - assertNotNull(this.eventHolder.get()); - assertEquals(4, this.eventHolder.get()); - } - - @Test - public void testBridge() { - GenericMessage message = new GenericMessage<>("test"); - this.bridgeFlowInput.send(message); - Message reply = this.bridgeFlowOutput.receive(5000); - assertNotNull(reply); - assertEquals("test", reply.getPayload()); - - assertTrue(this.beanFactory.containsBean("bridgeFlow2.channel#0")); - assertThat(this.beanFactory.getBean("bridgeFlow2.channel#0"), instanceOf(FixedSubscriberChannel.class)); - - try { - this.bridgeFlow2Input.send(message); - fail("Expected MessageDispatchingException"); - } - catch (Exception e) { - assertThat(e, instanceOf(MessageDeliveryException.class)); - assertThat(e.getCause(), instanceOf(MessageDispatchingException.class)); - assertThat(e.getMessage(), containsString("Dispatcher has no subscribers")); - } - this.controlBus.send("@bridge.start()"); - this.bridgeFlow2Input.send(message); - reply = this.bridgeFlow2Output.receive(5000); - assertNotNull(reply); - assertEquals("test", reply.getPayload()); - assertTrue(this.delayedAdvice.getInvoked()); - } - - @Autowired - @Qualifier("routerAsNonLastFlow.input") - private MessageChannel routerAsNonLastFlowChannel; - - @Autowired - @Qualifier("routerAsNonLastDefaultOutputChannel") - private PollableChannel routerAsNonLastDefaultOutputChannel; - - @Test - public void testRouterAsNonLastComponent() { - this.routerAsNonLastFlowChannel.send(new GenericMessage("Hello World")); - Message receive = this.routerAsNonLastDefaultOutputChannel.receive(1000); - assertNotNull(receive); - assertEquals("Hello World", receive.getPayload()); - } - - @Test - public void testWrongLastMessageChannel() { - ConfigurableApplicationContext context = null; - try { - context = new AnnotationConfigApplicationContext(InvalidLastMessageChannelFlowContext.class); - fail("BeanCreationException expected"); - } - catch (Exception e) { - assertThat(e, instanceOf(BeanCreationException.class)); - assertThat(e.getMessage(), containsString("'.fixedSubscriberChannel()' " + - "can't be the last EIP-method in the IntegrationFlow definition")); - } - finally { - if (context != null) { - context.close(); - } - } - } - - @Test - public void testMethodInvokingMessageHandler() { - QueueChannel replyChannel = new QueueChannel(); - Message message = MessageBuilder.withPayload("world") - .setHeader(MessageHeaders.REPLY_CHANNEL, replyChannel) - .build(); - this.methodInvokingInput.send(message); - Message receive = replyChannel.receive(5000); - assertNotNull(receive); - assertEquals("Hello World and world", receive.getPayload()); - } - - @Test - public void testLambdas() { - QueueChannel replyChannel = new QueueChannel(); - Message message = MessageBuilder.withPayload("World") - .setHeader(MessageHeaders.REPLY_CHANNEL, replyChannel) - .build(); - this.lamdasInput.send(message); - Message receive = replyChannel.receive(5000); - assertNotNull(receive); - assertEquals("Hello World", receive.getPayload()); - - message = MessageBuilder.withPayload("Spring") - .setHeader(MessageHeaders.REPLY_CHANNEL, replyChannel) - .build(); - - this.lamdasInput.send(message); - assertNull(replyChannel.receive(10)); - - } - - @Test - public void testWrongConfigurationWithSpecBean() { - ConfigurableApplicationContext context = null; - try { - context = new AnnotationConfigApplicationContext(InvalidConfigurationWithSpec.class); - fail("BeanCreationException expected"); - } - catch (Exception e) { - assertThat(e, instanceOf(IllegalArgumentException.class)); - assertThat(e.getCause(), instanceOf(BeanCreationException.class)); - assertThat(e.getCause().getMessage(), - containsString("must be populated to target objects via 'get()' method call")); - } - finally { - if (context != null) { - context.close(); - } - } - } - - @Test - public void testContentEnricher() { - QueueChannel replyChannel = new QueueChannel(); - Message message = MessageBuilder.withPayload(new TestPojo("Bar")) - .setHeader(MessageHeaders.REPLY_CHANNEL, replyChannel) - .build(); - this.enricherInput.send(message); - Message receive = replyChannel.receive(5000); - assertNotNull(receive); - assertEquals("Bar Bar", receive.getHeaders().get("foo")); - Object payload = receive.getPayload(); - assertThat(payload, instanceOf(TestPojo.class)); - TestPojo result = (TestPojo) payload; - assertEquals("Bar Bar", result.getName()); - assertNotNull(result.getDate()); - assertThat(new Date(), Matchers.greaterThanOrEqualTo(result.getDate())); - } - - @Test - public void testContentEnricher2() { - QueueChannel replyChannel = new QueueChannel(); - Message message = MessageBuilder.withPayload(new TestPojo("Bar")) - .setHeader(MessageHeaders.REPLY_CHANNEL, replyChannel) - .build(); - this.enricherInput2.send(message); - Message receive = replyChannel.receive(5000); - assertNotNull(receive); - assertNull(receive.getHeaders().get("foo")); - Object payload = receive.getPayload(); - assertThat(payload, instanceOf(TestPojo.class)); - TestPojo result = (TestPojo) payload; - assertEquals("Bar Bar", result.getName()); - assertNotNull(result.getDate()); - assertThat(new Date(), Matchers.greaterThanOrEqualTo(result.getDate())); - } - - @Test - public void testContentEnricher3() { - QueueChannel replyChannel = new QueueChannel(); - Message message = MessageBuilder.withPayload(new TestPojo("Bar")) - .setHeader(MessageHeaders.REPLY_CHANNEL, replyChannel) - .build(); - this.enricherInput3.send(message); - Message receive = replyChannel.receive(5000); - assertNotNull(receive); - assertEquals("Bar Bar", receive.getHeaders().get("foo")); - Object payload = receive.getPayload(); - assertThat(payload, instanceOf(TestPojo.class)); - TestPojo result = (TestPojo) payload; - assertEquals("Bar", result.getName()); - assertNull(result.getDate()); - } - - @Test - public void testSplitterResequencer() { - QueueChannel replyChannel = new QueueChannel(); - - this.splitInput.send(MessageBuilder.withPayload("") - .setReplyChannel(replyChannel) - .setHeader("foo", "bar") - .build()); - - for (int i = 0; i < 12; i++) { - Message receive = replyChannel.receive(2000); - assertNotNull(receive); - assertFalse(receive.getHeaders().containsKey("foo")); - assertTrue(receive.getHeaders().containsKey("FOO")); - assertEquals("BAR", receive.getHeaders().get("FOO")); - assertEquals(i + 1, receive.getPayload()); - } - } - - @Test - public void testSplitterAggregator() { - List payload = Arrays.asList('a', 'b', 'c', 'd', 'e'); - - QueueChannel replyChannel = new QueueChannel(); - this.splitAggregateInput.send(MessageBuilder.withPayload(payload) - .setReplyChannel(replyChannel) - .build()); - - Message receive = replyChannel.receive(2000); - assertNotNull(receive); - assertThat(receive.getPayload(), instanceOf(List.class)); - @SuppressWarnings("unchecked") - List result = (List) receive.getPayload(); - for (int i = 0; i < payload.size(); i++) { - assertEquals(payload.get(i), result.get(i)); - } - } - - @Test - public void testHeaderEnricher() { - QueueChannel replyChannel = new QueueChannel(); - - Message message = - MessageBuilder.withPayload("12") - .setReplyChannel(replyChannel) - .build(); - - try { - this.xpathHeaderEnricherInput.send(message); - fail("Expected MessageDispatchingException"); - } - catch (Exception e) { - assertThat(e, instanceOf(MessageDeliveryException.class)); - assertThat(e.getCause(), instanceOf(MessageDispatchingException.class)); - assertThat(e.getMessage(), containsString("Dispatcher has no subscribers")); - } - - this.controlBus.send("@xpathHeaderEnricher.start()"); - this.xpathHeaderEnricherInput.send(message); - - Message result = replyChannel.receive(2000); - assertNotNull(result); - MessageHeaders headers = result.getHeaders(); - assertEquals("1", headers.get("one")); - assertEquals("2", headers.get("two")); - assertThat(headers.getReplyChannel(), instanceOf(String.class)); - } - - @Test - public void testRouter() { - this.beanFactory.containsBean("routeFlow.subFlow#0.channel#0"); - - int[] payloads = new int[] {1, 2, 3, 4, 5, 6}; - - for (int payload : payloads) { - this.routerInput.send(new GenericMessage<>(payload)); - } - - for (int i = 0; i < 3; i++) { - Message receive = this.oddChannel.receive(2000); - assertNotNull(receive); - assertEquals(payloads[i * 2] * 3, receive.getPayload()); - - receive = this.evenChannel.receive(2000); - assertNotNull(receive); - assertEquals(payloads[i * 2 + 1], receive.getPayload()); - } - } - - @Autowired - @Qualifier("routerTwoSubFlows.input") - private MessageChannel routerTwoSubFlowsInput; - - @Autowired - @Qualifier("routerTwoSubFlowsOutput") - private PollableChannel routerTwoSubFlowsOutput; - - @Test - public void testRouterWithTwoSubflows() { - this.routerTwoSubFlowsInput.send(new GenericMessage(Arrays.asList(1, 2, 3, 4, 5, 6))); - Message receive = this.routerTwoSubFlowsOutput.receive(5000); - assertNotNull(receive); - Object payload = receive.getPayload(); - assertThat(payload, instanceOf(List.class)); - @SuppressWarnings("unchecked") - List results = (List) payload; - - assertArrayEquals(new Integer[] {3, 4, 9, 8, 15, 12}, results.toArray(new Integer[results.size()])); - } - - @Test - public void testMethodInvokingRouter() { - Message fooMessage = new GenericMessage<>("foo"); - Message barMessage = new GenericMessage<>("bar"); - Message badMessage = new GenericMessage<>("bad"); - - this.routerMethodInput.send(fooMessage); - - Message result1a = this.fooChannel.receive(2000); - assertNotNull(result1a); - assertEquals("foo", result1a.getPayload()); - assertNull(this.barChannel.receive(0)); - - this.routerMethodInput.send(barMessage); - assertNull(this.fooChannel.receive(0)); - Message result2b = this.barChannel.receive(2000); - assertNotNull(result2b); - assertEquals("bar", result2b.getPayload()); - - try { - this.routerMethodInput.send(badMessage); - fail("MessageDeliveryException expected."); - } - catch (MessageDeliveryException e) { - assertThat(e.getMessage(), - containsString("no channel resolved by router and no default output channel defined")); - } - - } - - @Test - public void testMethodInvokingRouter2() { - Message fooMessage = MessageBuilder.withPayload("foo").setHeader("targetChannel", "foo").build(); - Message barMessage = MessageBuilder.withPayload("bar").setHeader("targetChannel", "bar").build(); - Message badMessage = MessageBuilder.withPayload("bad").setHeader("targetChannel", "bad").build(); - - this.routerMethod2Input.send(fooMessage); - - Message result1a = this.fooChannel.receive(2000); - assertNotNull(result1a); - assertEquals("foo", result1a.getPayload()); - assertNull(this.barChannel.receive(0)); - - this.routerMethod2Input.send(barMessage); - assertNull(this.fooChannel.receive(0)); - Message result2b = this.barChannel.receive(2000); - assertNotNull(result2b); - assertEquals("bar", result2b.getPayload()); - - try { - this.routerMethod2Input.send(badMessage); - fail("DestinationResolutionException expected."); - } - catch (MessagingException e) { - assertThat(e.getCause(), instanceOf(DestinationResolutionException.class)); - assertThat(e.getCause().getMessage(), - containsString("failed to look up MessageChannel with name 'bad-channel'")); - } - - } - - @Test - public void testMethodInvokingRouter3() { - Message fooMessage = new GenericMessage<>("foo"); - Message barMessage = new GenericMessage<>("bar"); - Message badMessage = new GenericMessage<>("bad"); - - this.routerMethod3Input.send(fooMessage); - - Message result1a = this.fooChannel.receive(2000); - assertNotNull(result1a); - assertEquals("foo", result1a.getPayload()); - assertNull(this.barChannel.receive(0)); - - this.routerMethod3Input.send(barMessage); - assertNull(this.fooChannel.receive(0)); - Message result2b = this.barChannel.receive(2000); - assertNotNull(result2b); - assertEquals("bar", result2b.getPayload()); - - try { - this.routerMethod3Input.send(badMessage); - fail("DestinationResolutionException expected."); - } - catch (MessagingException e) { - assertThat(e.getCause(), instanceOf(DestinationResolutionException.class)); - assertThat(e.getCause().getMessage(), - containsString("failed to look up MessageChannel with name 'bad-channel'")); - } - } - - @Test - public void testMultiRouter() { - - Message fooMessage = new GenericMessage<>("foo"); - Message barMessage = new GenericMessage<>("bar"); - Message badMessage = new GenericMessage<>("bad"); - - this.routerMultiInput.send(fooMessage); - Message result1a = this.fooChannel.receive(2000); - assertNotNull(result1a); - assertEquals("foo", result1a.getPayload()); - Message result1b = this.barChannel.receive(2000); - assertNotNull(result1b); - assertEquals("foo", result1b.getPayload()); - - this.routerMultiInput.send(barMessage); - Message result2a = this.fooChannel.receive(2000); - assertNotNull(result2a); - assertEquals("bar", result2a.getPayload()); - Message result2b = this.barChannel.receive(2000); - assertNotNull(result2b); - assertEquals("bar", result2b.getPayload()); - - try { - this.routerMultiInput.send(badMessage); - fail("MessageDeliveryException expected."); - } - catch (MessageDeliveryException e) { - assertThat(e.getMessage(), - containsString("no channel resolved by router and no default output channel defined")); - } - } - - @Test - public void testRecipientListRouter() { - - Message fooMessage = MessageBuilder.withPayload("fooPayload").setHeader("recipient", true).build(); - Message barMessage = MessageBuilder.withPayload("barPayload").setHeader("recipient", true).build(); - Message bazMessage = new GenericMessage<>("baz"); - Message badMessage = new GenericMessage<>("badPayload"); - - this.recipientListInput.send(fooMessage); - Message result1a = this.fooChannel.receive(2000); - assertNotNull(result1a); - assertEquals("foo", result1a.getPayload()); - Message result1b = this.barChannel.receive(2000); - assertNotNull(result1b); - assertEquals("foo", result1b.getPayload()); - Message result1c = this.recipientListSubFlow1Result.receive(2000); - assertNotNull(result1c); - assertEquals("FOO", result1c.getPayload()); - assertNull(this.recipientListSubFlow2Result.receive(0)); - - this.recipientListInput.send(barMessage); - assertNull(this.fooChannel.receive(0)); - assertNull(this.recipientListSubFlow2Result.receive(0)); - Message result2b = this.barChannel.receive(2000); - assertNotNull(result2b); - assertEquals("bar", result2b.getPayload()); - Message result2c = this.recipientListSubFlow1Result.receive(2000); - assertNotNull(result1c); - assertEquals("BAR", result2c.getPayload()); - - this.recipientListInput.send(bazMessage); - assertNull(this.fooChannel.receive(0)); - assertNull(this.barChannel.receive(0)); - Message result3c = this.recipientListSubFlow1Result.receive(2000); - assertNotNull(result3c); - assertEquals("BAZ", result3c.getPayload()); - Message result4c = this.recipientListSubFlow2Result.receive(2000); - assertNotNull(result4c); - assertEquals("Hello baz", result4c.getPayload()); - - this.recipientListInput.send(badMessage); - assertNull(this.fooChannel.receive(0)); - assertNull(this.barChannel.receive(0)); - assertNull(this.recipientListSubFlow1Result.receive(0)); - assertNull(this.recipientListSubFlow2Result.receive(0)); - Message resultD = this.defaultOutputChannel.receive(2000); - assertNotNull(resultD); - assertEquals("bad", resultD.getPayload()); - } - - @Test - public void testClaimCheck() { - QueueChannel replyChannel = new QueueChannel(); - - Message message = MutableMessageBuilder.withPayload("foo").setReplyChannel(replyChannel).build(); - - this.claimCheckInput.send(message); - - Message receive = replyChannel.receive(2000); - assertNotNull(receive); - assertSame(message, receive); - - assertEquals(1, this.messageStore.getMessageCount()); - assertSame(message, this.messageStore.getMessage(message.getHeaders().getId())); - } - - @Test - public void testGatewayFlow() throws Exception { - PollableChannel replyChannel = new QueueChannel(); - Message message = MessageBuilder.withPayload("foo").setReplyChannel(replyChannel).build(); - - this.gatewayInput.send(message); - - Message receive = replyChannel.receive(2000); - assertNotNull(receive); - assertEquals("From Gateway SubFlow: FOO", receive.getPayload()); - assertNull(this.gatewayError.receive(1)); - - message = MessageBuilder.withPayload("bar").setReplyChannel(replyChannel).build(); - - this.gatewayInput.send(message); - - receive = replyChannel.receive(1); - assertNull(receive); - - receive = this.gatewayError.receive(2000); - assertNotNull(receive); - assertThat(receive, instanceOf(ErrorMessage.class)); - assertThat(receive.getPayload(), instanceOf(MessageRejectedException.class)); - assertThat(((Exception) receive.getPayload()).getMessage(), containsString("' rejected Message")); - } - - @Autowired - @Qualifier("subscribersFlow.input") - private MessageChannel subscribersFlowInput; - - @Autowired - @Qualifier("subscriber1Results") - private PollableChannel subscriber1Results; - - @Autowired - @Qualifier("subscriber2Results") - private PollableChannel subscriber2Results; - - @Autowired - @Qualifier("subscriber3Results") - private PollableChannel subscriber3Results; - - @Test - public void testSubscribersSubFlows() { - this.subscribersFlowInput.send(new GenericMessage(2)); - - Message receive1 = this.subscriber1Results.receive(5000); - assertNotNull(receive1); - assertEquals(1, receive1.getPayload()); - - Message receive2 = this.subscriber2Results.receive(5000); - assertNotNull(receive2); - assertEquals(4, receive2.getPayload()); - Message receive3 = this.subscriber3Results.receive(5000); - assertNotNull(receive3); - assertEquals(6, receive3.getPayload()); - } - - @MessagingGateway(defaultRequestChannel = "controlBus") - private static interface ControlBusGateway { - - void send(String command); - } - - @Configuration - @EnableIntegration - @IntegrationComponentScan - public static class ContextConfiguration { - - @Bean - public IntegrationFlow controlBusFlow() { - return IntegrationFlows.from("controlBus").controlBus().get(); - } - - @Bean(name = PollerMetadata.DEFAULT_POLLER) - public PollerMetadata poller() { - return Pollers.fixedRate(500).maxMessagesPerPoll(1).get(); - } - - @Bean(name = IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME) - public TaskScheduler taskScheduler() { - ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler(); - threadPoolTaskScheduler.setPoolSize(100); - return threadPoolTaskScheduler; - } - - @Bean - public MessageChannel inputChannel() { - return MessageChannels.direct().get(); - } - - @Bean - public MessageChannel foo() { - return MessageChannels.publishSubscribe().get(); - } - - @Bean - public IntegrationFlow routerAsNonLastFlow() { - return f -> f.route(p -> p, r -> r.resolutionRequired(false)) - .channel(MessageChannels.queue("routerAsNonLastDefaultOutputChannel")); - } - - } - - @Configuration - @ComponentScan - public static class ContextConfiguration2 { - - @Autowired - @Qualifier("inputChannel") - private MessageChannel inputChannel; - - @Autowired - @Qualifier("successChannel") - private PollableChannel successChannel; - - - @Bean - public Advice expressionAdvice() { - ExpressionEvaluatingRequestHandlerAdvice advice = new ExpressionEvaluatingRequestHandlerAdvice(); - advice.setOnSuccessExpression("payload"); - advice.setSuccessChannel(this.successChannel); - return advice; - } - - @Bean - public IntegrationFlow flow2() { - return IntegrationFlows.from(this.inputChannel) - .filter(p -> p instanceof String, e -> e - .id("filter") - .discardFlow(df -> df - .transform(String.class, "Discarded: "::concat) - .channel(c -> c.queue("discardChannel")))) - .channel("foo") - .fixedSubscriberChannel() - .transform(Integer::parseInt) - .transform(new PayloadSerializingTransformer(), - c -> c.autoStartup(false).id("payloadSerializingTransformer")) - .channel(MessageChannels.queue(new SimpleMessageStore(), "fooQueue")) - .transform(new PayloadDeserializingTransformer()) - .channel(publishSubscribeChannel()) - .transform((Integer p) -> p * 2, c -> c.advice(this.expressionAdvice())) - .get(); - } - - @Bean - public MessageChannel publishSubscribeChannel() { - return MessageChannels.publishSubscribe().get(); - } - - @Bean - public IntegrationFlow subscribersFlow() { - return flow -> flow - .publishSubscribeChannel(Executors.newCachedThreadPool(), s -> s - .subscribe(f -> f - .handle((p, h) -> p / 2) - .channel(c -> c.queue("subscriber1Results"))) - .subscribe(f -> f - .handle((p, h) -> p * 2) - .channel(c -> c.queue("subscriber2Results")))) - .handle((p, h) -> p * 3) - .channel(c -> c.queue("subscriber3Results")); - } - - } - - @MessageEndpoint - public static class AnnotationTestService { - - @ServiceActivator(inputChannel = "publishSubscribeChannel") - public void handle(Object payload) { - assertEquals(100, payload); - } - } - - @Configuration - public static class ContextConfiguration3 { - - @Autowired - @Qualifier("delayedAdvice") - private MethodInterceptor delayedAdvice; - - @Bean - public QueueChannel successChannel() { - return MessageChannels.queue().get(); - } - - @Bean - public AtomicReference eventHolder() { - return new AtomicReference<>(); - } - - @Bean - public ApplicationListener eventListener() { - return new ApplicationListener() { - - @Override - public void onApplicationEvent(MessagingEvent event) { - eventHolder().set(event.getMessage().getPayload()); - } - - }; - } - - @Bean - public IntegrationFlow flow3() { - return IntegrationFlows.from("flow3Input") - .handle(Integer.class, (p, h) -> p * 2) - .handle(new ApplicationEventPublishingMessageHandler()) - .get(); - } - - @Bean - public IntegrationFlow bridgeFlow() { - return IntegrationFlows.from(MessageChannels.queue("bridgeFlowInput")) - .channel(MessageChannels.queue("bridgeFlowOutput")) - .get(); - } - - @Bean - public IntegrationFlow bridgeFlow2() { - return IntegrationFlows.from("bridgeFlow2Input") - .bridge(c -> c.autoStartup(false).id("bridge")) - .fixedSubscriberChannel() - .delay("delayer", "200", c -> c.advice(this.delayedAdvice).messageStore(this.messageStore())) - .channel(c -> c.queue("bridgeFlow2Output")) - .get(); - } - - @Bean - public SimpleMessageStore messageStore() { - return new SimpleMessageStore(); - } - - @Bean - public IntegrationFlow claimCheckFlow() { - return IntegrationFlows.from("claimCheckInput") - .claimCheckIn(this.messageStore()) - .claimCheckOut(this.messageStore()) - .get(); - } - - @Bean(name = "foo-channel") - public MessageChannel fooChannel() { - return new QueueChannel(); - } - - @Bean(name = "bar-channel") - public MessageChannel barChannel() { - return new QueueChannel(); - } - - @Bean - public MessageChannel defaultOutputChannel() { - return new QueueChannel(); - } - - @Bean - public IntegrationFlow recipientListFlow() { - return IntegrationFlows.from("recipientListInput") - .transform(p -> p.replaceFirst("Payload", "")) - .routeToRecipients(r -> r - .recipient("foo-channel", "'foo' == payload") - .recipient("bar-channel", m -> - m.getHeaders().containsKey("recipient") - && (boolean) m.getHeaders().get("recipient")) - .recipientFlow("'foo' == payload or 'bar' == payload or 'baz' == payload", - f -> f.transform(String.class, p -> p.toUpperCase()) - .channel(c -> c.queue("recipientListSubFlow1Result"))) - .recipientFlow(m -> "baz".equals(m.getPayload()), - f -> f.transform("Hello "::concat) - .channel(c -> c.queue("recipientListSubFlow2Result")))) - .channel("defaultOutputChannel") - .get(); - } - } - - @Component("delayedAdvice") - public static class DelayedAdvice implements MethodInterceptor { - - private final AtomicBoolean invoked = new AtomicBoolean(); - - @Override - public Object invoke(MethodInvocation invocation) throws Throwable { - this.invoked.set(true); - return invocation.proceed(); - } - - public Boolean getInvoked() { - return invoked.get(); - } - - } - - @Configuration - public static class ContextConfiguration4 { - - @Autowired - @Qualifier("integrationFlowTests.GreetingService") - private MessageHandler greetingService; - - @Bean - public IntegrationFlow methodInvokingFlow() { - return IntegrationFlows.from("methodInvokingInput") - .handle(this.greetingService) - .get(); - } - - @Bean - public IntegrationFlow lamdasFlow() { - return IntegrationFlows.from("lamdasInput") - .filter("World"::equals) - .transform("Hello "::concat) - .get(); - } - - @Bean - @DependsOn("enrichFlow") - public IntegrationFlow enricherFlow() { - return IntegrationFlows.from("enricherInput", true) - .enrich(e -> e.requestChannel("enrichChannel") - .requestPayloadExpression("payload") - .shouldClonePayload(false) - .propertyExpression("name", "payload['name']") - .propertyFunction("date", m -> new Date()) - .headerExpression("foo", "payload['name']") - ) - .get(); - } - - @Bean - @DependsOn("enrichFlow") - public IntegrationFlow enricherFlow2() { - return IntegrationFlows.from("enricherInput2", true) - .enrich(e -> e.requestChannel("enrichChannel") - .requestPayloadExpression("payload") - .shouldClonePayload(false) - .propertyExpression("name", "payload['name']") - .propertyExpression("date", "new java.util.Date()") - ) - .get(); - } - - @Bean - @DependsOn("enrichFlow") - public IntegrationFlow enricherFlow3() { - return IntegrationFlows.from("enricherInput3", true) - .enrich(e -> e.requestChannel("enrichChannel") - .requestPayload(Message::getPayload) - .shouldClonePayload(false) - .>headerFunction("foo", m -> m.getPayload().get("name"))) - .get(); - } - - @Bean - public IntegrationFlow enrichFlow() { - return IntegrationFlows.from("enrichChannel") - .>transform(p -> Collections.singletonMap("name", p.getName() + " Bar")) - .get(); - } - - @Bean - public Executor taskExecutor() { - return Executors.newCachedThreadPool(); - } - - @Bean - public TestSplitterPojo testSplitterData() { - List first = new ArrayList<>(); - first.add("1,2,3"); - first.add("4,5,6"); - - List second = new ArrayList<>(); - second.add("7,8,9"); - second.add("10,11,12"); - - return new TestSplitterPojo(first, second); - } - - @Bean - public IntegrationFlow splitResequenceFlow() { - return f -> f.enrichHeaders(s -> s.header("FOO", "BAR")) - .split("testSplitterData", "buildList", c -> c.applySequence(false)) - .channel(c -> c.executor(this.taskExecutor())) - .split(Message.class, target -> (List) target.getPayload(), c -> c.applySequence(false)) - .channel(MessageChannels.executor(this.taskExecutor())) - .split(s -> s.applySequence(false).get().getT2().setDelimiters(",")) - .channel(c -> c.executor(this.taskExecutor())) - .transform(Integer::parseInt) - .enrichHeaders(h -> - h.headerFunction(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, Message::getPayload)) - .resequence(r -> r.releasePartialSequences(true).correlationExpression("'foo'"), null) - .headerFilter("foo", false); - } - - @Bean - public IntegrationFlow splitAggregateFlow() { - return IntegrationFlows.from("splitAggregateInput", true) - .split() - .channel(MessageChannels.executor(this.taskExecutor())) - .resequence() - .aggregate() - .get(); - } - - @Bean - public IntegrationFlow xpathHeaderEnricherFlow() { - return IntegrationFlows.from("xpathHeaderEnricherInput") - .enrichHeaders( - s -> s.header("one", - new XPathExpressionEvaluatingHeaderValueMessageProcessor("/root/elementOne")) - .header("two", - new XPathExpressionEvaluatingHeaderValueMessageProcessor("/root/elementTwo")) - .headerChannelsToString(), - c -> c.autoStartup(false).id("xpathHeaderEnricher") - ) - .get(); - } - - @Bean - public QueueChannel evenChannel() { - return new QueueChannel(); - } - - @Bean - public IntegrationFlow routeFlow() { - return IntegrationFlows.from("routerInput") - .route(p -> p % 2 == 0, - m -> m.channelMapping("true", "evenChannel") - .subFlowMapping("false", f -> - f.handle((p, h) -> p * 3))) - .channel(c -> c.queue("oddChannel")) - .get(); - } - - - @Bean - public IntegrationFlow routerTwoSubFlows() { - return f -> f - .split() - .route(p -> p % 2 == 0, m -> m - .subFlowMapping("true", sf -> sf.handle((p, h) -> p * 2)) - .subFlowMapping("false", sf -> sf.handle((p, h) -> p * 3))) - .aggregate() - .channel(c -> c.queue("routerTwoSubFlowsOutput")); - } - - @Bean - public RoutingTestBean routingTestBean() { - return new RoutingTestBean(); - } - - @Bean - public IntegrationFlow routeMethodInvocationFlow() { - return IntegrationFlows.from("routerMethodInput") - .route("routingTestBean", "routeMessage") - .get(); - } - - @Bean - public IntegrationFlow routeMethodInvocationFlow2() { - return IntegrationFlows.from("routerMethod2Input") - .route(new MethodInvokingRouter(new RoutingTestBean(), "routeByHeader")) - .get(); - } - - @Bean - public IntegrationFlow routeMethodInvocationFlow3() { - return f -> f.route((String p) -> ContextConfiguration4.this.routingTestBean().routePayload(p)); - } - - @Bean - public IntegrationFlow routeMultiMethodInvocationFlow() { - return IntegrationFlows.from("routerMultiInput") - .route(String.class, p -> p.equals("foo") || p.equals("bar") ? new String[] {"foo", "bar"} : null, - s -> s.suffix("-channel")) - .get(); - } - - @Bean - @DependsOn("gatewayRequestFlow") - public IntegrationFlow gatewayFlow() { - return IntegrationFlows.from("gatewayInput") - .gateway("gatewayRequest", g -> g.errorChannel("gatewayError").replyTimeout(10L)) - .gateway(f -> f.transform("From Gateway SubFlow: "::concat)) - .get(); - } - - @Bean - public IntegrationFlow gatewayRequestFlow() { - return IntegrationFlows.from("gatewayRequest") - .filter("foo"::equals, f -> f.throwExceptionOnRejection(true)) - .transform(String::toUpperCase) - .get(); - } - - @Bean - public MessageChannel gatewayError() { - return MessageChannels.queue().get(); - } - - } - - private static class RoutingTestBean { - - public String routePayload(String name) { - return name + "-channel"; - } - - public String routeByHeader(@Header("targetChannel") String name) { - return name + "-channel"; - } - - public String routeMessage(Message message) { - if (message.getPayload().equals("foo")) { - return "foo-channel"; - } - else if (message.getPayload().equals("bar")) { - return "bar-channel"; - } - return null; - } - } - - @Service - public static class GreetingService extends AbstractReplyProducingMessageHandler { - - @Autowired - private WorldService worldService; - - @Override - protected Object handleRequestMessage(Message requestMessage) { - return "Hello " + this.worldService.world() + " and " + requestMessage.getPayload(); - } - } - - @Service - public static class WorldService { - - public String world() { - return "World"; - } - } - - - private static class InvalidLastMessageChannelFlowContext { - - @Bean - public IntegrationFlow wrongLastComponent() { - return IntegrationFlows.from(MessageChannels.direct()) - .fixedSubscriberChannel() - .get(); - } - - } - - @EnableIntegration - public static class InvalidConfigurationWithSpec { - - @Bean - public DirectChannelSpec invalidBean() { - return MessageChannels.direct(); - } - - } - - private static class TestPojo { - - private String name; - - private Date date; - - private TestPojo(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Date getDate() { - return date; - } - - public void setDate(Date date) { - this.date = date; - } - - } - - private static class TestSplitterPojo { - - final List first; - - final List second; - - private TestSplitterPojo(List first, List second) { - this.first = first; - this.second = second; - } - - public List getFirst() { - return first; - } - - public List getSecond() { - return second; - } - - public List> buildList() { - return Arrays.asList(this.first, this.second); - } - - } - -} - diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/ftp/FtpTests.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/ftp/FtpTests.java deleted file mode 100644 index 84d1d82..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/ftp/FtpTests.java +++ /dev/null @@ -1,259 +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.test.ftp; - -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.Matchers.isOneOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; - -import java.io.File; -import java.util.List; -import java.util.regex.Matcher; - -import javax.management.MBeanServer; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; - -import org.apache.commons.net.ftp.FTPFile; -import org.hamcrest.Matchers; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.ConfigFileApplicationContextInitializer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.integration.annotation.IntegrationComponentScan; -import org.springframework.integration.annotation.MessagingGateway; -import org.springframework.integration.channel.QueueChannel; -import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; -import org.springframework.integration.dsl.channel.MessageChannels; -import org.springframework.integration.dsl.core.Pollers; -import org.springframework.integration.dsl.ftp.Ftp; -import org.springframework.integration.dsl.sftp.Sftp; -import org.springframework.integration.dsl.test.sftp.TestSftpServer; -import org.springframework.integration.file.FileHeaders; -import org.springframework.integration.file.remote.RemoteFileTemplate; -import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway; -import org.springframework.integration.ftp.session.DefaultFtpSessionFactory; -import org.springframework.integration.scheduling.PollerMetadata; -import org.springframework.integration.sftp.session.DefaultSftpSessionFactory; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.MessageHandler; -import org.springframework.messaging.PollableChannel; -import org.springframework.messaging.support.GenericMessage; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Artem Bilan - */ -@ContextConfiguration(initializers = ConfigFileApplicationContextInitializer.class) -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class FtpTests { - - @Autowired - private ControlBusGateway controlBus; - - @Autowired - private MBeanServer mBeanServer; - - @Autowired - private TestFtpServer ftpServer; - - @Autowired - private DefaultFtpSessionFactory ftpSessionFactory; - - @Autowired - @Qualifier("ftpInboundResultChannel") - private PollableChannel ftpInboundResultChannel; - - @Autowired - @Qualifier("toFtpChannel") - private MessageChannel toFtpChannel; - - @Autowired - @Qualifier("ftpMgetInputChannel") - private MessageChannel ftpMgetInputChannel; - - @Autowired - @Qualifier("remoteFileOutputChannel") - private PollableChannel remoteFileOutputChannel; - - @Before - @After - public void setupRemoteFileServers() { - this.ftpServer.recursiveDelete(this.ftpServer.getTargetLocalDirectory()); - this.ftpServer.recursiveDelete(this.ftpServer.getTargetFtpDirectory()); - } - - @Test - public void testFtpInboundFlow() { - this.controlBus.send("@ftpInboundAdapter.start()"); - - Message message = this.ftpInboundResultChannel.receive(1000); - assertNotNull(message); - Object payload = message.getPayload(); - assertThat(payload, instanceOf(File.class)); - File file = (File) payload; - assertThat(file.getName(), isOneOf("FTPSOURCE1.TXT.a", "FTPSOURCE2.TXT.a")); - assertThat(file.getAbsolutePath(), containsString("ftpTest")); - - message = this.ftpInboundResultChannel.receive(1000); - assertNotNull(message); - file = (File) message.getPayload(); - assertThat(file.getName(), isOneOf("FTPSOURCE1.TXT.a", "FTPSOURCE2.TXT.a")); - assertThat(file.getAbsolutePath(), containsString("ftpTest")); - - this.controlBus.send("@ftpInboundAdapter.stop()"); - } - - @Test - public void testFtpOutboundFlow() { - String fileName = "foo.file"; - this.toFtpChannel.send(MessageBuilder.withPayload("foo") - .setHeader(FileHeaders.FILENAME, fileName) - .build()); - - RemoteFileTemplate template = new RemoteFileTemplate<>(this.ftpSessionFactory); - FTPFile[] files = template.execute(session -> - session.list(this.ftpServer.getTargetFtpDirectory().getName() + "/" + fileName)); - assertEquals(1, files.length); - assertEquals(3, files[0].getSize()); - } - - @Test - @SuppressWarnings("unchecked") - public void testFtpMgetFlow() { - String dir = "ftpSource/"; - this.ftpMgetInputChannel.send(new GenericMessage(dir + "*")); - Message result = this.remoteFileOutputChannel.receive(1000); - assertNotNull(result); - List localFiles = (List) result.getPayload(); - // should have filtered ftpSource2.txt - assertEquals(2, localFiles.size()); - - for (File file : localFiles) { - assertThat(file.getPath().replaceAll(Matcher.quoteReplacement(File.separator), "/"), - Matchers.containsString(dir)); - } - assertThat(localFiles.get(1).getPath().replaceAll(Matcher.quoteReplacement(File.separator), "/"), - Matchers.containsString(dir + "subFtpSource")); - } - - @Test - public void testMBeansForDSL() throws MalformedObjectNameException { - assertFalse(this.mBeanServer.queryMBeans(ObjectName.getInstance("org.springframework.integration:" + - "type=MessageHandler,name=ftpMgetInputChannel,bean=anonymous"), null).isEmpty()); - } - - - @MessagingGateway(defaultRequestChannel = "controlBus.input") - private static interface ControlBusGateway { - - void send(String command); - - } - - @Configuration - @Import(TestFtpServer.class) - @EnableAutoConfiguration - @IntegrationComponentScan - public static class ContextConfiguration { - - @Autowired - private TestFtpServer ftpServer; - - @Autowired - private DefaultFtpSessionFactory ftpSessionFactory; - - @Bean(name = PollerMetadata.DEFAULT_POLLER) - public PollerMetadata poller() { - return Pollers.fixedRate(500).maxMessagesPerPoll(1).get(); - } - - @Bean - public IntegrationFlow controlBus() { - return f -> f.controlBus(); - } - - @Bean - public IntegrationFlow ftpInboundFlow() { - return IntegrationFlows - .from(s -> s.ftp(this.ftpSessionFactory) - .preserveTimestamp(true) - .remoteDirectory("ftpSource") - .regexFilter(".*\\.txt$") - .localFilename(f -> f.toUpperCase() + ".a") - .localDirectory(this.ftpServer.getTargetLocalDirectory()), - e -> e.id("ftpInboundAdapter").autoStartup(false)) - .channel(MessageChannels.queue("ftpInboundResultChannel")) - .get(); - } - - @Bean - public IntegrationFlow ftpOutboundFlow() { - return IntegrationFlows.from("toFtpChannel") - .handle(Ftp.outboundAdapter(this.ftpSessionFactory) - .useTemporaryFileName(false) - .fileNameExpression("headers['" + FileHeaders.FILENAME + "']") - .remoteDirectory(this.ftpServer.getTargetFtpDirectory().getName()) - ).get(); - } - - @Bean - public PollableChannel remoteFileOutputChannel() { - return new QueueChannel(); - } - - @Bean - public MessageHandler ftpOutboundGateway() { - return Ftp.outboundGateway(this.ftpSessionFactory, AbstractRemoteFileOutboundGateway.Command.MGET, - "payload") - .options(AbstractRemoteFileOutboundGateway.Option.RECURSIVE) - .regexFileNameFilter("(subFtpSource|.*1.txt)") - .localDirectoryExpression("@ftpServer.targetLocalDirectoryName + #remoteDirectory") - .localFilenameExpression("#remoteFileName.replaceFirst('ftpSource', 'localTarget')") - .get(); - } - - @Bean - public IntegrationFlow ftpMGetFlow() { - return IntegrationFlows.from("ftpMgetInputChannel") - .handle(ftpOutboundGateway()) - .channel(remoteFileOutputChannel()) - .get(); - } - - } - -} diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/ftp/TestFtpServer.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/ftp/TestFtpServer.java deleted file mode 100644 index d57eb83..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/ftp/TestFtpServer.java +++ /dev/null @@ -1,253 +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.test.ftp; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Arrays; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; - -import org.apache.ftpserver.FtpServer; -import org.apache.ftpserver.FtpServerFactory; -import org.apache.ftpserver.ftplet.Authentication; -import org.apache.ftpserver.ftplet.AuthenticationFailedException; -import org.apache.ftpserver.ftplet.FtpException; -import org.apache.ftpserver.ftplet.User; -import org.apache.ftpserver.ftplet.UserManager; -import org.apache.ftpserver.listener.ListenerFactory; -import org.apache.ftpserver.usermanager.impl.BaseUser; -import org.apache.ftpserver.usermanager.impl.ConcurrentLoginPermission; -import org.apache.ftpserver.usermanager.impl.TransferRatePermission; -import org.apache.ftpserver.usermanager.impl.WritePermission; -import org.junit.rules.TemporaryFolder; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.integration.ftp.session.DefaultFtpSessionFactory; -import org.springframework.integration.test.util.SocketUtils; - -/** - * Embedded FTP Server for test cases; exposes an associated session factory - * as a @Bean. - * - * @author Artem Bilan - * @author Gary Russell - */ -@Configuration("ftpServer") -public class TestFtpServer { - - private final int ftpPort = SocketUtils.findAvailableServerSocket(); - - private final TemporaryFolder ftpFolder; - - private final TemporaryFolder localFolder; - - private volatile File ftpRootFolder; - - private volatile File sourceFtpDirectory; - - private volatile File targetFtpDirectory; - - private volatile File sourceLocalDirectory; - - private volatile File targetLocalDirectory; - - private volatile FtpServer server; - - public TestFtpServer() { - this.ftpFolder = new TemporaryFolder() { - - @Override - public void create() throws IOException { - super.create(); - ftpRootFolder = this.newFolder("ftpTest"); - sourceFtpDirectory = new File(ftpRootFolder, "ftpSource"); - sourceFtpDirectory.mkdir(); - File file = new File(sourceFtpDirectory, "ftpSource1.txt"); - file.createNewFile(); - FileOutputStream fos = new FileOutputStream(file); - fos.write("source1".getBytes()); - fos.close(); - file = new File(sourceFtpDirectory, "ftpSource2.txt"); - file.createNewFile(); - fos = new FileOutputStream(file); - fos.write("source2".getBytes()); - fos.close(); - - File subSourceFtpDirectory = new File(sourceFtpDirectory, "subFtpSource"); - subSourceFtpDirectory.mkdir(); - file = new File(subSourceFtpDirectory, "subFtpSource1.txt"); - file.createNewFile(); - fos = new FileOutputStream(file); - fos.write("subSource1".getBytes()); - fos.close(); - - targetFtpDirectory = new File(ftpRootFolder, "ftpTarget"); - targetFtpDirectory.mkdir(); - } - }; - - this.localFolder = new TemporaryFolder() { - - @Override - public void create() throws IOException { - super.create(); - File rootFolder = this.newFolder("ftpTest"); - sourceLocalDirectory = new File(rootFolder, "localSource"); - sourceLocalDirectory.mkdirs(); - File file = new File(sourceLocalDirectory, "localSource1.txt"); - file.createNewFile(); - file = new File(sourceLocalDirectory, "localSource2.txt"); - file.createNewFile(); - - File subSourceLocalDirectory = new File(sourceLocalDirectory, "subLocalSource"); - subSourceLocalDirectory.mkdir(); - file = new File(subSourceLocalDirectory, "subLocalSource1.txt"); - file.createNewFile(); - - targetLocalDirectory = new File(rootFolder, "localTarget"); - targetLocalDirectory.mkdir(); - } - }; - } - - public File getSourceFtpDirectory() { - return sourceFtpDirectory; - } - - public File getTargetFtpDirectory() { - return targetFtpDirectory; - } - - public File getSourceLocalDirectory() { - return sourceLocalDirectory; - } - - public File getTargetLocalDirectory() { - return targetLocalDirectory; - } - - public String getTargetLocalDirectoryName() { - return targetLocalDirectory.getAbsolutePath() + File.separator; - } - - @Bean - public DefaultFtpSessionFactory ftpSessionFactory() { - DefaultFtpSessionFactory factory = new DefaultFtpSessionFactory(); - factory.setHost("localhost"); - factory.setPort(this.ftpPort); - factory.setUsername("foo"); - factory.setPassword("foo"); - return factory; - } - - @PostConstruct - public void before() throws Throwable { - this.ftpFolder.create(); - this.localFolder.create(); - - FtpServerFactory serverFactory = new FtpServerFactory(); - serverFactory.setUserManager(new TestUserManager(this.ftpRootFolder.getAbsolutePath())); - - ListenerFactory factory = new ListenerFactory(); - factory.setPort(ftpPort); - serverFactory.addListener("default", factory.createListener()); - - server = serverFactory.createServer(); - server.start(); - } - - - @PreDestroy - public void after() { - this.server.stop(); - this.ftpFolder.delete(); - this.localFolder.delete(); - } - - - public void recursiveDelete(File file) { - File[] files = file.listFiles(); - if (files != null) { - for (File each : files) { - recursiveDelete(each); - } - } - if (!(file.equals(this.targetFtpDirectory) || file.equals(this.targetLocalDirectory))) { - file.delete(); - } - } - - - private class TestUserManager implements UserManager { - - private final BaseUser testUser; - - private TestUserManager(String homeDirectory) { - this.testUser = new BaseUser(); - this.testUser.setAuthorities(Arrays.asList(new ConcurrentLoginPermission(1024, 1024), - new WritePermission(), - new TransferRatePermission(1024, 1024))); - this.testUser.setHomeDirectory(homeDirectory); - this.testUser.setName("TEST_USER"); - } - - - @Override - public User getUserByName(String s) throws FtpException { - return this.testUser; - } - - @Override - public String[] getAllUserNames() throws FtpException { - return new String[]{"TEST_USER"}; - } - - @Override - public void delete(String s) throws FtpException { - } - - @Override - public void save(User user) throws FtpException { - } - - @Override - public boolean doesExist(String s) throws FtpException { - return true; - } - - @Override - public User authenticate(Authentication authentication) throws AuthenticationFailedException { - return this.testUser; - } - - @Override - public String getAdminName() throws FtpException { - return "admin"; - } - - @Override - public boolean isAdmin(String s) throws FtpException { - return s.equals("admin"); - } - - } - -} diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/jdbc/JdbcTests.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/jdbc/JdbcTests.java deleted file mode 100644 index df4b723..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/jdbc/JdbcTests.java +++ /dev/null @@ -1,143 +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.test.jdbc; - -import static org.junit.Assert.assertNotNull; - -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Iterator; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.jdbc.InvalidResultSetAccessException; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.RowMapper; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.PollableChannel; -import org.springframework.messaging.support.GenericMessage; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Artem Bilan - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class JdbcTests { - - @Autowired - @Qualifier("jdbcSplitter.input") - private MessageChannel jdbcSplitterChannel; - - @Autowired - private PollableChannel splitResultsChannel; - - @Test - public void testJdbcSplitter() { - this.jdbcSplitterChannel.send(new GenericMessage<>("foo")); - for (int i = 0; i < 10; i++) { - Message result = this.splitResultsChannel.receive(1000); - assertNotNull(result); - } - } - - @Configuration - @EnableAutoConfiguration - public static class ContextConfiguration { - - @Autowired - private JdbcTemplate jdbcTemplate; - - @Bean - public IntegrationFlow jdbcSplitter() { - return f -> - f.split(p -> - jdbcTemplate.execute("SELECT * from FOO", - (PreparedStatement ps) -> - new ResultSetIterator(ps.executeQuery(), - (rs1, rowNum) -> - new Foo(rs1.getInt(1), rs1.getString(2)))) - , e -> e.applySequence(false)) - .channel(c -> c.queue("splitResultsChannel")); - } - - } - - private static class Foo { - - private final int id; - - private final String name; - - private Foo(int id, String name) { - this.id = id; - this.name = name; - } - - } - - private static class ResultSetIterator implements Iterator { - - private final ResultSet rs; - - private final RowMapper rowMapper; - - private ResultSetIterator(ResultSet rs, RowMapper rowMapper) { - this.rs = rs; - this.rowMapper = rowMapper; - } - - @Override - public boolean hasNext() { - try { - boolean hasNext = !this.rs.isLast(); - if (!hasNext) { - this.rs.close(); - } - return hasNext; - } - catch (SQLException e) { - throw new InvalidResultSetAccessException(e); - } - } - - @Override - public T next() { - try { - this.rs.next(); - return this.rowMapper.mapRow(this.rs, this.rs.getRow()); - } - catch (SQLException e) { - throw new InvalidResultSetAccessException(e); - } - } - - } - -} diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/jms/JmsTests.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/jms/JmsTests.java deleted file mode 100644 index c929010..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/jms/JmsTests.java +++ /dev/null @@ -1,263 +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.test.jms; - -import static org.hamcrest.Matchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -import java.util.concurrent.atomic.AtomicInteger; - -import javax.jms.ConnectionFactory; - -import org.hamcrest.Matchers; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.integration.annotation.IntegrationComponentScan; -import org.springframework.integration.annotation.MessagingGateway; -import org.springframework.integration.channel.ChannelInterceptorAware; -import org.springframework.integration.channel.FixedSubscriberChannel; -import org.springframework.integration.channel.QueueChannel; -import org.springframework.integration.config.GlobalChannelInterceptor; -import org.springframework.integration.core.MessageSource; -import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; -import org.springframework.integration.dsl.MessageSources; -import org.springframework.integration.dsl.MessagingGateways; -import org.springframework.integration.dsl.channel.MessageChannels; -import org.springframework.integration.dsl.core.Pollers; -import org.springframework.integration.dsl.jms.Jms; -import org.springframework.integration.endpoint.MethodInvokingMessageSource; -import org.springframework.integration.scheduling.PollerMetadata; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.PollableChannel; -import org.springframework.messaging.simp.SimpMessageHeaderAccessor; -import org.springframework.messaging.support.ChannelInterceptorAdapter; -import org.springframework.stereotype.Component; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Artem Bilan - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class JmsTests { - - @Autowired - private ListableBeanFactory beanFactory; - - @Autowired - private ControlBusGateway controlBus; - - @Autowired - @Qualifier("flow1QueueChannel") - private PollableChannel outputChannel; - - @Autowired - @Qualifier("jmsOutboundFlow.input") - private MessageChannel jmsOutboundInboundChannel; - - @Autowired - @Qualifier("jmsOutboundInboundReplyChannel") - private PollableChannel jmsOutboundInboundReplyChannel; - - @Autowired - @Qualifier("jmsOutboundGatewayFlow.input") - private MessageChannel jmsOutboundGatewayChannel; - - @Autowired - private TestChannelInterceptor testChannelInterceptor; - - @Test - public void testPollingFlow() { - this.controlBus.send("@integerEndpoint.start()"); - assertThat(this.beanFactory.getBean("integerChannel"), instanceOf(FixedSubscriberChannel.class)); - for (int i = 0; i < 5; i++) { - Message message = this.outputChannel.receive(20000); - assertNotNull(message); - assertEquals("" + i, message.getPayload()); - } - this.controlBus.send("@integerEndpoint.stop()"); - - assertTrue(((ChannelInterceptorAware) this.outputChannel).getChannelInterceptors() - .contains(this.testChannelInterceptor)); - assertThat(this.testChannelInterceptor.invoked.get(), Matchers.greaterThanOrEqualTo(5)); - - } - - @Test - public void testJmsOutboundInboundFlow() { - this.jmsOutboundInboundChannel.send(MessageBuilder.withPayload("hello THROUGH the JMS") - .setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "jmsInbound") - .build()); - - Message receive = this.jmsOutboundInboundReplyChannel.receive(5000); - - assertNotNull(receive); - assertEquals("HELLO THROUGH THE JMS", receive.getPayload()); - - this.jmsOutboundInboundChannel.send(MessageBuilder.withPayload("hello THROUGH the JMS") - .setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "jmsMessageDriver") - .build()); - - receive = this.jmsOutboundInboundReplyChannel.receive(5000); - - assertNotNull(receive); - assertEquals("hello through the jms", receive.getPayload()); - } - - @Test - public void testJmsPipelineFlow() { - PollableChannel replyChannel = new QueueChannel(); - Message message = MessageBuilder.withPayload("hello through the jms pipeline") - .setReplyChannel(replyChannel) - .setHeader("destination", "jmsPipelineTest") - .build(); - this.jmsOutboundGatewayChannel.send(message); - - Message receive = replyChannel.receive(5000); - - assertNotNull(receive); - assertEquals("HELLO THROUGH THE JMS PIPELINE", receive.getPayload()); - } - - @MessagingGateway(defaultRequestChannel = "controlBus.input") - private static interface ControlBusGateway { - - void send(String command); - - } - - @Configuration - @EnableAutoConfiguration - @IntegrationComponentScan - @ComponentScan - public static class ContextConfiguration { - - @Autowired - private ConnectionFactory jmsConnectionFactory; - - @Bean(name = PollerMetadata.DEFAULT_POLLER) - public PollerMetadata poller() { - return Pollers.fixedRate(500).maxMessagesPerPoll(1).get(); - } - - @Bean - public IntegrationFlow controlBus() { - return f -> f.controlBus(); - } - - @Bean - public MessageSource integerMessageSource() { - MethodInvokingMessageSource source = new MethodInvokingMessageSource(); - source.setObject(new AtomicInteger()); - source.setMethodName("getAndIncrement"); - return source; - } - - @Bean - public IntegrationFlow flow1() { - return IntegrationFlows.from(integerMessageSource(), - c -> c.poller(p -> p.fixedRate(100)) - .id("integerEndpoint") - .autoStartup(false)) - .fixedSubscriberChannel("integerChannel") - .transform("payload.toString()") - .channel(Jms.pollableChannel("flow1QueueChannel", this.jmsConnectionFactory) - .destination("flow1QueueChannel")) - .get(); - } - - @Bean - public IntegrationFlow jmsOutboundFlow() { - return f -> f.handleWithAdapter(h -> h.jms(this.jmsConnectionFactory) - .destinationExpression("headers." + SimpMessageHeaderAccessor.DESTINATION_HEADER)); - } - - @Bean - public MessageChannel jmsOutboundInboundReplyChannel() { - return MessageChannels.queue().get(); - } - - @Bean - public IntegrationFlow jmsInboundFlow() { - return IntegrationFlows - .from((MessageSources s) -> s.jms(this.jmsConnectionFactory).destination("jmsInbound")) - .transform(String::toUpperCase) - .channel(this.jmsOutboundInboundReplyChannel()) - .get(); - } - - @Bean - public IntegrationFlow jmsMessageDriverFlow() { - return IntegrationFlows - .from(Jms.messageDriverChannelAdapter(this.jmsConnectionFactory) - .destination("jmsMessageDriver")) - .transform(String::toLowerCase) - .channel(this.jmsOutboundInboundReplyChannel()) - .get(); - } - - @Bean - public IntegrationFlow jmsOutboundGatewayFlow() { - return f -> f.handleWithAdapter(a -> - a.jmsGateway(this.jmsConnectionFactory) - .replyContainer() - .requestDestination("jmsPipelineTest")); - } - - @Bean - public IntegrationFlow jmsInboundGatewayFlow() { - return IntegrationFlows.from((MessagingGateways g) -> - g.jms(this.jmsConnectionFactory) - .destination("jmsPipelineTest")) - .transform(String::toUpperCase) - .get(); - } - - } - - @Component - @GlobalChannelInterceptor(patterns = "flow1QueueChannel") - public static class TestChannelInterceptor extends ChannelInterceptorAdapter { - - private final AtomicInteger invoked = new AtomicInteger(); - - @Override - public Message preSend(Message message, MessageChannel channel) { - this.invoked.incrementAndGet(); - return message; - } - - } - -} diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/mail/MailTests.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/mail/MailTests.java deleted file mode 100644 index fe39f42..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/mail/MailTests.java +++ /dev/null @@ -1,262 +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.test.mail; - -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.endsWith; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -import java.util.Properties; - -import javax.mail.Flags; -import javax.mail.Folder; -import javax.mail.internet.AddressException; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeMessage.RecipientType; -import javax.mail.search.AndTerm; -import javax.mail.search.FlagTerm; -import javax.mail.search.FromTerm; -import javax.mail.search.SearchTerm; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.integration.config.EnableIntegration; -import org.springframework.integration.dsl.HeaderEnricherSpec; -import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; -import org.springframework.integration.dsl.MessageProducers; -import org.springframework.integration.dsl.channel.MessageChannels; -import org.springframework.integration.dsl.mail.Mail; -import org.springframework.integration.dsl.test.mail.PoorMansMailServer.ImapServer; -import org.springframework.integration.dsl.test.mail.PoorMansMailServer.Pop3Server; -import org.springframework.integration.dsl.test.mail.PoorMansMailServer.SmtpServer; -import org.springframework.integration.mail.ImapIdleChannelAdapter; -import org.springframework.integration.mail.MailHeaders; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.integration.test.util.TestUtils; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.MessageHandler; -import org.springframework.messaging.PollableChannel; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.util.SocketUtils; - -/** - * @author Gary Russell - * @author Artem Bilan - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class MailTests { - - private final static int smtpPort = SocketUtils.findAvailableTcpPort(); - - private final static SmtpServer smtpServer = PoorMansMailServer.smtp(smtpPort); - - private final static int pop3Port = SocketUtils.findAvailableTcpPort(smtpPort + 1); - - private final static Pop3Server pop3Server = PoorMansMailServer.pop3(pop3Port); - - private final static int imapPort = SocketUtils.findAvailableTcpPort(pop3Port + 1); - - private final static ImapServer imapServer = PoorMansMailServer.imap(imapPort); - - private final static int imapIdlePort = SocketUtils.findAvailableTcpPort(imapPort + 1); - - private final static ImapServer imapIdleServer = PoorMansMailServer.imap(imapIdlePort); - - - @BeforeClass - public static void setup() throws InterruptedException { - int n = 0; - while (n++ < 100 && (!smtpServer.isListening() || !pop3Server.isListening() || !imapServer.isListening())) { - Thread.sleep(100); - } - assertTrue(n < 100); - } - - @AfterClass - public static void tearDown() { - smtpServer.stop(); - pop3Server.stop(); - imapServer.stop(); - imapIdleServer.stop(); - } - - @Autowired - private MessageChannel sendMailChannel; - - @Autowired - @Qualifier("sendMailEndpoint.handler") - private MessageHandler sendMailHandler; - - @Autowired - private PollableChannel pop3Channel; - - @Autowired - private PollableChannel imapChannel; - - @Autowired - private PollableChannel imapIdleChannel; - - @Autowired - private ImapIdleChannelAdapter imapIdleAdapter; - - @Test - public void testSmtp() throws Exception { - assertEquals("localhost", TestUtils.getPropertyValue(this.sendMailHandler, "mailSender.host")); - - Properties javaMailProperties = TestUtils.getPropertyValue(this.sendMailHandler, - "mailSender.javaMailProperties", Properties.class); - assertEquals("true", javaMailProperties.getProperty("mail.debug")); - - this.sendMailChannel.send(MessageBuilder.withPayload("foo").build()); - - int n = 0; - while (n++ < 100 && smtpServer.getMessages().size() == 0) { - Thread.sleep(100); - } - - assertTrue(smtpServer.getMessages().size() > 0); - String message = smtpServer.getMessages().get(0); - assertThat(message, endsWith("foo\n")); - assertThat(message, containsString("foo@bar")); - assertThat(message, containsString("bar@baz")); - assertThat(message, containsString("user:user")); - assertThat(message, containsString("password:pw")); - - } - - @Test - public void testPop3() throws Exception { - Message message = this.pop3Channel.receive(10000); - assertNotNull(message); - MimeMessage mm = (MimeMessage) message.getPayload(); - assertEquals("foo@bar", mm.getRecipients(RecipientType.TO)[0].toString()); - assertEquals("bar@baz", message.getHeaders().get(MailHeaders.FROM)); - assertEquals("Test Email", message.getHeaders().get(MailHeaders.SUBJECT)); - assertEquals("foo\r\n", mm.getContent()); - } - - @Test - public void testImap() throws Exception { - Message message = this.imapChannel.receive(10000); - assertNotNull(message); - MimeMessage mm = (MimeMessage) message.getPayload(); - assertEquals("foo@bar", mm.getRecipients(RecipientType.TO)[0].toString()); - assertEquals("bar@baz", mm.getFrom()[0].toString()); - assertEquals("Test Email", mm.getSubject()); - assertEquals("foo\r\n", mm.getContent()); - } - - @Test - public void testImapIdle() throws Exception { - Message message = this.imapIdleChannel.receive(10000); - assertNotNull(message); - MimeMessage mm = (MimeMessage) message.getPayload(); - assertEquals("foo@bar", mm.getRecipients(RecipientType.TO)[0].toString()); - assertEquals("bar@baz", mm.getFrom()[0].toString()); - assertEquals("Test Email", mm.getSubject()); - assertEquals("foo\r\n", mm.getContent()); - this.imapIdleAdapter.stop(); - assertFalse(TestUtils.getPropertyValue(this.imapIdleAdapter, "shouldReconnectAutomatically", Boolean.class)); - } - - @Configuration - @EnableIntegration - public static class ContextConfiguration { - - @Bean - public IntegrationFlow sendMailFlow() { - return IntegrationFlows.from("sendMailChannel") - .enrichHeaders(Mail.headers() - .subjectFunction(m -> "foo") - .from("foo@bar") - .toFunction(m -> new String[] {"bar@baz"})) - .handleWithAdapter(h -> h.mail("localhost") - .port(smtpPort) - .credentials("user", "pw") - .protocol("smtp") - .javaMailProperties(p -> p.put("mail.debug", "true")), - e -> e.id("sendMailEndpoint")) - .get(); - } - - @Bean - public IntegrationFlow pop3MailFlow() { - return IntegrationFlows - .from(s -> s.pop3("localhost", pop3Port, "user", "pw") - .javaMailProperties(p -> p.put("mail.debug", "true")), - e -> e.autoStartup(true).poller(p -> p.fixedDelay(1000))) - .enrichHeaders(s -> s.headerExpressions(c -> c.put(MailHeaders.SUBJECT, "payload.subject") - .put(MailHeaders.FROM, "payload.from[0].toString()"))) - .channel(MessageChannels.queue("pop3Channel")) - .get(); - } - - @Bean - public IntegrationFlow imapMailFlow() { - return IntegrationFlows - .from(s -> s.imap("imap://user:pw@localhost:" + imapPort + "/INBOX") - .searchTermStrategy(this::fromAndNotSeenTerm) - .javaMailProperties(p -> p.put("mail.debug", "true")), - e -> e.autoStartup(true) - .poller(p -> p.fixedDelay(1000))) - .channel(MessageChannels.queue("imapChannel")) - .get(); - } - - @Bean - public IntegrationFlow imapIdleFlow() { - return IntegrationFlows - .from((MessageProducers mp) -> mp.imap("imap://user:pw@localhost:" + imapIdlePort + "/INBOX") - .searchTermStrategy(this::fromAndNotSeenTerm) - .javaMailProperties(p -> p.put("mail.debug", "true") - .put("mail.imap.connectionpoolsize", "5")) - .shouldReconnectAutomatically(false)) - .channel(MessageChannels.queue("imapIdleChannel")) - .get(); - } - - private SearchTerm fromAndNotSeenTerm(Flags supportedFlags, Folder folder) { - try { - FromTerm fromTerm = new FromTerm(new InternetAddress("bar@baz")); - return new AndTerm(fromTerm, new FlagTerm(new Flags(Flags.Flag.SEEN), false)); - } - catch (AddressException e) { - throw new RuntimeException(e); - } - - } - - } - -} diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/mail/PoorMansMailServer.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/mail/PoorMansMailServer.java deleted file mode 100644 index 87d6008..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/mail/PoorMansMailServer.java +++ /dev/null @@ -1,422 +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.test.mail; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import javax.net.ServerSocketFactory; - -import org.apache.sshd.common.util.Base64; - -/** - * @author Gary Russell - * - */ -public class PoorMansMailServer { - - public static SmtpServer smtp(int port) { - try { - return new SmtpServer(port); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static Pop3Server pop3(int port) { - try { - return new Pop3Server(port); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static ImapServer imap(int port) { - try { - return new ImapServer(port); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static class SmtpServer extends MailServer { - - public SmtpServer(int port) throws IOException { - super(port); - } - - @Override - protected MailHandler mailHandler(Socket socket) { - return new SmtpHandler(socket); - } - - public class SmtpHandler extends MailHandler { - - public SmtpHandler(Socket socket) { - super(socket); - } - - @Override - void doRun() { - try { - write("220 foo SMTP"); - while (!socket.isClosed()) { - String line = reader.readLine(); - if (line.contains("EHLO")) { - write("250-foo hello [0,0,0,0], foo"); - write("250-AUTH LOGIN PLAIN"); - write("250 OK"); - } - else if (line.contains("MAIL FROM")) { - write("250 OK"); - } - else if (line.contains("RCPT TO")) { - write("250 OK"); - } - else if (line.contains("AUTH LOGIN")) { - write("334 VXNlcm5hbWU6"); - } - else if (line.contains("dXNlcg==")) { // base64 'user' - sb.append("user:"); - sb.append((new String(new Base64().decode(line.getBytes())))); - sb.append("\n"); - write("334 UGFzc3dvcmQ6"); - } - else if (line.contains("cHc=")) { // base64 'pw' - sb.append("password:"); - sb.append((new String(new Base64().decode(line.getBytes())))); - sb.append("\n"); - write("235"); - } - else if (line.equals("DATA")) { - write("354"); - } - else if (line.equals(".")) { - write("250"); - } - else if (line.equals("QUIT")) { - write("221"); - socket.close(); - } - else { - sb.append(line); - sb.append("\n"); - } - } - messages.add(sb.toString()); - } - catch (IOException e) { - e.printStackTrace(); - } - } - - } - - } - - public static class Pop3Server extends MailServer { - - public Pop3Server(int port) throws IOException { - super(port); - } - - @Override - protected MailHandler mailHandler(Socket socket) { - return new Pop3Handler(socket); - } - - public class Pop3Handler extends MailHandler { - - public Pop3Handler(Socket socket) { - super(socket); - } - - @Override - void doRun() { - try { - write("+OK POP3"); - while (!socket.isClosed()) { - String line = reader.readLine(); - switch (line) { - case "CAPA": - write("+OK"); - write("USER"); - write("."); - break; - case "USER user": - write("+OK"); - break; - case "PASS pw": - write("+OK"); - break; - case "STAT": - write("+OK 1 3"); - break; - case "NOOP": - write("+OK"); - break; - case "RETR 1": - write("+OK"); - write(MESSAGE); - write("."); - break; - case "QUIT": - write("+OK"); - socket.close(); - break; - } - } - } - catch (IOException e) { - e.printStackTrace(); - } - } - - } - - } - - public static class ImapServer extends MailServer { - - private boolean seen; - - public ImapServer(int port) throws IOException { - super(port); - } - - @Override - protected MailHandler mailHandler(Socket socket) { - return new ImapHandler(socket); - } - - public class ImapHandler extends MailHandler { - - public ImapHandler(Socket socket) { - super(socket); - } - - @Override - void doRun() { - try { - write("* OK IMAP4rev1 Service Ready"); - String idleTag = ""; - while (!socket.isClosed()) { - String line = reader.readLine(); - if (line == null) { - break; - } - String tag = line.substring(0, line.indexOf(" ") + 1); - if (line.endsWith("CAPABILITY")) { - write("* CAPABILITY IDLE IMAP4rev1"); - write(tag + "OK CAPABILITY completed"); - } - else if (line.endsWith("LOGIN user pw")) { - write(tag + "OK LOGIN completed"); - } - else if (line.endsWith("LIST \"\" INBOX")) { - write("* LIST \"/\" \"INBOX\""); - write(tag + "OK LIST completed"); - } - else if (line.endsWith("LIST \"\" \"\"")) { - write("* LIST \"/\" \"\""); - write(tag + "OK LIST completed"); - } - else if (line.endsWith("SELECT INBOX")) { - if (!seen) { - write("* 1 EXISTS"); - write("* 1 RECENT"); - write("* OK [UNSEEN 1]"); - } - write(tag + "OK SELECT completed"); - } - else if (line.endsWith("EXAMINE INBOX")) { - write(tag + "OK"); - } - else if (line.endsWith("SEARCH FROM bar@baz UNSEEN ALL")) { - if (seen) { - write("* SEARCH"); - } - else { - write("* SEARCH 1"); - } - write(tag + "OK SEARCH completed"); - } - else if (line.contains("FETCH 1 (ENVELOPE")) { - write("* 1 FETCH (RFC822.SIZE 6909 INTERNALDATE \"27-May-2013 09:45:41 +0000\" " - + "FLAGS (\\Seen) " - + "ENVELOPE (\"Mon, 27 May 2013 15:14:49 +0530\" " - + "\"Test Email\" ((\"Foo\" NIL \"foo\" \"bar.tv\")) " - + "((\"Foo\" NIL \"foo\" \"bar.tv\")) " - + "((\"Foo\" NIL \"foo\" \"bar.tv\")) " - + "((\"Bar\" NIL \"bar\" \"baz.net\")) NIL NIL " - + "\"<4DA0A7E4.3010506@baz.net>\" " - + "\"\") " - + "BODYSTRUCTURE (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"ISO-8859-1\") NIL NIL " - + "\"7BIT\" 1176 43)))"); - write(tag + "OK FETCH completed"); - } - else if (line.contains("STORE 1 +FLAGS (\\Flagged)")) { - write("* 1 FETCH (FLAGS (\\Flagged))"); - write(tag + "OK STORE completed"); - } - else if (line.contains("STORE 1 +FLAGS (\\Seen)")) { - write("* 1 FETCH (FLAGS (\\Flagged \\Seen))"); - write(tag + "OK STORE completed"); - seen = true; - } - else if (line.contains("FETCH 1 FLAGS")) { - write("* 1 FLAGS(\\Seen)"); - write(tag + "OK FETCH completed"); - } - else if (line.contains("FETCH 1 (BODY.PEEK")) { - write("* 1 FETCH (BODY[]<0> {" + (MESSAGE.length() + 2) + "}"); - write(MESSAGE); - write(")"); - write(tag + "OK FETCH completed"); - } - else if (line.contains("CLOSE")) { - write(tag + "OK CLOSE completed"); - } - else if (line.contains("NOOP")) { - write(tag + "OK NOOP completed"); - } - else if (line.endsWith("IDLE")) { - write("+ idling"); - idleTag = tag; - } - else if (line.equals("DONE")) { - write(idleTag + "OK"); - } - else if (line.contains("LOGOUT")) { - write(tag + "OK LOGOUT completed"); - this.socket.close(); - } - } - } - catch (IOException e) { - e.printStackTrace(); - } - } - - } - - } - - public abstract static class MailServer implements Runnable { - - private final ServerSocket socket; - - private final ExecutorService exec = Executors.newCachedThreadPool(); - - protected final List messages = new ArrayList(); - - private volatile boolean listening; - - public MailServer(int port) throws IOException { - this.socket = ServerSocketFactory.getDefault().createServerSocket(port); - this.listening = true; - exec.execute(this); - } - - public boolean isListening() { - return listening; - } - - public List getMessages() { - return messages; - } - - @Override - public void run() { - try { - while (!socket.isClosed()) { - Socket socket = this.socket.accept(); - exec.execute(mailHandler(socket)); - } - } - catch (IOException e) { - this.listening = false; - } - } - - protected abstract MailHandler mailHandler(Socket socket); - - public void stop() { - try { - this.socket.close(); - } - catch (IOException e) { - e.printStackTrace(); - } - this.exec.shutdownNow(); - } - - public abstract class MailHandler implements Runnable { - - protected static final String MESSAGE = "To: foo@bar\r\nFrom: bar@baz\r\nSubject: Test Email\r\n\r\nfoo"; - - protected final Socket socket; - - private BufferedWriter writer; - - protected StringBuilder sb = new StringBuilder(); - - protected BufferedReader reader; - - public MailHandler(Socket socket) { - this.socket = socket; - } - - @Override - public void run() { - try { - this.reader = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); - this.writer = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream())); - } - catch (IOException e) { - e.printStackTrace(); - } - doRun(); - } - - protected void write(String str) throws IOException { - this.writer.write(str); - this.writer.write("\r\n"); - this.writer.flush(); - } - - abstract void doRun(); - - } - - } - - private PoorMansMailServer() { - } - -} diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/mongodb/MongoDbTest.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/mongodb/MongoDbTest.java deleted file mode 100644 index 5ac0bb2..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/mongodb/MongoDbTest.java +++ /dev/null @@ -1,199 +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.test.mongodb; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.mongodb.MongoDbFactory; -import org.springframework.data.mongodb.core.SimpleMongoDbFactory; -import org.springframework.integration.annotation.IntegrationComponentScan; -import org.springframework.integration.annotation.MessagingGateway; -import org.springframework.integration.config.EnableIntegration; -import org.springframework.integration.dsl.Channels; -import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; -import org.springframework.integration.dsl.channel.MessageChannels; -import org.springframework.integration.dsl.core.Pollers; -import org.springframework.integration.mongodb.store.MongoDbChannelMessageStore; -import org.springframework.integration.store.PriorityCapableChannelMessageStore; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.PollableChannel; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import com.mongodb.MongoClient; -import de.flapdoodle.embed.mongo.MongodExecutable; -import de.flapdoodle.embed.mongo.MongodStarter; -import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; -import de.flapdoodle.embed.mongo.config.Net; -import de.flapdoodle.embed.mongo.distribution.Version; -import de.flapdoodle.embed.process.runtime.Network; - -/** - * @author Artem Bilan - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class MongoDbTest { - - private static int mongoPort; - - private static MongodExecutable mongodExe; - - @BeforeClass - public static void setup() throws IOException { - mongoPort = Network.getFreeServerPort(); - mongodExe = MongodStarter.getDefaultInstance() - .prepare(new MongodConfigBuilder() - .version(Version.Main.PRODUCTION) - .net(new Net(mongoPort, Network.localhostIsIPv6())) - .build()); - mongodExe.start(); - } - - @AfterClass - public static void tearDown() { - mongodExe.stop(); - } - - @Autowired - private ControlBusGateway controlBus; - - @Autowired - @Qualifier("priorityChannel") - private MessageChannel priorityChannel; - - @Autowired - @Qualifier("priorityReplyChannel") - private PollableChannel priorityReplyChannel; - - - @Test - public void testPriority() throws InterruptedException { - Message message = MessageBuilder.withPayload("1").setPriority(1).build(); - this.priorityChannel.send(message); - - message = MessageBuilder.withPayload("-1").setPriority(-1).build(); - this.priorityChannel.send(message); - - message = MessageBuilder.withPayload("3").setPriority(3).build(); - this.priorityChannel.send(message); - - message = MessageBuilder.withPayload("0").setPriority(0).build(); - this.priorityChannel.send(message); - - message = MessageBuilder.withPayload("2").setPriority(2).build(); - this.priorityChannel.send(message); - - message = MessageBuilder.withPayload("none").build(); - this.priorityChannel.send(message); - - message = MessageBuilder.withPayload("31").setPriority(3).build(); - this.priorityChannel.send(message); - - this.controlBus.send("@priorityChannelBridge.start()"); - - Message receive = this.priorityReplyChannel.receive(2000); - assertNotNull(receive); - assertEquals("3", receive.getPayload()); - - receive = this.priorityReplyChannel.receive(2000); - assertNotNull(receive); - assertEquals("31", receive.getPayload()); - - receive = this.priorityReplyChannel.receive(2000); - assertNotNull(receive); - assertEquals("2", receive.getPayload()); - - receive = this.priorityReplyChannel.receive(2000); - assertNotNull(receive); - assertEquals("1", receive.getPayload()); - - receive = this.priorityReplyChannel.receive(2000); - assertNotNull(receive); - assertEquals("0", receive.getPayload()); - - receive = this.priorityReplyChannel.receive(2000); - assertNotNull(receive); - assertEquals("-1", receive.getPayload()); - - receive = this.priorityReplyChannel.receive(2000); - assertNotNull(receive); - assertEquals("none", receive.getPayload()); - - this.controlBus.send("@priorityChannelBridge.stop()"); - } - - @MessagingGateway(defaultRequestChannel = "controlBus.input") - private static interface ControlBusGateway { - - void send(String command); - } - - - @Configuration - @EnableIntegration - @IntegrationComponentScan - public static class ContextConfiguration { - - @Bean - public IntegrationFlow controlBus() { - return f -> f.controlBus(); - } - - @Bean - public MongoDbFactory mongoDbFactory() throws Exception { - return new SimpleMongoDbFactory(new MongoClient("localhost", mongoPort), "local"); - } - - @Bean - public MongoDbChannelMessageStore mongoDbChannelMessageStore(MongoDbFactory mongoDbFactory) { - MongoDbChannelMessageStore mongoDbChannelMessageStore = new MongoDbChannelMessageStore(mongoDbFactory); - mongoDbChannelMessageStore.setPriorityEnabled(true); - return mongoDbChannelMessageStore; - } - - @Bean - public IntegrationFlow priorityFlow(PriorityCapableChannelMessageStore mongoDbChannelMessageStore) { - return IntegrationFlows.from((Channels c) -> - c.priority("priorityChannel", mongoDbChannelMessageStore, "priorityGroup")) - .bridge(s -> s.poller(Pollers.fixedDelay(100)) - .autoStartup(false) - .id("priorityChannelBridge")) - .channel(MessageChannels.queue("priorityReplyChannel")) - .get(); - } - - } - -} diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/sftp/SftpTests.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/sftp/SftpTests.java deleted file mode 100644 index f7c632f..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/sftp/SftpTests.java +++ /dev/null @@ -1,250 +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.test.sftp; - -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.Matchers.isOneOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; - -import java.io.File; -import java.util.List; -import java.util.regex.Matcher; - -import javax.management.MBeanServer; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; - -import org.hamcrest.Matchers; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.ConfigFileApplicationContextInitializer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.integration.annotation.IntegrationComponentScan; -import org.springframework.integration.annotation.MessagingGateway; -import org.springframework.integration.channel.QueueChannel; -import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; -import org.springframework.integration.dsl.channel.MessageChannels; -import org.springframework.integration.dsl.core.Pollers; -import org.springframework.integration.dsl.sftp.Sftp; -import org.springframework.integration.file.FileHeaders; -import org.springframework.integration.file.remote.RemoteFileTemplate; -import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway; -import org.springframework.integration.scheduling.PollerMetadata; -import org.springframework.integration.sftp.session.DefaultSftpSessionFactory; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.PollableChannel; -import org.springframework.messaging.support.GenericMessage; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import com.jcraft.jsch.ChannelSftp; - -/** - * @author Artem Bilan - */ -@ContextConfiguration(initializers = ConfigFileApplicationContextInitializer.class) -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class SftpTests { - - @Autowired - private ControlBusGateway controlBus; - - @Autowired - private MBeanServer mBeanServer; - - @Autowired - private TestSftpServer sftpServer; - - @Autowired - private DefaultSftpSessionFactory sftpSessionFactory; - - @Autowired - @Qualifier("sftpInboundResultChannel") - private PollableChannel sftpInboundResultChannel; - - @Autowired - @Qualifier("toSftpChannel") - private MessageChannel toSftpChannel; - - @Autowired - @Qualifier("remoteFileOutputChannel") - private PollableChannel remoteFileOutputChannel; - - - @Autowired - @Qualifier("sftpMgetInputChannel") - private MessageChannel sftpMgetInputChannel; - - @Before - @After - public void setupRemoteFileServers() { - this.sftpServer.recursiveDelete(this.sftpServer.getTargetLocalDirectory()); - this.sftpServer.recursiveDelete(this.sftpServer.getTargetSftpDirectory()); - } - - @Test - public void testSftpInboundFlow() { - this.controlBus.send("@sftpInboundAdapter.start()"); - - Message message = this.sftpInboundResultChannel.receive(1000); - assertNotNull(message); - Object payload = message.getPayload(); - assertThat(payload, instanceOf(File.class)); - File file = (File) payload; - assertThat(file.getName(), isOneOf("SFTPSOURCE1.TXT.a", "SFTPSOURCE2.TXT.a")); - assertThat(file.getAbsolutePath(), containsString("sftpTest")); - - message = this.sftpInboundResultChannel.receive(1000); - assertNotNull(message); - file = (File) message.getPayload(); - assertThat(file.getName(), isOneOf("SFTPSOURCE1.TXT.a", "SFTPSOURCE2.TXT.a")); - assertThat(file.getAbsolutePath(), containsString("sftpTest")); - - this.controlBus.send("@sftpInboundAdapter.stop()"); - } - - @Test - public void testSftpOutboundFlow() { - String fileName = "foo.file"; - this.toSftpChannel.send(MessageBuilder.withPayload("foo") - .setHeader(FileHeaders.FILENAME, fileName) - .build()); - - RemoteFileTemplate template = new RemoteFileTemplate<>(this.sftpSessionFactory); - ChannelSftp.LsEntry[] files = template.execute(session -> - session.list(this.sftpServer.getTargetSftpDirectory().getName() + "/" + fileName)); - assertEquals(1, files.length); - assertEquals(3, files[0].getAttrs().getSize()); - } - - @Test - @SuppressWarnings("unchecked") - public void testSftpMgetFlow() { - String dir = "sftpSource/"; - this.sftpMgetInputChannel.send(new GenericMessage(dir + "*")); - Message result = this.remoteFileOutputChannel.receive(1000); - assertNotNull(result); - List localFiles = (List) result.getPayload(); - // should have filtered sftpSource2.txt - assertEquals(2, localFiles.size()); - - for (File file : localFiles) { - assertThat(file.getPath().replaceAll(Matcher.quoteReplacement(File.separator), "/"), - Matchers.containsString(dir)); - } - assertThat(localFiles.get(1).getPath().replaceAll(Matcher.quoteReplacement(File.separator), "/"), - Matchers.containsString(dir + "subSftpSource")); - } - - @Test - public void testMBeansForDSL() throws MalformedObjectNameException { - assertFalse(this.mBeanServer.queryMBeans(ObjectName.getInstance("org.springframework.integration:" + - "bean=anonymous,name=sftpMgetInputChannel,type=MessageHandler"), null).isEmpty()); - } - - - @MessagingGateway(defaultRequestChannel = "controlBus.input") - private static interface ControlBusGateway { - - void send(String command); - - } - - @Configuration - @Import(TestSftpServer.class) - @EnableAutoConfiguration - @IntegrationComponentScan - public static class ContextConfiguration { - - @Autowired - private TestSftpServer sftpServer; - - @Autowired - private DefaultSftpSessionFactory sftpSessionFactory; - - @Bean(name = PollerMetadata.DEFAULT_POLLER) - public PollerMetadata poller() { - return Pollers.fixedRate(500).maxMessagesPerPoll(1).get(); - } - - @Bean - public IntegrationFlow controlBus() { - return f -> f.controlBus(); - } - - @Bean - public IntegrationFlow sftpInboundFlow() { - return IntegrationFlows - .from(s -> s.sftp(this.sftpSessionFactory) - .preserveTimestamp(true) - .remoteDirectory("sftpSource") - .regexFilter(".*\\.txt$") - .localFilenameExpression("#this.toUpperCase() + '.a'") - .localDirectory(this.sftpServer.getTargetLocalDirectory()), - e -> e.id("sftpInboundAdapter").autoStartup(false)) - .channel(MessageChannels.queue("sftpInboundResultChannel")) - .get(); - } - - @Bean - public IntegrationFlow sftpOutboundFlow() { - return IntegrationFlows.from("toSftpChannel") - .handle(Sftp.outboundAdapter(this.sftpSessionFactory) - .useTemporaryFileName(false) - .remoteDirectory(this.sftpServer.getTargetSftpDirectory().getName()) - ).get(); - } - - @Bean - public PollableChannel remoteFileOutputChannel() { - return new QueueChannel(); - } - - @Bean - public IntegrationFlow sftpMGetFlow() { - return IntegrationFlows.from("sftpMgetInputChannel") - .handleWithAdapter(h -> - h.sftpGateway(this.sftpSessionFactory, AbstractRemoteFileOutboundGateway.Command.MGET, - "payload") - .options(AbstractRemoteFileOutboundGateway.Option.RECURSIVE) - .regexFileNameFilter("(subSftpSource|.*1.txt)") - .localDirectoryExpression("@sftpServer.targetLocalDirectoryName + #remoteDirectory") - .localFilenameExpression("#remoteFileName.replaceFirst('sftpSource', 'localTarget')")) - .channel(remoteFileOutputChannel()) - .get(); - } - - } - -} diff --git a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/sftp/TestSftpServer.java b/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/sftp/TestSftpServer.java deleted file mode 100644 index faf946d..0000000 --- a/spring-integration-java-dsl/src/test/java/org/springframework/integration/dsl/test/sftp/TestSftpServer.java +++ /dev/null @@ -1,195 +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.test.sftp; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Arrays; - -import org.apache.sshd.SshServer; -import org.apache.sshd.common.NamedFactory; -import org.apache.sshd.common.file.FileSystemView; -import org.apache.sshd.common.file.nativefs.NativeFileSystemFactory; -import org.apache.sshd.common.file.nativefs.NativeFileSystemView; -import org.apache.sshd.server.Command; -import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; -import org.apache.sshd.server.sftp.SftpSubsystem; -import org.junit.rules.TemporaryFolder; - -import org.springframework.beans.factory.DisposableBean; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.integration.sftp.session.DefaultSftpSessionFactory; -import org.springframework.util.SocketUtils; - -/** - * @author Gary Russell - * @author Artem Bilan - */ -@Configuration("sftpServer") -public class TestSftpServer implements InitializingBean, DisposableBean { - - private final SshServer server = SshServer.setUpDefaultServer(); - - private final int port = SocketUtils.findAvailableTcpPort(); - - private final TemporaryFolder sftpFolder; - - private final TemporaryFolder localFolder; - - private volatile File sftpRootFolder; - - private volatile File sourceSftpDirectory; - - private volatile File targetSftpDirectory; - - private volatile File sourceLocalDirectory; - - private volatile File targetLocalDirectory; - - public TestSftpServer() { - this.sftpFolder = new TemporaryFolder() { - - @Override - public void create() throws IOException { - super.create(); - sftpRootFolder = this.newFolder("sftpTest"); - sourceSftpDirectory = new File(sftpRootFolder, "sftpSource"); - sourceSftpDirectory.mkdir(); - File file = new File(sourceSftpDirectory, "sftpSource1.txt"); - file.createNewFile(); - FileOutputStream fos = new FileOutputStream(file); - fos.write("source1".getBytes()); - fos.close(); - file = new File(sourceSftpDirectory, "sftpSource2.txt"); - file.createNewFile(); - fos = new FileOutputStream(file); - fos.write("source2".getBytes()); - fos.close(); - - File subSourceFtpDirectory = new File(sourceSftpDirectory, "subSftpSource"); - subSourceFtpDirectory.mkdir(); - file = new File(subSourceFtpDirectory, "subSftpSource1.txt"); - file.createNewFile(); - fos = new FileOutputStream(file); - fos.write("subSource1".getBytes()); - fos.close(); - - targetSftpDirectory = new File(sftpRootFolder, "sftpTarget"); - targetSftpDirectory.mkdir(); - } - }; - - this.localFolder = new TemporaryFolder() { - - @Override - public void create() throws IOException { - super.create(); - File rootFolder = this.newFolder("sftpTest"); - sourceLocalDirectory = new File(rootFolder, "localSource"); - sourceLocalDirectory.mkdirs(); - File file = new File(sourceLocalDirectory, "localSource1.txt"); - file.createNewFile(); - file = new File(sourceLocalDirectory, "localSource2.txt"); - file.createNewFile(); - - File subSourceLocalDirectory = new File(sourceLocalDirectory, "subLocalSource"); - subSourceLocalDirectory.mkdir(); - file = new File(subSourceLocalDirectory, "subLocalSource1.txt"); - file.createNewFile(); - - targetLocalDirectory = new File(rootFolder, "localTarget"); - targetLocalDirectory.mkdir(); - } - }; - } - - @SuppressWarnings("unchecked") - @Override - public void afterPropertiesSet() throws Exception { - this.sftpFolder.create(); - this.localFolder.create(); - this.server.setPasswordAuthenticator((username, password, session) -> true); - this.server.setPort(this.port); - this.server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); - SftpSubsystem.Factory sftp = new SftpSubsystem.Factory(); - this.server.setSubsystemFactories(Arrays.>asList(sftp)); - this.server.setFileSystemFactory(new NativeFileSystemFactory() { - - @Override - public FileSystemView createFileSystemView(org.apache.sshd.common.Session session) { - return new NativeFileSystemView(session.getUsername(), false) { - - @Override - public String getVirtualUserDir() { - return sftpRootFolder.getAbsolutePath(); - } - }; - } - - }); - this.server.start(); - } - - @Override - public void destroy() throws Exception { - this.server.stop(); - this.sftpFolder.delete(); - this.localFolder.delete(); - } - - public File getSourceLocalDirectory() { - return this.sourceLocalDirectory; - } - - public File getTargetLocalDirectory() { - return this.targetLocalDirectory; - } - - public String getTargetLocalDirectoryName() { - return this.targetLocalDirectory.getAbsolutePath() + File.separator; - } - - public File getTargetSftpDirectory() { - return this.targetSftpDirectory; - } - - public void recursiveDelete(File file) { - File[] files = file.listFiles(); - if (files != null) { - for (File each : files) { - recursiveDelete(each); - } - } - if (!(file.equals(this.targetSftpDirectory) || file.equals(this.targetLocalDirectory))) { - file.delete(); - } - } - - @Bean - public DefaultSftpSessionFactory sftpSessionFactory() { - DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true); - factory.setHost("localhost"); - factory.setPort(this.port); - factory.setUser("foo"); - factory.setPassword("foo"); - return factory; - } - -} diff --git a/spring-integration-java-dsl/src/test/resources/application.properties b/spring-integration-java-dsl/src/test/resources/application.properties deleted file mode 100644 index eb9d820..0000000 --- a/spring-integration-java-dsl/src/test/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -#spring.jmx.enabled=false diff --git a/spring-integration-java-dsl/src/test/resources/data.sql b/spring-integration-java-dsl/src/test/resources/data.sql deleted file mode 100644 index 715c1c4..0000000 --- a/spring-integration-java-dsl/src/test/resources/data.sql +++ /dev/null @@ -1,10 +0,0 @@ -INSERT INTO FOO VALUES (1, 'foo1'); -INSERT INTO FOO VALUES (2, 'foo2'); -INSERT INTO FOO VALUES (3, 'foo3'); -INSERT INTO FOO VALUES (4, 'foo4'); -INSERT INTO FOO VALUES (5, 'foo5'); -INSERT INTO FOO VALUES (6, 'foo6'); -INSERT INTO FOO VALUES (7, 'foo7'); -INSERT INTO FOO VALUES (8, 'foo8'); -INSERT INTO FOO VALUES (9, 'foo9'); -INSERT INTO FOO VALUES (10, 'foo10'); diff --git a/spring-integration-java-dsl/src/test/resources/log4j.properties b/spring-integration-java-dsl/src/test/resources/log4j.properties deleted file mode 100644 index 80f6cef..0000000 --- a/spring-integration-java-dsl/src/test/resources/log4j.properties +++ /dev/null @@ -1,8 +0,0 @@ -log4j.rootCategory=WARN, stdout - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d %c{1} [%t] : %m%n - -log4j.category.org.springframework=WARN -log4j.category.org.springframework.integration.dsl=INFO diff --git a/spring-integration-java-dsl/src/test/resources/schema.sql b/spring-integration-java-dsl/src/test/resources/schema.sql deleted file mode 100644 index 38de881..0000000 --- a/spring-integration-java-dsl/src/test/resources/schema.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE FOO ( - id INTEGER IDENTITY PRIMARY KEY, - name VARCHAR(30), -); \ No newline at end of file