Skip to content

Commit 6e19b54

Browse files
committed
GH-5076: Port spring-components to Spring 6
- Duplicate `spring-components` into `spring6-components` folder - rename duplicated submodules: `spring` -> `spring6` - Apply OpenRewrite recipe for spring-boot 3.5, excluding all changes related to new java language features - Align dependency versions in spring6-components with those required by spring-boot 3.5 - Fix tests of spring6-boot-sparql-web: parsing paths in the Spring Rest subsystem are now stricter, trailing slashes are not matched with a controller method that does not have the trailing slash.
1 parent 471b03c commit 6e19b54

File tree

194 files changed

+14498
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+14498
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<module>core</module>
4343
<module>tools</module>
4444
<module>spring-components</module>
45+
<module>spring6-components</module>
4546
<module>testsuites</module>
4647
<module>compliance</module>
4748
<module>examples</module>

spring6-components/pom.xml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>org.eclipse.rdf4j</groupId>
6+
<artifactId>rdf4j</artifactId>
7+
<version>5.3.0-SNAPSHOT</version>
8+
</parent>
9+
<packaging>pom</packaging>
10+
<modules>
11+
<module>spring6-boot-sparql-web</module>
12+
<module>rdf4j-spring6</module>
13+
<module>rdf4j-spring6-demo</module>
14+
</modules>
15+
<properties>
16+
<spring.boot.version>3.5.7</spring.boot.version>
17+
<!-- override properties to match versions for spring-boot -->
18+
<slf4j.version>2.0.17</slf4j.version>
19+
<logback.version>1.5.20</logback.version>
20+
<log4j.version>2.24.3</log4j.version>
21+
<jetty.version>12.0.29</jetty.version>
22+
<spring.version>6.2.12</spring.version>
23+
</properties>
24+
<artifactId>rdf4j-spring6-components</artifactId>
25+
<name>RDF4J: Spring6 components</name>
26+
<description>Components to use with Spring</description>
27+
<dependencyManagement>
28+
<dependencies>
29+
<dependency>
30+
<groupId>org.junit</groupId>
31+
<artifactId>junit-bom</artifactId>
32+
<version>${junit.version}</version>
33+
<type>pom</type>
34+
<scope>import</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-dependencies</artifactId>
39+
<version>${spring.boot.version}</version>
40+
<type>pom</type>
41+
<scope>import</scope>
42+
</dependency>
43+
</dependencies>
44+
</dependencyManagement>
45+
<dependencies>
46+
<dependency>
47+
<groupId>org.springframework</groupId>
48+
<artifactId>spring-test</artifactId>
49+
<scope>test</scope>
50+
<exclusions>
51+
<exclusion>
52+
<groupId>org.springframework</groupId>
53+
<artifactId>spring-jcl</artifactId>
54+
</exclusion>
55+
</exclusions>
56+
</dependency>
57+
</dependencies>
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.springframework.boot</groupId>
62+
<artifactId>spring-boot-maven-plugin</artifactId>
63+
<version>${spring.boot.version}</version>
64+
</plugin>
65+
</plugins>
66+
</build>
67+
</project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# RDF4J-Spring Demo
2+
3+
Small demo application for `rdf4j-spring`.
4+
5+
The purpose of `rdf4j-spring` is to use an RDF4J repository as the data backend of a spring or spring boot application.
6+
7+
To run the demo, do
8+
9+
```$bash
10+
mvn spring-boot:run
11+
```
12+
13+
The program writes to stdout and exits. The class [ArtDemoCli](src/main/java/org/eclipse/rdf4j/spring.demo/ArtDemoCli.java) is a good starting point for looking at the code.
14+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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+
<artifactId>rdf4j-spring6-demo</artifactId>
5+
<name>RDF4J: Spring6 Demo</name>
6+
<description>Demo of a spring-boot project using an RDF4J repo as its backend</description>
7+
<parent>
8+
<groupId>org.eclipse.rdf4j</groupId>
9+
<artifactId>rdf4j-spring6-components</artifactId>
10+
<version>5.3.0-SNAPSHOT</version>
11+
</parent>
12+
<dependencies>
13+
<dependency>
14+
<groupId>org.eclipse.rdf4j</groupId>
15+
<artifactId>rdf4j-spring</artifactId>
16+
<version>${project.version}</version>
17+
</dependency>
18+
<dependency>
19+
<groupId>org.springframework.boot</groupId>
20+
<artifactId>spring-boot-starter</artifactId>
21+
<exclusions>
22+
<exclusion>
23+
<groupId>org.springframework</groupId>
24+
<artifactId>spring-jcl</artifactId>
25+
</exclusion>
26+
</exclusions>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-test</artifactId>
31+
<scope>test</scope>
32+
</dependency>
33+
</dependencies>
34+
<dependencyManagement>
35+
<dependencies>
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-dependencies</artifactId>
39+
<version>${spring.boot.version}</version>
40+
<type>pom</type>
41+
<scope>import</scope>
42+
</dependency>
43+
</dependencies>
44+
</dependencyManagement>
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-compiler-plugin</artifactId>
50+
</plugin>
51+
<plugin>
52+
<groupId>org.springframework.boot</groupId>
53+
<artifactId>spring-boot-maven-plugin</artifactId>
54+
<version>${spring.boot.version}</version>
55+
</plugin>
56+
</plugins>
57+
</build>
58+
</project>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2021 Eclipse RDF4J contributors.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Distribution License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/org/documents/edl-v10.php.
8+
*
9+
* SPDX-License-Identifier: BSD-3-Clause
10+
*******************************************************************************/
11+
12+
package org.eclipse.rdf4j.spring.demo;
13+
14+
import java.util.Map;
15+
import java.util.Set;
16+
17+
import org.eclipse.rdf4j.model.IRI;
18+
import org.eclipse.rdf4j.spring.demo.model.Artist;
19+
import org.eclipse.rdf4j.spring.demo.model.Painting;
20+
import org.eclipse.rdf4j.spring.demo.service.ArtService;
21+
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.boot.CommandLineRunner;
23+
import org.springframework.boot.SpringApplication;
24+
import org.springframework.boot.autoconfigure.SpringBootApplication;
25+
26+
/**
27+
* Command line interface for the demo. Takes no parameters. It outputs the content of the demo repository, then adds
28+
* some data and outputs the content of the repository again.
29+
* <p>
30+
* Accessing the repository is done via the {@link ArtService} class, which just encapsulates accesses to the
31+
* {@link org.eclipse.rdf4j.spring.demo.dao.PaintingDao} and {@link org.eclipse.rdf4j.spring.demo.dao.ArtistDao}
32+
* classes.
33+
*
34+
* @author Florian Kleedorfer
35+
* @since 4.0.0
36+
*/
37+
@SpringBootApplication
38+
public class ArtDemoCli implements CommandLineRunner {
39+
@Autowired
40+
ArtService artService;
41+
42+
public static void main(String[] args) {
43+
SpringApplication.run(ArtDemoCli.class, args).close();
44+
}
45+
46+
@Override
47+
public void run(String... args) {
48+
System.out.println("\nData read from 'artists.ttl':");
49+
Map<Artist, Set<Painting>> paintingsMap = artService.getPaintingsGroupedByArtist();
50+
listPaintingsByArtist(paintingsMap);
51+
System.out.println("\nNow adding some data...");
52+
addPaintingWithArtist();
53+
System.out.println("\nReloaded data:");
54+
paintingsMap = artService.getPaintingsGroupedByArtist();
55+
listPaintingsByArtist(paintingsMap);
56+
System.out.println("\n");
57+
listArtistsWithoutPaintings();
58+
System.out.println("\n");
59+
}
60+
61+
private void addPaintingWithArtist() {
62+
Artist a = new Artist();
63+
a.setFirstName("Jan");
64+
a.setLastName("Vermeer");
65+
IRI artistId = artService.addArtist(a);
66+
Painting p = new Painting();
67+
p.setTitle("View of Delft");
68+
p.setTechnique("oil on canvas");
69+
p.setArtistId(artistId);
70+
artService.addPainting(p);
71+
}
72+
73+
private void listPaintingsByArtist(Map<Artist, Set<Painting>> paintingsMap) {
74+
for (Artist a : paintingsMap.keySet()) {
75+
System.out.println(String.format("%s %s", a.getFirstName(), a.getLastName()));
76+
for (Painting p : paintingsMap.get(a)) {
77+
System.out.println(String.format("\t%s (%s)", p.getTitle(), p.getTechnique()));
78+
}
79+
}
80+
}
81+
82+
private void listArtistsWithoutPaintings() {
83+
System.out.println("Artists without paintings:");
84+
Set<Artist> a = artService.getArtistsWithoutPaintings();
85+
if (a.isEmpty()) {
86+
System.out.println("\t[none]");
87+
} else {
88+
for (Artist artist : a) {
89+
System.out.println(String.format("%s %s", artist.getFirstName(), artist.getLastName()));
90+
}
91+
}
92+
}
93+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2021 Eclipse RDF4J contributors.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Distribution License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/org/documents/edl-v10.php.
8+
*
9+
* SPDX-License-Identifier: BSD-3-Clause
10+
*******************************************************************************/
11+
12+
package org.eclipse.rdf4j.spring.demo;
13+
14+
import org.eclipse.rdf4j.spring.RDF4JConfig;
15+
import org.eclipse.rdf4j.spring.dao.RDF4JDao;
16+
import org.eclipse.rdf4j.spring.demo.support.InitialDataInserter;
17+
import org.eclipse.rdf4j.spring.support.DataInserter;
18+
import org.springframework.beans.factory.annotation.Autowired;
19+
import org.springframework.beans.factory.annotation.Value;
20+
import org.springframework.context.annotation.Bean;
21+
import org.springframework.context.annotation.ComponentScan;
22+
import org.springframework.context.annotation.Configuration;
23+
import org.springframework.context.annotation.FilterType;
24+
import org.springframework.context.annotation.Import;
25+
import org.springframework.core.io.Resource;
26+
27+
/**
28+
* Spring config for the demo.
29+
* <p>
30+
* Here is what it does:
31+
*
32+
* <ul>
33+
* <li>it imports {@link RDF4JConfig} which interprets the config properties (in our example, they are in
34+
* <code>application.properties</code>) and registers a number of beans.</li>
35+
* <li>it scans the <code>org.eclipse.rdf4j.spring.demo.dao</code> package, finds the DAOs, registers them as beans and
36+
* injects their dependencies</li>
37+
* <li>it configures the 'data inserter' beans, which read data from the 'artists.ttl' file and adds them to the
38+
* repository at startup</li>
39+
* </ul>
40+
* <p>
41+
* See {@link org.eclipse.rdf4j.spring Rdf4J-Spring} for an overview and more pointers.
42+
*
43+
* @author Florian Kleedorfer
44+
* @since 4.0.0
45+
*/
46+
@Configuration
47+
@Import(RDF4JConfig.class)
48+
@ComponentScan(
49+
value = "org.eclipse.rdf4j.spring.demo.dao", includeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = RDF4JDao.class))
50+
public class ArtDemoConfig {
51+
@Bean
52+
public DataInserter getDataInserter() {
53+
return new DataInserter();
54+
}
55+
56+
@Bean
57+
public InitialDataInserter getInitialDataInserter(
58+
@Autowired DataInserter dataInserter,
59+
@Value("classpath:/artists.ttl") Resource ttlFile) {
60+
return new InitialDataInserter(dataInserter, ttlFile);
61+
}
62+
}

0 commit comments

Comments
 (0)