Spring Integration

org.springframework.integration.jdbc
Class StoredProcMessageHandler

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

public class StoredProcMessageHandler
extends AbstractMessageHandler
implements org.springframework.beans.factory.InitializingBean

A message handler that executes Stored Procedures for update purposes. Stored procedure parameter values are by default automatically extracted from the Payload if the payload's bean properties match the parameters of the Stored Procedure. This may be sufficient for basic use cases. For more sophisticated options consider passing in one or more ProcedureParameter. If you need to handle the return parameters of the called stored procedure explicitly, please consider using a StoredProcOutboundGateway instead. Also, if you need to execute SQL Functions, please also use the StoredProcOutboundGateway. As functions are typically used to look up values, only, the Stored Procedure message handler purposefully does not support SQL function calls. If you believe there are valid use-cases for that, please file a feature request at http://jira.springsource.org.

Since:
2.1
Author:
Gunnar Hillert

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
StoredProcMessageHandler(javax.sql.DataSource dataSource, java.lang.String storedProcedureName)
          Deprecated. Since 2.2 use the constructor that expects a StoredProcExecutor instead
StoredProcMessageHandler(StoredProcExecutor storedProcExecutor)
          Constructor passing in the StoredProcExecutor.
 
Method Summary
protected  void handleMessageInternal(Message<?> message)
          Executes the Stored procedure, delegates to executeStoredProcedure(...).
protected  void onInit()
          Verifies parameters, sets the parameters on SimpleJdbcCallOperations and ensures the appropriate SqlParameterSourceFactory is defined when ProcedureParameter are passed in.
 void setIgnoreColumnMetaData(boolean ignoreColumnMetaData)
          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 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.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.beans.factory.InitializingBean
afterPropertiesSet
 
Methods inherited from interface org.springframework.integration.context.NamedComponent
getComponentName
 

Constructor Detail

StoredProcMessageHandler

@Deprecated
public StoredProcMessageHandler(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 - Must not be null.
storedProcedureName - The name of the Stored Procedure or Function. Must not be null.

StoredProcMessageHandler

public StoredProcMessageHandler(StoredProcExecutor storedProcExecutor)
Constructor passing in the StoredProcExecutor.

Parameters:
storedProcExecutor - Must not be null.
Method Detail

onInit

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

Overrides:
onInit in class IntegrationObjectSupport
Throws:
java.lang.Exception

handleMessageInternal

protected void handleMessageInternal(Message<?> message)
Executes the Stored procedure, delegates to executeStoredProcedure(...). Any return values from the Stored procedure are ignored. Return values are logged at debug level, though.

Specified by:
handleMessageInternal in class AbstractMessageHandler

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)

setIgnoreColumnMetaData

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

For fully supported databases, the underlying SimpleJdbcCall can retrieve the parameter information for the to be invoked Stored Procedure from the JDBC Meta-data. However, if the used database does not support meta data lookups or if you like to provide customized parameter definitions, this flag can be set to true. It defaults to false.

See Also:
StoredProcExecutor.setIgnoreColumnMetaData(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)

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

If your database system is not fully supported by Spring and thus obtaining parameter definitions from the JDBC Meta-data is not possible, you must define the SqlParameter explicitly.

See Also:
StoredProcExecutor.setSqlParameters(List)

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)

Spring Integration