public class GatewayProxySpec extends Object implements ComponentsRegistration
GatewayProxyFactoryBean
options
when MessagingGateway
on the service interface cannot be
declared.Modifier and Type | Field and Description |
---|---|
protected GatewayMethodMetadata |
gatewayMethodMetadata |
protected GatewayProxyFactoryBean |
gatewayProxyFactoryBean |
protected MessageChannel |
gatewayRequestChannel |
protected Map<String,Expression> |
headerExpressions |
protected static SpelExpressionParser |
PARSER |
Modifier | Constructor and Description |
---|---|
protected |
GatewayProxySpec(Class<?> serviceInterface) |
Modifier and Type | Method and Description |
---|---|
GatewayProxySpec |
asyncExecutor(Executor executor)
|
GatewayProxySpec |
beanName(String beanName)
Specify a bean name for the target
GatewayProxyFactoryBean . |
GatewayProxySpec |
errorChannel(MessageChannel errorChannel)
Identifies a channel that error messages will be sent to if a failure occurs in the
gateway's proxy invocation.
|
GatewayProxySpec |
errorChannel(String errorChannelName)
Identifies a channel that error messages will be sent to if a failure occurs in the
gateway's proxy invocation.
|
Map<Object,String> |
getComponentsToRegister() |
GatewayProxySpec |
header(String headerName,
Expression valueExpression)
Provides custom message header.
|
GatewayProxySpec |
header(String headerName,
java.util.function.Function<MethodArgsHolder,?> valueFunction)
Provides custom message header.
|
GatewayProxySpec |
header(String headerName,
Object value)
Provides custom message header.
|
GatewayProxySpec |
mapper(MethodArgsMessageMapper mapper)
An
MethodArgsMessageMapper
to map the method arguments to a Message . |
GatewayProxySpec |
payloadExpression(Expression expression)
An expression that will be used to generate the
payload for all methods in the service interface
unless explicitly overridden by a method declaration. |
GatewayProxySpec |
payloadExpression(String expression)
An expression that will be used to generate the
payload for all methods in the service interface
unless explicitly overridden by a method declaration. |
GatewayProxySpec |
payloadFunction(java.util.function.Function<MethodArgsHolder,?> defaultPayloadFunction)
A
Function that will be used to generate the payload for all methods in the service interface
unless explicitly overridden by a method declaration. |
GatewayProxySpec |
proxyDefaultMethods(boolean proxyDefaultMethods)
Indicate if
default methods on the interface should be proxied as well. |
GatewayProxySpec |
replyChannel(MessageChannel replyChannel)
Identifies the default channel the gateway proxy will subscribe to, to receive reply
Message s, the payloads of
which will be converted to the return type of the method signature. |
GatewayProxySpec |
replyChannel(String channelName)
Identifies the default channel the gateway proxy will subscribe to, to receive reply
Message s, the payloads of
which will be converted to the return type of the method signature. |
GatewayProxySpec |
replyTimeout(long replyTimeout)
Allows to specify how long this gateway will wait for the reply
Message
before returning. |
GatewayProxySpec |
requestTimeout(long requestTimeout)
Provides the amount of time dispatcher would wait to send a
Message . |
protected static final SpelExpressionParser PARSER
protected final MessageChannel gatewayRequestChannel
protected final GatewayProxyFactoryBean gatewayProxyFactoryBean
protected final GatewayMethodMetadata gatewayMethodMetadata
protected final Map<String,Expression> headerExpressions
protected GatewayProxySpec(Class<?> serviceInterface)
public GatewayProxySpec beanName(@Nullable String beanName)
GatewayProxyFactoryBean
.beanName
- the bean name to be used for registering bean for the gateway proxyGatewayProxySpec
.public GatewayProxySpec replyChannel(String channelName)
Message
s, the payloads of
which will be converted to the return type of the method signature.channelName
- the bean name for MessageChannel
GatewayProxySpec
.GatewayProxyFactoryBean.setDefaultReplyChannel(org.springframework.messaging.MessageChannel)
public GatewayProxySpec replyChannel(MessageChannel replyChannel)
Message
s, the payloads of
which will be converted to the return type of the method signature.replyChannel
- the MessageChannel
for replies.GatewayProxySpec
.GatewayProxyFactoryBean.setDefaultReplyChannel(org.springframework.messaging.MessageChannel)
public GatewayProxySpec errorChannel(String errorChannelName)
errorChannel
reference is provided, the gateway will
propagate Exception
s to the caller. To completely suppress Exception
s, provide a
reference to the nullChannel
here.errorChannelName
- the bean name for MessageChannel
GatewayProxySpec
.GatewayProxyFactoryBean.setErrorChannel(org.springframework.messaging.MessageChannel)
public GatewayProxySpec errorChannel(MessageChannel errorChannel)
errorChannel
reference is provided, the gateway will
propagate Exception
s to the caller. To completely suppress Exception
s, provide a
reference to the nullChannel
here.errorChannel
- the MessageChannel
for replies.GatewayProxySpec
.GatewayProxyFactoryBean.setErrorChannel(org.springframework.messaging.MessageChannel)
public GatewayProxySpec requestTimeout(long requestTimeout)
Message
. This
timeout would only apply if there is a potential to block in the send call. For
example if this gateway is hooked up to a QueueChannel
. Value is specified
in milliseconds.requestTimeout
- the timeout for requests in milliseconds.GatewayProxySpec
.GatewayProxyFactoryBean.setDefaultRequestTimeout(java.lang.Long)
public GatewayProxySpec replyTimeout(long replyTimeout)
Message
before returning. By default it will wait indefinitely. null
is returned if
the gateway times out. Value is specified in milliseconds.replyTimeout
- the timeout for replies in milliseconds.GatewayProxySpec
.GatewayProxyFactoryBean.setDefaultReplyTimeout(java.lang.Long)
public GatewayProxySpec asyncExecutor(@Nullable Executor executor)
Executor
to use for any of the interface methods that have a Future
return type.
This Executor
will only be used for those async methods; the sync methods
will be invoked in the caller's thread.
Use null
to specify no async executor - for example
if your downstream flow returns a Future
.executor
- the Executor
to use.GatewayProxySpec
.GatewayProxyFactoryBean.setAsyncExecutor(java.util.concurrent.Executor)
public GatewayProxySpec payloadExpression(String expression)
payload
for all methods in the service interface
unless explicitly overridden by a method declaration.
The root object for evaluation context is MethodArgsHolder
.expression
- the SpEL expression for default payload.GatewayProxySpec
.MessagingGateway.defaultPayloadExpression()
public GatewayProxySpec payloadFunction(java.util.function.Function<MethodArgsHolder,?> defaultPayloadFunction)
Function
that will be used to generate the payload
for all methods in the service interface
unless explicitly overridden by a method declaration.defaultPayloadFunction
- the Function
for default payload.GatewayProxySpec
.MessagingGateway.defaultPayloadExpression()
public GatewayProxySpec payloadExpression(Expression expression)
payload
for all methods in the service interface
unless explicitly overridden by a method declaration.
The root object for evaluation context is MethodArgsHolder
.
a bean resolver is also available, enabling expressions like @someBean(#args)
.expression
- the SpEL expression for default payload.GatewayProxySpec
.MessagingGateway.defaultPayloadExpression()
public GatewayProxySpec header(String headerName, Object value)
headerName
- the name ofr the header.value
- the static value for the header.GatewayProxySpec
.MessagingGateway.defaultHeaders()
public GatewayProxySpec header(String headerName, java.util.function.Function<MethodArgsHolder,?> valueFunction)
headerName
- the name ofr the header.valueFunction
- the Function
for the header value.GatewayProxySpec
.MessagingGateway.defaultHeaders()
public GatewayProxySpec header(String headerName, Expression valueExpression)
MethodArgsHolder
as a root object for evaluation context.headerName
- the name ofr the header.valueExpression
- the SpEL expression for the header value.GatewayProxySpec
.MessagingGateway.defaultHeaders()
public GatewayProxySpec mapper(MethodArgsMessageMapper mapper)
MethodArgsMessageMapper
to map the method arguments to a Message
. When this
is provided, no payload-expression
s or header
s are allowed; the custom mapper is
responsible for creating the message.mapper
- the MethodArgsMessageMapper
to use.GatewayProxySpec
.GatewayProxyFactoryBean.setMapper(MethodArgsMessageMapper)
public GatewayProxySpec proxyDefaultMethods(boolean proxyDefaultMethods)
default
methods on the interface should be proxied as well.proxyDefaultMethods
- the boolean flag to proxy default methods or invoke via MethodHandle
.GatewayProxySpec
.GatewayProxyFactoryBean.setProxyDefaultMethods(boolean)
public Map<Object,String> getComponentsToRegister()
getComponentsToRegister
in interface ComponentsRegistration