diff --git a/src/main/java/org/springframework/data/repository/query/ReactiveExtensionAwareQueryMethodEvaluationContextProvider.java b/src/main/java/org/springframework/data/repository/query/ReactiveExtensionAwareQueryMethodEvaluationContextProvider.java index e93eeba19..df74c6f8e 100644 --- a/src/main/java/org/springframework/data/repository/query/ReactiveExtensionAwareQueryMethodEvaluationContextProvider.java +++ b/src/main/java/org/springframework/data/repository/query/ReactiveExtensionAwareQueryMethodEvaluationContextProvider.java @@ -42,7 +42,7 @@ public class ReactiveExtensionAwareQueryMethodEvaluationContextProvider private final ReactiveExtensionAwareEvaluationContextProvider delegate; /** - * Creates a new {@link ReactiveExtensionAwareQueryMethodEvaluationContextProvider}. + * Create a new {@link ReactiveExtensionAwareQueryMethodEvaluationContextProvider}. * * @param beanFactory the {@link ListableBeanFactory} to lookup the {@link EvaluationContextExtension}s from, must not * be {@literal null}. @@ -55,7 +55,7 @@ public class ReactiveExtensionAwareQueryMethodEvaluationContextProvider } /** - * Creates a new {@link ReactiveExtensionAwareQueryMethodEvaluationContextProvider} using the given + * Create a new {@link ReactiveExtensionAwareQueryMethodEvaluationContextProvider} using the given * {@link EvaluationContextExtension}s and * {@link org.springframework.data.spel.spi.ReactiveEvaluationContextExtension}s. * @@ -68,7 +68,7 @@ public class ReactiveExtensionAwareQueryMethodEvaluationContextProvider this.delegate = new ReactiveExtensionAwareEvaluationContextProvider(extensions); } - /* + /* * (non-Javadoc) * @see org.springframework.data.repository.query.QueryMethodEvaluationContextProvider#getEvaluationContext(org.springframework.data.repository.query.Parameters, java.lang.Object[]) */ @@ -85,7 +85,7 @@ public class ReactiveExtensionAwareQueryMethodEvaluationContextProvider return evaluationContext; } - /* + /* * (non-Javadoc) * @see org.springframework.data.repository.query.QueryMethodEvaluationContextProvider#getEvaluationContext(org.springframework.data.repository.query.Parameters, java.lang.Object[], org.springframework.data.spel.ExpressionDependencies) */ @@ -119,7 +119,7 @@ public class ReactiveExtensionAwareQueryMethodEvaluationContextProvider .cast(EvaluationContext.class); } - /* + /* * (non-Javadoc) * @see org.springframework.data.repository.query.ReactiveQueryMethodEvaluationContextProvider#getEvaluationContextLater(org.springframework.data.repository.query.Parameters, java.lang.Object[], org.springframework.data.spel.ExpressionDependencies) */ diff --git a/src/main/java/org/springframework/data/repository/query/ReactiveQueryMethodEvaluationContextProvider.java b/src/main/java/org/springframework/data/repository/query/ReactiveQueryMethodEvaluationContextProvider.java index 7dd25f0ad..eedd9b68a 100644 --- a/src/main/java/org/springframework/data/repository/query/ReactiveQueryMethodEvaluationContextProvider.java +++ b/src/main/java/org/springframework/data/repository/query/ReactiveQueryMethodEvaluationContextProvider.java @@ -35,7 +35,7 @@ public interface ReactiveQueryMethodEvaluationContextProvider extends QueryMetho Collections.emptyList()); /** - * Returns an {@link EvaluationContext} built using the given {@link Parameters} and parameter values. + * Return a {@link EvaluationContext} built using the given {@link Parameters} and parameter values. * * @param parameters the {@link Parameters} instance obtained from the query method the context is built for. * @param parameterValues the values for the parameters. @@ -45,7 +45,7 @@ public interface ReactiveQueryMethodEvaluationContextProvider extends QueryMetho Object[] parameterValues); /** - * Returns an {@link EvaluationContext} built using the given {@link Parameters} and parameter values. + * Return a {@link EvaluationContext} built using the given {@link Parameters} and parameter values. * * @param parameters the {@link Parameters} instance obtained from the query method the context is built for. * @param parameterValues the values for the parameters. diff --git a/src/main/java/org/springframework/data/spel/EvaluationContextExtensionInformation.java b/src/main/java/org/springframework/data/spel/EvaluationContextExtensionInformation.java index 41e4404bf..abc70976a 100644 --- a/src/main/java/org/springframework/data/spel/EvaluationContextExtensionInformation.java +++ b/src/main/java/org/springframework/data/spel/EvaluationContextExtensionInformation.java @@ -102,7 +102,7 @@ class EvaluationContextExtensionInformation { } /** - * Returns whether this extension provides {@link ExpressionDependencies.ExpressionDependency}. + * Return {@literal true} if this extension provides {@link ExpressionDependencies.ExpressionDependency}. * * @param dependency the expression dependency. * @return {@literal true} if {@link ExpressionDependencies.ExpressionDependency} is provided by this root object or @@ -159,7 +159,7 @@ class EvaluationContextExtensionInformation { } /** - * Returns whether this extension provides {@link ExpressionDependencies.ExpressionDependency}. + * Return {@literal true} if this extension provides {@link ExpressionDependencies.ExpressionDependency}. * * @param dependency the expression dependency. * @return {@literal true} if {@link ExpressionDependencies.ExpressionDependency} is provided by this root object. diff --git a/src/main/java/org/springframework/data/spel/EvaluationContextProvider.java b/src/main/java/org/springframework/data/spel/EvaluationContextProvider.java index 4ccb6acad..0739b88ee 100644 --- a/src/main/java/org/springframework/data/spel/EvaluationContextProvider.java +++ b/src/main/java/org/springframework/data/spel/EvaluationContextProvider.java @@ -34,12 +34,12 @@ public interface EvaluationContextProvider { * A simple default {@link EvaluationContextProvider} returning a {@link StandardEvaluationContext} with the given * root object. */ - static EvaluationContextProvider DEFAULT = rootObject -> rootObject == null // + EvaluationContextProvider DEFAULT = rootObject -> rootObject == null // ? new StandardEvaluationContext() // : new StandardEvaluationContext(rootObject); /** - * Returns an {@link EvaluationContext} built using the given parameter values. + * Return a {@link EvaluationContext} built using the given parameter values. * * @param rootObject the root object to set in the {@link EvaluationContext}. * @return @@ -47,10 +47,10 @@ public interface EvaluationContextProvider { EvaluationContext getEvaluationContext(Object rootObject); /** - * Returns a tailored {@link EvaluationContext} built using the given parameter values and considering - * {@link ExpressionDependencies.ExpressionDependency expression dependencies}. The returned {@link EvaluationContext} - * may contain a reduced visibility of methods and properties/fields according to the required - * {@link ExpressionDependencies.ExpressionDependency expression dependencies}. + * Return a tailored {@link EvaluationContext} built using the given parameter values and considering + * {@link ExpressionDependencies expression dependencies}. The returned {@link EvaluationContext} may contain a + * reduced visibility of methods and properties/fields according to the required {@link ExpressionDependencies + * expression dependencies}. * * @param rootObject the root object to set in the {@link EvaluationContext}. * @param dependencies the requested expression dependencies to be available. diff --git a/src/main/java/org/springframework/data/spel/ExpressionDependencies.java b/src/main/java/org/springframework/data/spel/ExpressionDependencies.java index d7c114994..34f6f6f4f 100644 --- a/src/main/java/org/springframework/data/spel/ExpressionDependencies.java +++ b/src/main/java/org/springframework/data/spel/ExpressionDependencies.java @@ -179,21 +179,21 @@ public class ExpressionDependencies implements Streamable, EvaluationContextExtensionInformation> extensionInformationCache = new ConcurrentHashMap<>(); - private final Lazy> extensions; + private ListableBeanFactory beanFactory; ExtensionAwareEvaluationContextProvider() { @@ -80,7 +81,7 @@ public class ExtensionAwareEvaluationContextProvider implements EvaluationContex */ public ExtensionAwareEvaluationContextProvider(ListableBeanFactory beanFactory) { - this(Lazy.of(() -> getExtensionsFrom(beanFactory))); + this(Lazy.of(() -> beanFactory.getBeansOfType(ExtensionIdAware.class, true, false).values())); this.beanFactory = beanFactory; } @@ -142,12 +143,12 @@ public class ExtensionAwareEvaluationContextProvider implements EvaluationContex return this.extensions.get(); } - Collection getExtensions( + private Collection getExtensions( Predicate extensionFilter) { Collection extensionsToUse = new ArrayList<>(); - for (ExtensionIdAware candidate : this.extensions.get()) { + for (ExtensionIdAware candidate : getExtensions()) { if (candidate instanceof EvaluationContextExtension) { @@ -161,16 +162,6 @@ public class ExtensionAwareEvaluationContextProvider implements EvaluationContex return extensionsToUse; } - /** - * Looks up all {@link ExtensionIdAware} instances from the given {@link ListableBeanFactory}. - * - * @param beanFactory must not be {@literal null}. - * @return - */ - private static Collection getExtensionsFrom(ListableBeanFactory beanFactory) { - return beanFactory.getBeansOfType(ExtensionIdAware.class, true, false).values(); - } - /** * Looks up the {@link EvaluationContextExtensionInformation} for the given {@link EvaluationContextExtension} from * the cache or creates a new one and caches that for later lookup. diff --git a/src/main/java/org/springframework/data/spel/ReactiveEvaluationContextProvider.java b/src/main/java/org/springframework/data/spel/ReactiveEvaluationContextProvider.java index 80eb5d863..2c5d6994e 100644 --- a/src/main/java/org/springframework/data/spel/ReactiveEvaluationContextProvider.java +++ b/src/main/java/org/springframework/data/spel/ReactiveEvaluationContextProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 the original author or authors. + * Copyright 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. @@ -28,7 +28,7 @@ import org.springframework.expression.EvaluationContext; public interface ReactiveEvaluationContextProvider extends EvaluationContextProvider { /** - * Returns an {@link EvaluationContext} built using the given parameter values. + * Return a {@link EvaluationContext} built using the given parameter values. * * @param rootObject the root object to set in the {@link EvaluationContext}. * @return a mono that emits exactly one {@link EvaluationContext}. @@ -36,10 +36,10 @@ public interface ReactiveEvaluationContextProvider extends EvaluationContextProv Mono getEvaluationContextLater(Object rootObject); /** - * Returns a tailored {@link EvaluationContext} built using the given parameter values and considering - * {@link ExpressionDependencies.ExpressionDependency expression dependencies}. The returned {@link EvaluationContext} - * may contain a reduced visibility of methods and properties/fields according to the required - * {@link ExpressionDependencies.ExpressionDependency expression dependencies}. + * Return a tailored {@link EvaluationContext} built using the given parameter values and considering + * {@link ExpressionDependencies expression dependencies}. The returned {@link EvaluationContext} may contain a + * reduced visibility of methods and properties/fields according to the required {@link ExpressionDependencies + * expression dependencies}. * * @param rootObject the root object to set in the {@link EvaluationContext}. * @param dependencies the requested expression dependencies to be available. diff --git a/src/main/java/org/springframework/data/spel/spi/EvaluationContextExtension.java b/src/main/java/org/springframework/data/spel/spi/EvaluationContextExtension.java index e9b6ebc9a..7badce5a2 100644 --- a/src/main/java/org/springframework/data/spel/spi/EvaluationContextExtension.java +++ b/src/main/java/org/springframework/data/spel/spi/EvaluationContextExtension.java @@ -37,7 +37,7 @@ import org.springframework.lang.Nullable; public interface EvaluationContextExtension extends ExtensionIdAware { /** - * Returns the properties exposed by the extension. + * Return the properties exposed by the extension. * * @return the properties */ @@ -46,7 +46,7 @@ public interface EvaluationContextExtension extends ExtensionIdAware { } /** - * Returns the functions exposed by the extension. + * Return the functions exposed by the extension. * * @return the functions */ @@ -55,11 +55,11 @@ public interface EvaluationContextExtension extends ExtensionIdAware { } /** - * Returns the root object to be exposed by the extension. It's strongly recommended to declare the most concrete type + * Return the root object to be exposed by the extension. It's strongly recommended to declare the most concrete type * possible as return type of the implementation method. This will allow us to obtain the necessary metadata once and * not for every evaluation. * - * @return + * @return the root object to be exposed by the extension. */ @Nullable default Object getRootObject() { diff --git a/src/main/java/org/springframework/data/spel/spi/ExtensionIdAware.java b/src/main/java/org/springframework/data/spel/spi/ExtensionIdAware.java index 93161d0fd..d9557298d 100644 --- a/src/main/java/org/springframework/data/spel/spi/ExtensionIdAware.java +++ b/src/main/java/org/springframework/data/spel/spi/ExtensionIdAware.java @@ -26,8 +26,8 @@ package org.springframework.data.spel.spi; public interface ExtensionIdAware { /** - * Returns the identifier of the extension. The id can be leveraged by users to fully qualify property lookups and - * thus overcome ambiguities in case multiple extensions expose properties with the same name. + * Return the identifier of the extension. The id can be leveraged by users to fully qualify property lookups and thus + * overcome ambiguities in case multiple extensions expose properties with the same name. * * @return the extension id, must not be {@literal null}. */ diff --git a/src/main/java/org/springframework/data/spel/spi/ReactiveEvaluationContextExtension.java b/src/main/java/org/springframework/data/spel/spi/ReactiveEvaluationContextExtension.java index 2fb8d1bc4..0a28b9eb5 100644 --- a/src/main/java/org/springframework/data/spel/spi/ReactiveEvaluationContextExtension.java +++ b/src/main/java/org/springframework/data/spel/spi/ReactiveEvaluationContextExtension.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 the original author or authors. + * Copyright 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. @@ -35,9 +35,9 @@ import org.springframework.expression.EvaluationContext; public interface ReactiveEvaluationContextExtension extends ExtensionIdAware { /** - * Returns the {@link EvaluationContextExtension} to be consumed during the actual execution. It's strongly - * recommended to declare the most concrete type possible as return type of the implementation method. This will allow - * us to obtain the necessary metadata once and not for every evaluation. + * Return the {@link EvaluationContextExtension} to be consumed during the actual execution. It's strongly recommended + * to declare the most concrete type possible as return type of the implementation method. This will allow us to + * obtain the necessary metadata once and not for every evaluation. * * @return the resolved {@link EvaluationContextExtension}. Publishers emitting no value will be skipped. */