Skip to content

Commit a670f6e

Browse files
committed
setup java app project 1
1 parent e946bac commit a670f6e

9 files changed

Lines changed: 154 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>cloud.localstack.samples</groupId>
7+
<artifactId>java-notification-app</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
<parent>
10+
<groupId>org.springframework.boot</groupId>
11+
<artifactId>spring-boot-starter-parent</artifactId>
12+
<version>2.2.5.RELEASE</version>
13+
<relativePath/> <!-- lookup parent from repository -->
14+
</parent>
15+
<properties>
16+
<java.version>11</java.version>
17+
<awsjavasdk.version>2.17.189</awsjavasdk.version>
18+
</properties>
19+
<dependencyManagement>
20+
<dependencies>
21+
<dependency>
22+
<groupId>software.amazon.awssdk</groupId>
23+
<artifactId>bom</artifactId>
24+
<version>2.17.189</version>
25+
<type>pom</type>
26+
<scope>import</scope>
27+
</dependency>
28+
</dependencies>
29+
</dependencyManagement>
30+
<dependencies>
31+
32+
<dependency>
33+
<groupId>software.amazon.awssdk</groupId>
34+
<artifactId>ses</artifactId>
35+
</dependency>
36+
<dependency>
37+
<groupId>software.amazon.awssdk</groupId>
38+
<artifactId>sns</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>software.amazon.awssdk</groupId>
42+
<artifactId>sqs</artifactId>
43+
</dependency>
44+
<dependency>
45+
<groupId>software.amazon.awssdk</groupId>
46+
<artifactId>cloudformation</artifactId>
47+
</dependency>
48+
49+
<dependency>
50+
<groupId>org.springframework.boot</groupId>
51+
<artifactId>spring-boot-starter-web</artifactId>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.springframework.boot</groupId>
55+
<artifactId>spring-boot-starter-test</artifactId>
56+
<scope>test</scope>
57+
<exclusions>
58+
<exclusion>
59+
<groupId>org.junit.vintage</groupId>
60+
<artifactId>junit-vintage-engine</artifactId>
61+
</exclusion>
62+
</exclusions>
63+
</dependency>
64+
65+
</dependencies>
66+
<build>
67+
<plugins>
68+
<plugin>
69+
<groupId>org.springframework.boot</groupId>
70+
<artifactId>spring-boot-maven-plugin</artifactId>
71+
</plugin>
72+
</plugins>
73+
</build>
74+
</project>

18-projects/1-java-notification-app-ses-cf/readme.md

Whitespace-only changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.example;
2+
3+
import java.net.URI;
4+
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
8+
9+
import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
10+
import software.amazon.awssdk.regions.Region;
11+
import software.amazon.awssdk.services.ses.SesClient;
12+
import software.amazon.awssdk.services.sqs.SqsClient;
13+
14+
@Configuration
15+
public class AwsConfiguration {
16+
17+
private static final String ENDPOINT_URL = "http://localhost:4566";
18+
private static final Region DEFAULT_REGION = Region.US_EAST_1;
19+
20+
@Bean
21+
public SqsClient sqsClient() {
22+
return SqsClient.builder()
23+
.region(DEFAULT_REGION)
24+
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
25+
.applyMutation(builder -> {
26+
builder.endpointOverride(URI.create(ENDPOINT_URL));
27+
})
28+
.build();
29+
}
30+
31+
@Bean
32+
public SesClient sesClient() {
33+
return SesClient.builder()
34+
.region(DEFAULT_REGION)
35+
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
36+
.applyMutation(builder -> {
37+
builder.endpointOverride(URI.create(ENDPOINT_URL));
38+
})
39+
.build();
40+
}
41+
42+
@Bean
43+
@Autowired
44+
public String notificationQueueUrl(SqsClient sqsClient) {
45+
return sqsClient.getQueueUrl(builder -> {
46+
builder.queueName("email-notification-queue");
47+
}).queueUrl();
48+
}
49+
}

18-projects/1-java-notification-app-ses-cf/src/main/java/com/example/MessageApplication.java

Whitespace-only changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.example;
2+
3+
public class Notification {
4+
private String address;
5+
private String subject;
6+
private String body;
7+
8+
public String getAddress() {
9+
return address;
10+
}
11+
12+
public void setAddress(String address) {
13+
this.address = address;
14+
}
15+
16+
public String getSubject() {
17+
return subject;
18+
}
19+
20+
public void setSubject(String subject) {
21+
this.subject = subject;
22+
}
23+
24+
public String getBody() {
25+
return body;
26+
}
27+
28+
public void setBody(String body) {
29+
this.body = body;
30+
}
31+
}

18-projects/1-java-notification-app-ses-cf/src/main/java/com/example/NotificationController.java

Whitespace-only changes.

18-projects/1-java-notification-app-ses-cf/src/main/java/com/example/ReceiveSendNotifications.java

Whitespace-only changes.

18-projects/1-java-notification-app-ses-cf/src/main/resources/email-infra.yml

Whitespace-only changes.

0 commit comments

Comments
 (0)