Class GatewayProxyFactoryBean
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.GatewayProxyFactoryBean
- All Implemented Interfaces:
Advice
,Interceptor
,MethodInterceptor
,Aware
,BeanClassLoaderAware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,FactoryBean<Object>
,InitializingBean
,ApplicationContextAware
,Lifecycle
,Phased
,SmartLifecycle
,ExpressionCapable
,NamedComponent
,IntegrationManagement
,ManageableLifecycle
,ManageableSmartLifecycle
,TrackableComponent
- Direct Known Subclasses:
AnnotationGatewayProxyFactoryBean
public class GatewayProxyFactoryBean extends AbstractEndpoint implements TrackableComponent, FactoryBean<Object>, 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
-
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, lifecycleLock
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields 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(Class<?> serviceInterface)
-
Method Summary
Modifier and Type Method Description void
destroy()
protected Object
doInvoke(MethodInvocation invocation, boolean runningOnCallerThread)
protected void
doStart()
Subclasses must implement this method with the start behavior.protected void
doStop()
Subclasses must implement this method with the stop behavior.protected AsyncTaskExecutor
getAsyncExecutor()
protected MessageChannel
getDefaultReplyChannel()
protected String
getDefaultReplyChannelName()
protected Expression
getDefaultReplyTimeout()
protected MessageChannel
getDefaultRequestChannel()
protected String
getDefaultRequestChannelName()
protected Expression
getDefaultRequestTimeout()
protected MessageChannel
getErrorChannel()
protected String
getErrorChannelName()
Map<Method,MessagingGatewaySupport>
getGateways()
Return the Map ofMethod
toMessagingGatewaySupport
generated by this factory bean.protected GatewayMethodMetadata
getGlobalMethodMetadata()
protected MethodArgsMessageMapper
getMapper()
Object
getObject()
Class<?>
getObjectType()
Object
invoke(MethodInvocation invocation)
protected boolean
isAsyncExecutorExplicitlySet()
protected void
onInit()
Subclasses may implement this for initialization logic.void
registerMetricsCaptor(MetricsCaptor metricsCaptorToRegister)
Inject aMetricsCaptor
void
setAsyncExecutor(Executor executor)
Set the executor for use when the gateway method returnsFuture
orListenableFuture
.void
setBeanClassLoader(ClassLoader beanClassLoader)
void
setDefaultReplyChannel(MessageChannel defaultReplyChannel)
Set the default reply channel.void
setDefaultReplyChannelName(String defaultReplyChannelName)
Set the default reply channel bean name.void
setDefaultReplyTimeout(Long defaultReplyTimeout)
Set the default timeout value for receiving reply messages.void
setDefaultReplyTimeoutExpression(Expression defaultReplyTimeout)
Set an expression to be evaluated to determine the default timeout value for receiving reply messages.void
setDefaultReplyTimeoutExpressionString(String defaultReplyTimeout)
Set an expression to be evaluated to determine the default timeout value for receiving reply messages.void
setDefaultRequestChannel(MessageChannel defaultRequestChannel)
Set the default request channel.void
setDefaultRequestChannelName(String defaultRequestChannelName)
Set the default request channel bean name.void
setDefaultRequestTimeout(Long defaultRequestTimeout)
Set the default timeout value for sending request messages.void
setDefaultRequestTimeoutExpression(Expression defaultRequestTimeout)
Set an expression to be evaluated to determine the default timeout value for sending request messages.void
setDefaultRequestTimeoutExpressionString(String defaultRequestTimeout)
Set an expression to be evaluated to determine the default timeout value for sending request messages.void
setErrorChannel(MessageChannel errorChannel)
Set the error channel.void
setErrorChannelName(String errorChannelName)
Set the error channel name.void
setGlobalMethodMetadata(GatewayMethodMetadata globalMethodMetadata)
void
setMapper(MethodArgsMessageMapper mapper)
void
setMethodMetadataMap(Map<String,GatewayMethodMetadata> methodMetadataMap)
void
setProxyDefaultMethods(boolean proxyDefaultMethods)
Indicate ifdefault
methods on the interface should be proxied as well.void
setShouldTrack(boolean shouldTrack)
void
setTypeConverter(TypeConverter typeConverter)
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
Methods 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, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, setLoggingEnabled, setManagedName, setManagedType
Methods 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
-
-
Method Details
-
setDefaultRequestChannel
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
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
-
getDefaultRequestChannelName
-
setDefaultReplyChannel
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
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
-
getDefaultReplyChannelName
-
setErrorChannel
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
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
-
getErrorChannelName
-
setDefaultRequestTimeout
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
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
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
-
setDefaultReplyTimeout
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
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
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
-
setShouldTrack
public void setShouldTrack(boolean shouldTrack)- Specified by:
setShouldTrack
in interfaceTrackableComponent
-
setAsyncExecutor
Set the executor for use when the gateway method returnsFuture
orListenableFuture
. Set it to null to disable the async processing, and anyFuture
return types must be returned by the downstream flow.- Parameters:
executor
- The executor.
-
setTypeConverter
-
setMethodMetadataMap
-
setGlobalMethodMetadata
-
getGlobalMethodMetadata
-
setBeanClassLoader
- Specified by:
setBeanClassLoader
in interfaceBeanClassLoaderAware
-
setMapper
- Parameters:
mapper
- the mapper.
-
getMapper
-
setProxyDefaultMethods
public void setProxyDefaultMethods(boolean proxyDefaultMethods)Indicate ifdefault
methods on the interface should be proxied as well. If an explicitGateway
annotation 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 viaMethodHandle
by an internal Java security restriction forMethodHandle.Lookup
.- Parameters:
proxyDefaultMethods
- the boolean flag to proxy default methods or invoke viaMethodHandle
.- Since:
- 5.3
-
getAsyncExecutor
-
isAsyncExecutorExplicitlySet
protected boolean isAsyncExecutorExplicitlySet() -
getGateways
Return the Map ofMethod
toMessagingGatewaySupport
generated by this factory bean.- Returns:
- the map.
- Since:
- 4.3
-
registerMetricsCaptor
Description copied from interface:IntegrationManagement
Inject aMetricsCaptor
- Specified by:
registerMetricsCaptor
in interfaceIntegrationManagement
- Parameters:
metricsCaptorToRegister
- the captor.
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classAbstractEndpoint
-
getObjectType
- Specified by:
getObjectType
in interfaceFactoryBean<Object>
-
getObject
- Specified by:
getObject
in interfaceFactoryBean<Object>
-
invoke
- Specified by:
invoke
in interfaceMethodInterceptor
- Throws:
Throwable
-
doInvoke
@Nullable protected Object doInvoke(MethodInvocation invocation, boolean runningOnCallerThread) throws Throwable- Throws:
Throwable
-
doStart
protected void doStart()Description copied from class:AbstractEndpoint
Subclasses must implement this method with the start behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock
.- Specified by:
doStart
in classAbstractEndpoint
-
doStop
protected void doStop()Description copied from class:AbstractEndpoint
Subclasses must implement this method with the stop behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock
.- Specified by:
doStop
in classAbstractEndpoint
-
destroy
public void destroy()- Specified by:
destroy
in interfaceDisposableBean
- Specified by:
destroy
in interfaceIntegrationManagement
- Overrides:
destroy
in classAbstractEndpoint
-