-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(integrations/spring): add AutoConfiguration class for Spring Mvc…
… and Webflux Signed-off-by: ZhangJian He <shoothzj@gmail.com>
- Loading branch information
Showing
13 changed files
with
131 additions
and
7 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
25 changes: 25 additions & 0 deletions
25
...tive/src/main/java/org/apache/opendal/spring/config/OpenDALReactiveAutoConfiguration.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,25 @@ | ||
package org.apache.opendal.spring.config; | ||
|
||
import org.apache.opendal.spring.core.DefaultOpenDALReactive; | ||
import org.apache.opendal.spring.core.OpenDALProperties; | ||
import org.apache.opendal.spring.core.OpenDALReactive; | ||
import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
@AutoConfiguration | ||
@EnableConfigurationProperties(OpenDALProperties.class) | ||
public class OpenDALReactiveAutoConfiguration { | ||
private final OpenDALProperties openDALProperties; | ||
|
||
public OpenDALReactiveAutoConfiguration(OpenDALProperties openDALProperties) { | ||
this.openDALProperties = openDALProperties; | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(OpenDALReactive.class) | ||
public DefaultOpenDALReactive opendalReactive(OpenDALProperties openDALProperties) { | ||
return new DefaultOpenDALReactive(openDALProperties); | ||
} | ||
} |
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 @@ | ||
org.apache.opendal.spring.config.OpenDALReactiveAutoConfiguration |
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
25 changes: 25 additions & 0 deletions
25
...boot-starter/src/main/java/org/apache/opendal/spring/config/OpenDALAutoConfiguration.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,25 @@ | ||
package org.apache.opendal.spring.config; | ||
|
||
import org.apache.opendal.spring.core.DefaultOpenDAL; | ||
import org.apache.opendal.spring.core.OpenDAL; | ||
import org.apache.opendal.spring.core.OpenDALProperties; | ||
import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
@AutoConfiguration | ||
@EnableConfigurationProperties(OpenDALProperties.class) | ||
public class OpenDALAutoConfiguration { | ||
private final OpenDALProperties openDALProperties; | ||
|
||
public OpenDALAutoConfiguration(OpenDALProperties openDALProperties) { | ||
this.openDALProperties = openDALProperties; | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(OpenDAL.class) | ||
public DefaultOpenDAL openGeminiTemplate(OpenDALProperties openDALProperties) { | ||
return new DefaultOpenDAL(openDALProperties); | ||
} | ||
} |
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 @@ | ||
org.apache.opendal.spring.config.OpenDALAutoConfiguration |
11 changes: 11 additions & 0 deletions
11
...ns/spring/opendal-spring/src/main/java/org/apache/opendal/spring/core/DefaultOpenDAL.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,11 @@ | ||
package org.apache.opendal.spring.core; | ||
|
||
import org.apache.opendal.AsyncOperator; | ||
|
||
public class DefaultOpenDAL implements OpenDAL { | ||
private final AsyncOperator asyncOperator; | ||
|
||
public DefaultOpenDAL(OpenDALProperties openDALProperties) { | ||
this.asyncOperator = AsyncOperator.of(openDALProperties.getSchema(), openDALProperties.getConf()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...g/opendal-spring/src/main/java/org/apache/opendal/spring/core/DefaultOpenDALReactive.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,11 @@ | ||
package org.apache.opendal.spring.core; | ||
|
||
import org.apache.opendal.AsyncOperator; | ||
|
||
public class DefaultOpenDALReactive implements OpenDALReactive { | ||
private final AsyncOperator asyncOperator; | ||
|
||
public DefaultOpenDALReactive(OpenDALProperties openDALProperties) { | ||
this.asyncOperator = AsyncOperator.of(openDALProperties.getSchema(), openDALProperties.getConf()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
integrations/spring/opendal-spring/src/main/java/org/apache/opendal/spring/core/OpenDAL.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,7 @@ | ||
package org.apache.opendal.spring.core; | ||
|
||
/** | ||
* Interface that specified a basic set of Apache OpenDAL, implemented by {@link DefaultOpenDAL}. | ||
*/ | ||
public interface OpenDAL { | ||
} |
19 changes: 19 additions & 0 deletions
19
...spring/opendal-spring/src/main/java/org/apache/opendal/spring/core/OpenDALProperties.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,19 @@ | ||
package org.apache.opendal.spring.core; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Configuration properties for Apache OpenDAL. | ||
*/ | ||
@Getter | ||
@Setter | ||
@ConfigurationProperties("spring.opendal") | ||
public class OpenDALProperties { | ||
private String schema; | ||
|
||
private Map<String, String> conf; | ||
} |
7 changes: 7 additions & 0 deletions
7
...s/spring/opendal-spring/src/main/java/org/apache/opendal/spring/core/OpenDALReactive.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,7 @@ | ||
package org.apache.opendal.spring.core; | ||
|
||
/** | ||
* Interface that specified a basic set of Apache OpenDAL, implemented by {@link DefaultOpenDALReactive}. | ||
*/ | ||
public interface OpenDALReactive { | ||
} |
1 change: 1 addition & 0 deletions
1
...ions/spring/opendal-spring/src/main/java/org/apache/opendal/spring/core/package-info.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 @@ | ||
package org.apache.opendal.spring.core; |
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