-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Upgrade to Spring Data Neo4j 6 #22299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
meistermeier
wants to merge
6
commits into
spring-projects:master
from
meistermeier:feature/neo4j-starter
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d1fef06
Update starter for Spring Data Neo4j.
meistermeier 7180b08
First round of requested changes.
meistermeier 9b89300
Remove exclude filter from test support.
meistermeier 1dc1483
Inverse logic from driver auto-config.
meistermeier 1851701
Formatting and split auto-config tests.
meistermeier eacfd19
Polishing.
meistermeier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
65 changes: 0 additions & 65 deletions
65
...g/springframework/boot/autoconfigure/data/neo4j/Neo4jBookmarkManagementConfiguration.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
88 changes: 88 additions & 0 deletions
88
...c/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataConfiguration.java
This file contains hidden or 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,88 @@ | ||
/* | ||
* Copyright 2012-2020 the original author or 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 | ||
* | ||
* https://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 org.springframework.boot.autoconfigure.data.neo4j; | ||
|
||
import org.neo4j.driver.Driver; | ||
import org.springframework.beans.factory.ObjectProvider; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.AutoConfigureBefore; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.data.ConditionalOnRepositoryType; | ||
import org.springframework.boot.autoconfigure.data.RepositoryType; | ||
import org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.data.neo4j.config.Neo4jDefaultCallbacksRegistrar; | ||
import org.springframework.data.neo4j.core.DatabaseSelectionProvider; | ||
import org.springframework.data.neo4j.core.Neo4jClient; | ||
import org.springframework.data.neo4j.core.Neo4jOperations; | ||
import org.springframework.data.neo4j.core.Neo4jTemplate; | ||
import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; | ||
import org.springframework.data.neo4j.core.transaction.Neo4jTransactionManager; | ||
import org.springframework.data.neo4j.repository.config.Neo4jRepositoryConfigurationExtension; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
|
||
/** | ||
* Internal configuration of Neo4j client and transaction manager. | ||
* | ||
* @author Michael J. Simons | ||
*/ | ||
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnClass({ Neo4jTransactionManager.class, PlatformTransactionManager.class }) | ||
@ConditionalOnRepositoryType(store = "neo4j", type = RepositoryType.IMPERATIVE) | ||
@AutoConfigureAfter(Neo4jAutoConfiguration.class) | ||
@AutoConfigureBefore(Neo4jRepositoriesConfiguration.class) | ||
@Import(Neo4jDefaultCallbacksRegistrar.class) | ||
class Neo4jDataConfiguration { | ||
|
||
@Bean("databaseSelectionProvider") | ||
@ConditionalOnMissingBean | ||
DatabaseSelectionProvider defaultSelectionProvider(Environment environment) { | ||
String database = environment.getProperty("spring.data.neo4j.database"); | ||
if (database != null) { | ||
return DatabaseSelectionProvider.createStaticDatabaseSelectionProvider(database); | ||
} | ||
return DatabaseSelectionProvider.getDefaultSelectionProvider(); | ||
} | ||
|
||
@Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_CLIENT_BEAN_NAME) | ||
@ConditionalOnMissingBean | ||
Neo4jClient neo4jClient(Driver driver) { | ||
return Neo4jClient.create(driver); | ||
} | ||
|
||
@Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_TEMPLATE_BEAN_NAME) | ||
@ConditionalOnMissingBean(Neo4jOperations.class) | ||
Neo4jTemplate neo4jTemplate(Neo4jClient neo4jClient, Neo4jMappingContext neo4jMappingContext, | ||
DatabaseSelectionProvider databaseNameProvider) { | ||
return new Neo4jTemplate(neo4jClient, neo4jMappingContext, databaseNameProvider); | ||
} | ||
|
||
@Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME) | ||
@ConditionalOnMissingBean(PlatformTransactionManager.class) | ||
Neo4jTransactionManager transactionManager(Driver driver, DatabaseSelectionProvider databaseNameProvider, | ||
ObjectProvider<TransactionManagerCustomizers> optionalCustomizers) { | ||
Neo4jTransactionManager transactionManager = new Neo4jTransactionManager(driver, databaseNameProvider); | ||
optionalCustomizers.ifAvailable((customizer) -> customizer.customize(transactionManager)); | ||
return transactionManager; | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
.../src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataProperties.java
This file contains hidden or 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 2012-2020 the original author or 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 | ||
* | ||
* https://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 org.springframework.boot.autoconfigure.data.neo4j; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.data.neo4j.core.DatabaseSelectionProvider; | ||
|
||
/** | ||
* Configuration properties for Spring Data Neo4j. | ||
* | ||
* @author Michael J. Simons | ||
* @since 2.4.0 | ||
*/ | ||
@ConfigurationProperties(prefix = "spring.data.neo4j") | ||
public class Neo4jDataProperties { | ||
|
||
/** | ||
* A statically configured database. This property is only applicable when connecting | ||
* against a 4.0 cluster or server and will lead to errors if used with a prior | ||
* version of Neo4j. Leave this null (the default) to indicate that you like the | ||
* server to decide the default database to use. | ||
*/ | ||
private String database; | ||
snicoll marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public String getDatabase() { | ||
return this.database; | ||
} | ||
|
||
public void setDatabase(String database) { | ||
this.database = database; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.