-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move spring-data-querydsl-predicate-injector autoconfiguration to tha…
…t subproject, to make it more selfcontained
- Loading branch information
1 parent
7ac9c7f
commit 230a6dc
Showing
8 changed files
with
86 additions
and
116 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
77 changes: 77 additions & 0 deletions
77
.../predicate/injector/rest/webmvc/SpringDataQuerydslPredicateInjectorAutoConfiguration.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,77 @@ | ||
package com.contentgrid.thunx.spring.data.querydsl.predicate.injector.rest.webmvc; | ||
|
||
import com.contentgrid.thunx.spring.data.querydsl.predicate.injector.repository.RepositoryInvokerAdapterFactory; | ||
import com.contentgrid.thunx.spring.data.querydsl.predicate.injector.resolver.QuerydslPredicateResolver; | ||
import org.springframework.beans.BeansException; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.beans.factory.config.BeanPostProcessor; | ||
import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.convert.ConversionService; | ||
import org.springframework.data.querydsl.binding.QuerydslBindingsFactory; | ||
import org.springframework.data.repository.support.Repositories; | ||
import org.springframework.data.repository.support.RepositoryInvokerFactory; | ||
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; | ||
import org.springframework.data.rest.webmvc.config.ResourceMetadataHandlerMethodArgumentResolver; | ||
import org.springframework.data.rest.webmvc.config.RootResourceInformationHandlerMethodArgumentResolver; | ||
|
||
@AutoConfiguration | ||
@AutoConfigureAfter(RepositoryRestMvcAutoConfiguration.class) | ||
@ConditionalOnClass(RepositoryRestMvcConfiguration.class) | ||
@ConditionalOnBean(RepositoryRestMvcConfiguration.class) | ||
public class SpringDataQuerydslPredicateInjectorAutoConfiguration { | ||
|
||
@Bean | ||
BeanPostProcessor interceptRepositoryRestMvcConfiguration(ApplicationContext applicationContext) { | ||
return new BeanPostProcessor() { | ||
@Override | ||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { | ||
|
||
if (bean instanceof RootResourceInformationHandlerMethodArgumentResolver) { | ||
var repositories = applicationContext.getBean(Repositories.class); | ||
var invokerFactory = applicationContext.getBean(RepositoryInvokerFactory.class); | ||
var resourceMetadataResolver = applicationContext.getBean( | ||
ResourceMetadataHandlerMethodArgumentResolver.class); | ||
|
||
var predicateResolvers = applicationContext.getBeanProvider(QuerydslPredicateResolver.class); | ||
var repositoryInvokerAdapterFactory = applicationContext.getBean( | ||
RepositoryInvokerAdapterFactory.class); | ||
|
||
return new PredicateInjectingRootResourceInformationHandlerMethodArgumentResolver( | ||
repositories, | ||
invokerFactory, | ||
resourceMetadataResolver, | ||
repositoryInvokerAdapterFactory, | ||
predicateResolvers | ||
); | ||
} | ||
|
||
return bean; | ||
} | ||
}; | ||
} | ||
|
||
@Bean | ||
@ConditionalOnBean(QuerydslBindingsPredicateResolver.class) | ||
@ConditionalOnMissingBean | ||
RepositoryInvokerAdapterFactory repositoryInvokerAdapterFactory(Repositories repositories) { | ||
return new QuerydslRepositoryInvokerAdapterFactory(repositories); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnBean(QuerydslBindingsFactory.class) | ||
QuerydslPredicateResolver querydslBindingsPredicateResolver( | ||
@Qualifier("defaultConversionService") ConversionService conversionService, | ||
QuerydslBindingsFactory querydslBindingsFactory | ||
) { | ||
return new QuerydslBindingsPredicateResolver(conversionService, querydslBindingsFactory); | ||
} | ||
|
||
} |
75 changes: 0 additions & 75 deletions
75
.../data/querydsl/predicate/injector/rest/webmvc/SpringDataRestIntegrationConfiguration.java
This file was deleted.
Oops, something went wrong.
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 @@ | ||
com.contentgrid.thunx.spring.data.querydsl.predicate.injector.rest.webmvc.SpringDataQuerydslPredicateInjectorAutoConfiguration |
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
2 changes: 2 additions & 0 deletions
2
...onfigure/src/main/java/com/contentgrid/thunx/api/autoconfigure/AbacAutoConfiguration.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
37 changes: 0 additions & 37 deletions
37
...entgrid/thunx/api/autoconfigure/SpringDataQuerydslPredicateInjectorAutoConfiguration.java
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
com.contentgrid.thunx.api.autoconfigure.SpringDataQuerydslPredicateInjectorAutoConfiguration | ||
com.contentgrid.thunx.api.autoconfigure.AbacAutoConfiguration | ||
com.contentgrid.thunx.gateway.autoconfigure.GatewayAutoConfiguration |