-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Spring Boot enhancements, Sring Data Repository, Testcontainers
Signed-off-by: Artur Ciocanu <ciocanu@adobe.com>
- Loading branch information
Artur Ciocanu
committed
Aug 28, 2024
1 parent
a6923ed
commit 287be6c
Showing
61 changed files
with
4,080 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
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> | ||
|
||
<parent> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-parent</artifactId> | ||
<version>0.13.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>dapr-spring-boot-autoconfigure</artifactId> | ||
<name>dapr-spring-boot-autoconfigure</name> | ||
<description>Dapr Spring Boot Autoconfigure</description> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-core</artifactId> | ||
<version>${project.parent.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-data</artifactId> | ||
<version>${project.parent.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-messaging</artifactId> | ||
<version>${project.parent.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-autoconfigure-processor</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.data</groupId> | ||
<artifactId>spring-data-keyvalue</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>com.vaadin.external.google</groupId> | ||
<artifactId>android-json</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.dapr</groupId> | ||
<artifactId>testcontainers-dapr</artifactId> | ||
<version>${dapr.sdk.alpha.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
54 changes: 54 additions & 0 deletions
54
...e/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2024 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.spring.boot.autoconfigure.client; | ||
|
||
import io.dapr.client.DaprClient; | ||
import io.dapr.client.DaprClientBuilder; | ||
import io.dapr.spring.core.client.DaprClientCustomizer; | ||
import org.springframework.beans.factory.ObjectProvider; | ||
import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
@AutoConfiguration | ||
@ConditionalOnClass(DaprClient.class) | ||
public class DaprClientAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
DaprClientBuilderConfigurer daprClientBuilderConfigurer(ObjectProvider<DaprClientCustomizer> customizerProvider) { | ||
DaprClientBuilderConfigurer configurer = new DaprClientBuilderConfigurer(); | ||
configurer.setDaprClientCustomizer(customizerProvider.orderedStream().collect(Collectors.toList())); | ||
|
||
return configurer; | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
DaprClientBuilder daprClientBuilder(DaprClientBuilderConfigurer daprClientBuilderConfigurer) { | ||
DaprClientBuilder builder = new DaprClientBuilder(); | ||
|
||
return daprClientBuilderConfigurer.configure(builder); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
DaprClient daprClient(DaprClientBuilder daprClientBuilder) { | ||
return daprClientBuilder.build(); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...e/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientBuilderConfigurer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2024 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.spring.boot.autoconfigure.client; | ||
|
||
import io.dapr.client.DaprClientBuilder; | ||
import io.dapr.spring.core.client.DaprClientCustomizer; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Builder for configuring a {@link DaprClientBuilder}. | ||
*/ | ||
public class DaprClientBuilderConfigurer { | ||
|
||
private List<DaprClientCustomizer> customizers; | ||
|
||
void setDaprClientCustomizer(List<DaprClientCustomizer> customizers) { | ||
this.customizers = List.copyOf(customizers); | ||
} | ||
|
||
/** | ||
* Configure the specified {@link DaprClientBuilder}. The builder can be further | ||
* tuned and default settings can be overridden. | ||
* | ||
* @param builder the {@link DaprClientBuilder} instance to configure | ||
* @return the configured builder | ||
*/ | ||
public DaprClientBuilder configure(DaprClientBuilder builder) { | ||
applyCustomizers(builder); | ||
return builder; | ||
} | ||
|
||
private void applyCustomizers(DaprClientBuilder builder) { | ||
if (this.customizers != null) { | ||
for (DaprClientCustomizer customizer : this.customizers) { | ||
customizer.customize(builder); | ||
} | ||
} | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...onfigure/src/main/java/io/dapr/spring/boot/autoconfigure/pubsub/DaprPubSubProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2024 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.spring.boot.autoconfigure.pubsub; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
|
||
@ConfigurationProperties(prefix = DaprPubSubProperties.CONFIG_PREFIX) | ||
public class DaprPubSubProperties { | ||
|
||
public static final String CONFIG_PREFIX = "dapr.pubsub"; | ||
|
||
/** | ||
* Name of the PubSub Dapr component. | ||
*/ | ||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
.../src/main/java/io/dapr/spring/boot/autoconfigure/statestore/DaprStateStoreProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2024 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.spring.boot.autoconfigure.statestore; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties(prefix = DaprStateStoreProperties.CONFIG_PREFIX) | ||
public class DaprStateStoreProperties { | ||
|
||
public static final String CONFIG_PREFIX = "dapr.statestore"; | ||
|
||
/** | ||
* Name of the StateStore Dapr component. | ||
*/ | ||
private String name; | ||
private String binding; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getBinding() { | ||
return binding; | ||
} | ||
|
||
public void setBinding(String binding) { | ||
this.binding = binding; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
io.dapr.spring.boot.autoconfigure.client.DaprClientAutoConfiguration |
47 changes: 47 additions & 0 deletions
47
.../test/java/io/dapr/spring/boot/autoconfigure/client/DaprClientAutoConfigurationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2024 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.spring.boot.autoconfigure.client; | ||
|
||
import io.dapr.client.DaprClient; | ||
import io.dapr.client.DaprClientBuilder; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.autoconfigure.AutoConfigurations; | ||
import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* Unit tests for {@link DaprClientAutoConfiguration}. | ||
*/ | ||
class DaprClientAutoConfigurationTests { | ||
|
||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() | ||
.withConfiguration(AutoConfigurations.of(DaprClientAutoConfiguration.class)); | ||
|
||
@Test | ||
void daprClientBuilderConfigurer() { | ||
contextRunner.run(context -> assertThat(context).hasSingleBean(DaprClientBuilderConfigurer.class)); | ||
} | ||
|
||
@Test | ||
void daprClientBuilder() { | ||
contextRunner.run(context -> assertThat(context).hasSingleBean(DaprClientBuilder.class)); | ||
} | ||
|
||
@Test | ||
void daprClient() { | ||
contextRunner.run(context -> assertThat(context).hasSingleBean(DaprClient.class)); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
dapr-spring/dapr-spring-boot-starters/dapr-spring-boot-starter/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
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> | ||
|
||
<parent> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-parent</artifactId> | ||
<version>0.13.0-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>dapr-spring-boot-starter</artifactId> | ||
<name>dapr-spring-boot-starter</name> | ||
<description>Dapr Client Spring Boot Starter</description> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-core</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-boot-autoconfigure</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
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> | ||
|
||
<parent> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-parent</artifactId> | ||
<version>0.13.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>dapr-spring-core</artifactId> | ||
<name>dapr-spring-core</name> | ||
<description>Dapr Spring Core</description> | ||
<packaging>jar</packaging> | ||
|
||
</project> |
Oops, something went wrong.