Package com.adaptris.core.services.jdbc
Class JdbcDataQueryService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.jdbc.JdbcService
-
- com.adaptris.core.services.jdbc.JdbcServiceWithParameters
-
- com.adaptris.core.services.jdbc.JdbcDataQueryService
-
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,ConnectedService,DynamicPollingTemplate.TemplateProvider,MessageEventGenerator,Service,StateManagedComponent
@ComponentProfile(summary="Query a database and store the results in the message", tag="service,jdbc", recommended=DatabaseConnection.class) public class JdbcDataQueryService extends JdbcServiceWithParameters implements DynamicPollingTemplate.TemplateProviderPerform a triggered JDBC query and the results of this query that can be stored in the AdaptrisMessage.In the adapter configuration file this class is aliased as jdbc-data-query-service which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description JdbcDataQueryService()JdbcDataQueryService(JdbcStatementCreator creator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcloseJdbcService()Close the service.voiddoService(AdaptrisMessage msg)The main service method, which sees the specified query executed and the results returned in an XML message.java.lang.BooleangetIgnoreExecuteQueryErrors()KeyValuePairSetgetNamespaceContext()ResultSetTranslatorgetResultSetTranslator()JdbcStatementCreatorgetStatementCreator()DocumentBuilderFactoryBuildergetXmlDocumentFactoryConfig()protected voidinitJdbcService()protected voidprepareService()voidsetIgnoreExecuteQueryErrors(java.lang.Boolean b)Whether or not to ignore the SQL Exception when executingPreparedStatement.executeQuery().voidsetNamespaceContext(KeyValuePairSet kvps)Set the namespace context for resolving namespaces.voidsetResultSetTranslator(ResultSetTranslator outputTranslator)Set the implementation that will be used to parse the result set.voidsetStatementCreator(JdbcStatementCreator statementCreator)Set the SQL Query statement creator.voidsetXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)voidstartService()Start the service.voidstopService()Stop the service.-
Methods inherited from class com.adaptris.core.services.jdbc.JdbcServiceWithParameters
addStatementParameter, getParameterApplicator, getStatementParameters, setParameterApplicator, setStatementParameters
-
Methods inherited from class com.adaptris.core.jdbc.JdbcService
applyTimeout, closeService, createStatement, getConnection, getConnection, getStatementTimeout, initService, prepare, prepareStatement, prepareStatement, setConnection, setStatementTimeout, start, stop
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init, start, stop
-
Methods inherited from interface com.adaptris.core.ComponentLifecycleExtension
prepare
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, isBranching, setUniqueId
-
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
-
-
-
Constructor Detail
-
JdbcDataQueryService
public JdbcDataQueryService()
-
JdbcDataQueryService
public JdbcDataQueryService(JdbcStatementCreator creator)
-
-
Method Detail
-
initJdbcService
protected void initJdbcService() throws CoreException- Specified by:
initJdbcServicein classJdbcService- Throws:
CoreException
-
prepareService
protected void prepareService() throws CoreException- Specified by:
prepareServicein classJdbcService- Throws:
CoreException
-
startService
public void startService() throws CoreExceptionDescription copied from class:JdbcServiceStart the service.This is called after the connection is started
- Specified by:
startServicein classJdbcService- Throws:
CoreException
-
closeJdbcService
protected void closeJdbcService()
Description copied from class:JdbcServiceClose the service.This is called before the connection is closed
- Specified by:
closeJdbcServicein classJdbcService
-
stopService
public void stopService()
Description copied from class:JdbcServiceStop the service.This is called after before the connection is stopped
- Specified by:
stopServicein classJdbcService
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
The main service method, which sees the specified query executed and the results returned in an XML message.- Specified by:
doServicein interfaceService- Parameters:
msg- theAdaptrisMessageto process- Throws:
ServiceException- wrapping any underlyingExceptions- See Also:
Service.doService(com.adaptris.core.AdaptrisMessage)
-
getResultSetTranslator
public ResultSetTranslator getResultSetTranslator()
- Returns:
- the output translator implementation.
-
setResultSetTranslator
public void setResultSetTranslator(ResultSetTranslator outputTranslator)
Set the implementation that will be used to parse the result set.- Parameters:
outputTranslator- the implementation to use.
-
getNamespaceContext
public KeyValuePairSet getNamespaceContext()
- Returns:
- the namespaceContext
-
setNamespaceContext
public void setNamespaceContext(KeyValuePairSet kvps)
Set the namespace context for resolving namespaces.- The key is the namespace prefix
- The value is the namespace uri
- Parameters:
kvps- the namespace context- See Also:
SimpleNamespaceContext.create(KeyValuePairSet)
-
getXmlDocumentFactoryConfig
public DocumentBuilderFactoryBuilder getXmlDocumentFactoryConfig()
-
setXmlDocumentFactoryConfig
public void setXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)
-
getStatementCreator
public JdbcStatementCreator getStatementCreator()
-
setStatementCreator
public void setStatementCreator(JdbcStatementCreator statementCreator)
Set the SQL Query statement creator. If set, a StatementCreator will override the configured statement, if any.- Parameters:
statementCreator- The statement creator to set.
-
getIgnoreExecuteQueryErrors
public java.lang.Boolean getIgnoreExecuteQueryErrors()
- Returns:
- the ignoreExecuteQueryErrors
-
setIgnoreExecuteQueryErrors
public void setIgnoreExecuteQueryErrors(java.lang.Boolean b)
Whether or not to ignore the SQL Exception when executingPreparedStatement.executeQuery().If set to true this means is that the
PreparedStatement.executeQuery()is treated as successful, but with an empty result set.- Parameters:
b- the ignoreExecuteQueryErrors to set
-
-