Skip to content

Commit 064623c

Browse files
authored
Add files via upload
1 parent cf00efa commit 064623c

11 files changed

Lines changed: 597 additions & 0 deletions

File tree

‎Baeldung Spring Intro/README.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Spring Integration - Simple Standalone Template
2+
================================================================================
3+
4+
This template is meant for running Spring Integration standalone (No runtime
5+
container needed). This template by default only uses core Spring Integration
6+
components.
7+
8+
You can run the application by either
9+
10+
* running the "Main" class from within STS (Right-click on Main class --> Run As --> Java Application)
11+
* or from the command line:
12+
- mvn package
13+
- mvn exec:java
14+
15+
--------------------------------------------------------------------------------
16+
17+
For help please take a look at the Spring Integration documentation:
18+
19+
http://www.springsource.org/spring-integration
20+

‎Baeldung Spring Intro/pom.xml‎

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.baeldung.samples.spring.integration</groupId>
6+
<artifactId>baeldungSIsample</artifactId>
7+
<version>1.0.0.BUILD-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
10+
<name>Baeldung Spring Intro</name>
11+
<url>http://www.springsource.org/spring-integration</url>
12+
13+
<prerequisites>
14+
<maven>2.2.1</maven>
15+
</prerequisites>
16+
17+
<properties>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
<spring.integration.version>2.2.4.RELEASE</spring.integration.version>
20+
<log4j.version>1.2.17</log4j.version>
21+
<junit.version>4.11</junit.version>
22+
</properties>
23+
24+
<repositories>
25+
<repository>
26+
<id>repo.springsource.org.milestone</id>
27+
<name>Spring Framework Maven Milestone Repository</name>
28+
<url>https://repo.springsource.org/milestone</url>
29+
</repository>
30+
</repositories>
31+
32+
<build>
33+
<plugins>
34+
<plugin>
35+
<artifactId>maven-eclipse-plugin</artifactId>
36+
<version>2.9</version>
37+
<configuration>
38+
<additionalProjectnatures>
39+
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
40+
</additionalProjectnatures>
41+
<additionalBuildcommands>
42+
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
43+
</additionalBuildcommands>
44+
<downloadSources>true</downloadSources>
45+
<downloadJavadocs>true</downloadJavadocs>
46+
</configuration>
47+
</plugin>
48+
<plugin>
49+
<groupId>org.apache.maven.plugins</groupId>
50+
<artifactId>maven-compiler-plugin</artifactId>
51+
<version>3.1</version>
52+
<configuration>
53+
<source>1.6</source>
54+
<target>1.6</target>
55+
<compilerArgument>-Xlint:all</compilerArgument>
56+
<showWarnings>true</showWarnings>
57+
<showDeprecation>true</showDeprecation>
58+
</configuration>
59+
</plugin>
60+
<plugin>
61+
<groupId>org.codehaus.mojo</groupId>
62+
<artifactId>exec-maven-plugin</artifactId>
63+
<version>1.2.1</version>
64+
<configuration>
65+
<mainClass>com.baeldung.samples.Main</mainClass>
66+
</configuration>
67+
</plugin>
68+
</plugins>
69+
</build>
70+
71+
<dependencies>
72+
73+
<!-- Testing -->
74+
75+
<dependency>
76+
<groupId>junit</groupId>
77+
<artifactId>junit</artifactId>
78+
<version>${junit.version}</version>
79+
<scope>test</scope>
80+
</dependency>
81+
<dependency>
82+
<groupId>org.springframework.integration</groupId>
83+
<artifactId>spring-integration-core</artifactId>
84+
<version>4.3.2.RELEASE</version>
85+
</dependency>
86+
<dependency>
87+
<groupId>javax.activation</groupId>
88+
<artifactId>activation</artifactId>
89+
<version>1.1.1</version>
90+
<optional>true</optional>
91+
</dependency>
92+
<dependency>
93+
<groupId>javax.mail</groupId>
94+
<artifactId>mail</artifactId>
95+
<version>1.4.7</version>
96+
</dependency>
97+
<dependency>
98+
<groupId>log4j</groupId>
99+
<artifactId>log4j</artifactId>
100+
<version>${log4j.version}</version>
101+
</dependency>
102+
<dependency>
103+
<groupId>org.springframework.integration</groupId>
104+
<artifactId>spring-integration-twitter</artifactId>
105+
<version>4.0.4.RELEASE</version>
106+
</dependency>
107+
<dependency>
108+
<groupId>org.springframework.integration</groupId>
109+
<artifactId>spring-integration-mail</artifactId>
110+
<version>4.0.4.RELEASE</version>
111+
</dependency>
112+
<dependency>
113+
<groupId>org.springframework.integration</groupId>
114+
<artifactId>spring-integration-ftp</artifactId>
115+
<version>4.0.4.RELEASE</version>
116+
</dependency>
117+
<dependency>
118+
<groupId>org.springframework.social</groupId>
119+
<artifactId>spring-social-core</artifactId>
120+
<version>1.1.4.RELEASE</version>
121+
</dependency>
122+
<dependency>
123+
<groupId>org.springframework.integration</groupId>
124+
<artifactId>spring-integration-file</artifactId>
125+
<version>4.0.4.RELEASE</version>
126+
</dependency>
127+
</dependencies>
128+
</project>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright 2002-2013 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.baeldung.samples;
17+
18+
import java.util.Scanner;
19+
20+
import org.apache.log4j.Logger;
21+
import org.springframework.context.support.AbstractApplicationContext;
22+
import org.springframework.context.support.ClassPathXmlApplicationContext;
23+
24+
25+
/**
26+
* Starts the Spring Context and will initialize the Spring Integration routes.
27+
*
28+
* @author Baeldung
29+
* @since 1.0
30+
*
31+
*/
32+
public final class Main {
33+
34+
private static final Logger LOGGER = Logger.getLogger(Main.class);
35+
36+
private Main() { }
37+
38+
/**
39+
* Load the Spring Integration Application Context
40+
*
41+
* @param args - command line arguments
42+
*/
43+
public static void main(final String... args) {
44+
45+
if (LOGGER.isInfoEnabled()) {
46+
LOGGER.info("\n========================================================="
47+
+ "\n "
48+
+ "\n Welcome to Spring Integration! "
49+
+ "\n "
50+
+ "\n For more information please visit: "
51+
+ "\n http://www.springsource.org/spring-integration "
52+
+ "\n "
53+
+ "\n=========================================================" );
54+
}
55+
56+
final AbstractApplicationContext context =
57+
new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/*-context.xml");
58+
59+
context.registerShutdownHook();
60+
61+
final Scanner scanner = new Scanner(System.in);
62+
63+
if (LOGGER.isInfoEnabled()) {
64+
LOGGER.info("\n========================================================="
65+
+ "\n "
66+
+ "\n Please press 'q + Enter' to quit the application. "
67+
+ "\n "
68+
+ "\n=========================================================" );
69+
}
70+
71+
System.out.print("Please enter a string and press <enter>: ");
72+
73+
while (true) {
74+
75+
final String input = scanner.nextLine();
76+
77+
if("q".equals(input.trim())) {
78+
break;
79+
}
80+
81+
82+
}
83+
84+
if (LOGGER.isInfoEnabled()) {
85+
LOGGER.info("Exiting application...bye.");
86+
}
87+
88+
System.exit(0);
89+
90+
}
91+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
4+
xmlns:file="http://www.springframework.org/schema/integration/file"
5+
xmlns:ftp="http://www.springframework.org/schema/integration/ftp"
6+
xmlns:mail="http://www.springframework.org/schema/integration/mail"
7+
xmlns:twitter="http://www.springframework.org/schema/integration/twitter"
8+
xsi:schemaLocation="http://www.springframework.org/schema/beans
9+
http://www.springframework.org/schema/beans/spring-beans.xsd
10+
http://www.springframework.org/schema/integration
11+
http://www.springframework.org/schema/integration/spring-integration.xsd
12+
http://www.springframework.org/schema/integration/file
13+
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
14+
http://www.springframework.org/schema/integration/ftp
15+
http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd
16+
http://www.springframework.org/schema/integration/mail
17+
http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
18+
http://www.springframework.org/schema/integration/twitter
19+
http://www.springframework.org/schema/integration/twitter/spring-integration-twitter.xsd">
20+
21+
<!-- See also: http://static.springsource.org/spring-integration/reference/htmlsingle/#gateway-proxy
22+
http://www.eaipatterns.com/MessagingGateway.html -->
23+
24+
25+
<!-- See also: http://static.springsource.org/spring-integration/reference/htmlsingle/#service-activator
26+
http://www.eaipatterns.com/MessagingAdapter.html -->
27+
28+
29+
<int:publish-subscribe-channel id="videoChannel" />
30+
31+
<int:bridge input-channel="videoChannel" output-channel="ftpOutbound" />
32+
<int:channel id="ftpOutbound" />
33+
<int:bridge input-channel="videoChannel" output-channel="emailOutbound" />
34+
<int:channel id="emailOutbound" />
35+
36+
37+
<int:bridge output-channel="twitterOutbound" input-channel="videoChannel" />
38+
39+
<int:channel id="twitterOutbound" />
40+
41+
<twitter:outbound-channel-adapter
42+
twitter-template="twitterTemplate" channel="twitterOutbound" />
43+
44+
<bean name="twitterTemplate"
45+
class="org.springframework.social.twitter.api.impl.TwitterTemplate">
46+
<constructor-arg index="0" value="${consumer-key}" />
47+
<constructor-arg index="1" value="${consumer-secret}" />
48+
<constructor-arg index="2" value="${access-token}" />
49+
<constructor-arg index="3" value="${access-token-secret}" />
50+
</bean>
51+
52+
<file:inbound-channel-adapter id="videoFolder"
53+
directory="/studio/edits/video" channel="videoChannel"
54+
prevent-duplicates="true">
55+
<int:poller fixed-rate="1000" />
56+
</file:inbound-channel-adapter>
57+
58+
<mail:outbound-channel-adapter channel="emailOutbound"
59+
mail-sender="mailSender" />
60+
61+
<bean name="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
62+
<property name="host" value="smtp.gmail.com" />
63+
<property name="port" value="587" />
64+
<property name="username" value="yourUsername" />
65+
<property name="password" value="yourPassword" />
66+
</bean>
67+
68+
<ftp:outbound-channel-adapter channel="ftpOutbound"
69+
remote-directory="/news/archive/video/" session-factory="sessionFactory" />
70+
71+
72+
73+
<bean name="sessionFactory"
74+
class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
75+
<property name="host" value="localhost" />
76+
<property name="port" value="587" />
77+
<property name="username" value="yourUsername" />
78+
<property name="password" value="yourPassword" />
79+
</bean>
80+
81+
</beans>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3+
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
4+
5+
<!-- Appenders -->
6+
<appender name="console" class="org.apache.log4j.ConsoleAppender">
7+
<param name="Target" value="System.out" />
8+
<layout class="org.apache.log4j.PatternLayout">
9+
<param name="ConversionPattern" value="%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n" />
10+
</layout>
11+
</appender>
12+
13+
<!-- Loggers -->
14+
<logger name="org.springframework.integration">
15+
<level value="warn" />
16+
</logger>
17+
18+
<logger name="com.baeldung.samples">
19+
<level value="info" />
20+
</logger>
21+
22+
<!-- Root Logger -->
23+
<root>
24+
<priority value="warn" />
25+
<appender-ref ref="console" />
26+
</root>
27+
28+
</log4j:configuration>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Manifest-Version: 1.0
2+
Built-By: Tayo
3+
Build-Jdk: 1.8.0_101
4+
Created-By: Maven Integration for Eclipse
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Generated by Maven Integration for Eclipse
2+
#Thu Sep 29 12:34:55 EDT 2016
3+
version=1.0.0.BUILD-SNAPSHOT
4+
groupId=com.baeldung.samples.spring.integration
5+
m2e.projectName=Baeldung Spring Intro
6+
m2e.projectLocation=C\:\\Users\\Tayo\\Documents\\STS\\Baeldung Spring Intro
7+
artifactId=baeldungSIsample

0 commit comments

Comments
 (0)