Spring Integration

org.springframework.integration.jdbc
Class StoredProcOutboundGateway

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.handler.AbstractMessageHandler
          extended by org.springframework.integration.handler.AbstractReplyProducingMessageHandler
              extended by org.springframework.integration.jdbc.StoredProcOutboundGateway
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.core.Ordered, NamedComponent, Orderable, MessageHandler, MessageProducer, TrackableComponent

public class StoredProcOutboundGateway
extends AbstractReplyProducingMessageHandler

Since:
2.1
Author:
Gunnar Hillert

Nested Class Summary
 
Nested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
AbstractReplyProducingMessageHandler.RequestHandler
 
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)
          Deprecated. Since 2.2 use the constructor that expects a StoredProcExecutor instead
StoredProcOutboundGateway(StoredProcExecutor storedProcExecutor)
          Constructor taking StoredProcExecutor.
 
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)
          Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor
 void setIsFunction(boolean isFunction)
          Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor
 void setProcedureParameters(java.util.List<ProcedureParameter> procedureParameters)
          Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor
 void setReturningResultSetRowMappers(java.util.Map<java.lang.String,org.springframework.jdbc.core.RowMapper<?>> returningResultSetRowMappers)
          Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor
 void setReturnValueRequired(boolean returnValueRequired)
          Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor
 void setSkipUndeclaredResults(boolean skipUndeclaredResults)
          Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor
 void setSqlParameters(java.util.List<org.springframework.jdbc.core.SqlParameter> sqlParameters)
          Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor
 void setSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory)
          Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor
 void setStoredProcedureName(java.lang.String storedProcedureName)
          Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor
 void setUsePayloadAsParameterSource(boolean usePayloadAsParameterSource)
          Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor
 
Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
getMessagingTemplate, handleMessageInternal, setAdviceChain, setBeanClassLoader, 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

StoredProcOutboundGateway

@Deprecated
public StoredProcOutboundGateway(javax.sql.DataSource dataSource,
                                            java.lang.String storedProcedureName)
Deprecated. Since 2.2 use the constructor that expects a StoredProcExecutor instead

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.

Parameters:
dataSource - used to create a SimpleJdbcCall instance
storedProcedureName - Must not be null.

StoredProcOutboundGateway

public StoredProcOutboundGateway(StoredProcExecutor storedProcExecutor)
Constructor taking StoredProcExecutor.

Parameters:
storedProcExecutor - Must not be null.
Method Detail

onInit

protected void onInit()
Verifies parameters, sets the parameters on SimpleJdbcCallOperations and ensures the appropriate SqlParameterSourceFactory is defined when ProcedureParameter are passed in.

Overrides:
onInit in class AbstractReplyProducingMessageHandler

handleRequestMessage

protected java.lang.Object handleRequestMessage(Message<?> requestMessage)
Description copied from class: AbstractReplyProducingMessageHandler
Subclasses must implement this method to handle the request Message. The return value may be a Message, a MessageBuilder, or any plain Object. The base class will handle the final creation of a reply Message from any of those starting points. If the return value is null, the Message flow will end here.

Specified by:
handleRequestMessage in class AbstractReplyProducingMessageHandler

setStoredProcedureName

@Deprecated
public void setStoredProcedureName(java.lang.String storedProcedureName)
Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor

The name of the Stored Procedure or Stored Function to be executed. If StoredProcExecutor.isFunction is set to "true", then this property specifies the Stored Function name. Alternatively you can also specify the Stored Procedure name via StoredProcExecutor.setStoredProcedureNameExpression(Expression).

Parameters:
storedProcedureName - Must not be null and must not be empty
See Also:
StoredProcExecutor.setStoredProcedureNameExpression(Expression), StoredProcExecutor.setStoredProcedureName(String)

setSqlParameters

@Deprecated
public void setSqlParameters(java.util.List<org.springframework.jdbc.core.SqlParameter> sqlParameters)
Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor

Explicit declarations are necessary if the database you use is not a Spring-supported database. Currently Spring supports metadata lookup of stored procedure calls for the following databases: , , We also support metadata lookup of stored functions for the following databases: See also: http://static.springsource.org/spring/docs/3.1.0.M2/spring-framework-reference/html/jdbc.html

See Also:
StoredProcExecutor.setSqlParameters(List)

setReturningResultSetRowMappers

@Deprecated
public void setReturningResultSetRowMappers(java.util.Map<java.lang.String,org.springframework.jdbc.core.RowMapper<?>> returningResultSetRowMappers)
Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor

Does your stored procedure return one or more result sets? If so, you can use the provided method for setting the respective RowMappers.

See Also:
StoredProcExecutor.setReturningResultSetRowMappers(Map)

setIgnoreColumnMetaData

@Deprecated
public void setIgnoreColumnMetaData(boolean ignoreColumnMetaData)
Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor

If true, the JDBC parameter definitions for the stored procedure are not automatically derived from the underlying JDBC connection. In that case you must pass in SqlParameter explicitly..

Parameters:
ignoreColumnMetaData - Defaults to false.
See Also:
StoredProcExecutor.setIgnoreColumnMetaData(boolean)

setReturnValueRequired

@Deprecated
public void setReturnValueRequired(boolean returnValueRequired)
Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor

Indicates the procedure's return value should be included in the results returned.

Parameters:
returnValueRequired -
See Also:
StoredProcExecutor.setReturnValueRequired(boolean)

setProcedureParameters

@Deprecated
public void setProcedureParameters(java.util.List<ProcedureParameter> procedureParameters)
Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor

Custom Stored Procedure parameters that may contain static values or Strings representing an Expression.

See Also:
StoredProcExecutor.setProcedureParameters(List)

setIsFunction

@Deprecated
public void setIsFunction(boolean isFunction)
Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor

Indicates whether a Stored Procedure or a Function is being executed. The default value is false.

Parameters:
isFunction - If set to true an Sql Function is executed rather than a Stored Procedure.
See Also:
StoredProcExecutor.setIsFunction(boolean)

setExpectSingleResult

public void setExpectSingleResult(boolean expectSingleResult)
This parameter indicates that only one result object shall be returned from the Stored Procedure/Function Call. If set to true, a resultMap that contains only 1 element, will have that 1 element extracted and returned as payload. If the resultMap contains more than 1 element and expectSingleResult is true, then a 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.

Parameters:
expectSingleResult -

setSqlParameterSourceFactory

@Deprecated
public void setSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory)
Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor

Provides the ability to set a custom 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.

Parameters:
sqlParameterSourceFactory -
See Also:
StoredProcExecutor.setSqlParameterSourceFactory(SqlParameterSourceFactory)

setUsePayloadAsParameterSource

@Deprecated
public void setUsePayloadAsParameterSource(boolean usePayloadAsParameterSource)
Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor

If set to 'true', the payload of the Message will be used as a source for providing parameters. If false the entire Message will be available as a source for parameters. If no 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.

Parameters:
usePayloadAsParameterSource - If false the entire Message is used as parameter source.
See Also:
StoredProcExecutor.setUsePayloadAsParameterSource(boolean)

setSkipUndeclaredResults

@Deprecated
public void setSkipUndeclaredResults(boolean skipUndeclaredResults)
Deprecated. Since 2.2 set the respective property on the passed-in StoredProcExecutor

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. 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.

See Also:
StoredProcExecutor.setSkipUndeclaredResults(boolean)

Spring Integration