Class GatewayProxyFactoryBean
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.GatewayProxyFactoryBean
- All Implemented Interfaces:
org.aopalliance.aop.Advice,org.aopalliance.intercept.Interceptor,org.aopalliance.intercept.MethodInterceptor,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanClassLoaderAware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.FactoryBean<java.lang.Object>,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle,ExpressionCapable,NamedComponent,IntegrationManagement,ManageableLifecycle,ManageableSmartLifecycle,TrackableComponent
- Direct Known Subclasses:
AnnotationGatewayProxyFactoryBean
public class GatewayProxyFactoryBean extends AbstractEndpoint implements TrackableComponent, org.springframework.beans.factory.FactoryBean<java.lang.Object>, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.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).-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
Fields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME -
Constructor Summary
Constructors Constructor Description GatewayProxyFactoryBean()Create a Factory whose service interface type can be configured by setter injection.GatewayProxyFactoryBean(java.lang.Class<?> serviceInterface) -
Method Summary
Modifier and Type Method Description voiddestroy()protected java.lang.ObjectdoInvoke(org.aopalliance.intercept.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 org.springframework.core.task.AsyncTaskExecutorgetAsyncExecutor()protected org.springframework.messaging.MessageChannelgetDefaultReplyChannel()protected java.lang.StringgetDefaultReplyChannelName()protected org.springframework.expression.ExpressiongetDefaultReplyTimeout()protected org.springframework.messaging.MessageChannelgetDefaultRequestChannel()protected java.lang.StringgetDefaultRequestChannelName()protected org.springframework.expression.ExpressiongetDefaultRequestTimeout()protected org.springframework.messaging.MessageChannelgetErrorChannel()protected java.lang.StringgetErrorChannelName()java.util.Map<java.lang.reflect.Method,MessagingGatewaySupport>getGateways()Return the Map ofMethodtoMessagingGatewaySupportgenerated by this factory bean.protected GatewayMethodMetadatagetGlobalMethodMetadata()protected MethodArgsMessageMappergetMapper()java.lang.ObjectgetObject()java.lang.Class<?>getObjectType()java.lang.Objectinvoke(org.aopalliance.intercept.MethodInvocation invocation)protected booleanisAsyncExecutorExplicitlySet()protected voidonInit()Subclasses may implement this for initialization logic.voidregisterMetricsCaptor(MetricsCaptor metricsCaptorToRegister)Inject aMetricsCaptorvoidsetAsyncExecutor(java.util.concurrent.Executor executor)Set the executor for use when the gateway method returnsFutureorListenableFuture.voidsetBeanClassLoader(java.lang.ClassLoader beanClassLoader)voidsetDefaultReplyChannel(org.springframework.messaging.MessageChannel defaultReplyChannel)Set the default reply channel.voidsetDefaultReplyChannelName(java.lang.String defaultReplyChannelName)Set the default reply channel bean name.voidsetDefaultReplyTimeout(java.lang.Long defaultReplyTimeout)Set the default timeout value for receiving reply messages.voidsetDefaultReplyTimeoutExpression(org.springframework.expression.Expression defaultReplyTimeout)Set an expression to be evaluated to determine the default timeout value for receiving reply messages.voidsetDefaultReplyTimeoutExpressionString(java.lang.String defaultReplyTimeout)Set an expression to be evaluated to determine the default timeout value for receiving reply messages.voidsetDefaultRequestChannel(org.springframework.messaging.MessageChannel defaultRequestChannel)Set the default request channel.voidsetDefaultRequestChannelName(java.lang.String defaultRequestChannelName)Set the default request channel bean name.voidsetDefaultRequestTimeout(java.lang.Long defaultRequestTimeout)Set the default timeout value for sending request messages.voidsetDefaultRequestTimeoutExpression(org.springframework.expression.Expression defaultRequestTimeout)Set an expression to be evaluated to determine the default timeout value for sending request messages.voidsetDefaultRequestTimeoutExpressionString(java.lang.String defaultRequestTimeout)Set an expression to be evaluated to determine the default timeout value for sending request messages.voidsetErrorChannel(org.springframework.messaging.MessageChannel errorChannel)Set the error channel.voidsetErrorChannelName(java.lang.String errorChannelName)Set the error channel name.voidsetGlobalMethodMetadata(GatewayMethodMetadata globalMethodMetadata)voidsetMapper(MethodArgsMessageMapper mapper)voidsetMethodMetadataMap(java.util.Map<java.lang.String,GatewayMethodMetadata> methodMetadataMap)voidsetProxyDefaultMethods(boolean proxyDefaultMethods)Indicate ifdefaultmethods on the interface should be proxied as well.voidsetShouldTrack(boolean shouldTrack)voidsetTypeConverter(org.springframework.beans.TypeConverter typeConverter)Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, setLoggingEnabled, setManagedName, setManagedTypeMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName, getComponentType
-
Constructor Details
-
GatewayProxyFactoryBean
public 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
public GatewayProxyFactoryBean(java.lang.Class<?> serviceInterface)
-
-
Method Details
-
setDefaultRequestChannel
public void setDefaultRequestChannel(org.springframework.messaging.MessageChannel defaultRequestChannel)Set 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.
-
setDefaultRequestChannelName
public void setDefaultRequestChannelName(java.lang.String defaultRequestChannelName)Set 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
@Nullable protected org.springframework.messaging.MessageChannel getDefaultRequestChannel() -
getDefaultRequestChannelName
@Nullable protected java.lang.String getDefaultRequestChannelName() -
setDefaultReplyChannel
public void setDefaultReplyChannel(org.springframework.messaging.MessageChannel defaultReplyChannel)Set 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
-
setDefaultReplyChannelName
public void setDefaultReplyChannelName(java.lang.String defaultReplyChannelName)Set 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
@Nullable protected org.springframework.messaging.MessageChannel getDefaultReplyChannel() -
getDefaultReplyChannelName
@Nullable protected java.lang.String getDefaultReplyChannelName() -
setErrorChannel
public void setErrorChannel(org.springframework.messaging.MessageChannel errorChannel)Set 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.
-
setErrorChannelName
public void setErrorChannelName(java.lang.String errorChannelName)Set 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
@Nullable protected org.springframework.messaging.MessageChannel getErrorChannel() -
getErrorChannelName
@Nullable protected java.lang.String getErrorChannelName() -
setDefaultRequestTimeout
public void setDefaultRequestTimeout(java.lang.Long defaultRequestTimeout)Set 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
-
setDefaultRequestTimeoutExpression
public void setDefaultRequestTimeoutExpression(org.springframework.expression.Expression defaultRequestTimeout)Set 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
-
setDefaultRequestTimeoutExpressionString
public void setDefaultRequestTimeoutExpressionString(java.lang.String defaultRequestTimeout)Set 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
@Nullable protected org.springframework.expression.Expression getDefaultRequestTimeout() -
setDefaultReplyTimeout
public void setDefaultReplyTimeout(java.lang.Long defaultReplyTimeout)Set 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
-
setDefaultReplyTimeoutExpression
public void setDefaultReplyTimeoutExpression(org.springframework.expression.Expression defaultReplyTimeout)Set 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
-
setDefaultReplyTimeoutExpressionString
public void setDefaultReplyTimeoutExpressionString(java.lang.String defaultReplyTimeout)Set 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
@Nullable protected org.springframework.expression.Expression getDefaultReplyTimeout() -
setShouldTrack
public void setShouldTrack(boolean shouldTrack)- Specified by:
setShouldTrackin interfaceTrackableComponent
-
setAsyncExecutor
public void setAsyncExecutor(@Nullable java.util.concurrent.Executor executor)Set 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
public void setTypeConverter(org.springframework.beans.TypeConverter typeConverter) -
setMethodMetadataMap
public void setMethodMetadataMap(java.util.Map<java.lang.String,GatewayMethodMetadata> methodMetadataMap) -
setGlobalMethodMetadata
-
getGlobalMethodMetadata
-
setBeanClassLoader
public void setBeanClassLoader(java.lang.ClassLoader beanClassLoader)- Specified by:
setBeanClassLoaderin interfaceorg.springframework.beans.factory.BeanClassLoaderAware
-
setMapper
- Parameters:
mapper- the mapper.
-
getMapper
-
setProxyDefaultMethods
public 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 viaMethodHandle.- Since:
- 5.3
-
getAsyncExecutor
@Nullable protected org.springframework.core.task.AsyncTaskExecutor getAsyncExecutor() -
isAsyncExecutorExplicitlySet
protected boolean isAsyncExecutorExplicitlySet() -
getGateways
Return the Map ofMethodtoMessagingGatewaySupportgenerated by this factory bean.- Returns:
- the map.
- Since:
- 4.3
-
registerMetricsCaptor
Description copied from interface:IntegrationManagementInject aMetricsCaptor- Specified by:
registerMetricsCaptorin interfaceIntegrationManagement- Parameters:
metricsCaptorToRegister- the captor.
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classAbstractEndpoint
-
getObjectType
public java.lang.Class<?> getObjectType()- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean<java.lang.Object>
-
getObject
public java.lang.Object getObject()- Specified by:
getObjectin interfaceorg.springframework.beans.factory.FactoryBean<java.lang.Object>
-
invoke
@Nullable public java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation invocation) throws java.lang.Throwable- Specified by:
invokein interfaceorg.aopalliance.intercept.MethodInterceptor- Throws:
java.lang.Throwable
-
doInvoke
@Nullable protected java.lang.Object doInvoke(org.aopalliance.intercept.MethodInvocation invocation, boolean runningOnCallerThread) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
doStart
protected 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 classAbstractEndpoint
-
doStop
protected 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 classAbstractEndpoint
-
destroy
public void destroy()- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Specified by:
destroyin interfaceIntegrationManagement- Overrides:
destroyin classAbstractEndpoint
-