Class GatewayProxyFactoryBean<T>
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.GatewayProxyFactoryBean<T>
- Type Parameters:
- T- the target gateway interface to build a proxy against.
- All Implemented Interfaces:
- Advice,- Interceptor,- MethodInterceptor,- Aware,- BeanClassLoaderAware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- FactoryBean<T>,- InitializingBean,- ApplicationContextAware,- Lifecycle,- Phased,- SmartLifecycle,- ExpressionCapable,- NamedComponent,- IntegrationManagement,- ManageableLifecycle,- ManageableSmartLifecycle,- TrackableComponent
- Direct Known Subclasses:
- AnnotationGatewayProxyFactoryBean
public class GatewayProxyFactoryBean<T>
extends AbstractEndpoint
implements TrackableComponent, FactoryBean<T>, MethodInterceptor, BeanClassLoaderAware, IntegrationManagement
Generates a proxy for the provided service interface to enable interaction
 with messaging components without application code being aware of them allowing
 for POJO-style interaction.
 This component is also aware of the
 
ConversionService set on the enclosing BeanFactory
 under the name
 IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME
 to
 perform type conversions when necessary (thanks to Jon Schneider's contribution and suggestion in INT-1230).- Author:
- Mark Fisher, Oleg Zhurakousky, Gary Russell, Artem Bilan, JingPeng Xie, Christian Tzolov
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.endpoint.AbstractEndpointlifecycleCondition, lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.beans.factory.FactoryBeanOBJECT_TYPE_ATTRIBUTEFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.context.SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a Factory whose service interface type can be configured by setter injection.GatewayProxyFactoryBean(Class<T> serviceInterface) 
- 
Method SummaryModifier and TypeMethodDescriptionvoiddestroy()protected ObjectdoInvoke(MethodInvocation invocation, boolean runningOnCallerThread) protected voiddoStart()Subclasses must implement this method with the start behavior.protected voiddoStop()Subclasses must implement this method with the stop behavior.protected AsyncTaskExecutorprotected MessageChannelprotected Stringprotected Expressionprotected MessageChannelprotected Stringprotected Expressionprotected MessageChannelprotected StringReturn the Map ofMethodtoMessagingGatewaySupportgenerated by this factory bean.protected GatewayMethodMetadataprotected MethodArgsMessageMapperClass<?>invoke(MethodInvocation invocation) protected booleanprotected voidonInit()Subclasses may implement this for initialization logic.voidregisterMetricsCaptor(MetricsCaptor metricsCaptorToRegister) Inject aMetricsCaptor.voidsetAsyncExecutor(Executor executor) Set the executor for use when the gateway method returnsFutureorListenableFuture.voidsetBeanClassLoader(ClassLoader beanClassLoader) voidsetDefaultReplyChannel(MessageChannel defaultReplyChannel) Set the default reply channel.voidsetDefaultReplyChannelName(String defaultReplyChannelName) Set the default reply channel bean name.voidsetDefaultReplyTimeout(Long defaultReplyTimeout) Set the default timeout value for receiving reply messages.voidsetDefaultReplyTimeoutExpression(Expression defaultReplyTimeout) Set an expression to be evaluated to determine the default timeout value for receiving reply messages.voidsetDefaultReplyTimeoutExpressionString(String defaultReplyTimeout) Set an expression to be evaluated to determine the default timeout value for receiving reply messages.voidsetDefaultRequestChannel(MessageChannel defaultRequestChannel) Set the default request channel.voidsetDefaultRequestChannelName(String defaultRequestChannelName) Set the default request channel bean name.voidsetDefaultRequestTimeout(Long defaultRequestTimeout) Set the default timeout value for sending request messages.voidsetDefaultRequestTimeoutExpression(Expression defaultRequestTimeout) Set an expression to be evaluated to determine the default timeout value for sending request messages.voidsetDefaultRequestTimeoutExpressionString(String defaultRequestTimeout) Set an expression to be evaluated to determine the default timeout value for sending request messages.voidsetErrorChannel(MessageChannel errorChannel) Set the error channel.voidsetErrorChannelName(String errorChannelName) Set the error channel name.voidsetErrorOnTimeout(boolean errorOnTimeout) If errorOnTimeout is true, null won't be returned as a result of a gateway method invocation, when a timeout occurs.voidsetGlobalMethodMetadata(GatewayMethodMetadata globalMethodMetadata) final voidsetMapper(MethodArgsMessageMapper mapper) voidsetMethodMetadataMap(Map<String, GatewayMethodMetadata> methodMetadataMap) voidsetProxyDefaultMethods(boolean proxyDefaultMethods) Indicate ifdefaultmethods on the interface should be proxied as well.voidsetShouldTrack(boolean shouldTrack) voidsetTypeConverter(TypeConverter typeConverter) Methods inherited from class org.springframework.integration.endpoint.AbstractEndpointdoStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.FactoryBeanisSingletonMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, isObserved, registerObservationRegistry, setLoggingEnabled, setManagedName, setManagedTypeMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName, getComponentType
- 
Constructor Details- 
GatewayProxyFactoryBeanpublic GatewayProxyFactoryBean()Create a Factory whose service interface type can be configured by setter injection. If none is set, it will fall back to the default service interface type,RequestReplyExchanger, upon initialization.
- 
GatewayProxyFactoryBean
 
- 
- 
Method Details- 
setDefaultRequestChannelSet the default request channel.- Parameters:
- defaultRequestChannel- the channel to which request messages will be sent if no request channel has been configured with an annotation.
 
- 
setDefaultRequestChannelNameSet the default request channel bean name.- Parameters:
- defaultRequestChannelName- the channel name to which request messages will be sent if no request channel has been configured with an annotation.
- Since:
- 4.2.9
 
- 
getDefaultRequestChannel
- 
getDefaultRequestChannelName
- 
setDefaultReplyChannelSet the default reply channel. If no default reply channel is provided, and no reply channel is configured with annotations, an anonymous, temporary channel will be used for handling replies.- Parameters:
- defaultReplyChannel- the channel from which reply messages will be received if no reply channel has been configured with an annotation
 
- 
setDefaultReplyChannelNameSet the default reply channel bean name. If no default reply channel is provided, and no reply channel is configured with annotations, an anonymous, temporary channel will be used for handling replies.- Parameters:
- defaultReplyChannelName- the channel name from which reply messages will be received if no reply channel has been configured with an annotation
- Since:
- 4.2.9
 
- 
getDefaultReplyChannel
- 
getDefaultReplyChannelName
- 
setErrorChannelSet the error channel. If no error channel is provided, this gateway will propagate Exceptions to the caller. To completely suppress Exceptions, provide a reference to the "nullChannel" here.- Parameters:
- errorChannel- The error channel.
 
- 
setErrorChannelNameSet the error channel name. If no error channel is provided, this gateway will propagate Exceptions to the caller. To completely suppress Exceptions, provide a reference to the "nullChannel" here.- Parameters:
- errorChannelName- The error channel bean name.
- Since:
- 4.2.9
 
- 
getErrorChannel
- 
getErrorChannelName
- 
setDefaultRequestTimeoutSet the default timeout value for sending request messages. If not explicitly configured with an annotation, or on a method element, this value will be used.- Parameters:
- defaultRequestTimeout- the timeout value in milliseconds
 
- 
setDefaultRequestTimeoutExpressionSet an expression to be evaluated to determine the default timeout value for sending request messages. If not explicitly configured with an annotation, or on a method element, this value will be used.- Parameters:
- defaultRequestTimeout- the timeout value in milliseconds
- Since:
- 5.0
 
- 
setDefaultRequestTimeoutExpressionStringSet an expression to be evaluated to determine the default timeout value for sending request messages. If not explicitly configured with an annotation, or on a method element, this value will be used.- Parameters:
- defaultRequestTimeout- the timeout value in milliseconds
- Since:
- 5.0
 
- 
getDefaultRequestTimeout
- 
setDefaultReplyTimeoutSet the default timeout value for receiving reply messages. If not explicitly configured with an annotation, or on a method element, this value will be used.- Parameters:
- defaultReplyTimeout- the timeout value in milliseconds
 
- 
setDefaultReplyTimeoutExpressionSet an expression to be evaluated to determine the default timeout value for receiving reply messages. If not explicitly configured with an annotation, or on a method element, this value will be used.- Parameters:
- defaultReplyTimeout- the timeout value in milliseconds
- Since:
- 5.0
 
- 
setDefaultReplyTimeoutExpressionStringSet an expression to be evaluated to determine the default timeout value for receiving reply messages. If not explicitly configured with an annotation, or on a method element, this value will be used.- Parameters:
- defaultReplyTimeout- the timeout value in milliseconds
- Since:
- 5.0
 
- 
getDefaultReplyTimeout
- 
setShouldTrackpublic void setShouldTrack(boolean shouldTrack) - Specified by:
- setShouldTrackin interface- TrackableComponent
 
- 
setAsyncExecutorSet the executor for use when the gateway method returnsFutureorListenableFuture. Set it to null to disable the async processing, and anyFuturereturn types must be returned by the downstream flow.- Parameters:
- executor- The executor.
 
- 
setTypeConverter
- 
setMethodMetadataMap
- 
setGlobalMethodMetadata
- 
getGlobalMethodMetadata
- 
setBeanClassLoader- Specified by:
- setBeanClassLoaderin interface- BeanClassLoaderAware
 
- 
setMapper- Parameters:
- mapper- the mapper.
 
- 
getMapper
- 
setProxyDefaultMethodspublic void setProxyDefaultMethods(boolean proxyDefaultMethods) Indicate ifdefaultmethods on the interface should be proxied as well. If an explicitGatewayannotation is present on method it is proxied independently of this option. Note: default methods in JDK classes (such asFunction) can be proxied, but cannot be invoked viaMethodHandleby an internal Java security restriction forMethodHandle.Lookup.- Parameters:
- proxyDefaultMethods- the boolean flag to proxy default methods or invoke via- MethodHandle.
- Since:
- 5.3
 
- 
getAsyncExecutor
- 
isAsyncExecutorExplicitlySetprotected boolean isAsyncExecutorExplicitlySet()
- 
getGatewaysReturn the Map ofMethodtoMessagingGatewaySupportgenerated by this factory bean.- Returns:
- the map.
- Since:
- 4.3
 
- 
registerMetricsCaptorDescription copied from interface:IntegrationManagementInject aMetricsCaptor. Ignored ifObservationRegistryis provided.- Specified by:
- registerMetricsCaptorin interface- IntegrationManagement
- Parameters:
- metricsCaptorToRegister- the captor.
- See Also:
 
- 
setErrorOnTimeoutpublic void setErrorOnTimeout(boolean errorOnTimeout) If errorOnTimeout is true, null won't be returned as a result of a gateway method invocation, when a timeout occurs. Instead, aMessageTimeoutExceptionis thrown or an error message is published to the error channel.- Parameters:
- errorOnTimeout- true to create the error message on reply timeout.
- Since:
- 6.2
- See Also:
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- AbstractEndpoint
 
- 
getObjectType- Specified by:
- getObjectTypein interface- FactoryBean<T>
 
- 
getObject- Specified by:
- getObjectin interface- FactoryBean<T>
 
- 
invoke- Specified by:
- invokein interface- MethodInterceptor
- Throws:
- Throwable
 
- 
doInvoke@Nullable protected Object doInvoke(MethodInvocation invocation, boolean runningOnCallerThread) throws Throwable - Throws:
- Throwable
 
- 
doStartprotected void doStart()Description copied from class:AbstractEndpointSubclasses must implement this method with the start behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock.- Specified by:
- doStartin class- AbstractEndpoint
 
- 
doStopprotected void doStop()Description copied from class:AbstractEndpointSubclasses must implement this method with the stop behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock.- Specified by:
- doStopin class- AbstractEndpoint
 
- 
destroypublic void destroy()- Specified by:
- destroyin interface- DisposableBean
- Specified by:
- destroyin interface- IntegrationManagement
- Overrides:
- destroyin class- AbstractEndpoint
 
 
-