Upgrade samples to Log4J2
* Remove those samples which are note related to this repo any more
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
Spring Integration - Amazon S3 Sample
|
||||
=====================================
|
||||
|
||||
## Introduction
|
||||
|
||||
This sample demonstrate the usage of the *Spring Integration* support for
|
||||
[Amazon Simple Storage Service][] (Amazon S3). The sample covers 2 use-cases:
|
||||
|
||||
* **Upload** a file to Amazon S3 using the *s3-outbound-channel-adapter*
|
||||
* **Poll** files from Amazon S3 using the *s3-inbound-channel-adapter*
|
||||
|
||||
## How to Run the Sample
|
||||
|
||||
You can execute this sample simply via [Maven][]:
|
||||
|
||||
$ mvn clean package exec:java
|
||||
|
||||
Once executed you should see the following screen:
|
||||
|
||||
=========================================================
|
||||
|
||||
Welcome to the Spring Integration Amazon S3 Sample
|
||||
|
||||
For more information please visit:
|
||||
https://github.com/SpringSource/spring-integration-extensions
|
||||
|
||||
=========================================================
|
||||
What would you like to do?
|
||||
1. Upload a file to Amazon S3
|
||||
2. Poll files from Amazon S3
|
||||
q. Quit the application
|
||||
>
|
||||
|
||||
Once you have selected either **Option 1** or **Option 2**, you will be asked to
|
||||
provide the **Access Key ID** and the **Secret Access Key** for *Amazon Web Services*.
|
||||
|
||||
You may also consider providing the **Access Key ID** and the **Secret Access Key**
|
||||
via the command line:
|
||||
|
||||
$ mvn clean package exec:java -DaccessKey=12345 -DsecretKey=12345
|
||||
|
||||
In that case you will not be asked to provide that information again.
|
||||
|
||||
## s3-outbound-channel-adapter
|
||||
|
||||
When you selected the option to upload a file you will be asked to specify the file you would like to upload:
|
||||
|
||||
Please enter the path to the file you want to upload:
|
||||
|
||||
Enter a path such as `/demo/data/myfile.txt`.
|
||||
|
||||
## s3-inbound-channel-adapter
|
||||
|
||||
The polled files will be stored under `s3-local-storage`.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
For help please take a look at the [Spring Integration documentation][]
|
||||
|
||||
[Amazon Simple Storage Service]: https://aws.amazon.com/s3/
|
||||
[Maven]: https://maven.apache.org/
|
||||
[Spring Integration documentation]: https://www.springsource.org/spring-integration
|
||||
@@ -1,112 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.springframework.integration.samples</groupId>
|
||||
<artifactId>aws-s3</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>aws-s3</name>
|
||||
<url>https://www.springsource.org/spring-integration</url>
|
||||
|
||||
<prerequisites>
|
||||
<maven>2.2.1</maven>
|
||||
</prerequisites>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.integration.version>2.2.1.RELEASE</spring.integration.version>
|
||||
<spring.integration.aws.version>0.5.0.BUILD-SNAPSHOT</spring.integration.aws.version>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<junit.version>4.11</junit.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>repo.springsource.org.milestone</id>
|
||||
<name>Spring Framework Maven Milestone Repository</name>
|
||||
<url>https://repo.springsource.org/libs-snapshot</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-eclipse-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<configuration>
|
||||
<additionalProjectnatures>
|
||||
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
|
||||
</additionalProjectnatures>
|
||||
<additionalBuildcommands>
|
||||
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
|
||||
</additionalBuildcommands>
|
||||
<downloadSources>true</downloadSources>
|
||||
<downloadJavadocs>true</downloadJavadocs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<compilerArgument>-Xlint:all</compilerArgument>
|
||||
<showWarnings>true</showWarnings>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<configuration>
|
||||
<mainClass>org.springframework.integration.samples.aws.s3.Main</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Testing -->
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Integration -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-core</artifactId>
|
||||
<version>${spring.integration.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-file</artifactId>
|
||||
<version>${spring.integration.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-aws</artifactId>
|
||||
<version>${spring.integration.aws.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Logging -->
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,155 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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
|
||||
*
|
||||
* https://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.samples.aws.s3;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.context.support.GenericXmlApplicationContext;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
/**
|
||||
* Starts the Spring Context and will initialize the Spring Integration routes.
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public final class Main {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(Main.class);
|
||||
|
||||
private static final String HORIZONTAL_LINE = "\n=========================================================";
|
||||
|
||||
private Main() { }
|
||||
|
||||
/**
|
||||
* Load the Spring Integration Application Context
|
||||
*
|
||||
* @param args - command line arguments
|
||||
*/
|
||||
public static void main(final String... args) {
|
||||
|
||||
final Scanner scanner = new Scanner(System.in);
|
||||
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info(HORIZONTAL_LINE
|
||||
+ "\n "
|
||||
+ "\n Welcome to the Spring Integration Amazon S3 Sample "
|
||||
+ "\n "
|
||||
+ "\n For more information please visit: "
|
||||
+ "\nhttps://github.com/SpringSource/spring-integration-extensions"
|
||||
+ "\n "
|
||||
+ HORIZONTAL_LINE );
|
||||
}
|
||||
|
||||
final GenericXmlApplicationContext context = new GenericXmlApplicationContext();
|
||||
final ConfigurableEnvironment environment = context.getEnvironment();
|
||||
|
||||
System.out.println("What would you like to do?");
|
||||
System.out.println("\t1. Upload a file to Amazon S3");
|
||||
System.out.println("\t2. Poll files from Amazon S3");
|
||||
System.out.println("\tq. Quit the application");
|
||||
System.out.print(" > ");
|
||||
|
||||
String filePath;
|
||||
|
||||
while (true) {
|
||||
final String input = scanner.nextLine();
|
||||
|
||||
if("1".equals(input.trim())) {
|
||||
|
||||
System.out.println("Uploading to Amazon S3...");
|
||||
|
||||
environment.setActiveProfiles("upload-to-s3");
|
||||
setupCredentials(environment, scanner);
|
||||
setupS3info(environment, scanner);
|
||||
|
||||
context.load("classpath:META-INF/spring/integration/*-context.xml");
|
||||
context.registerShutdownHook();
|
||||
context.refresh();
|
||||
|
||||
System.out.print("\nPlease enter the path to the file you want to upload: ");
|
||||
filePath = scanner.nextLine();
|
||||
|
||||
final MessageChannel messageChannel = context.getBean("s3channel", MessageChannel.class);
|
||||
messageChannel.send(MessageBuilder.withPayload(new File(filePath)).build());
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
else if("2".equals(input.trim())) {
|
||||
|
||||
System.out.println("Polling files from Amazon S3...");
|
||||
environment.setActiveProfiles("poll-s3");
|
||||
setupCredentials(environment, scanner);
|
||||
setupS3info(environment, scanner);
|
||||
|
||||
context.load("classpath:META-INF/spring/integration/*-context.xml");
|
||||
context.registerShutdownHook();
|
||||
context.refresh();
|
||||
|
||||
}
|
||||
else if("q".equals(input.trim())) {
|
||||
System.out.println("Exiting application...bye.");
|
||||
System.exit(0);
|
||||
}
|
||||
else {
|
||||
System.out.println("Invalid choice\n\n");
|
||||
System.out.print("Enter you choice: ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("Exiting application...bye.");
|
||||
}
|
||||
|
||||
System.exit(0);
|
||||
|
||||
}
|
||||
|
||||
private static void setupCredentials(ConfigurableEnvironment environment, Scanner scanner) {
|
||||
if (!environment.containsProperty("accessKey")) {
|
||||
System.out.print("\nPlease enter your Access Key ID: ");
|
||||
final String accessKey = scanner.nextLine();
|
||||
environment.getSystemProperties().put("accessKey", accessKey);
|
||||
}
|
||||
|
||||
if (!environment.containsProperty("secretKey")) {
|
||||
System.out.print("\nPlease enter your Secret Access Key: ");
|
||||
final String secretKey = scanner.nextLine();
|
||||
environment.getSystemProperties().put("secretKey", secretKey);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setupS3info(ConfigurableEnvironment environment, Scanner scanner) {
|
||||
if (!environment.containsProperty("bucket")) {
|
||||
System.out.print("\nWhich bucket do you want to use? ");
|
||||
final String bucket = scanner.nextLine();
|
||||
environment.getSystemProperties().put("bucket", bucket);
|
||||
}
|
||||
|
||||
if (!environment.containsProperty("remoteDirectory")) {
|
||||
System.out.print("\nPlease enter the S3 remote directory to use: ");
|
||||
final String remoteDirectory = scanner.nextLine();
|
||||
environment.getSystemProperties().put("remoteDirectory", remoteDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-file="http://www.springframework.org/schema/integration/file"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:int-aws="http://www.springframework.org/schema/integration/aws"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/file https://www.springframework.org/schema/integration/file/spring-integration-file.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/aws https://www.springframework.org/schema/integration/aws/spring-integration-aws.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<context:property-placeholder />
|
||||
|
||||
<bean id="credentials" class="org.springframework.integration.aws.core.BasicAWSCredentials">
|
||||
<property name="accessKey" value="${accessKey}"/>
|
||||
<property name="secretKey" value="${secretKey}"/>
|
||||
</bean>
|
||||
|
||||
<int:channel id="s3channel">
|
||||
<int:interceptors>
|
||||
<int:wire-tap channel="loggit"/>
|
||||
</int:interceptors>
|
||||
</int:channel>
|
||||
|
||||
<int:logging-channel-adapter id="loggit" level="INFO"
|
||||
logger-name="org.springframework.integration.samples.aws.s3"
|
||||
expression="'File Name: ' + payload.name + '(' + payload.length() + ')'"/>
|
||||
|
||||
<beans profile="poll-s3">
|
||||
<int-aws:s3-inbound-channel-adapter credentials-ref="credentials" local-directory="s3-local-storage"
|
||||
temporary-suffix=".transferring"
|
||||
bucket="${bucket}" channel="s3channel" remote-directory="${remoteDirectory}"/>
|
||||
<int-file:outbound-channel-adapter channel="s3channel" directory="target/s3-out"/>
|
||||
|
||||
<int:poller default="true" fixed-rate="5000"/>
|
||||
|
||||
</beans>
|
||||
<beans profile="upload-to-s3">
|
||||
<int-aws:s3-outbound-channel-adapter credentials-ref="credentials"
|
||||
bucket="${bucket}" channel="s3channel" remote-directory="${remoteDirectory}"/>
|
||||
</beans>
|
||||
</beans>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
|
||||
<!-- Appenders -->
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out" />
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Loggers -->
|
||||
<logger name="org.springframework.integration">
|
||||
<level value="warn" />
|
||||
</logger>
|
||||
|
||||
<logger name="org.springframework.integration.samples.aws.s3">
|
||||
<level value="info" />
|
||||
</logger>
|
||||
|
||||
<!-- Root Logger -->
|
||||
<root>
|
||||
<priority value="warn" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
2
samples/kafka/.gitignore
vendored
2
samples/kafka/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
derby.log
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
Spring Integration Kafka Sample
|
||||
================================
|
||||
|
||||
This sample demonstrates the usage of the *[Spring Integration Kafka][]* adapters.
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
description = 'Spring Integration Kafka Sample'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url 'https://repo.maven.apache.org/maven2/' }
|
||||
//mavenLocal()
|
||||
maven { url 'https://repo.spring.io/simple/ext-release-local' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'org.apache.maven:maven-artifact:2.2.1' // 3.x won't work
|
||||
classpath 'org.apache.avro:avro-compiler:1.7.3' // use Avro 1.7.4 to compile the Avro files
|
||||
//classpath 'org.clojars.miguno:avro-gradle-plugin:1.7.2'
|
||||
classpath "org.apache.avro:avro-gradle-plugin:1.7.2"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'base'
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'application'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'avro-gradle-plugin'
|
||||
|
||||
ext {
|
||||
avroTaskGroup = "Avro"
|
||||
avroSource = "schemas"
|
||||
avroDest = "target/generated-avro-sources/main/java"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url 'https://repository.apache.org/content/groups/public'
|
||||
}
|
||||
maven { url 'https://repo.springsource.org/libs-milestone' }
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.springframework.integration:spring-integration-stream:$springIntegrationVersion"
|
||||
compile("org.springframework.integration:spring-integration-kafka:$springIntegrationKafkaVersion") {
|
||||
exclude module: 'log4j'
|
||||
exclude module: 'jms'
|
||||
exclude module: 'jmxtools'
|
||||
exclude module: 'jmxri'
|
||||
}
|
||||
compile("log4j:log4j:1.2.15") {
|
||||
exclude module: 'mail'
|
||||
exclude module: 'jms'
|
||||
exclude module: 'jmx'
|
||||
exclude module: 'jmxtools'
|
||||
exclude module: 'jmxri'
|
||||
}
|
||||
compile "commons-logging:commons-logging:1.1.1"
|
||||
}
|
||||
|
||||
compileAvro.group = avroTaskGroup
|
||||
compileAvro.description = "Generates Java code from avro schema"
|
||||
compileAvro.source = avroSource
|
||||
compileAvro.destinationDir = file(avroDest)
|
||||
|
||||
task cleanAvro(type: Delete) {
|
||||
group = avroTaskGroup
|
||||
description = "deletes generated avro code"
|
||||
delete avroDest
|
||||
}
|
||||
|
||||
compileJava.dependsOn compileAvro
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir avroDest
|
||||
}
|
||||
resources {
|
||||
srcDir avroSource
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
description = 'Generates gradlew[.bat] scripts'
|
||||
gradleVersion = '1.8'
|
||||
}
|
||||
|
||||
eclipse {
|
||||
project {
|
||||
name = "spring-integration-kafka-sample"
|
||||
}
|
||||
}
|
||||
|
||||
defaultTasks 'clean', 'build'
|
||||
@@ -1,6 +0,0 @@
|
||||
springIntegrationVersion = 4.0.3.RELEASE
|
||||
springIntegrationKafkaVersion = 1.0.0.BUILD-SNAPSHOT
|
||||
version = 1.0.0.BUILD-SNAPSHOT
|
||||
|
||||
|
||||
|
||||
BIN
samples/kafka/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
samples/kafka/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
#Tue Jul 22 17:46:28 EEST 2014
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-all.zip
|
||||
164
samples/kafka/gradlew
vendored
164
samples/kafka/gradlew
vendored
@@ -1,164 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
90
samples/kafka/gradlew.bat
vendored
90
samples/kafka/gradlew.bat
vendored
@@ -1,90 +0,0 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,7 +0,0 @@
|
||||
@namespace("org.springframework.integration.samples.kafka.user")
|
||||
protocol UserProtocol{
|
||||
record User {
|
||||
string firstName;
|
||||
string lastName;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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
|
||||
*
|
||||
* https://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.samples.kafka.inbound;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
public class InboundRunner {
|
||||
private static final String CONFIG = "kafkaInboundAdapterParserTests-context.xml";
|
||||
|
||||
public static void main(final String args[]) {
|
||||
final ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(CONFIG, InboundRunner.class);
|
||||
ctx.start();
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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
|
||||
*
|
||||
* https://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.samples.kafka.outbound;
|
||||
|
||||
import kafka.producer.Partitioner;
|
||||
|
||||
/**
|
||||
* @author Soby Chacko
|
||||
*
|
||||
* This class is for internal use only and therefore is at default access level
|
||||
*/
|
||||
class CustomPartitioner implements Partitioner {
|
||||
/**
|
||||
* Uses the key to calculate a partition bucket id for routing
|
||||
* the data to the appropriate broker partition
|
||||
* @return an integer between 0 and numPartitions-1
|
||||
*/
|
||||
@Override
|
||||
public int partition(final Object key, final int numPartitions) {
|
||||
final String s = (String) key;
|
||||
final Integer i = Integer.parseInt(s);
|
||||
return i % numPartitions;
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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
|
||||
*
|
||||
* https://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.samples.kafka.outbound;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.samples.kafka.user.User;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
public class OutboundRunner {
|
||||
private static final String CONFIG = "kafkaOutboundAdapterParserTests-context.xml";
|
||||
private static final Log LOG = LogFactory.getLog(OutboundRunner.class);
|
||||
|
||||
public static void main(final String args[]) {
|
||||
final ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(CONFIG, OutboundRunner.class);
|
||||
ctx.start();
|
||||
|
||||
final MessageChannel channel = ctx.getBean("inputToKafka", MessageChannel.class);
|
||||
LOG.info(channel.getClass());
|
||||
|
||||
//sending 100,000 messages to Kafka server for topic test1
|
||||
for (int i = 0; i < 500; i++) {
|
||||
final User user = new User();
|
||||
user.setFirstName("fname" + i);
|
||||
user.setLastName("lname" + i);
|
||||
channel.send(
|
||||
MessageBuilder.withPayload(user)
|
||||
.setHeader("messageKey", String.valueOf(i))
|
||||
.setHeader("topic", "test1").build());
|
||||
|
||||
LOG.info("message sent " + i);
|
||||
}
|
||||
|
||||
//sending 5,000 messages to kafka server for topic test2
|
||||
for (int i = 0; i < 50; i++) {
|
||||
channel.send(
|
||||
MessageBuilder.withPayload("hello Fom ob adapter test2 - " + i)
|
||||
.setHeader("messageKey", String.valueOf(i))
|
||||
.setHeader("topic", "test2").build());
|
||||
|
||||
LOG.info("message sent " + i);
|
||||
}
|
||||
|
||||
//Send some messages to multiple topics matching regex.
|
||||
for (int i = 0; i < 10; i++) {
|
||||
channel.send(
|
||||
MessageBuilder.withPayload("hello Fom ob adapter regextopic1 - " + i)
|
||||
.setHeader("messageKey", String.valueOf(i))
|
||||
.setHeader("topic", "regextopic1").build());
|
||||
|
||||
LOG.info("message sent " + i);
|
||||
}
|
||||
for (int i = 0; i < 10; i++) {
|
||||
channel.send(
|
||||
MessageBuilder.withPayload("hello Fom ob adapter regextopic2 - " + i)
|
||||
.setHeader("messageKey", String.valueOf(i))
|
||||
.setHeader("topic", "regextopic2").build());
|
||||
|
||||
LOG.info("message sent " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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
|
||||
*
|
||||
* https://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.samples.kafka.outbound;
|
||||
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.transformer.Transformer;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Soby Chacko
|
||||
*/
|
||||
public class PartitionlessTransformer implements Transformer {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Message<?> transform(final Message<?> message) {
|
||||
|
||||
final Map<String, Map<Integer, List<Object>>> origData =
|
||||
(Map<String, Map<Integer, List<Object>>>) message.getPayload();
|
||||
|
||||
final Map<String, List<Object>> nonPartitionedData = new HashMap<>();
|
||||
|
||||
for(final String topic : origData.keySet()) {
|
||||
final Map<Integer, List<Object>> partitionedData = origData.get(topic);
|
||||
final Collection<List<Object>> nonPartitionedDataFromTopic = partitionedData.values();
|
||||
|
||||
final List<Object> mergedList = new ArrayList<>();
|
||||
|
||||
for (final List<Object> l : nonPartitionedDataFromTopic){
|
||||
mergedList.addAll(l);
|
||||
}
|
||||
|
||||
nonPartitionedData.put(topic, mergedList);
|
||||
}
|
||||
|
||||
return MessageBuilder.withPayload(nonPartitionedData).build();
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package org.springframework.integration.samples.kafka.outbound;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.integration.samples.kafka.user.User;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.transformer.Transformer;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* @author Soby Chacko
|
||||
*/
|
||||
public class UserTransformer implements Transformer {
|
||||
|
||||
Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Override
|
||||
public Message<?> transform(Message<?> message) {
|
||||
if(message.getPayload().getClass().isAssignableFrom(User.class)) {
|
||||
User user = (User) message.getPayload();
|
||||
user.setFirstName(user.getFirstName().toString()+user.getFirstName());
|
||||
logger.info("user confirmed " + user.getFirstName());
|
||||
return MessageBuilder.withPayload(user).copyHeaders(message.getHeaders()).build();
|
||||
}
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +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{HH:mm:ss.SSS} %-5p [%t][%c] %m%n
|
||||
|
||||
#log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.kafka=INFO
|
||||
log4j.category.org.springframework.integration.samples.kafka=INFO
|
||||
log4j.category.kafka.consumer=ERROR
|
||||
@@ -1,74 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/integration/kafka https://www.springframework.org/schema/integration/kafka/spring-integration-kafka.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<int:channel id="inputFromKafka"/>
|
||||
<int:channel id="inputFromTransformer"/>
|
||||
|
||||
<stream:stdout-channel-adapter id="stdout" channel="inputFromKafka" append-newline="true"/>
|
||||
|
||||
<int-kafka:zookeeper-connect id="zookeeperConnect" zk-connect="localhost:2181"
|
||||
zk-connection-timeout="6000"
|
||||
zk-session-timeout="6000"
|
||||
zk-sync-time="2000"/>
|
||||
|
||||
<int-kafka:inbound-channel-adapter id="kafkaInboundChannelAdapter"
|
||||
kafka-consumer-context-ref="consumerContext"
|
||||
auto-startup="false"
|
||||
channel="inputFromKafka">
|
||||
<int:poller fixed-delay="1" time-unit="MILLISECONDS"/>
|
||||
</int-kafka:inbound-channel-adapter>
|
||||
|
||||
<bean id="kafkaReflectionDecoder" class="org.springframework.integration.kafka.serializer.avro.AvroReflectDatumBackedKafkaDecoder">
|
||||
<constructor-arg type="java.lang.Class" value="java.lang.String"/>
|
||||
</bean>
|
||||
|
||||
<bean id="kafkaSpecificDecoder" class="org.springframework.integration.kafka.serializer.avro.AvroSpecificDatumBackedKafkaDecoder">
|
||||
<constructor-arg value="org.springframework.integration.samples.kafka.user.User" />
|
||||
</bean>
|
||||
|
||||
<bean id="consumerProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
|
||||
<property name="properties">
|
||||
<props>
|
||||
<prop key="auto.offset.reset">smallest</prop>
|
||||
<prop key="socket.receive.buffer.bytes">10485760</prop> <!-- 10M -->
|
||||
<prop key="fetch.message.max.bytes">5242880</prop>
|
||||
<prop key="auto.commit.interval.ms">1000</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<int-kafka:consumer-context id="consumerContext"
|
||||
consumer-timeout="1000"
|
||||
zookeeper-connect="zookeeperConnect" consumer-properties="consumerProperties">
|
||||
<int-kafka:consumer-configurations>
|
||||
<int-kafka:consumer-configuration group-id="default1"
|
||||
value-decoder="kafkaSpecificDecoder"
|
||||
key-decoder="kafkaReflectionDecoder"
|
||||
max-messages="5000">
|
||||
<int-kafka:topic id="test1" streams="4"/>
|
||||
</int-kafka:consumer-configuration>
|
||||
<int-kafka:consumer-configuration group-id="default2"
|
||||
max-messages="50">
|
||||
<int-kafka:topic id="test2" streams="4"/>
|
||||
</int-kafka:consumer-configuration>
|
||||
<int-kafka:consumer-configuration group-id="default3"
|
||||
max-messages="10">
|
||||
<int-kafka:topic-filter pattern="regextopic.*" streams="4" exclude="false"/>
|
||||
</int-kafka:consumer-configuration>
|
||||
</int-kafka:consumer-configurations>
|
||||
</int-kafka:consumer-context>
|
||||
|
||||
<bean id="partitionlessTransformer" class="org.springframework.integration.samples.kafka.outbound.PartitionlessTransformer"/>
|
||||
|
||||
<int:transformer ref="partitionlessTransformer" method="transform"
|
||||
input-channel="inputFromKafka"
|
||||
output-channel="inputFromTransformer"/>
|
||||
</beans>
|
||||
@@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
|
||||
xmlns:task="http://www.springframework.org/schema/task"
|
||||
xmlns:int-stream="http://www.springframework.org/schema/integration/stream"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/kafka https://www.springframework.org/schema/integration/kafka/spring-integration-kafka.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/task https://www.springframework.org/schema/task/spring-task.xsd
|
||||
http://www.springframework.org/schema/integration/stream
|
||||
https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">
|
||||
|
||||
<int:publish-subscribe-channel id="inputToKafka"/>
|
||||
|
||||
<int-kafka:outbound-channel-adapter kafka-producer-context-ref="kafkaProducerContext"
|
||||
auto-startup="false"
|
||||
channel="inputToKafka"
|
||||
order="1">
|
||||
</int-kafka:outbound-channel-adapter>
|
||||
|
||||
<int-stream:stdout-channel-adapter id="stdout" append-newline="true"/>
|
||||
|
||||
<int:transformer order="0" ref="userTransformer" input-channel="inputToKafka" output-channel="stdout"/>
|
||||
|
||||
<bean id="userTransformer" class="org.springframework.integration.samples.kafka.outbound.UserTransformer"/>
|
||||
|
||||
<task:executor id="taskExecutor" pool-size="5" keep-alive="120" queue-capacity="500"/>
|
||||
|
||||
<bean id="kafkaReflectionEncoder" class="org.springframework.integration.kafka.serializer.avro.AvroReflectDatumBackedKafkaEncoder">
|
||||
<constructor-arg value="java.lang.String" />
|
||||
</bean>
|
||||
|
||||
<bean id="kafkaSpecificEncoder" class="org.springframework.integration.kafka.serializer.avro.AvroSpecificDatumBackedKafkaEncoder">
|
||||
<constructor-arg value="org.springframework.integration.samples.kafka.user.User" />
|
||||
</bean>
|
||||
|
||||
<bean id="customPartitioner" class="org.springframework.integration.samples.kafka.outbound.CustomPartitioner"/>
|
||||
|
||||
<bean id="producerProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
|
||||
<property name="properties">
|
||||
<props>
|
||||
<prop key="topic.metadata.refresh.interval.ms">3600000</prop>
|
||||
<prop key="message.send.max.retries">5</prop>
|
||||
<prop key="send.buffer.bytes">5242880</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<int-kafka:producer-context id="kafkaProducerContext" producer-properties="producerProperties">
|
||||
<int-kafka:producer-configurations>
|
||||
<int-kafka:producer-configuration broker-list="localhost:9092"
|
||||
key-class-type="java.lang.String"
|
||||
value-class-type="org.springframework.integration.samples.kafka.user.User"
|
||||
topic="test1"
|
||||
value-encoder="kafkaSpecificEncoder"
|
||||
key-encoder="kafkaReflectionEncoder"
|
||||
compression-codec="default"
|
||||
partitioner="customPartitioner"/>
|
||||
<int-kafka:producer-configuration broker-list="localhost:9092"
|
||||
topic="test2"
|
||||
compression-codec="default"/>
|
||||
<int-kafka:producer-configuration broker-list="localhost:9092"
|
||||
topic="regextopic.*"
|
||||
compression-codec="default"/>
|
||||
</int-kafka:producer-configurations>
|
||||
</int-kafka:producer-context>
|
||||
</beans>
|
||||
@@ -1,4 +0,0 @@
|
||||
AWS SES Spring Integration Sample
|
||||
=========================
|
||||
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.integration.samples</groupId>
|
||||
<artifactId>mail-ses-integration</artifactId>
|
||||
<name>AWS SES Mail Demo</name>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
|
||||
<prerequisites>
|
||||
<maven>2.2.1</maven>
|
||||
</prerequisites>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.integration.version>2.2.0.RELEASE</spring.integration.version>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<junit.version>4.10</junit.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-mail</artifactId>
|
||||
<version>${spring.integration.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-test</artifactId>
|
||||
<version>${spring.integration.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-aws</artifactId>
|
||||
<version>0.5.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<!-- test-scoped dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.subethamail</groupId>
|
||||
<artifactId>subethasmtp-wiser</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<compilerArgument>-Xlint:all</compilerArgument>
|
||||
<showWarnings>true</showWarnings>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<configuration>
|
||||
<mainClass>org.springframework.integration.samples.mailses.Main</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>repo.springsource.org.milestone</id>
|
||||
<name>SpringSource Maven Milestone Repository</name>
|
||||
<url>https://repo.springsource.org/libs-milestone</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.springframework.integration.samples.mailses;
|
||||
|
||||
import org.springframework.integration.annotation.Header;
|
||||
import org.springframework.integration.annotation.Payload;
|
||||
import org.springframework.integration.mail.MailHeaders;
|
||||
|
||||
public interface EmailService {
|
||||
|
||||
|
||||
void send(
|
||||
|
||||
@Header(MailHeaders.FROM)
|
||||
String fromEmail,
|
||||
|
||||
@Header(MailHeaders.TO)
|
||||
String toEmail,
|
||||
|
||||
@Header(MailHeaders.SUBJECT)
|
||||
String subject,
|
||||
|
||||
@Payload
|
||||
String body);
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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
|
||||
*
|
||||
* https://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.samples.mailses;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.context.support.GenericXmlApplicationContext;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
|
||||
/**
|
||||
* Starts the Spring Context and will initialize the Spring Integration routes.
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public final class Main {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(Main.class);
|
||||
|
||||
private static final String HORIZONTAL_LINE = "\n=========================================================";
|
||||
|
||||
private Main() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Spring Integration Application Context
|
||||
*
|
||||
* @param args - command line arguments
|
||||
*/
|
||||
public static void main(final String... args) {
|
||||
|
||||
final Scanner scanner = new Scanner(System.in);
|
||||
|
||||
LOGGER.info(HORIZONTAL_LINE + "\n"
|
||||
+ "\n Welcome to Spring Integration! "
|
||||
+ "\n"
|
||||
+ "\n For more information please visit: "
|
||||
+ "\n https://www.springsource.org/spring-integration "
|
||||
+ "\n" + HORIZONTAL_LINE);
|
||||
|
||||
final GenericXmlApplicationContext context = new GenericXmlApplicationContext();
|
||||
final ConfigurableEnvironment environment = context.getEnvironment();
|
||||
|
||||
final String fromEmailAddress;
|
||||
final String toEmailAddress;
|
||||
final String subject;
|
||||
final String body;
|
||||
|
||||
System.out.print("\nFrom which email address would you like to send a message?: ");
|
||||
fromEmailAddress = scanner.nextLine();
|
||||
|
||||
System.out.print("To which email address would you like to send a message?: ");
|
||||
toEmailAddress = scanner.nextLine();
|
||||
|
||||
System.out.print("What is the subject line?: ");
|
||||
subject = scanner.nextLine();
|
||||
|
||||
System.out.print("What is the body of the message?: ");
|
||||
body = scanner.nextLine();
|
||||
|
||||
if (!environment.containsProperty("accessKey")) {
|
||||
System.out.print("Please enter your access key: ");
|
||||
final String accessKey = scanner.nextLine();
|
||||
environment.getSystemProperties().put("accessKey", accessKey);
|
||||
}
|
||||
|
||||
if (!environment.containsProperty("secretKey")) {
|
||||
System.out.print("Please enter your secret key: ");
|
||||
final String secretKey = scanner.nextLine();
|
||||
environment.getSystemProperties().put("secretKey", secretKey);
|
||||
}
|
||||
|
||||
context.load("classpath:META-INF/spring/integration/*-context.xml");
|
||||
context.registerShutdownHook();
|
||||
context.refresh();
|
||||
|
||||
final EmailService emailService = context.getBean(EmailService.class);
|
||||
|
||||
emailService.send(fromEmailAddress, toEmailAddress, subject, body);
|
||||
|
||||
System.out.println(String.format("The email to '%s' was sent successfully.", toEmailAddress));
|
||||
|
||||
System.exit(0);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-file="http://www.springframework.org/schema/integration/file"
|
||||
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:int-aws="http://www.springframework.org/schema/integration/aws"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/mail https://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/file https://www.springframework.org/schema/integration/file/spring-integration-file.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/integration/aws https://www.springframework.org/schema/integration/aws/spring-integration-aws.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<context:property-placeholder />
|
||||
|
||||
<bean id="tcpIpUtils" class="org.springframework.integration.test.util.SocketUtils" />
|
||||
|
||||
<bean id="serverPort" class="java.lang.Integer">
|
||||
<constructor-arg value="#{tcpIpUtils.findAvailableServerSocket(12000)}"/>
|
||||
</bean>
|
||||
|
||||
<int:gateway id="emailService" service-interface="org.springframework.integration.samples.mailses.EmailService">
|
||||
<int:method name="send" request-channel="inputChannel" request-timeout="5000"/>
|
||||
</int:gateway>
|
||||
|
||||
<int:channel id="inputChannel"/>
|
||||
|
||||
<int-aws:ses-outbound-channel-adapter id="sesOutbound" channel="inputChannel" accessKey="${accessKey}" secretKey="${secretKey}"/>
|
||||
|
||||
</beans>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
|
||||
<!-- Appenders -->
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out" />
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Loggers -->
|
||||
<logger name="org.springframework.integration.mail">
|
||||
<level value="debug" />
|
||||
</logger>
|
||||
|
||||
<logger name="org.springframework.integration.samples">
|
||||
<level value="debug" />
|
||||
</logger>
|
||||
|
||||
<!-- Root Logger -->
|
||||
<root>
|
||||
<priority value="warn" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
@@ -1,5 +0,0 @@
|
||||
AWS SES MailSender sample
|
||||
=========================
|
||||
|
||||
This sample uses a Spring-provided *JavaMailSender* to send emails. This application demonstrates that by only replacing the *JavaMailSender* XML bean declaration with the *DefaultAmazonSESMailSender*, existing applications can send emails using Amazon SES without changing application code. The *DefaultAmazonSESMailSender* is provided by the *Spring Integration Extensions AWS Module*.
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.integration.samples</groupId>
|
||||
<artifactId>mail-ses</artifactId>
|
||||
<name>AWS SES Mail Demo</name>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
|
||||
<prerequisites>
|
||||
<maven>2.2.1</maven>
|
||||
</prerequisites>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.integration.version>2.2.0.RELEASE</spring.integration.version>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<junit.version>4.10</junit.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-mail</artifactId>
|
||||
<version>${spring.integration.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-test</artifactId>
|
||||
<version>${spring.integration.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-aws</artifactId>
|
||||
<version>0.5.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<!-- test-scoped dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.subethamail</groupId>
|
||||
<artifactId>subethasmtp-wiser</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<compilerArgument>-Xlint:all</compilerArgument>
|
||||
<showWarnings>true</showWarnings>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<configuration>
|
||||
<mainClass>org.springframework.integration.samples.mailses.Main</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>repo.springsource.org.milestone</id>
|
||||
<name>SpringSource Maven Milestone Repository</name>
|
||||
<url>https://repo.springsource.org/libs-milestone</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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
|
||||
*
|
||||
* https://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.samples.mailses;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.context.support.GenericXmlApplicationContext;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.mail.MailException;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessagePreparator;
|
||||
import org.subethamail.wiser.Wiser;
|
||||
import org.subethamail.wiser.WiserMessage;
|
||||
|
||||
/**
|
||||
* Starts the Spring Context and will initialize the Spring Integration routes.
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
* @since 2.2
|
||||
*
|
||||
*/
|
||||
public final class Main {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(Main.class);
|
||||
|
||||
private static final String HORIZONTAL_LINE = "\n=========================================================";
|
||||
|
||||
private Main() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Spring Integration Application Context
|
||||
*
|
||||
* @param args - command line arguments
|
||||
*/
|
||||
public static void main(final String... args) {
|
||||
|
||||
final Scanner scanner = new Scanner(System.in);
|
||||
|
||||
LOGGER.info(HORIZONTAL_LINE + "\n"
|
||||
+ "\n Welcome to Spring Integration! "
|
||||
+ "\n"
|
||||
+ "\n For more information please visit: "
|
||||
+ "\n https://www.springsource.org/spring-integration "
|
||||
+ "\n" + HORIZONTAL_LINE);
|
||||
|
||||
System.out.println("Please enter a choice and press <enter>: ");
|
||||
System.out.println("\t1. Use Embedded SMTP Server (Wiser)");
|
||||
System.out.println("\t2. Use Amazon SES");
|
||||
|
||||
System.out.println("\tq. Quit the application");
|
||||
System.out.print("Enter your choice: ");
|
||||
|
||||
final GenericXmlApplicationContext context = new GenericXmlApplicationContext();
|
||||
final ConfigurableEnvironment environment = context.getEnvironment();
|
||||
|
||||
boolean usingWiser = false;
|
||||
|
||||
String toEmailAddress;
|
||||
|
||||
while (true) {
|
||||
final String input = scanner.nextLine();
|
||||
|
||||
if("1".equals(input.trim())) {
|
||||
environment.setActiveProfiles("default");
|
||||
usingWiser = true;
|
||||
|
||||
System.out.print("\nTo which email address would you like to send a message?: ");
|
||||
toEmailAddress = scanner.nextLine();
|
||||
|
||||
break;
|
||||
} else if("2".equals(input.trim())) {
|
||||
environment.setActiveProfiles("aws");
|
||||
|
||||
if (!environment.containsProperty("accessKey")) {
|
||||
System.out.print("\nPlease enter your access key: ");
|
||||
final String accessKey = scanner.nextLine();
|
||||
environment.getSystemProperties().put("accessKey", accessKey);
|
||||
}
|
||||
|
||||
if (!environment.containsProperty("secretKey")) {
|
||||
System.out.print("\nPlease enter your secret key: ");
|
||||
final String secretKey = scanner.nextLine();
|
||||
environment.getSystemProperties().put("secretKey", secretKey);
|
||||
}
|
||||
System.out.print("\nTo which email address would you like to send a message?: ");
|
||||
toEmailAddress = scanner.nextLine();
|
||||
|
||||
break;
|
||||
} else if("q".equals(input.trim())) {
|
||||
System.out.println("Exiting application...bye.");
|
||||
System.exit(0);
|
||||
} else {
|
||||
System.out.println("Invalid choice\n\n");
|
||||
System.out.print("Enter you choice: ");
|
||||
}
|
||||
}
|
||||
|
||||
context.load("classpath:META-INF/spring/integration/*-context.xml");
|
||||
context.registerShutdownHook();
|
||||
context.refresh();
|
||||
|
||||
final JavaMailSender ms = context.getBean(JavaMailSender.class);
|
||||
final String toEmailAddressToUse = toEmailAddress;
|
||||
final MimeMessagePreparator preparator = new MimeMessagePreparator() {
|
||||
|
||||
public void prepare(MimeMessage mimeMessage) throws Exception {
|
||||
|
||||
mimeMessage.setRecipient(Message.RecipientType.TO,
|
||||
new InternetAddress(toEmailAddressToUse));
|
||||
mimeMessage.setFrom(new InternetAddress(toEmailAddressToUse));
|
||||
mimeMessage.setSubject("Testing Email - Subject");
|
||||
mimeMessage.setText("Hello World");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
try {
|
||||
ms.send(preparator);
|
||||
} catch (MailException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
System.out.println(String.format("The email to '%s' was sent successfully.", toEmailAddress));
|
||||
|
||||
if (usingWiser) {
|
||||
Wiser wiser = context.getBean(Wiser.class);
|
||||
List<WiserMessage> messages = wiser.getMessages();
|
||||
|
||||
final String from;
|
||||
final String subject;
|
||||
try {
|
||||
from = messages.get(0).getMimeMessage().getFrom()[0].toString();
|
||||
subject = messages.get(0).getMimeMessage().getSubject();
|
||||
} catch (MessagingException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
System.out.println(String.format("Wiser received an email from '%s' with subject '%s'", from, subject));
|
||||
}
|
||||
|
||||
System.exit(0);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-file="http://www.springframework.org/schema/integration/file"
|
||||
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/mail https://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/file https://www.springframework.org/schema/integration/file/spring-integration-file.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<context:property-placeholder />
|
||||
|
||||
<bean id="tcpIpUtils" class="org.springframework.integration.test.util.SocketUtils" />
|
||||
|
||||
<bean id="serverPort" class="java.lang.Integer">
|
||||
<constructor-arg value="#{tcpIpUtils.findAvailableServerSocket(12000)}"/>
|
||||
</bean>
|
||||
|
||||
<beans profile="default">
|
||||
<bean id="wiser" class="org.subethamail.wiser.Wiser" init-method="start">
|
||||
<property name="port" ref="serverPort"/>
|
||||
</bean>
|
||||
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
||||
<property name="port" ref="serverPort"/>
|
||||
</bean>
|
||||
</beans>
|
||||
|
||||
<beans profile="aws">
|
||||
<bean id="mailSender" class="org.springframework.integration.aws.ses.core.DefaultAmazonSESMailSender">
|
||||
<constructor-arg name="credentials">
|
||||
<bean class="org.springframework.integration.aws.core.BasicAWSCredentials">
|
||||
<property name="accessKey" value="${accessKey}"/>
|
||||
<property name="secretKey" value="${secretKey}"/>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</beans>
|
||||
|
||||
</beans>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
|
||||
<!-- Appenders -->
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out" />
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Loggers -->
|
||||
<logger name="org.springframework.integration.mail">
|
||||
<level value="debug" />
|
||||
</logger>
|
||||
|
||||
<logger name="org.springframework.integration.samples">
|
||||
<level value="debug" />
|
||||
</logger>
|
||||
|
||||
<!-- Root Logger -->
|
||||
<root>
|
||||
<priority value="warn" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
2
samples/splunk/.gitignore
vendored
2
samples/splunk/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
derby.log
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
Spring Integration Splunk Sample
|
||||
================================
|
||||
|
||||
This sample demonstrates the usage of the *[Spring Integration Splunk][]* adapters.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Splunk Server
|
||||
|
||||
You need to install or have access to a [Splunk][] Server. You can download [Splunk][] from:
|
||||
|
||||
* https://www.splunk.com/download
|
||||
|
||||
#### Data Inputs
|
||||
|
||||
Depending on your Splunk Server installation, you may have to open up a TCP by adding an additional *data input*. E.g. the sample uses TCP port **9999**.
|
||||
|
||||
For instructions please see:
|
||||
|
||||
* https://docs.splunk.com/Documentation/Splunk/latest/Data/Monitornetworkports
|
||||
|
||||
### Spring Integration Splunk dependencies
|
||||
|
||||
The sample application depends on the [Spring Integration Splunk][] support. As of Oct 1, 2012, the dependencies for *Spring Integration Splunk* are available through the [SpringSource Maven Repository][]:
|
||||
|
||||
* https://repo.springsource.org/simple/libs-snapshot-local/org/springframework/integration/spring-integration-splunk/0.5.0.BUILD-SNAPSHOT
|
||||
|
||||
However, if you prefer, you can manually build the *Spring Integration Splunk* project. In order order to do so, follow the following steps:
|
||||
|
||||
1. Change to folder `spring-integration-extensions/spring-integration-splunk`
|
||||
2. Execute `./gradlew publish`
|
||||
|
||||
This should install the [Spring Integration Splunk] jar files to your local Maven repository. Please see the [Spring Integration Splunk][] project for further information.
|
||||
|
||||
## Generate the Eclipse project:
|
||||
|
||||
Now you can generate the Eclipse project for the provided sample:
|
||||
|
||||
1. Change to folder `samples/splunk`
|
||||
2. Execute `./gradlew eclipse`
|
||||
|
||||
## Run the example applications
|
||||
|
||||
1. Update the [Splunk][] server info in `src/main/resources/org/springframework/integration/samples/splunk/SplunkCommon-context.xml`
|
||||
2. Run the main classes.
|
||||
|
||||
You may want to run the *Outbound Channel Adapter* application first in order to push some data into [Splunk][]. After that, run the *Inbound Channel Adapter* application to read the data.
|
||||
|
||||
### Outbound Channel Adapter
|
||||
|
||||
* **Submit**: SplunkOutboundChannelAdapterSubmitSample
|
||||
* **Tcp**: SplunkOutboundChannelAdapterTcpSample
|
||||
* **Stream**: SplunkOutboundChannelAdapterStreamSample
|
||||
|
||||
### Inbound Channel Adapter
|
||||
|
||||
* **Blocking search**: SplunkInboundChannelAdapterBlockingSample
|
||||
* **Non blocking search**: SplunkInboundChannelAdapterNonBlockingSample
|
||||
* **Realtime search**: SplunkInboundChannelAdapterRealtimeSample
|
||||
* **Export search**: SplunkInboundChannelAdapterExportSample
|
||||
* **Saved search**: SplunkInboundChannelAdapterSavedSample
|
||||
|
||||
[Splunk]: https://www.splunk.com/
|
||||
[Spring Integration Splunk]: https://github.com/SpringSource/spring-integration-extensions/tree/master/spring-integration-splunk
|
||||
[SpringSource Maven Repository]: https://repo.springsource.org/
|
||||
@@ -1,30 +0,0 @@
|
||||
description = 'Spring Integration Splunk Sample'
|
||||
apply plugin: 'base'
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'application'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url "https://repo.springsource.org/libs-snapshot" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.springframework.integration:spring-integration-splunk:$springIntegrationSplunkVersion"
|
||||
compile "org.springframework.integration:spring-integration-jdbc:$springIntegrationVersion"
|
||||
compile "org.springframework:spring-jdbc:$springVersion"
|
||||
compile "org.apache.derby:derby:$derbyVersion"
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
description = 'Generates gradlew[.bat] scripts'
|
||||
gradleVersion = '1.2'
|
||||
}
|
||||
|
||||
eclipse {
|
||||
project {
|
||||
name = "spring-integration-splunk-sample"
|
||||
}
|
||||
}
|
||||
|
||||
defaultTasks 'clean', 'build'
|
||||
@@ -1,8 +0,0 @@
|
||||
springVersion = 3.1.2.RELEASE
|
||||
springIntegrationVersion = 2.1.2.RELEASE
|
||||
derbyVersion = 10.9.1.0
|
||||
springIntegrationSplunkVersion = 0.5.0.BUILD-SNAPSHOT
|
||||
version = 0.5.0.BUILD-SNAPSHOT
|
||||
|
||||
|
||||
|
||||
BIN
samples/splunk/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
samples/splunk/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
#Fri Sep 28 16:40:22 CST 2012
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-1.2-bin.zip
|
||||
164
samples/splunk/gradlew
vendored
164
samples/splunk/gradlew
vendored
@@ -1,164 +0,0 @@
|
||||
#!/bin/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 businessSystem maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
90
samples/splunk/gradlew.bat
vendored
90
samples/splunk/gradlew.bat
vendored
@@ -1,90 +0,0 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* https://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.samples.splunk.inbound;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.splunk.entity.SplunkData;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author Jarred Li
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class SplunkDataHandler {
|
||||
|
||||
@ServiceActivator
|
||||
public void handle(List<SplunkData> data) {
|
||||
for (SplunkData sd : data) {
|
||||
System.out.println("splunk data:" + sd.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* https://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.samples.splunk.inbound;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Jarred Li
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class SplunkInboundChannelAdapterBlockingSample {
|
||||
|
||||
public static void main(String args[]) {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"SplunkInboundChannelAdapterBlockingSample-context.xml", SplunkInboundChannelAdapterBlockingSample.class);
|
||||
ctx.start();
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* https://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.samples.splunk.inbound;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Jarred Li
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class SplunkInboundChannelAdapterExportSample {
|
||||
|
||||
public static void main(String args[]) {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"SplunkInboundChannelAdapterExportSample-context.xml", SplunkInboundChannelAdapterExportSample.class);
|
||||
ctx.start();
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* https://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.samples.splunk.inbound;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Jarred Li
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class SplunkInboundChannelAdapterNonBlockingSample {
|
||||
|
||||
public static void main(String args[]) {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"SplunkInboundChannelAdapterNonBlockingSample-context.xml",
|
||||
SplunkInboundChannelAdapterNonBlockingSample.class);
|
||||
ctx.start();
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* https://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.samples.splunk.inbound;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Jarred Li
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class SplunkInboundChannelAdapterRealtimeSample {
|
||||
|
||||
public static void main(String args[]) {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"SplunkInboundChannelAdapterRealtimeSample-context.xml", SplunkInboundChannelAdapterRealtimeSample.class);
|
||||
ctx.start();
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* https://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.samples.splunk.inbound;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Jarred Li
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class SplunkInboundChannelAdapterSavedSample {
|
||||
|
||||
public static void main(String args[]) {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"SplunkInboundChannelAdapterSavedSample-context.xml", SplunkInboundChannelAdapterSavedSample.class);
|
||||
ctx.start();
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* https://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.samples.splunk.outbound;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.SubscribableChannel;
|
||||
import org.springframework.integration.splunk.entity.SplunkData;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jarred Li
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class SplunkOutboundChannelAdapterStreamSample {
|
||||
|
||||
public static void main(String args[]) {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"SplunkOutboundChannelAdapterStreamSample-context.xml", SplunkOutboundChannelAdapterStreamSample.class);
|
||||
ctx.start();
|
||||
|
||||
SubscribableChannel channel = ctx.getBean("outputToSplunk", SubscribableChannel.class);
|
||||
|
||||
SplunkData data = new SplunkData("spring", "spring:example");
|
||||
data.setCommonDesc("description");
|
||||
|
||||
Message<SplunkData> msg = MessageBuilder.withPayload(data).build();
|
||||
channel.send(msg);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* https://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.samples.splunk.outbound;
|
||||
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.splunk.entity.SplunkData;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jarred Li
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class SplunkOutboundChannelAdapterSubmitSample {
|
||||
|
||||
public static void main(String args[]) {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"SplunkOutboundChannelAdapterSubmitSample-context.xml", SplunkOutboundChannelAdapterSubmitSample.class);
|
||||
ctx.start();
|
||||
|
||||
generateMessage(ctx);
|
||||
}
|
||||
|
||||
private static void generateMessage(ClassPathXmlApplicationContext ctx) {
|
||||
QueueChannel channel = ctx.getBean("outputToSplunkWithMessageStore", QueueChannel.class);
|
||||
|
||||
SplunkData data = new SplunkData("spring", "spring:example");
|
||||
data.setCommonDesc("description");
|
||||
|
||||
Message<SplunkData> msg = MessageBuilder.withPayload(data).build();
|
||||
channel.send(msg);
|
||||
msg = MessageBuilder.withPayload(data).build();
|
||||
channel.send(msg);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2012 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
|
||||
*
|
||||
* https://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.samples.splunk.outbound;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.SubscribableChannel;
|
||||
import org.springframework.integration.splunk.entity.SplunkData;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jarred Li
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class SplunkOutboundChannelAdapterTcpSample {
|
||||
|
||||
public static void main(String args[]) {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"SplunkOutboundChannelAdapterTcpSample-context.xml", SplunkOutboundChannelAdapterTcpSample.class);
|
||||
ctx.start();
|
||||
|
||||
SubscribableChannel channel = ctx.getBean("outputToSplunk", SubscribableChannel.class);
|
||||
|
||||
SplunkData data = new SplunkData("spring", "spring:example");
|
||||
data.setCommonDesc("description");
|
||||
|
||||
Message<SplunkData> msg = MessageBuilder.withPayload(data).build();
|
||||
channel.send(msg);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
log4j.rootCategory=DEBUG, stdout
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/integration/splunk https://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||
|
||||
<context:component-scan base-package="org.springframework.integration.splunk"></context:component-scan>
|
||||
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"/>
|
||||
|
||||
<int-splunk:server id="splunkServer" host="10.112.127.51" port="8089" userName="admin" password="password" owner="admin"/>
|
||||
|
||||
</beans>
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/integration/splunk https://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||
|
||||
<import resource="SplunkInboundChannelAdapterCommon-context.xml"/>
|
||||
|
||||
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||
auto-startup="true" search="search spring:example"
|
||||
splunk-server-ref="splunkServer"
|
||||
channel="inputFromSplunk" mode="BLOCKING" initEarliestTime="-1d">
|
||||
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||
</int-splunk:inbound-channel-adapter>
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/integration/splunk https://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||
|
||||
<import resource="../SplunkCommon-context.xml"/>
|
||||
<context:component-scan base-package="org.springframework.integration.samples.splunk"></context:component-scan>
|
||||
<int:channel id="inputFromSplunk">
|
||||
</int:channel>
|
||||
<int:service-activator input-channel="inputFromSplunk" ref="splunkDataHandler"></int:service-activator>
|
||||
<!-- <stream:stdout-channel-adapter id="stdout" channel="inputFromSplunk" append-newline="true"/> -->
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/integration/splunk https://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||
|
||||
<import resource="SplunkInboundChannelAdapterCommon-context.xml"/>
|
||||
|
||||
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||
auto-startup="true" search="search spring:example" splunk-server-ref="splunkServer" channel="inputFromSplunk"
|
||||
mode="EXPORT" earliestTime="-5d" latestTime="now" initEarliestTime="-1d">
|
||||
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||
</int-splunk:inbound-channel-adapter>
|
||||
|
||||
</beans>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/integration/splunk https://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||
|
||||
<import resource="SplunkInboundChannelAdapterCommon-context.xml"/>
|
||||
|
||||
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||
auto-startup="true" search="search spring:example" splunk-server-ref="splunkServer" channel="inputFromSplunk"
|
||||
mode="NORMAL" earliestTime="-5d" latestTime="now" initEarliestTime="-1d">
|
||||
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||
</int-splunk:inbound-channel-adapter>
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/integration/splunk https://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||
|
||||
<import resource="SplunkInboundChannelAdapterCommon-context.xml"/>
|
||||
|
||||
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||
auto-startup="true" search="search spring:example" splunk-server-ref="splunkServer" channel="inputFromSplunk"
|
||||
mode="REALTIME" earliestTime="-5s" latestTime="rt" initEarliestTime="-1d">
|
||||
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||
</int-splunk:inbound-channel-adapter>
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/integration/splunk https://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||
|
||||
<import resource="SplunkInboundChannelAdapterCommon-context.xml"/>
|
||||
|
||||
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||
auto-startup="true" savedSearch="test" splunk-server-ref="splunkServer" channel="inputFromSplunk"
|
||||
mode="SAVEDSEARCH" earliestTime="-5d" latestTime="now" initEarliestTime="-1d">
|
||||
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||
</int-splunk:inbound-channel-adapter>
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -1,41 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/splunk https://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/stream https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd
|
||||
http://www.springframework.org/schema/jdbc https://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
http://www.springframework.org/schema/integration/jdbc https://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd">
|
||||
|
||||
<import resource="../SplunkCommon-context.xml" />
|
||||
|
||||
<jdbc:embedded-database id="dataSource" type="DERBY" />
|
||||
|
||||
<jdbc:initialize-database data-source="dataSource"
|
||||
ignore-failures="DROPS">
|
||||
<jdbc:script
|
||||
location="classpath:org/springframework/integration/jdbc/schema-derby.sql" />
|
||||
</jdbc:initialize-database>
|
||||
|
||||
<int-jdbc:message-store id="messageStore"
|
||||
data-source="dataSource" table-prefix="INT_" />
|
||||
|
||||
<bean id="txManager"
|
||||
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<int:channel id="outputToSplunk">
|
||||
</int:channel>
|
||||
|
||||
<int:channel id="outputToSplunkWithMessageStore">
|
||||
<int:queue message-store="messageStore" capacity="1000" />
|
||||
</int:channel>
|
||||
|
||||
</beans>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/integration/stream https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/splunk https://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd">
|
||||
|
||||
<import resource="SplunkOutboundChannelAdapterCommon-context.xml"/>
|
||||
|
||||
<int-splunk:outbound-channel-adapter
|
||||
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
|
||||
channel="outputToSplunk" splunk-server-ref="splunkServer"
|
||||
ingest="STREAM" host="localhost">
|
||||
</int-splunk:outbound-channel-adapter>
|
||||
|
||||
</beans>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/integration/stream https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/splunk https://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd">
|
||||
|
||||
<import resource="SplunkOutboundChannelAdapterCommon-context.xml"/>
|
||||
|
||||
<int-splunk:outbound-channel-adapter
|
||||
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
|
||||
channel="outputToSplunkWithMessageStore" splunk-server-ref="splunkServer"
|
||||
pool-server-connection="true" sourceType="spring-integration" source="example5"
|
||||
ingest="SUBMIT" host="test.host">
|
||||
<int:poller fixed-rate="5" time-unit="SECONDS">
|
||||
<int:transactional transaction-manager="txManager"
|
||||
isolation="DEFAULT" propagation="REQUIRED" />
|
||||
</int:poller>
|
||||
</int-splunk:outbound-channel-adapter>
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/integration/stream https://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/splunk https://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd">
|
||||
|
||||
<import resource="SplunkOutboundChannelAdapterCommon-context.xml"/>
|
||||
|
||||
<int-splunk:outbound-channel-adapter
|
||||
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
|
||||
channel="outputToSplunk" splunk-server-ref="splunkServer"
|
||||
ingest="TCP" tcpPort="9999">
|
||||
</int-splunk:outbound-channel-adapter>
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -8,47 +8,29 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>voldemort-sample</name>
|
||||
<url>https://www.springsource.org/spring-integration</url>
|
||||
|
||||
<prerequisites>
|
||||
<maven>2.2.1</maven>
|
||||
</prerequisites>
|
||||
<url>https://www.spring.io/spring-integration</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.integration.voldemort.version>1.0.0.BUILD-SNAPSHOT</spring.integration.voldemort.version>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<junit.version>4.11</junit.version>
|
||||
<log4j.version>2.13.0</log4j.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>repo.springsource.org.milestone</id>
|
||||
<name>Spring Framework Maven Milestone Repository</name>
|
||||
<url>https://repo.springsource.org/libs-milestone</url>
|
||||
<url>https://repo.spring.io/libs-milestone</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-eclipse-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<configuration>
|
||||
<additionalProjectnatures>
|
||||
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
|
||||
</additionalProjectnatures>
|
||||
<additionalBuildcommands>
|
||||
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
|
||||
</additionalBuildcommands>
|
||||
<downloadSources>true</downloadSources>
|
||||
<downloadJavadocs>true</downloadJavadocs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
@@ -60,7 +42,7 @@
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<version>1.6.0</version>
|
||||
<configuration>
|
||||
<mainClass>org.springframework.integration.samples.voldemort.Main</mainClass>
|
||||
</configuration>
|
||||
@@ -90,8 +72,8 @@
|
||||
<!-- Logging -->
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-jcl</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -13,14 +13,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.samples.voldemort;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import org.springframework.integration.samples.voldemort.service.BusinessService;
|
||||
|
||||
|
||||
@@ -28,14 +30,16 @@ import org.springframework.integration.samples.voldemort.service.BusinessService
|
||||
* Starts the Spring Context and will initialize the Spring Integration routes.
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public final class Main {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(Main.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(Main.class);
|
||||
|
||||
private Main() { }
|
||||
private Main() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Spring Integration Application Context
|
||||
@@ -46,13 +50,13 @@ public final class Main {
|
||||
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("\n========================================================="
|
||||
+ "\n "
|
||||
+ "\n Welcome to Spring Integration! "
|
||||
+ "\n "
|
||||
+ "\n For more information please visit: "
|
||||
+ "\n https://www.springsource.org/spring-integration "
|
||||
+ "\n "
|
||||
+ "\n=========================================================" );
|
||||
+ "\n "
|
||||
+ "\n Welcome to Spring Integration! "
|
||||
+ "\n "
|
||||
+ "\n For more information please visit: "
|
||||
+ "\n https://www.springsource.org/spring-integration "
|
||||
+ "\n "
|
||||
+ "\n=========================================================");
|
||||
}
|
||||
|
||||
final AbstractApplicationContext context =
|
||||
@@ -66,10 +70,10 @@ public final class Main {
|
||||
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("\n========================================================="
|
||||
+ "\n "
|
||||
+ "\n Please press 'q + Enter' to quit the application. "
|
||||
+ "\n "
|
||||
+ "\n=========================================================" );
|
||||
+ "\n "
|
||||
+ "\n Please press 'q + Enter' to quit the application. "
|
||||
+ "\n "
|
||||
+ "\n=========================================================");
|
||||
}
|
||||
|
||||
System.out.print("Please enter a string and press <enter>: ");
|
||||
@@ -80,7 +84,7 @@ public final class Main {
|
||||
|
||||
final String data = scanner.nextLine();
|
||||
|
||||
if("q".equals(data.trim())) {
|
||||
if ("q".equals(data.trim())) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -89,7 +93,8 @@ public final class Main {
|
||||
System.out.println(String.format("Persisting String: '%s' with key '%s'.", data, key));
|
||||
service.saveData(key, data);
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOGGER.error("An exception was caught: " + e);
|
||||
}
|
||||
|
||||
@@ -104,4 +109,5 @@ public final class Main {
|
||||
System.exit(0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-voldemort="http://www.springframework.org/schema/integration/voldemort"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration-2.2.xsd
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/voldemort https://www.springframework.org/schema/integration/voldemort/spring-integration-voldemort.xsd">
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
|
||||
<!-- Appenders -->
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out" />
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Loggers -->
|
||||
<logger name="org.springframework.integration">
|
||||
<level value="warn" />
|
||||
</logger>
|
||||
|
||||
<logger name="org.springframework.integration.samples.voldemort">
|
||||
<level value="info" />
|
||||
</logger>
|
||||
|
||||
<!-- Root Logger -->
|
||||
<root>
|
||||
<priority value="warn" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
15
samples/voldemort/src/main/resources/log4j2.xml
Normal file
15
samples/voldemort/src/main/resources/log4j2.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.samples.voldemort" level="info"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -1,103 +0,0 @@
|
||||
Spring Integration - XQuery Sample
|
||||
==================================
|
||||
|
||||
## Overview
|
||||
|
||||
This sample executes a simple [XQuery][] script. It uses the *[Spring Integration XQuery][]* module, which is part of the [Spring Integration Extensions][] project. The sample uses one of the following 3 XQuery processors:
|
||||
|
||||
* [Saxon][]
|
||||
* [Sedna][]
|
||||
* [BaseX][]
|
||||
|
||||
The example for [Saxon][] will work out of the box. [Sedna][] and [BaseX][] are in fact [XML Databases][], which run as external processes. For [Sedna][]- and [BaseX][]-specific setup instructions, please visit:
|
||||
|
||||
* http://xqj.net/sedna/
|
||||
* http://xqj.net/basex/
|
||||
|
||||
## Running the Sample
|
||||
|
||||
From the command line execute:
|
||||
|
||||
$ mvn clean package
|
||||
|
||||
followed by:
|
||||
|
||||
$ mvn exec:java
|
||||
|
||||
The application should start up and you will see the following screen on which you can choose which XQuery processor to use:
|
||||
|
||||
=========================================================
|
||||
|
||||
Welcome to the Spring Integration XQuery Sample!
|
||||
|
||||
For more information please visit:
|
||||
https://www.springsource.org/spring-integration/
|
||||
|
||||
=========================================================
|
||||
Which XQuery Processor would you like to use? <enter>:
|
||||
1. Use Saxon
|
||||
2. Use Sedna
|
||||
3. Use BaseX
|
||||
q. Quit the application
|
||||
Enter you choice:
|
||||
|
||||
### Note regarding BaseX
|
||||
|
||||
The [BaseX][] dependency conflicts with [Sedna][]. Therefore, this sample applies a separate Maven profile for [BaseX][]. If not triggering that special profile when you try to execute the [BaseX][] example, you may encounter the following error message:
|
||||
|
||||
Detected the Sedna library to be present. This conflicts with BaseX. Please start the application from the command line using:
|
||||
|
||||
mvn exec:java -Dbasex
|
||||
|
||||
Consequently, execute from the command line:
|
||||
|
||||
$ mvn exec:java -Dbasex
|
||||
|
||||
The [BaseX][] sample will now execute successfully.
|
||||
|
||||
## Details
|
||||
|
||||
The used XQuery Script, located under `src/main/resources/data/xquery.xql`, is quite simple:
|
||||
|
||||
<customers>
|
||||
{ //customers/customer/name }
|
||||
</customers>
|
||||
|
||||
All it does is extracting the customer names from the following XML document:
|
||||
|
||||
<customers>
|
||||
<customer id="1">
|
||||
<name>Foo Industries</name>
|
||||
<industry>Chemical</industry>
|
||||
<city>Glowing City</city>
|
||||
</customer>
|
||||
<customer id="2">
|
||||
<name>Bar Refreshments</name>
|
||||
<industry>Beverage</industry>
|
||||
<city>Desert Town</city>
|
||||
</customer>
|
||||
<customer id="3">
|
||||
<name>Hello World Services</name>
|
||||
<industry>Travel</industry>
|
||||
<city>Coral Sands</city>
|
||||
</customer>
|
||||
</customers>
|
||||
|
||||
|
||||
The XML document is located at `src/main/resources/data/customers.xml`.
|
||||
|
||||
The resulting XML document should look like:
|
||||
|
||||
<customers>
|
||||
<name>Foo Industries</name>
|
||||
<name>Bar Refreshments</name>
|
||||
<name>Hello World Services</name>
|
||||
</customers>
|
||||
|
||||
[Saxon]: https://sourceforge.net/projects/saxon/
|
||||
[Sedna]: https://www.sedna.org/
|
||||
[BaseX]: https://basex.org/
|
||||
[Spring Integration XQuery]: https://github.com/SpringSource/spring-integration-extensions/tree/master/spring-integration-xquery
|
||||
[Spring Integration Extensions]: https://github.com/SpringSource/spring-integration-extensions
|
||||
[XML Databases]: https://en.wikipedia.org/wiki/XML_database
|
||||
[XQuery]: https://en.wikipedia.org/wiki/XQuery
|
||||
@@ -1,153 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.springframework.integration.samples</groupId>
|
||||
<artifactId>xquery</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Samples (Basic) - XQuery Sample</name>
|
||||
<url>https://www.springsource.org/spring-integration</url>
|
||||
|
||||
<prerequisites>
|
||||
<maven>2.2.1</maven>
|
||||
</prerequisites>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.integration.version>4.3.19.RELEASE</spring.integration.version>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<junit.version>4.10</junit.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>repo.springsource.org.milestone</id>
|
||||
<name>Spring Framework Maven Snapshot Repository</name>
|
||||
<url>https://repo.springsource.org/libs-snapshot</url>
|
||||
<snapshots><enabled>true</enabled></snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-eclipse-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<configuration>
|
||||
<additionalProjectnatures>
|
||||
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
|
||||
</additionalProjectnatures>
|
||||
<additionalBuildcommands>
|
||||
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
|
||||
</additionalBuildcommands>
|
||||
<downloadSources>true</downloadSources>
|
||||
<downloadJavadocs>true</downloadJavadocs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<compilerArgument>-Xlint:all</compilerArgument>
|
||||
<showWarnings>true</showWarnings>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<configuration>
|
||||
<mainClass>org.springframework.integration.Main</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Testing -->
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Integration -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-core</artifactId>
|
||||
<version>${spring.integration.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-xml</artifactId>
|
||||
<version>${spring.integration.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-xquery</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Logging -->
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Saxon -->
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.saxon</groupId>
|
||||
<artifactId>Saxon-HE</artifactId>
|
||||
<version>9.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>default</id>
|
||||
<activation>
|
||||
<property><name>!basex</name></property>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.xqj.sedna</groupId>
|
||||
<artifactId>sedna-xqj</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xqj2</groupId>
|
||||
<artifactId>xqj2</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>basex</id>
|
||||
<activation>
|
||||
<property><name>basex</name></property>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.xqj</groupId>
|
||||
<artifactId>basex-xqj</artifactId>
|
||||
<version>1.2.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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
|
||||
*
|
||||
* https://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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.context.support.GenericXmlApplicationContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.service.CustomerService;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Starts the Spring Context and will initialize the Spring Integration routes.
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
public final class Main {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(Main.class);
|
||||
|
||||
private static final String HORIZONTAL_LINE = "=========================================================\n";
|
||||
|
||||
private Main() { }
|
||||
|
||||
/**
|
||||
* Load the Spring Integration Application Context
|
||||
*
|
||||
* @param args - command line arguments
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void main(final String... args) throws IOException {
|
||||
|
||||
final Scanner scanner = new Scanner(System.in);
|
||||
|
||||
System.out.println("\n"
|
||||
+ HORIZONTAL_LINE
|
||||
+ "\n "
|
||||
+ "\n Welcome to the Spring Integration XQuery Sample! "
|
||||
+ "\n "
|
||||
+ "\n For more information please visit: "
|
||||
+ "\n https://www.springsource.org/spring-integration/ "
|
||||
+ "\n "
|
||||
+ "\n"
|
||||
+ HORIZONTAL_LINE);
|
||||
|
||||
System.out.println("Which XQuery Processor would you like to use? <enter>: ");
|
||||
System.out.println("\t1. Use Saxon");
|
||||
System.out.println("\t2. Use Sedna");
|
||||
System.out.println("\t3. Use BaseX");
|
||||
|
||||
System.out.println("\tq. Quit the application");
|
||||
System.out.print("Enter your choice: ");
|
||||
|
||||
final GenericXmlApplicationContext context = new GenericXmlApplicationContext();
|
||||
|
||||
while (true) {
|
||||
final String input = scanner.nextLine();
|
||||
|
||||
if("1".equals(input.trim())) {
|
||||
context.getEnvironment().setActiveProfiles("saxon");
|
||||
System.out.println("\nUsing Saxon...");
|
||||
break;
|
||||
} else if("2".equals(input.trim())) {
|
||||
context.getEnvironment().setActiveProfiles("sedna");
|
||||
System.out.println("\nUsing Sedna...");
|
||||
break;
|
||||
} else if("3".equals(input.trim())) {
|
||||
context.getEnvironment().setActiveProfiles("basex");
|
||||
System.out.println("\nUsing BaseX...");
|
||||
|
||||
if(ClassUtils.isPresent("net.xqj.sedna.SednaXQDataSource", ClassUtils.getDefaultClassLoader())) {
|
||||
LOGGER.error("Detected the Sedna library to be present. This "
|
||||
+ "conflicts with BaseX. Please start the application "
|
||||
+ "from the command line using:\n\n"
|
||||
+ "mvn exec:java -Dbasex\n\nExiting...");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
break;
|
||||
} else if("q".equals(input.trim())) {
|
||||
System.out.println("Exiting application...bye.");
|
||||
System.exit(0);
|
||||
} else {
|
||||
System.out.println("Invalid choice\n\n");
|
||||
System.out.print("Enter you choice: ");
|
||||
}
|
||||
}
|
||||
|
||||
context.load("classpath:META-INF/spring/integration/*-context.xml");
|
||||
context.registerShutdownHook();
|
||||
context.refresh();
|
||||
|
||||
final CustomerService service = context.getBean(CustomerService.class);
|
||||
|
||||
final Resource resource = context.getResource("classpath:data/customers.xml");
|
||||
final InputStream is = resource.getInputStream();
|
||||
final String customers = new String(FileCopyUtils.copyToByteArray(is));
|
||||
|
||||
System.out.println("\n\nExtracting Customer Names from:\n"
|
||||
+ HORIZONTAL_LINE
|
||||
+ customers + "\n"
|
||||
+ HORIZONTAL_LINE
|
||||
+ "\n");
|
||||
final String customernames = service.getCustomerNames(customers);
|
||||
System.out.println("Extracted Customer Names: \n"
|
||||
+ HORIZONTAL_LINE
|
||||
+ customernames + "\n"
|
||||
+ HORIZONTAL_LINE
|
||||
+ "\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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
|
||||
*
|
||||
* https://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.service;
|
||||
|
||||
/**
|
||||
* XML Extraction Service.
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
public interface CustomerService {
|
||||
|
||||
/**
|
||||
* For a given customer XML file, this method extracts all customer names and
|
||||
* returns them as a new XML document.
|
||||
*
|
||||
* @param sourceXml The source XML file to extract the customer names from
|
||||
* @return The String-based XML document containing the customer names
|
||||
*/
|
||||
String getCustomerNames(String sourceXml);
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-xquery="http://www.springframework.org/schema/integration/xquery"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/xquery https://www.springframework.org/schema/integration/xquery/spring-integration-xquery.xsd">
|
||||
|
||||
<int:gateway id="gateway" default-request-timeout="5000"
|
||||
default-reply-timeout="5000" default-request-channel="requestChannel"
|
||||
service-interface="org.springframework.integration.service.CustomerService">
|
||||
<int:method name="getCustomerNames" />
|
||||
</int:gateway>
|
||||
|
||||
<int:channel id="requestChannel" />
|
||||
|
||||
<int-xquery:xquery-transformer id="xqueryTransformer"
|
||||
data-source="xqDataSource" input-channel="requestChannel"
|
||||
format-output="true" xquery-file-resource="classpath:data/xquery.xql">
|
||||
</int-xquery:xquery-transformer>
|
||||
|
||||
<beans profile="default, saxon">
|
||||
<bean id="xqDataSource" class="net.sf.saxon.xqj.SaxonXQDataSource" />
|
||||
</beans>
|
||||
|
||||
<beans profile="sedna">
|
||||
<bean id="xqDataSource" class="net.xqj.sedna.SednaXQDataSource">
|
||||
<property name="serverName" value="localhost" />
|
||||
<property name="databaseName" value="test" />
|
||||
</bean>
|
||||
</beans>
|
||||
|
||||
<beans profile="basex">
|
||||
<bean id="xqDataSource" class="net.xqj.basex.BaseXXQDataSource">
|
||||
<property name="user" value="admin" />
|
||||
<property name="password" value="admin" />
|
||||
<property name="serverName" value="localhost" />
|
||||
<property name="port" value="1984" />
|
||||
</bean>
|
||||
</beans>
|
||||
|
||||
</beans>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<customers>
|
||||
<customer id="1">
|
||||
<name>Foo Industries</name>
|
||||
<industry>Chemical</industry>
|
||||
<city>Glowing City</city>
|
||||
</customer>
|
||||
<customer id="2">
|
||||
<name>Bar Refreshments</name>
|
||||
<industry>Beverage</industry>
|
||||
<city>Desert Town</city>
|
||||
</customer>
|
||||
<customer id="3">
|
||||
<name>Hello World Services</name>
|
||||
<industry>Travel</industry>
|
||||
<city>Coral Sands</city>
|
||||
</customer>
|
||||
</customers>
|
||||
@@ -1,4 +0,0 @@
|
||||
(: The XQuery Script that will extract the customer names from the source XML file :)
|
||||
<customers>
|
||||
{ //customers/customer/name }
|
||||
</customers>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
|
||||
<!-- Appenders -->
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out" />
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Loggers -->
|
||||
<logger name="org.springframework.integration">
|
||||
<level value="warn" />
|
||||
</logger>
|
||||
|
||||
<logger name="org.springframework.integration">
|
||||
<level value="warn" />
|
||||
</logger>
|
||||
|
||||
<!-- Root Logger -->
|
||||
<root>
|
||||
<priority value="warn" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
15
samples/xquery/src/main/resources/log4j2.xml
Normal file
15
samples/xquery/src/main/resources/log4j2.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.samples.zip" level="info"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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
|
||||
*
|
||||
* https://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;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.service.CustomerService;
|
||||
|
||||
/**
|
||||
* Verify that the Spring Integration Application Context starts successfully.
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public class CustomerServiceTest {
|
||||
|
||||
@Test
|
||||
public void testStartupOfSpringInegrationContext() throws Exception{
|
||||
new ClassPathXmlApplicationContext("/META-INF/spring/integration/spring-integration-context.xml",
|
||||
CustomerServiceTest.class);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractCustomerNames() {
|
||||
final ApplicationContext context
|
||||
= new ClassPathXmlApplicationContext("/META-INF/spring/integration/spring-integration-context.xml",
|
||||
CustomerServiceTest.class);
|
||||
|
||||
final CustomerService service = context.getBean(CustomerService.class);
|
||||
|
||||
final String sourceXml = "<customers><customer id=\"1\"><name>Foo Industries</name>"
|
||||
+ "<industry>Chemical</industry><city>Glowing City</city></customer></customers>";
|
||||
final String expectedResult = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
+ "<customers>\n"
|
||||
+ " <name>Foo Industries</name>\n"
|
||||
+ "</customers>\n";
|
||||
|
||||
final String extractedCustomerNames = service.getCustomerNames(sourceXml);
|
||||
|
||||
System.out.println(">>" + expectedResult + "<<");
|
||||
System.out.println(">>" + extractedCustomerNames + "<<");
|
||||
|
||||
Assert.assertEquals("The expected list of customer names did not match.",
|
||||
expectedResult, extractedCustomerNames);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,15 +10,11 @@
|
||||
<name>zip-sample</name>
|
||||
<url>https://projects.spring.io/spring-integration/</url>
|
||||
|
||||
<prerequisites>
|
||||
<maven>2.2.1</maven>
|
||||
</prerequisites>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.integration.zip.version>1.0.1.RELEASE</spring.integration.zip.version>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<junit.version>4.11</junit.version>
|
||||
<spring.integration.zip.version>1.0.2.RELEASE</spring.integration.zip.version>
|
||||
<log4j.version>2.13.0</log4j.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
@@ -31,24 +27,10 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-eclipse-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<configuration>
|
||||
<additionalProjectnatures>
|
||||
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
|
||||
</additionalProjectnatures>
|
||||
<additionalBuildcommands>
|
||||
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
|
||||
</additionalBuildcommands>
|
||||
<downloadSources>true</downloadSources>
|
||||
<downloadJavadocs>true</downloadJavadocs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
@@ -60,7 +42,7 @@
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<version>1.6.0</version>
|
||||
<configuration>
|
||||
<mainClass>org.springframework.integration.samples.zip.Main</mainClass>
|
||||
</configuration>
|
||||
@@ -87,17 +69,17 @@
|
||||
<version>${spring.integration.zip.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-core</artifactId>
|
||||
<version>4.3.17.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Logging -->
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-jcl</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
@@ -109,11 +91,5 @@
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jcl</artifactId>
|
||||
<version>1.7.12</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2018 the original author or authors.
|
||||
* Copyright 2015-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,11 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.samples.zip;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
@@ -28,12 +30,14 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
*/
|
||||
public final class Main {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(Main.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(Main.class);
|
||||
|
||||
private Main() { }
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public final class SpringIntegrationUtils {
|
||||
stringBuilder.append("\n");
|
||||
|
||||
for (final String inputDirectory : inputDirectories) {
|
||||
stringBuilder.append("\n Intput directory is: '" + inputDirectory + "'");
|
||||
stringBuilder.append("\n Input directory is: '" + inputDirectory + "'");
|
||||
}
|
||||
|
||||
for (final String outputDirectory : outputDirectories) {
|
||||
|
||||
@@ -58,13 +58,11 @@ public class TransformationHandler {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
final Message<String> message = MessageBuilder.withPayload(inputAsString.toUpperCase(Locale.ENGLISH))
|
||||
return MessageBuilder.withPayload(inputAsString.toUpperCase(Locale.ENGLISH))
|
||||
.setHeader(FileHeaders.FILENAME, filename)
|
||||
.setHeader(FileHeaders.ORIGINAL_FILE, inputFile)
|
||||
.setHeader("file_size", inputFile.length())
|
||||
.setHeader("file_extension", fileExtension)
|
||||
.build();
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
|
||||
<!-- Appenders -->
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out" />
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Loggers -->
|
||||
<logger name="org.springframework.integration">
|
||||
<level value="warn" />
|
||||
</logger>
|
||||
|
||||
<logger name="org.springframework.integration.samples.zip">
|
||||
<level value="info" />
|
||||
</logger>
|
||||
|
||||
<!-- Root Logger -->
|
||||
<root>
|
||||
<priority value="warn" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
15
samples/zip/src/main/resources/log4j2.xml
Normal file
15
samples/zip/src/main/resources/log4j2.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework.integration" level="warn"/>
|
||||
<Logger name="org.springframework.integration.samples.zip" level="info"/>
|
||||
<Root level="warn">
|
||||
<AppenderRef ref="STDOUT" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
Reference in New Issue
Block a user