Search in sources :

Example 1 with QueryMethodEvaluationContextProvider

use of org.springframework.data.repository.query.QueryMethodEvaluationContextProvider in project spring-cloud-gcp by spring-cloud.

the class DatastoreRepositoryFactory method delegateContextProvider.

private QueryMethodEvaluationContextProvider delegateContextProvider(QueryMethodEvaluationContextProvider evaluationContextProvider) {
    return new QueryMethodEvaluationContextProvider() {

        @Override
        public <T extends Parameters<?, ?>> EvaluationContext getEvaluationContext(T parameters, Object[] parameterValues) {
            StandardEvaluationContext evaluationContext = (StandardEvaluationContext) evaluationContextProvider.getEvaluationContext(parameters, parameterValues);
            evaluationContext.setRootObject(DatastoreRepositoryFactory.this.applicationContext);
            evaluationContext.addPropertyAccessor(new BeanFactoryAccessor());
            evaluationContext.setBeanResolver(new BeanFactoryResolver(DatastoreRepositoryFactory.this.applicationContext));
            return evaluationContext;
        }
    };
}
Also used : BeanFactoryResolver(org.springframework.context.expression.BeanFactoryResolver) Parameters(org.springframework.data.repository.query.Parameters) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) QueryMethodEvaluationContextProvider(org.springframework.data.repository.query.QueryMethodEvaluationContextProvider) BeanFactoryAccessor(org.springframework.context.expression.BeanFactoryAccessor)

Example 2 with QueryMethodEvaluationContextProvider

use of org.springframework.data.repository.query.QueryMethodEvaluationContextProvider in project spring-cloud-gcp by spring-cloud.

the class SpannerRepositoryFactory method delegateContextProvider.

private QueryMethodEvaluationContextProvider delegateContextProvider(QueryMethodEvaluationContextProvider evaluationContextProvider) {
    return new QueryMethodEvaluationContextProvider() {

        @Override
        public <T extends Parameters<?, ?>> EvaluationContext getEvaluationContext(T parameters, Object[] parameterValues) {
            StandardEvaluationContext evaluationContext = (StandardEvaluationContext) evaluationContextProvider.getEvaluationContext(parameters, parameterValues);
            evaluationContext.setRootObject(SpannerRepositoryFactory.this.applicationContext);
            evaluationContext.addPropertyAccessor(new BeanFactoryAccessor());
            evaluationContext.setBeanResolver(new BeanFactoryResolver(SpannerRepositoryFactory.this.applicationContext));
            return evaluationContext;
        }
    };
}
Also used : BeanFactoryResolver(org.springframework.context.expression.BeanFactoryResolver) Parameters(org.springframework.data.repository.query.Parameters) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) QueryMethodEvaluationContextProvider(org.springframework.data.repository.query.QueryMethodEvaluationContextProvider) BeanFactoryAccessor(org.springframework.context.expression.BeanFactoryAccessor)

Aggregations

BeanFactoryAccessor (org.springframework.context.expression.BeanFactoryAccessor)2 BeanFactoryResolver (org.springframework.context.expression.BeanFactoryResolver)2 Parameters (org.springframework.data.repository.query.Parameters)2 QueryMethodEvaluationContextProvider (org.springframework.data.repository.query.QueryMethodEvaluationContextProvider)2 StandardEvaluationContext (org.springframework.expression.spel.support.StandardEvaluationContext)2