Class AnnotatedControllerDetectionSupport<M>
java.lang.Object
org.springframework.graphql.data.method.annotation.support.AnnotatedControllerDetectionSupport<M>
- Type Parameters:
M- the type of mapping info prepared from a controller method
- All Implemented Interfaces:
Aware, InitializingBean, ApplicationContextAware
- Direct Known Subclasses:
AnnotatedControllerConfigurer, FederationSchemaFactory
public abstract class AnnotatedControllerDetectionSupport<M>
extends Object
implements ApplicationContextAware, InitializingBean
Convenient base for classes that find annotated controller method with argument
values resolved from a
DataFetchingEnvironment.- Since:
- 1.3.0
- Author:
- Rossen Stoyanchev
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.commons.logging.Logprotected static final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFormatterRegistrar(FormatterRegistrar registrar) Deprecated, for removal: This API element is subject to removal in a future version.voidvoidconfigureBinder(Consumer<GraphQlArgumentBinder.Options> binderOptionsConsumer) Callback to configure options for binding GraphQL arguments to target objects.protected HandlerMethodcreateHandlerMethod(Method originalMethod, Object handler, Class<?> handlerType) Scan beans in the ApplicationContext, detect and prepare a map of handler methods.protected @Nullable ApplicationContextprotected HandlerMethodArgumentResolverCompositeReturn the configured argument resolvers.protected GraphQlArgumentBinder.Optionsprotected FormattingConversionServiceDeprecated, for removal: This API element is subject to removal in a future version.Return aDataFetcherExceptionResolverthat resolves exceptions with@GraphQlExceptionHandlermethods in@ControllerAdviceclasses declared in Spring configuration.@Nullable ExecutorReturn theconfigured Executor.protected abstract HandlerMethodgetHandlerMethod(M mappingInfo) protected abstract @Nullable MgetMappingInfo(Method method, Object handler, Class<?> handlerType) protected abstract HandlerMethodArgumentResolverCompositeprotected booleanDeprecated, for removal: This API element is subject to removal in a future version.protected final ApplicationContextvoidsetApplicationContext(ApplicationContext applicationContext) voidsetBinderOptions(GraphQlArgumentBinder.Options binderOptions) Set the options to use for binding GraphQL arguments to target objects.voidsetBlockingMethodPredicate(@Nullable Predicate<HandlerMethod> predicate) Configure a predicate to decide which controller methods are blocking.voidsetControllerPredicate(Predicate<Class<?>> controllerPredicate) Configure a predicate to determine if a given class should be introspected for annotated controller methods.voidsetExecutor(Executor executor) Configure anExecutorto use for asynchronous handling ofCallablereturn values from controller methods, as well as forblocking controller methodson Java 21+.voidsetFallBackOnDirectFieldAccess(boolean fallBackOnDirectFieldAccess) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofconfigureBinder(Consumer)protected booleanshouldInvokeAsync(HandlerMethod handlerMethod)
-
Field Details
-
springSecurityPresent
protected static final boolean springSecurityPresent -
logger
protected final org.apache.commons.logging.Log logger
-
-
Constructor Details
-
AnnotatedControllerDetectionSupport
public AnnotatedControllerDetectionSupport()
-
-
Method Details
-
configureBinder
Callback to configure options for binding GraphQL arguments to target objects.- Parameters:
binderOptionsConsumer- consumer to customize options with- Since:
- 2.0.0
-
setBinderOptions
Set the options to use for binding GraphQL arguments to target objects.- Parameters:
binderOptions- the options to use- Since:
- 2.0.0
-
getBinderOptions
-
addFormatterRegistrar
@Deprecated(since="2.0", forRemoval=true) public void addFormatterRegistrar(FormatterRegistrar registrar) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofconfigureBinder(Consumer)Add aFormatterRegistrarto customize theConversionServicethat assists in binding GraphQL arguments onto@Argumentannotated method parameters.- Parameters:
registrar- the formatter registrar
-
getConversionService
@Deprecated(since="2.0", forRemoval=true) protected FormattingConversionService getConversionService()Deprecated, for removal: This API element is subject to removal in a future version. -
setFallBackOnDirectFieldAccess
@Deprecated(since="2.0", forRemoval=true) public void setFallBackOnDirectFieldAccess(boolean fallBackOnDirectFieldAccess) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofconfigureBinder(Consumer)Whether binding GraphQL arguments onto@Argumentshould falls back to direct field access in case the target object does not use accessor methods.- Parameters:
fallBackOnDirectFieldAccess- whether binding should fall back on direct field access
-
isFallBackOnDirectFieldAccess
Deprecated, for removal: This API element is subject to removal in a future version. -
getExceptionResolver
Return aDataFetcherExceptionResolverthat resolves exceptions with@GraphQlExceptionHandlermethods in@ControllerAdviceclasses declared in Spring configuration. This is useful primarily for exceptions from non-controllerDataFetchers since exceptions from@SchemaMappingcontroller methods are handled automatically at the point of invocation.- Returns:
- a resolver instance that can be plugged into
GraphQlSource.Builder - Since:
- 1.2.0
-
setExecutor
Configure anExecutorto use for asynchronous handling ofCallablereturn values from controller methods, as well as forblocking controller methodson Java 21+.By default, this is not set in which case controller methods with a
Callablereturn value are not supported, and blocking methods will be invoked synchronously.- Parameters:
executor- the executor to use
-
getExecutor
Return theconfigured Executor. -
setBlockingMethodPredicate
Configure a predicate to decide which controller methods are blocking. On Java 21+, such methods are invoked asynchronously through theconfigured Executor, unless the executor is a thread pool executor as determined viaprefersShortLivedTasks.By default, on Java 21+ the predicate returns false for controller method return types known to
ReactiveAdapterRegistryas well asKotlin suspending functions. On Java 20 and lower, the predicate returns false. You can configure the predicate for more control, or alternatively, returnCallable.- Parameters:
predicate- the predicate to use- Since:
- 1.3.0
-
getArgumentResolvers
Return the configured argument resolvers. -
setControllerPredicate
Configure a predicate to determine if a given class should be introspected for annotated controller methods.The default predicate looks for a type-level
Controllerannotation.- Parameters:
controllerPredicate- the predicate to use- Since:
- 1.4.3
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware
-
getApplicationContext
-
obtainApplicationContext
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
initArgumentResolvers
-
detectHandlerMethods
-
getMappingInfo
-
createHandlerMethod
protected HandlerMethod createHandlerMethod(Method originalMethod, Object handler, Class<?> handlerType) -
getHandlerMethod
-
shouldInvokeAsync
-
configureBinder(Consumer)