|
Spring Integration | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.integration.context.IntegrationObjectSupport org.springframework.integration.handler.AbstractMessageHandler org.springframework.integration.handler.AbstractReplyProducingMessageHandler org.springframework.integration.jdbc.StoredProcOutboundGateway
public class StoredProcOutboundGateway
Field Summary |
---|
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport |
---|
logger |
Fields inherited from interface org.springframework.core.Ordered |
---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
Constructor Summary | |
---|---|
StoredProcOutboundGateway(javax.sql.DataSource dataSource,
java.lang.String storedProcedureName)
Constructor taking DataSource from which the DB Connection can be
obtained and the name of the stored procedure or function to
execute to retrieve new rows. |
Method Summary | |
---|---|
protected java.lang.Object |
handleRequestMessage(Message<?> requestMessage)
Subclasses must implement this method to handle the request Message. |
protected void |
onInit()
Verifies parameters, sets the parameters on SimpleJdbcCallOperations
and ensures the appropriate SqlParameterSourceFactory is defined
when ProcedureParameter are passed in. |
void |
setExpectSingleResult(boolean expectSingleResult)
This parameter indicates that only one result object shall be returned from the Stored Procedure/Function Call. |
void |
setIgnoreColumnMetaData(boolean ignoreColumnMetaData)
If true, the JDBC parameter definitions for the stored procedure are not automatically derived from the underlying JDBC connection. |
void |
setIsFunction(boolean isFunction)
Indicates whether a Stored Procedure or a Function is being executed. |
void |
setProcedureParameters(java.util.List<ProcedureParameter> procedureParameters)
Custom Stored Procedure parameters that may contain static values or Strings representing an Expression . |
void |
setReturningResultSetRowMappers(java.util.Map<java.lang.String,org.springframework.jdbc.core.RowMapper<?>> returningResultSetRowMappers)
Does your stored procedure return one or more result sets? If so, you can use the provided method for setting the respective RowMappers. |
void |
setReturnValueRequired(boolean returnValueRequired)
Indicates the procedure's return value should be included in the results returned. |
void |
setSkipUndeclaredResults(boolean skipUndeclaredResults)
If this variable is set to true then all results from a stored
procedure call that don't have a corresponding SqlOutParameter
declaration will be bypassed. |
void |
setSqlParameters(java.util.List<org.springframework.jdbc.core.SqlParameter> sqlParameters)
Explicit declarations are necessary if the database you use is not a Spring-supported database. |
void |
setSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory)
Provides the ability to set a custom SqlParameterSourceFactory . |
void |
setUsePayloadAsParameterSource(boolean usePayloadAsParameterSource)
If set to 'true', the payload of the Message will be used as a source for providing parameters. |
Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler |
---|
getMessagingTemplate, handleMessageInternal, setChannelResolver, setOutputChannel, setRequiresReply, setSendTimeout, shouldCopyRequestHeaders |
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler |
---|
getComponentType, getOrder, handleMessage, setOrder, setShouldTrack |
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
---|
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, 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.context.NamedComponent |
---|
getComponentName |
Constructor Detail |
---|
public StoredProcOutboundGateway(javax.sql.DataSource dataSource, java.lang.String storedProcedureName)
DataSource
from which the DB Connection can be
obtained and the name of the stored procedure or function to
execute to retrieve new rows.
dataSource
- used to create a SimpleJdbcTemplate
storedProcedureName
- Method Detail |
---|
protected void onInit()
SimpleJdbcCallOperations
and ensures the appropriate SqlParameterSourceFactory
is defined
when ProcedureParameter
are passed in.
onInit
in class AbstractReplyProducingMessageHandler
protected java.lang.Object handleRequestMessage(Message<?> requestMessage)
AbstractReplyProducingMessageHandler
handleRequestMessage
in class AbstractReplyProducingMessageHandler
public void setSqlParameters(java.util.List<org.springframework.jdbc.core.SqlParameter> sqlParameters)
public void setReturningResultSetRowMappers(java.util.Map<java.lang.String,org.springframework.jdbc.core.RowMapper<?>> returningResultSetRowMappers)
public void setIgnoreColumnMetaData(boolean ignoreColumnMetaData)
SqlParameter
explicitly..
ignoreColumnMetaData
- Defaults to false
.public void setReturnValueRequired(boolean returnValueRequired)
returnValueRequired
- public void setProcedureParameters(java.util.List<ProcedureParameter> procedureParameters)
Expression
.
public void setIsFunction(boolean isFunction)
isFunction
- If set to true an Sql Function is executed rather than a Stored Procedure.public void setExpectSingleResult(boolean expectSingleResult)
MessagingException
is thrown.
Otherwise the complete resultMap is returned as the Message
payload.
Important Note: Several databases such as H2 are not fully supported.
The H2 database, for example, does not fully support the CallableStatement
semantics and when executing function calls against H2, a result list is
returned rather than a single value.
Therefore, even if you set expectSingleResult = true, you may end up with
a collection being returned.
expectSingleResult
- public void setSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory)
SqlParameterSourceFactory
.
Keep in mind that if ProcedureParameter
are set explicitly and
you would like to provide a custom SqlParameterSourceFactory
,
then you must provide an instance of ExpressionEvaluatingSqlParameterSourceFactory
.
If not the SqlParameterSourceFactory will be replaced by the default
ExpressionEvaluatingSqlParameterSourceFactory
.
sqlParameterSourceFactory
- public void setUsePayloadAsParameterSource(boolean usePayloadAsParameterSource)
ProcedureParameter
are passed in, this property will default to
'true'. This means that using a default BeanPropertySqlParameterSourceFactory
the bean properties of the payload will be used as a source for parameter values for
the to-be-executed Stored Procedure or Function.
However, if ProcedureParameter
are passed in, then this property
will by default evaluate to 'false'. ProcedureParameter
allow for
SpEl Expressions to be provided and therefore it is highly beneficial to
have access to the entire Message
.
usePayloadAsParameterSource
- If false the entire Message
is used as parameter source.public void setSkipUndeclaredResults(boolean skipUndeclaredResults)
true
then all results from a stored
procedure call that don't have a corresponding SqlOutParameter
declaration will be bypassed.
E.g. Stored Procedures may return an update count value, even though your
Stored Procedure only declared a single result parameter. The exact behavior
depends on the used database.
The value is set on the underlying JdbcTemplate
.
Only few developers will probably ever like to process update counts, thus
the value defaults to true
.
|
Spring Integration | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |