Skip to content

Commit 1f4359f

Browse files
Merge pull request #210 from xdev-software/#142-springboot-restservice
#142 springboot restservice
2 parents d3bc1b1 + affc348 commit 1f4359f

File tree

13 files changed

+173
-69
lines changed

13 files changed

+173
-69
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 2.4.1
2+
3+
* Updated EclipseStore to v2.1.0
4+
* Added EclipseStore-Rest-API to tests (storage-restservice-springboot)
5+
16
# 2.4.0
27

38
* Updated org.springframework.boot.version to v3.4.0
@@ -8,6 +13,7 @@
813

914
* Auto-Fix problems with adding ids to entities with existing data store.
1015

16+
~~~~
1117
# 2.3.0
1218
1319
* Add support for shutting down the storage during application shutdown

docs/antora.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: ROOT
22
title: Spring-Data-Eclipse-Store
33
version: master
4-
display_version: '2.4.0'
4+
display_version: '2.4.1'
55
start_page: index.adoc
66
nav:
77
- modules/ROOT/nav.adoc
88
asciidoc:
99
attributes:
1010
product-name: 'Spring-Data-Eclipse-Store'
11-
display-version: '2.4.0'
12-
maven-version: '2.4.0'
11+
display-version: '2.4.1'
12+
maven-version: '2.4.1'
1313
page-editable: false
1414
page-out-of-support: false

docs/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
** xref:features/queries.adoc[Queries]
99
** xref:features/transactions.adoc[Transactions]
1010
** xref:features/versions.adoc[Versions]
11+
** xref:features/rest-api.adoc[REST Interface]
1112
* xref:migration.adoc[Migration from JPA]
1213
* xref:known-issues.adoc[Known issues]

docs/modules/ROOT/pages/features/features.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
* xref:features/queries.adoc[Queries]
66
* xref:features/transactions.adoc[Transactions]
77
* xref:features/versions.adoc[Versions]
8+
* xref:features/rest-api.adoc[REST Interface]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
= REST Interface
2+
3+
To utilize the https://docs.eclipsestore.io/manual/storage/rest-interface/index.html[REST interface provided by EclipseStore], only a small adjustment is needed.
4+
5+
First add the dependency described in the https://docs.eclipsestore.io/manual/storage/rest-interface/setup.html#_spring_boot_rest_service[EclipseStore documentation]:
6+
7+
[source,xml,subs=attributes+,title="Maven [pom.xml]"]
8+
----
9+
<dependencies>
10+
<dependency>
11+
<groupId>org.eclipse.store</groupId>
12+
<artifactId>storage-restservice-springboot</artifactId>
13+
</dependency>
14+
<dependency>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-web</artifactId>
17+
</dependency>
18+
</dependencies>
19+
----
20+
21+
Next a few adjustments are needed in your configuration:
22+
23+
[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/ComplexConfiguration.java[Example from complex demo]"]
24+
----
25+
package software.xdev.spring.data.eclipse.store.demo.complex;
26+
27+
//...
28+
import org.eclipse.store.storage.restadapter.types.StorageRestAdapter;
29+
import org.springframework.context.annotation.Bean;
30+
import org.springframework.context.annotation.ComponentScan;
31+
import org.springframework.context.annotation.Configuration;
32+
33+
import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration;
34+
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
35+
36+
37+
@ComponentScan({"org.eclipse.store.storage.restservice.spring.boot.types.rest"})
38+
@Configuration
39+
@EnableEclipseStoreRepositories
40+
public class ComplexConfiguration extends EclipseStoreClientConfiguration
41+
{
42+
//...
43+
@Bean
44+
@DependsOn({"embeddedStorageFoundationFactory"})
45+
public Map<String, StorageRestAdapter> storageRestAdapters(final Map<String, EmbeddedStorageManager> storages)
46+
{
47+
return Map.of(
48+
"defaultStorageManager", StorageRestAdapter.New(this.storageInstance.getInstanceOfStorageManager())
49+
);
50+
}
51+
//...
52+
----
53+
54+
After that the API is usable just like https://docs.eclipsestore.io/manual/storage/rest-interface/rest-api.html[plain EclipseStore].
55+
The ``instance-name`` in this case would be ``default`` which means, the active URL in the ComplexDemo is ``http://localhost:8080/store-data/default/root``.

pom.xml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020

2121
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2222
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
23+
24+
<!-- Should be in sync with org.eclipse.store:integrations-spring-boot3 -->
25+
<org.springframework.boot.version>3.4.0</org.springframework.boot.version>
26+
<org.eclipse.store.version>2.1.0</org.eclipse.store.version>
27+
<org.eclipse.serializer.version>2.1.0</org.eclipse.serializer.version>
28+
<org.eclipse.storage-restservice-springboot.version>2.1.0</org.eclipse.storage-restservice-springboot.version>
2329
</properties>
2430

2531
<modules>
@@ -37,6 +43,57 @@
3743
</license>
3844
</licenses>
3945

46+
<dependencyManagement>
47+
<dependencies>
48+
<dependency>
49+
<groupId>org.eclipse.store</groupId>
50+
<artifactId>storage-embedded</artifactId>
51+
<version>${org.eclipse.store.version}</version>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.eclipse.store</groupId>
55+
<artifactId>integrations-spring-boot3</artifactId>
56+
<version>${org.eclipse.store.version}</version>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.eclipse.serializer</groupId>
60+
<artifactId>serializer</artifactId>
61+
<version>${org.eclipse.serializer.version}</version>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.eclipse.serializer</groupId>
65+
<artifactId>persistence-binary-jdk17</artifactId>
66+
<version>${org.eclipse.serializer.version}</version>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.eclipse.store</groupId>
70+
<artifactId>storage-restservice-springboot</artifactId>
71+
<version>${org.eclipse.storage-restservice-springboot.version}</version>
72+
</dependency>
73+
74+
<dependency>
75+
<groupId>org.springframework.boot</groupId>
76+
<artifactId>spring-boot-dependencies</artifactId>
77+
<version>${org.springframework.boot.version}</version>
78+
<type>pom</type>
79+
<scope>import</scope>
80+
</dependency>
81+
82+
<dependency>
83+
<groupId>org.springframework.boot</groupId>
84+
<artifactId>spring-boot-starter-test</artifactId>
85+
<version>${org.springframework.boot.version}</version>
86+
<scope>test</scope>
87+
<exclusions>
88+
<exclusion>
89+
<artifactId>spring-boot-starter-logging</artifactId>
90+
<groupId>org.springframework.boot</groupId>
91+
</exclusion>
92+
</exclusions>
93+
</dependency>
94+
</dependencies>
95+
</dependencyManagement>
96+
4097
<profiles>
4198
<profile>
4299
<id>checkstyle</id>

spring-data-eclipse-store-benchmark/pom.xml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,9 @@
2020
</organization>
2121

2222
<properties>
23-
<javaVersion>17</javaVersion>
24-
<maven.compiler.release>${javaVersion}</maven.compiler.release>
25-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
26-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
27-
28-
<org.springframework.boot.version>3.4.0</org.springframework.boot.version>
2923
<jmh.version>1.37</jmh.version>
3024
</properties>
3125

32-
<dependencyManagement>
33-
<dependencies>
34-
<dependency>
35-
<groupId>org.springframework.boot</groupId>
36-
<artifactId>spring-boot-dependencies</artifactId>
37-
<version>${org.springframework.boot.version}</version>
38-
<type>pom</type>
39-
<scope>import</scope>
40-
</dependency>
41-
</dependencies>
42-
</dependencyManagement>
43-
4426
<dependencies>
4527
<dependency>
4628
<groupId>software.xdev</groupId>

spring-data-eclipse-store-demo/pom.xml

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,23 @@
2020
</organization>
2121

2222
<properties>
23-
<javaVersion>17</javaVersion>
24-
<maven.compiler.release>${javaVersion}</maven.compiler.release>
25-
26-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
27-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
28-
2923
<mainClass>software.xdev.spring.data.eclipse.store.demo.complex.ComplexDemoApplication</mainClass>
30-
31-
<org.springframework.boot.version>3.4.0</org.springframework.boot.version>
3224
</properties>
3325

34-
<dependencyManagement>
35-
<dependencies>
36-
<dependency>
37-
<groupId>org.springframework.boot</groupId>
38-
<artifactId>spring-boot-dependencies</artifactId>
39-
<version>${org.springframework.boot.version}</version>
40-
<type>pom</type>
41-
<scope>import</scope>
42-
</dependency>
43-
</dependencies>
44-
</dependencyManagement>
45-
4626
<dependencies>
4727
<dependency>
4828
<groupId>software.xdev</groupId>
4929
<artifactId>spring-data-eclipse-store</artifactId>
5030
<version>${project.version}</version>
5131
</dependency>
32+
<dependency>
33+
<groupId>org.eclipse.store</groupId>
34+
<artifactId>storage-restservice-springboot</artifactId>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-starter-web</artifactId>
39+
</dependency>
5240

5341
<dependency>
5442
<groupId>org.apache.logging.log4j</groupId>
@@ -73,12 +61,6 @@
7361
<groupId>org.springframework.boot</groupId>
7462
<artifactId>spring-boot-starter-test</artifactId>
7563
<scope>test</scope>
76-
<exclusions>
77-
<exclusion>
78-
<artifactId>spring-boot-starter-logging</artifactId>
79-
<groupId>org.springframework.boot</groupId>
80-
</exclusion>
81-
</exclusions>
8264
</dependency>
8365
</dependencies>
8466

spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/ComplexConfiguration.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
package software.xdev.spring.data.eclipse.store.demo.complex;
22

33
import java.nio.file.Path;
4+
import java.util.Map;
45

56
import org.eclipse.serializer.reflect.ClassLoaderProvider;
67
import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties;
78
import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageFoundationFactory;
89
import org.eclipse.store.storage.embedded.types.EmbeddedStorage;
910
import org.eclipse.store.storage.embedded.types.EmbeddedStorageFoundation;
11+
import org.eclipse.store.storage.embedded.types.EmbeddedStorageManager;
12+
import org.eclipse.store.storage.restadapter.types.StorageRestAdapter;
1013
import org.eclipse.store.storage.types.Storage;
1114
import org.springframework.beans.factory.ObjectProvider;
1215
import org.springframework.beans.factory.annotation.Autowired;
1316
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
1417
import org.springframework.context.annotation.Bean;
18+
import org.springframework.context.annotation.ComponentScan;
1519
import org.springframework.context.annotation.Configuration;
20+
import org.springframework.context.annotation.DependsOn;
1621
import org.springframework.transaction.PlatformTransactionManager;
1722

1823
import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration;
1924
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
2025

2126

27+
@ComponentScan({"org.eclipse.store.storage.restservice.spring.boot.types.rest"})
2228
@Configuration
2329
@EnableEclipseStoreRepositories
2430
public class ComplexConfiguration extends EclipseStoreClientConfiguration
@@ -53,6 +59,15 @@ public EmbeddedStorageFoundation<?> createEmbeddedStorageFoundation()
5359
storageFoundation.getConnectionFoundation().setClassLoaderProvider(this.getClassLoaderProvider());
5460
return storageFoundation;
5561
}
62+
63+
@Bean
64+
@DependsOn({"embeddedStorageFoundationFactory"})
65+
public Map<String, StorageRestAdapter> storageRestAdapters(final Map<String, EmbeddedStorageManager> storages)
66+
{
67+
return Map.of(
68+
"defaultStorageManager", StorageRestAdapter.New(this.storageInstance.getInstanceOfStorageManager())
69+
);
70+
}
5671

5772
/**
5873
* Overriding {@link #transactionManager(ObjectProvider)} only to add the {@link Bean}-Annotation.

spring-data-eclipse-store-demo/src/test/java/software/xdev/spring/data/eclipse/store/demo/complex/ComplexDemoApplicationTest.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
package software.xdev.spring.data.eclipse.store.demo.complex;
22

3+
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
4+
35
import java.io.File;
46

57
import org.junit.jupiter.api.BeforeAll;
68
import org.junit.jupiter.api.Test;
79
import org.springframework.beans.factory.annotation.Autowired;
810
import org.springframework.boot.test.context.SpringBootTest;
11+
import org.springframework.boot.test.web.client.TestRestTemplate;
12+
import org.springframework.boot.test.web.server.LocalServerPort;
913

1014
import software.xdev.spring.data.eclipse.store.demo.TestUtil;
1115
import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration;
1216

1317

14-
@SpringBootTest(classes = ComplexDemoApplication.class)
18+
@SpringBootTest(
19+
classes = ComplexDemoApplication.class,
20+
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
21+
)
1522
class ComplexDemoApplicationTest
1623
{
24+
@LocalServerPort
25+
private int port;
26+
@Autowired
27+
private TestRestTemplate restTemplate;
28+
1729
private final EclipseStoreClientConfiguration configuration;
1830

1931
@Autowired
@@ -34,4 +46,15 @@ void checkPossibilityToSimplyStartAndRestartApplication()
3446
this.configuration.getStorageInstance().stop();
3547
ComplexDemoApplication.main(new String[]{});
3648
}
49+
50+
@Test
51+
void restEndpoint()
52+
{
53+
assertThat(
54+
this.restTemplate.getForObject(
55+
"http://localhost:" + this.port + "/store-data/default/root",
56+
String.class
57+
)
58+
).contains("ROOT");
59+
}
3760
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
server:
2+
port: 0

spring-data-eclipse-store-jpa/pom.xml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,9 @@
2222
</organization>
2323

2424
<properties>
25-
<javaVersion>17</javaVersion>
26-
<maven.compiler.release>${javaVersion}</maven.compiler.release>
27-
28-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
29-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
30-
3125
<mainClass>software.xdev.spring.data.eclipse.store.demo.complex.ComplexDemoApplication</mainClass>
32-
33-
<org.springframework.boot.version>3.4.0</org.springframework.boot.version>
3426
</properties>
3527

36-
<dependencyManagement>
37-
<dependencies>
38-
<dependency>
39-
<groupId>org.springframework.boot</groupId>
40-
<artifactId>spring-boot-dependencies</artifactId>
41-
<version>${org.springframework.boot.version}</version>
42-
<type>pom</type>
43-
<scope>import</scope>
44-
</dependency>
45-
</dependencies>
46-
</dependencyManagement>
47-
4828
<dependencies>
4929
<dependency>
5030
<groupId>org.springframework.boot</groupId>

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public EclipseStoreStorage(final EclipseStoreClientConfiguration storeConfigurat
9292
this.classLoaderProvider = storeConfiguration.getClassLoaderProvider();
9393
}
9494

95-
private StorageManager getInstanceOfStorageManager()
95+
public StorageManager getInstanceOfStorageManager()
9696
{
9797
this.ensureEntitiesInRoot();
9898
return this.storageManager;

0 commit comments

Comments
 (0)