Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
2add65fe
Commit
2add65fe
authored
Oct 01, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish Neo4J BookmarkManager auto-configuration
Closes gh-14568
parent
b7847d98
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
23 deletions
+16
-23
Neo4jBookmarkManagementConfiguration.java
...gure/data/neo4j/Neo4jBookmarkManagementConfiguration.java
+3
-5
Neo4jDataAutoConfiguration.java
.../autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java
+0
-1
Neo4jDataAutoConfigurationTests.java
...configure/data/neo4j/Neo4jDataAutoConfigurationTests.java
+13
-17
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jBookmarkManagementConfiguration.java
View file @
2add65fe
...
@@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.data.neo4j;
...
@@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.data.neo4j;
import
com.github.benmanes.caffeine.cache.Caffeine
;
import
com.github.benmanes.caffeine.cache.Caffeine
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
...
@@ -41,7 +40,7 @@ import org.springframework.web.context.WebApplicationContext;
...
@@ -41,7 +40,7 @@ import org.springframework.web.context.WebApplicationContext;
* bound to the application or the request, as recommend by Spring Data Neo4j.
* bound to the application or the request, as recommend by Spring Data Neo4j.
*
*
* @author Michael Simons
* @author Michael Simons
* @since 2.1
* @since 2.1
.0
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
({
Caffeine
.
class
,
CaffeineCacheManager
.
class
})
@ConditionalOnClass
({
Caffeine
.
class
,
CaffeineCacheManager
.
class
})
...
@@ -50,17 +49,16 @@ import org.springframework.web.context.WebApplicationContext;
...
@@ -50,17 +49,16 @@ import org.springframework.web.context.WebApplicationContext;
BookmarkInterceptor
.
class
})
BookmarkInterceptor
.
class
})
class
Neo4jBookmarkManagementConfiguration
{
class
Neo4jBookmarkManagementConfiguration
{
static
final
String
BOOKMARK_MANAGER_BEAN_NAME
=
"bookmarkManager"
;
private
static
final
String
BOOKMARK_MANAGER_BEAN_NAME
=
"bookmarkManager"
;
@Bean
(
BOOKMARK_MANAGER_BEAN_NAME
)
@Bean
(
BOOKMARK_MANAGER_BEAN_NAME
)
@Scope
(
value
=
WebApplicationContext
.
SCOPE_REQUEST
,
proxyMode
=
ScopedProxyMode
.
INTERFACES
)
@ConditionalOnWebApplication
@ConditionalOnWebApplication
@Scope
(
value
=
WebApplicationContext
.
SCOPE_REQUEST
,
proxyMode
=
ScopedProxyMode
.
INTERFACES
)
public
BookmarkManager
requestScopedBookmarkManager
()
{
public
BookmarkManager
requestScopedBookmarkManager
()
{
return
new
CaffeineBookmarkManager
();
return
new
CaffeineBookmarkManager
();
}
}
@Bean
(
BOOKMARK_MANAGER_BEAN_NAME
)
@Bean
(
BOOKMARK_MANAGER_BEAN_NAME
)
@Scope
(
ConfigurableBeanFactory
.
SCOPE_SINGLETON
)
@ConditionalOnNotWebApplication
@ConditionalOnNotWebApplication
public
BookmarkManager
singletonScopedBookmarkManager
()
{
public
BookmarkManager
singletonScopedBookmarkManager
()
{
return
new
CaffeineBookmarkManager
();
return
new
CaffeineBookmarkManager
();
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java
View file @
2add65fe
...
@@ -53,7 +53,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
...
@@ -53,7 +53,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
* @author Vince Bickers
* @author Vince Bickers
* @author Stephane Nicoll
* @author Stephane Nicoll
* @author Kazuki Shimizu
* @author Kazuki Shimizu
* @author Michael Simons
* @since 1.4.0
* @since 1.4.0
*/
*/
@Configuration
@Configuration
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java
View file @
2add65fe
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -16,10 +16,7 @@
...
@@ -16,10 +16,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
data
.
neo4j
;
package
org
.
springframework
.
boot
.
autoconfigure
.
data
.
neo4j
;
import
java.util.function.Predicate
;
import
com.github.benmanes.caffeine.cache.Caffeine
;
import
com.github.benmanes.caffeine.cache.Caffeine
;
import
org.assertj.core.api.Condition
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.neo4j.ogm.session.Session
;
import
org.neo4j.ogm.session.Session
;
import
org.neo4j.ogm.session.SessionFactory
;
import
org.neo4j.ogm.session.SessionFactory
;
...
@@ -27,6 +24,7 @@ import org.neo4j.ogm.session.event.Event;
...
@@ -27,6 +24,7 @@ import org.neo4j.ogm.session.event.Event;
import
org.neo4j.ogm.session.event.EventListener
;
import
org.neo4j.ogm.session.event.EventListener
;
import
org.neo4j.ogm.session.event.PersistenceEvent
;
import
org.neo4j.ogm.session.event.PersistenceEvent
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.boot.autoconfigure.AutoConfigurationPackages
;
import
org.springframework.boot.autoconfigure.AutoConfigurationPackages
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.autoconfigure.data.neo4j.city.City
;
import
org.springframework.boot.autoconfigure.data.neo4j.city.City
;
...
@@ -36,7 +34,6 @@ import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfigu
...
@@ -36,7 +34,6 @@ import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfigu
import
org.springframework.boot.test.context.FilteredClassLoader
;
import
org.springframework.boot.test.context.FilteredClassLoader
;
import
org.springframework.boot.test.context.runner.ApplicationContextRunner
;
import
org.springframework.boot.test.context.runner.ApplicationContextRunner
;
import
org.springframework.boot.test.context.runner.WebApplicationContextRunner
;
import
org.springframework.boot.test.context.runner.WebApplicationContextRunner
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -160,18 +157,14 @@ public class Neo4jDataAutoConfigurationTests {
...
@@ -160,18 +157,14 @@ public class Neo4jDataAutoConfigurationTests {
@Test
@Test
public
void
providesARequestScopedBookmarkManangerIfNecessaryAndPossible
()
{
public
void
providesARequestScopedBookmarkManangerIfNecessaryAndPossible
()
{
Predicate
<
ConfigurableApplicationContext
>
hasRequestScopedBookmarkManager
=
(
context
)
->
context
.
getBeanFactory
()
//
.
getBeanDefinition
(
"scopedTarget."
+
Neo4jBookmarkManagementConfiguration
.
BOOKMARK_MANAGER_BEAN_NAME
)
//
.
getScope
()
//
.
equals
(
WebApplicationContext
.
SCOPE_REQUEST
);
this
.
contextRunner
this
.
contextRunner
.
withUserConfiguration
(
BookmarkManagementEnabledConfiguration
.
class
)
.
withUserConfiguration
(
BookmarkManagementEnabledConfiguration
.
class
)
.
run
((
context
)
->
assertThat
(
context
)
.
run
((
context
)
->
{
.
satisfies
(
new
Condition
<>(
hasRequestScopedBookmarkManager
,
BeanDefinition
bookmarkManagerBean
=
context
.
getBeanFactory
()
"hasRequestScopedBookmarkManager"
)));
.
getBeanDefinition
(
"scopedTarget.bookmarkManager"
);
assertThat
(
bookmarkManagerBean
.
getScope
())
.
isEqualTo
(
WebApplicationContext
.
SCOPE_REQUEST
);
});
}
}
@Test
@Test
...
@@ -181,8 +174,11 @@ public class Neo4jDataAutoConfigurationTests {
...
@@ -181,8 +174,11 @@ public class Neo4jDataAutoConfigurationTests {
BookmarkManagementEnabledConfiguration
.
class
)
BookmarkManagementEnabledConfiguration
.
class
)
.
withConfiguration
(
AutoConfigurations
.
of
(
Neo4jDataAutoConfiguration
.
class
,
.
withConfiguration
(
AutoConfigurations
.
of
(
Neo4jDataAutoConfiguration
.
class
,
TransactionAutoConfiguration
.
class
))
TransactionAutoConfiguration
.
class
))
.
run
((
context
)
->
assertThat
(
context
)
.
run
((
context
)
->
{
.
hasSingleBean
(
BookmarkManager
.
class
));
assertThat
(
context
).
hasSingleBean
(
BookmarkManager
.
class
);
assertThat
(
context
.
getBeanDefinitionNames
())
.
doesNotContain
(
"scopedTarget.bookmarkManager"
);
});
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment